Quick Search:

View

Revision:

Diff

Diff from 1850 to:

Annotations

Annotate by Age | Author | Mixed | None
/fisheye/browse/osCommerce/branches/hpdl/oscommerce/admin/includes/applications/administrators/administrators.php

Annotated File View

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