Quick Search:

View

Revision:

Diff

Diff from 1498 to:

Annotations

Annotate by Age | Author | Mixed | None
/fisheye/browse/osCommerce/trunk/oscommerce/admin/includes/classes/access.php

Annotated File View

hpdl
1070
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
hpdl
1498
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
1070
13 */
14
15   class osC_Access {
16     var $_group = 'misc',
17         $_icon = 'configure.png',
18         $_title,
19         $_sort_order = 0,
20         $_subgroups;
21
hpdl
1078
22     function getUserLevels($id) {
23       global $osC_Database;
24
25       $modules = array();
26
27       $Qaccess = $osC_Database->query('select module from :table_administrators_access where administrators_id = :administrators_id');
28       $Qaccess->bindTable(':table_administrators_access', TABLE_ADMINISTRATORS_ACCESS);
29       $Qaccess->bindInt(':administrators_id', $id);
30       $Qaccess->execute();
31
32       while ( $Qaccess->next() ) {
33         $modules[] = $Qaccess->value('module');
34       }
35
36       if ( in_array('*', $modules) ) {
37         $modules = array();
38
39         $osC_DirectoryListing = new osC_DirectoryListing('includes/modules/access');
40         $osC_DirectoryListing->setIncludeDirectories(false);
41
42         foreach ($osC_DirectoryListing->getFiles() as $file) {
43           $modules[] = substr($file['name'], 0, strrpos($file['name'], '.'));
44         }
45       }
46
47       return $modules;
48     }
49
hpdl
1070
50     function getLevels() {
51       global $osC_Language;
52
53       $access = array();
54
55       foreach ( $_SESSION['admin']['access'] as $module ) {
56         if ( file_exists('includes/modules/access/' . $module . '.php') ) {
57           $module_class = 'osC_Access_' . ucfirst($module);
58
59           if ( !class_exists( $module_class ) ) {
hpdl
1492
60             $osC_Language->loadIniFile('modules/access/' . $module . '.php');
hpdl
1070
61             include('includes/modules/access/' . $module . '.php');
62           }
63
64           $module_class = new $module_class();
65
66           $data = array('module' => $module,
67                         'icon' => $module_class->getIcon(),
68                         'title' => $module_class->getTitle(),
69                         'subgroups' => $module_class->getSubGroups());
70
71           if ( !isset( $access[$module_class->getGroup()][$module_class->getSortOrder()] ) ) {
72             $access[$module_class->getGroup()][$module_class->getSortOrder()] = $data;
73           } else {
74             $access[$module_class->getGroup()][] = $data;
75           }
76         }
77       }
78
79       return $access;
80     }
81
82     function getModule() {
83       return $this->_module;
84     }
85
86     function getGroup() {
87       return $this->_group;
88     }
89
90     function getGroupTitle($group) {
91       global $osC_Language;
92
hpdl
1492
93       if ( !$osC_Language->isDefined('access_group_' . $group . '_title') ) {
94         $osC_Language->loadIniFile( 'modules/access/groups/' . $group . '.php' );
hpdl
1070
95       }
96
hpdl
1492
97       return $osC_Language->get('access_group_' . $group . '_title');
hpdl
1070
98     }
99
100     function getIcon() {
101       return $this->_icon;
102     }
103
104     function getTitle() {
105       return $this->_title;
106     }
107
108     function getSortOrder() {
109       return $this->_sort_order;
110     }
111
112     function getSubGroups() {
113       return $this->_subgroups;
114     }
115
116     function hasAccess($module = null) {
117       if ( empty($module) ) {
118         $module = $this->_module;
119       }
120
121       return !file_exists( 'includes/modules/access/' . $module . '.php' ) || in_array( $module, $_SESSION['admin']['access'] );
122     }
123   }
124 ?>