/** * Determine if this class of user can perform an action or has ability. * * @param string $ability * @return bool * @throws SCoreException */ public function can($ability) { if (array_key_exists($ability, $this->abilities)) { $val = $this->abilities[$ability]; return $val; } else { if (!is_null($this->parent)) { return $this->parent->can($ability); } else { global $_shm_user_classes; $min_dist = 9999; $min_ability = null; foreach ($_shm_user_classes['base']->abilities as $a => $cando) { $v = levenshtein($ability, $a); if ($v < $min_dist) { $min_dist = $v; $min_ability = $a; } } throw new SCoreException("Unknown ability '" . html_escape($ability) . "'. Did the developer mean '" . html_escape($min_ability) . "'?"); } } }
/** * @param string $ability * @return bool */ public function can($ability) { return $this->class->can($ability); }