
Public Member Functions | |
| getTranslatedRole ($role) | |
| getAllRoles ($addSpecial=false) | |
| barredRole ($role) | |
| getLinkedRoles () | |
| getUserRoles ($id) | |
| canRoleAccessAll ($role, $action, $control) | |
Static Public Member Functions | |
| static | getInstance () |
Protected Member Functions | |
| __construct () | |
Static Protected Attributes | |
| static | $instance = __CLASS__ |
Private Attributes | |
| $linked_roles = array() | |
| $user_roles = array() | |
| $all_roles = array() | |
| $all_subjects = array() | |
| $translations | |
Definition at line 52 of file aliroAuthoriser.php.
| aliroAuthoriserCache::__construct | ( | ) | [protected] |
Definition at line 66 of file aliroAuthoriser.php.
References $user_roles, aliroCoreDatabase::getInstance(), and role.
00066 { 00067 // Making private enforces singleton 00068 $database = aliroCoreDatabase::getInstance(); 00069 $database->setQuery("SELECT role, implied FROM #__role_link UNION SELECT DISTINCT role, role AS implied FROM #__assignments UNION SELECT DISTINCT role, role AS implied FROM #__permissions"); 00070 $links = $database->loadObjectList(); 00071 if ($links) foreach ($links as $link) { 00072 $this->all_roles[$link->role] = $link->role; 00073 $this->linked_roles[$link->role][$link->implied] = 1; 00074 foreach ($this->linked_roles as $role=>$impliedarray) { 00075 foreach ($impliedarray as $implied=>$marker) { 00076 if ($implied == $link->role OR $implied == $link->implied) { 00077 $this->linked_roles[$role][$link->implied] = 1; 00078 if (isset($this->linked_roles[$link->implied])) foreach ($this->linked_roles[$link->implied] as $more=>$marker) { 00079 $this->linked_roles[$role][$more] = 1; 00080 } 00081 } 00082 } 00083 } 00084 } 00085 $user_roles = $database->doSQLget("SELECT role, access_id FROM #__assignments WHERE access_type = 'aUser' AND (access_id = '*' OR access_id = '0')"); 00086 foreach ($user_roles as $role) $this->user_roles[$role->access_id][$role->role] = 1; 00087 if (!isset($this->user_roles['0'])) $this->user_roles['0'] = array(); 00088 if (isset($this->user_roles['*'])) $this->user_roles['0'] = array_merge($this->user_roles['0'], $this->user_roles['*']); 00089 $allsubject = $database->doSQLget("SELECT role, control, action FROM #__permissions WHERE subject_type = '*' AND subject_id - '*'"); 00090 foreach ($allsubject as $asub) $this->all_subjects[$asub->role] = $asub; 00091 00092 }
| static aliroAuthoriserCache::getInstance | ( | ) | [static] |
Definition at line 94 of file aliroAuthoriser.php.
Referenced by aliroAuthoriser::__construct(), and aliroAuthorisationAdmin::__construct().
00094 { 00095 return is_object(self::$instance) ? self::$instance : (self::$instance = parent::getCachedSingleton(self::$instance)); 00096 }
| aliroAuthoriserCache::getTranslatedRole | ( | $ | role | ) |
Definition at line 98 of file aliroAuthoriser.php.
00098 { 00099 if (isset($this->translations[$role])) return $this->translations[$role]; 00100 else return $role; 00101 }
| aliroAuthoriserCache::getAllRoles | ( | $ | addSpecial = false |
) |
Definition at line 103 of file aliroAuthoriser.php.
00103 { 00104 $roles = $this->all_roles; 00105 if ($addSpecial) foreach ($this->translations as $raw=>$translated) $roles[$raw] = $translated; 00106 return $roles; 00107 }
| aliroAuthoriserCache::barredRole | ( | $ | role | ) |
| aliroAuthoriserCache::getLinkedRoles | ( | ) |
| aliroAuthoriserCache::getUserRoles | ( | $ | id | ) |
Definition at line 118 of file aliroAuthoriser.php.
00118 { 00119 return isset($this->user_roles[$id]) ? array_keys($this->user_roles[$id]) : array(); 00120 }
| aliroAuthoriserCache::canRoleAccessAll | ( | $ | role, | |
| $ | action, | |||
| $ | control | |||
| ) |
Definition at line 122 of file aliroAuthoriser.php.
00122 { 00123 if (isset($this->all_subjects[$role])) { 00124 $asub = $this->all_subjects[$role]; 00125 if ($action == $asub->action AND ($control & $asub->control)) return true; 00126 } 00127 return false; 00128 }
aliroAuthoriserCache::$instance = __CLASS__ [static, protected] |
Definition at line 53 of file aliroAuthoriser.php.
aliroAuthoriserCache::$linked_roles = array() [private] |
Definition at line 55 of file aliroAuthoriser.php.
aliroAuthoriserCache::$user_roles = array() [private] |
aliroAuthoriserCache::$all_roles = array() [private] |
Definition at line 57 of file aliroAuthoriser.php.
aliroAuthoriserCache::$all_subjects = array() [private] |
Definition at line 58 of file aliroAuthoriser.php.
aliroAuthoriserCache::$translations [private] |
Initial value:
array (
'Registered' => 'Registered(translated)',
'Visitor' => 'Visitor(translated)',
'Nobody' => 'Nobody(translated)',
'none' => 'None of these(trans)'
)
Definition at line 59 of file aliroAuthoriser.php.
1.5.5