hpdl
|
1016
|
1
|
<?php
|
|
2
|
/*
|
|
3
|
$Id: $
|
|
4
|
|
|
5
|
osCommerce, Open Source E-Commerce Solutions
|
|
6
|
http://www.oscommerce.com
|
|
7
|
|
|
8
|
Copyright (c) 2006 osCommerce
|
|
9
|
|
|
10
|
Released under the GNU General Public License
|
|
11
|
*/
|
|
12
|
|
hpdl
|
1200
|
13
|
require('includes/classes/administrators.php');
|
|
14
|
|
hpdl
|
1016
|
15
|
class osC_Content_Administrators extends osC_Template {
|
|
16
|
|
|
17
|
/* Private variables */
|
|
18
|
|
|
19
|
var $_module = 'administrators',
|
hpdl
|
1070
|
20
|
$_page_title = HEADING_TITLE,
|
hpdl
|
1130
|
21
|
$_page_contents = 'main.php';
|
hpdl
|
1016
|
22
|
|
|
23
|
/* Class constructor */
|
|
24
|
|
|
25
|
function osC_Content_Administrators() {
|
hpdl
|
1200
|
26
|
global $osC_MessageStack;
|
|
27
|
|
hpdl
|
1016
|
28
|
if (!isset($_GET['action'])) {
|
|
29
|
$_GET['action'] = '';
|
|
30
|
}
|
|
31
|
|
|
32
|
if (!isset($_GET['page']) || (isset($_GET['page']) && !is_numeric($_GET['page']))) {
|
|
33
|
$_GET['page'] = 1;
|
|
34
|
}
|
|
35
|
|
|
36
|
if (!empty($_GET['action'])) {
|
|
37
|
switch ($_GET['action']) {
|
|
38
|
case 'save':
|
hpdl
|
1200
|
39
|
if ( isset($_GET['aID']) && is_numeric($_GET['aID']) ) {
|
|
40
|
$this->_page_contents = 'edit.php';
|
hpdl
|
1125
|
41
|
} else {
|
hpdl
|
1200
|
42
|
$this->_page_contents = 'new.php';
|
hpdl
|
1125
|
43
|
}
|
|
44
|
|
hpdl
|
1200
|
45
|
if ( isset($_POST['subaction']) && ($_POST['subaction'] == 'confirm') ) {
|
|
46
|
$data = array('username' => $_POST['user_name'],
|
|
47
|
'password' => $_POST['user_password']);
|
hpdl
|
1125
|
48
|
|
hpdl
|
1200
|
49
|
switch ( osC_Administrators_Admin::save((isset($_GET['aID']) && is_numeric($_GET['aID']) ? $_GET['aID'] : null), $data, (isset($_POST['modules']) ? $_POST['modules'] : null)) ) {
|
|
50
|
case true:
|
|
51
|
if ( isset($_GET['aID']) && is_numeric($_GET['aID']) && ($_GET['aID'] == $_SESSION['admin']['id']) ) {
|
|
52
|
$_SESSION['admin']['access'] = osC_Access::getUserLevels($_GET['aID']);
|
|
53
|
}
|
hpdl
|
1125
|
54
|
|
hpdl
|
1200
|
55
|
$osC_MessageStack->add_session($this->_module, SUCCESS_DB_ROWS_UPDATED, 'success');
|
hpdl
|
1125
|
56
|
|
hpdl
|
1200
|
57
|
osc_redirect(osc_href_link_admin(FILENAME_DEFAULT, $this->_module . '&page=' . $_GET['page']));
|
hpdl
|
1070
|
58
|
|
hpdl
|
1200
|
59
|
break;
|
hpdl
|
1016
|
60
|
|
hpdl
|
1200
|
61
|
case false:
|
|
62
|
$osC_MessageStack->add_session($this->_module, ERROR_DB_ROWS_NOT_UPDATED, 'error');
|
hpdl
|
1016
|
63
|
|
hpdl
|
1200
|
64
|
osc_redirect(osc_href_link_admin(FILENAME_DEFAULT, $this->_module . '&page=' . $_GET['page']));
|
hpdl
|
1016
|
65
|
|
hpdl
|
1200
|
66
|
break;
|
hpdl
|
1016
|
67
|
|
hpdl
|
1200
|
68
|
case -1:
|
|
69
|
$osC_MessageStack->add($this->_module, ERROR_ADMINISTRATORS_USERNAME_EXISTS, 'error');
|
hpdl
|
1016
|
70
|
|
hpdl
|
1085
|
71
|
break;
|
hpdl
|
1070
|
72
|
}
|
|
73
|
}
|
|
74
|
|
hpdl
|
1200
|
75
|
break;
|
hpdl
|
1070
|
76
|
|
hpdl
|
1200
|
77
|
case 'delete':
|
|
78
|
$this->_page_contents = 'delete.php';
|
hpdl
|
1085
|
79
|
|
hpdl
|
1200
|
80
|
if ( isset($_POST['subaction']) && ($_POST['subaction'] == 'confirm') ) {
|
|
81
|
if ( osC_Administrators_Admin::delete($_GET['aID']) ) {
|
|
82
|
$osC_MessageStack->add_session($this->_module, SUCCESS_DB_ROWS_UPDATED, 'success');
|
|
83
|
} else {
|
|
84
|
$osC_MessageStack->add_session($this->_module, ERROR_DB_ROWS_NOT_UPDATED, 'error');
|
|
85
|
}
|
hpdl
|
1085
|
86
|
|
hpdl
|
1200
|
87
|
osc_redirect(osc_href_link_admin(FILENAME_DEFAULT, $this->_module . '&page=' . $_GET['page']));
|
|
88
|
}
|
hpdl
|
1070
|
89
|
|
hpdl
|
1200
|
90
|
break;
|
hpdl
|
1070
|
91
|
|
hpdl
|
1200
|
92
|
case 'batchSave':
|
|
93
|
if ( isset($_POST['batch']) && is_array($_POST['batch']) && !empty($_POST['batch']) ) {
|
|
94
|
$this->_page_contents = 'batch_edit.php';
|
hpdl
|
1125
|
95
|
|
hpdl
|
1200
|
96
|
if ( isset($_POST['subaction']) && ($_POST['subaction'] == 'confirm') ) {
|
|
97
|
$error = false;
|
hpdl
|
1085
|
98
|
|
hpdl
|
1200
|
99
|
foreach ($_POST['batch'] as $id) {
|
|
100
|
if ( !osC_Administrators_Admin::setAccessLevels($id, $_POST['modules'], $_POST['mode']) ) {
|
|
101
|
$error = true;
|
|
102
|
break;
|
|
103
|
}
|
|
104
|
}
|
hpdl
|
1070
|
105
|
|
hpdl
|
1200
|
106
|
if ( $error === false ) {
|
|
107
|
$osC_MessageStack->add_session($this->_module, SUCCESS_DB_ROWS_UPDATED, 'success');
|
hpdl
|
1070
|
108
|
|
hpdl
|
1200
|
109
|
if ( in_array($_SESSION['admin']['id'], $_POST['batch']) ) {
|
|
110
|
$_SESSION['admin']['access'] = osC_Access::getUserLevels($_SESSION['admin']['id']);
|
|
111
|
}
|
|
112
|
} else {
|
|
113
|
$osC_MessageStack->add_session($this->_module, ERROR_DB_ROWS_NOT_UPDATED, 'error');
|
|
114
|
}
|
hpdl
|
1016
|
115
|
|
hpdl
|
1200
|
116
|
osc_redirect(osc_href_link_admin(FILENAME_DEFAULT, $this->_module . '&page=' . $_GET['page']));
|
hpdl
|
1125
|
117
|
}
|
|
118
|
}
|
|
119
|
|
hpdl
|
1200
|
120
|
break;
|
hpdl
|
1125
|
121
|
|
hpdl
|
1200
|
122
|
case 'batchDelete':
|
|
123
|
if ( isset($_POST['batch']) && is_array($_POST['batch']) && !empty($_POST['batch']) ) {
|
|
124
|
$this->_page_contents = 'batch_delete.php';
|
hpdl
|
1125
|
125
|
|
hpdl
|
1200
|
126
|
if ( isset($_POST['subaction']) && ($_POST['subaction'] == 'confirm') ) {
|
|
127
|
$error = false;
|
|
128
|
|
|
129
|
foreach ($_POST['batch'] as $id) {
|
|
130
|
if ( !osC_Administrators_Admin::delete($id) ) {
|
|
131
|
$error = true;
|
|
132
|
break;
|
|
133
|
}
|
hpdl
|
1125
|
134
|
}
|
|
135
|
|
hpdl
|
1200
|
136
|
if ( $error === false ) {
|
|
137
|
$osC_MessageStack->add_session($this->_module, SUCCESS_DB_ROWS_UPDATED, 'success');
|
|
138
|
} else {
|
|
139
|
$osC_MessageStack->add_session($this->_module, ERROR_DB_ROWS_NOT_UPDATED, 'error');
|
hpdl
|
1125
|
140
|
}
|
|
141
|
|
hpdl
|
1200
|
142
|
osc_redirect(osc_href_link_admin(FILENAME_DEFAULT, $this->_module . '&page=' . $_GET['page']));
|
hpdl
|
1125
|
143
|
}
|
|
144
|
}
|
|
145
|
|
hpdl
|
1200
|
146
|
break;
|
hpdl
|
1125
|
147
|
}
|
|
148
|
}
|
|
149
|
}
|
hpdl
|
1016
|
150
|
}
|
|
151
|
?>
|