permissions) { global $database; $query = "SELECT b.name as module, a.module as moduleid, a.view, a.comment, a.moderatecomment, a.add, a.modify, a.admin FROM `modules` b LEFT JOIN `access` a on a.module=b.id and accesslevel=" . $this->id . " WHERE b.active='Y' ORDER BY b.name ASC"; $results = $database->getrows($query); if(is_array($results)) { foreach($results as $result) { $this->permissions[$result['module']] = $result; } } } return $this->permissions; } /** * Save the permissions * * @param array $permissions * @return bool true */ public function savePermissions(array $permissions) { global $database; $database->query('DELETE FROM access WHERE accesslevel=' . (int) $this->id); foreach($permissions as $permission) { $permission['accesslevel'] = (int) $this->id; $database->insert('access',$permission); } return true; } }