public function hasPermission($name, $requireAll = false)
{
if (is_array($name)) {
foreach ($name as $permName) {
$hasPerm = $this->hasPermission($permName);
if ($hasPerm && !$requireAll) {
return true;
} elseif (!$hasPerm && $requireAll) {
return false;
}
}
// If we've made it this far and $requireAll is FALSE, then NONE of the permissions were found
// If we've made it this far and $requireAll is TRUE, then ALL of the permissions were found.
// Return the value of $requireAll;
return $requireAll;
} else {
// The 'root' user is all powerful.
// TODO: Get super user name from config, and replace all occurrences.
if ('root' == $this->username) {
return true;
} elseif ('open-to-all' == $name) {
return true;
} elseif ('basic-authenticated' == $name) {
return true;
} else {
foreach ($this->permissions as $perm) {
if ($perm->name == $name) {
return true;
}
}
}
}
return false;
}