Quick Search:

View

Revision:

Diff

Diff from 1016 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: $
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
13   class osC_Content_Administrators extends osC_Template {
14
15 /* Private variables */
16
17     var $_module = 'administrators',
18         $_page_title,
19         $_page_contents = 'administrators.php';
20
21 /* Class constructor */
22
23     function osC_Content_Administrators() {
24       $this->_page_title = HEADING_TITLE;
25
26       if (!isset($_GET['action'])) {
27         $_GET['action'] = '';
28       }
29
30       if (!isset($_GET['page']) || (isset($_GET['page']) && !is_numeric($_GET['page']))) {
31         $_GET['page'] = 1;
32       }
33
34       if (!empty($_GET['action'])) {
35         switch ($_GET['action']) {
36           case 'save':
37             $this->_save();
38             break;
39
40           case 'deleteconfirm':
41             $this->_delete();
42             break;
43         }
44       }
45     }
46
47 /* Private methods */
48
49     function _save() {
50       global $osC_Database, $osC_MessageStack;
51
52       $id = 0;
53
54       if (isset($_GET['aID']) && is_numeric($_GET['aID'])) {
55         $Qadmin = $osC_Database->query('update :table_administrators set user_name = :user_name where id = :id');
56         $Qadmin->bindInt(':id', $_GET['aID']);
57       } else {
58         $Qadmin = $osC_Database->query('insert into :table_administrators (user_name) values (:user_name)');
59       }
60       $Qadmin->bindTable(':table_administrators', TABLE_ADMINISTRATORS);
61       $Qadmin->bindValue(':user_name', $_POST['user_name']);
62       $Qadmin->execute();
63
64       if (($osC_Database->isError() === false) && !empty($_POST['user_password'])) {
65         $id = ((isset($_GET['aID']) && is_numeric($_GET['aID'])) ? $_GET['aID'] : $osC_Database->nextID());
66
67         $Qadmin = $osC_Database->query('update :table_administrators set user_password = :user_password where id = :id');
68         $Qadmin->bindTable(':table_administrators', TABLE_ADMINISTRATORS);
69         $Qadmin->bindValue(':user_password', osc_encrypt_string(trim($_POST['user_password'])));
70         $Qadmin->bindInt(':id', $id);
71         $Qadmin->execute();
72       }
73
74       if ($osC_Database->isError() === false) {
75         $osC_MessageStack->add_session($this->_module, SUCCESS_DB_ROWS_UPDATED, 'success');
76       } else {
77         $osC_MessageStack->add_session($this->_module, ERROR_DB_ROWS_NOT_UPDATED, 'error');
78       }
79
80       osc_redirect(osc_href_link_admin(FILENAME_DEFAULT, $this->_module . '&page=' . $_GET['page'] . '&aID=' . $id));
81     }
82
83     function _delete() {
84       global $osC_Database, $osC_MessageStack;
85
86       if (isset($_GET['aID']) && is_numeric($_GET['aID'])) {
87         $Qdel = $osC_Database->query('delete from :table_administrators where id = :id');
88         $Qdel->bindTable(':table_administrators', TABLE_ADMINISTRATORS);
89         $Qdel->bindInt(':id', $_GET['aID']);
90         $Qdel->execute();
91
92         $osC_MessageStack->add_session($this->_module, SUCCESS_DB_ROWS_UPDATED, 'success');
93       }
94
95       osc_redirect(osc_href_link_admin(FILENAME_DEFAULT, $this->_module . '&page=' . $_GET['page']));
96     }
97   }
98 ?>