root/trunk/gui/admin/manage_reseller_owners.php

Revision 1327, 5.2 kB (checked in by rats, 4 months ago)

* Fixed: --scan-knownbad-files and --check-deleted are no longer supported by rkhunter
* Fixed #1471: chkrootkit should be in lenny / hardy
* Updated Chinese (simplified)
* Updated German
* Fixed #1475: typo on installation (ispcp-setup)
* Fixed: default user for rkhunter.log

Line 
1 <?php
2 /**
3  * ispCP ω (OMEGA) a Virtual Hosting Control System
4  *
5  * @copyright     2001-2006 by moleSoftware GmbH
6  * @copyright     2006-2008 by ispCP | http://isp-control.net
7  * @version     SVN: $Id$
8  * @link         http://isp-control.net
9  * @author         ispCP Team
10  *
11  * @license
12  *   This program is free software; you can redistribute it and/or modify it under
13  *   the terms of the MPL General Public License as published by the Free Software
14  *   Foundation; either version 1.1 of the License, or (at your option) any later
15  *   version.
16  *   You should have received a copy of the MPL Mozilla Public License along with
17  *   this program; if not, write to the Open Source Initiative (OSI)
18  *   http://opensource.org | osi@opensource.org
19  */
20
21 require '../include/ispcp-lib.php';
22
23 check_login(__FILE__);
24
25 $tpl = new pTemplate();
26 $tpl->define_dynamic('page', Config::get('ADMIN_TEMPLATE_PATH') . '/manage_reseller_owners.tpl');
27 $tpl->define_dynamic('page_message', 'page');
28 $tpl->define_dynamic('hosting_plans', 'page');
29 $tpl->define_dynamic('reseller_list', 'page');
30 $tpl->define_dynamic('reseller_item', 'reseller_list');
31 $tpl->define_dynamic('select_admin', 'page');
32 $tpl->define_dynamic('select_admin_option', 'select_admin');
33
34 $theme_color = Config::get('USER_INITIAL_THEME');
35
36 function gen_reseller_table(&$tpl, &$sql) {
37     $query = <<<SQL_QUERY
38         SELECT
39             t1.admin_id, t1.admin_name, t2.admin_name AS created_by
40         FROM
41             admin AS t1,
42             admin AS t2
43         WHERE
44             t1.admin_type = 'reseller'
45           AND
46             t1.created_by = t2.admin_id
47         ORDER BY
48             created_by,
49             admin_id
50 SQL_QUERY;
51
52     $rs = exec_query($sql, $query, array());
53
54     $i = 0;
55
56     if ($rs->RecordCount() == 0) {
57         $tpl->assign(
58             array('MESSAGE' => tr('Reseller list is empty!'),
59                 'RESELLER_LIST' => '',
60                 )
61             );
62
63         $tpl->parse('PAGE_MESSAGE', 'page_message');
64     } else {
65         while (!$rs->EOF) {
66             if ($i % 2 == 0) {
67                 $tpl->assign(
68                     array('RSL_CLASS' => 'content',
69                         )
70                     );
71             } else {
72                 $tpl->assign(
73                     array('RSL_CLASS' => 'content2',
74                         )
75                     );
76             }
77
78             $admin_id = $rs->fields['admin_id'];
79
80             $admin_id_var_name = "admin_id_$admin_id";
81
82             $tpl->assign(
83                 array('NUMBER' => $i + 1,
84                     'RESELLER_NAME' => $rs->fields['admin_name'],
85                     'OWNER' => $rs->fields['created_by'],
86                     'CKB_NAME' => $admin_id_var_name,
87                     )
88                 );
89
90             $tpl->parse('RESELLER_ITEM', '.reseller_item');
91
92             $rs->MoveNext();
93
94             $i++;
95         }
96
97         $tpl->parse('RESELLER_LIST', 'reseller_list');
98
99         $tpl->assign('PAGE_MESSAGE', '');
100     }
101
102     $query = <<<SQL_QUERY
103         SELECT
104             admin_id, admin_name
105         FROM
106             admin
107         WHERE
108             admin_type = 'admin'
109         ORDER BY
110             admin_name
111 SQL_QUERY;
112
113     $rs = exec_query($sql, $query, array());
114
115     while (!$rs->EOF) {
116         $selected = '';
117
118         if (isset($_POST['uaction']) && $_POST['uaction'] === 'reseller_owner') {
119             if (isset($_POST['dest_admin']) && $_POST['dest_admin'] == $rs->fields['admin_id']) {
120                 $selected = 'selected';
121             }
122         }
123
124         $tpl->assign(
125             array('OPTION' => $rs->fields['admin_name'],
126                 'VALUE' => $rs->fields['admin_id'],
127                 'SELECTED' => $selected,
128                 )
129             );
130
131         $tpl->parse('SELECT_ADMIN_OPTION', '.select_admin_option');
132
133         $rs->MoveNext();
134
135         $i++;
136     }
137
138     $tpl->parse('SELECT_ADMIN', 'select_admin');
139
140     $tpl->assign('PAGE_MESSAGE', '');
141 }
142
143 function update_reseller_owner($sql) {
144     if (isset($_POST['uaction']) && $_POST['uaction'] === 'reseller_owner') {
145         $query = <<<SQL_QUERY
146             SELECT
147                 admin_id
148             FROM
149                 admin
150             WHERE
151                 admin_type = 'reseller'
152             ORDER BY
153                 admin_name
154 SQL_QUERY;
155
156         $rs = execute_query($sql, $query);
157
158         while (!$rs->EOF) {
159             $admin_id = $rs->fields['admin_id'];
160
161             $admin_id_var_name = "admin_id_$admin_id";
162
163             if (isset($_POST[$admin_id_var_name]) && $_POST[$admin_id_var_name] === 'on') {
164                 $dest_admin = $_POST['dest_admin'];
165
166                 $query = <<<SQL_QUERY
167                     UPDATE
168                         admin
169                     SET
170                         created_by = ?
171                     WHERE
172                         admin_id  = ?
173 SQL_QUERY;
174
175                 $up = exec_query($sql, $query, array($dest_admin, $admin_id));
176             }
177
178             $rs->MoveNext();
179         }
180     }
181 }
182
183 /*
184  *
185  * static page messages.
186  *
187  */
188
189 $tpl->assign(
190     array('TR_ADMIN_MANAGE_RESELLER_OWNERS_PAGE_TITLE' => tr('ispCP - Admin/Manage users/Reseller assignment'),
191         'THEME_COLOR_PATH' => "../themes/$theme_color",
192         'THEME_CHARSET' => tr('encoding'),
193         'ISP_LOGO' => get_logo($_SESSION['user_id'])
194         )
195     );
196
197 gen_admin_mainmenu($tpl, Config::get('ADMIN_TEMPLATE_PATH') . '/main_menu_users_manage.tpl');
198 gen_admin_menu($tpl, Config::get('ADMIN_TEMPLATE_PATH') . '/menu_users_manage.tpl');
199
200 update_reseller_owner($sql);
201
202 gen_reseller_table($tpl, $sql);
203
204 $tpl->assign(
205     array('TR_RESELLER_ASSIGNMENT' => tr('Reseller assignment'),
206         'TR_RESELLER_USERS' => tr('Reseller users'),
207         'TR_NUMBER' => tr('No.'),
208         'TR_MARK' => tr('Mark'),
209         'TR_RESELLER_NAME' => tr('Reseller name'),
210         'TR_OWNER' => tr('Owner'),
211         'TR_TO_ADMIN' => tr('To Admin'),
212         'TR_MOVE' => tr('Move'),
213         )
214     );
215
216 $tpl->parse('PAGE', 'page');
217 $tpl->prnt();
218
219 if (Config::get('DUMP_GUI_DEBUG'))
220     dump_gui_debug();
221
222 unset_messages();
223
224 ?>
Note: See TracBrowser for help on using the browser.