Project

General

Profile

« Previous | Next » 

Revision 1789

Added by Dietmar about 12 years ago

! update Group Permission, add module_advanced
! upgrade-script will be updating Adminitrator Group

View differences:

class.login.php
80 80
			$sql  = 'SELECT * FROM `'.$this->users_table.'` ';
81 81
			$sql .= 'WHERE `user_id`=\''.$this->get_safe_remember_key().'\'';
82 82
			$query_details = $database->query($sql);
83
			$fetch_details = $query_details->fetchRow();
83
			$fetch_details = $query_details->fetchRow(MYSQL_ASSOC);
84 84
			$this->username = $fetch_details['username'];
85 85
			$this->password = $fetch_details['password'];
86 86
			// Check if the user exists (authenticate them)
......
188 188
			$_SESSION['TEMPLATE_PERMISSIONS'] = array();
189 189
			$_SESSION['GROUP_NAME'] = array();
190 190

  
191
            $aGroupsIds = ((explode(',', $this->get_session('GROUPS_ID'))));
192
            $bOnlyAdminGroup = $this->ami_group_member('1') && (sizeof($aGroupsIds) == 1);
193
			$first_group = true;
191 194

  
192

  
193
			$first_group = true;
194
			foreach (explode(",", $this->get_session('GROUPS_ID')) as $cur_group_id)
195
			foreach ( $aGroupsIds  as $cur_group_id)
195 196
            {
196 197
				$sql = 'SELECT * FROM `'.$this->groups_table.'` WHERE `group_id`=\''.$cur_group_id.'\'';
197
				$results = $database->query($sql);
198
				$results_array = $results->fetchRow();
199
				$_SESSION['GROUP_NAME'][$cur_group_id] = $results_array['name'];
198
				if($results = $database->query($sql)) {
199
    				$results_array = $results->fetchRow(MYSQL_ASSOC);
200
    				$_SESSION['GROUP_NAME'][$cur_group_id] = $results_array['name'];
201
				}
202

  
200 203
				// Set system permissions
201
				if( $results_array['system_permissions'] != '' ) {
202
					$_SESSION['SYSTEM_PERMISSIONS'] = array_merge($_SESSION['SYSTEM_PERMISSIONS'], explode(',', $results_array['system_permissions']));
204
				if( ($results_array['system_permissions'] != '') ) {
205
                    switch ($cur_group_id) :
206
                        case 1:
207
                            if($bOnlyAdminGroup) {
208
                                $_SESSION['SYSTEM_PERMISSIONS'] = array_merge($_SESSION['SYSTEM_PERMISSIONS'], explode(',', $results_array['system_permissions']));
209
                            }
210
                            break;
211
                        default:
212
        					$_SESSION['SYSTEM_PERMISSIONS'] = array_merge($_SESSION['SYSTEM_PERMISSIONS'], explode(',', $results_array['system_permissions']));
213
                    endswitch;
203 214
				}
215

  
204 216
				// Set module permissions
205 217
				if( $results_array['module_permissions'] != '' ) {
206 218
					if ($first_group) {
......
220 232
				$first_group = false;
221 233
			}
222 234

  
223
            if( $this->ami_group_member('1')) {
235
            if( $$bOnlyAdminGroup ) {
224 236
    			$_SESSION['MODULE_PERMISSIONS'] = array();
225 237
    			$_SESSION['TEMPLATE_PERMISSIONS'] = array();
226 238
            }

Also available in: Unified diff