/** * Is Test * Whilst running unit tests, this will be true. * @return BOOL */ public static function isTest() { if (isset($_GET['isTest']) && Auth::isAuthenticated() && Auth::currentUser()->can("runTestingTools")) { SESSION::set("isTest", $_GET['isTest']); } return !static::isDev() && (SESSION::get("isTest") || TOUCHBASE_ENV == 'test' || in_array(@$_SERVER['HTTP_HOST'], static::config()->get("servers")->get("testing", []))); }
/** * Check Access Action * Check that the $Action can be called form a URL * @param string $action * @return BOOL */ protected function checkAccessAction($action) { if ($action == 'handleAction') { return true; } //Save original action $action = strtolower($action); $allowedActions = $this->getAllowedActions(); if (!empty($allowedActions)) { //Check for specific action rules first, and fall back to global rules defined by asterisk! foreach (array($action, '*') as $actionOrAll) { //Check if specific action is set: if (isset($allowedActions[$actionOrAll])) { $test = $allowedActions[$actionOrAll]; if ($test === true) { //Case 1: TRUE should always allow access return true; } else { if (substr($test, 0, 2) == '->') { //Fire a custom method to determine if access is allowed return $this->{substr($test, 2)}(); } else { if ($test == '::isAuthenticated') { return Auth::isAuthenticated(); } else { //Case 4: Check if user has permission return Auth::isAuthenticated() && Auth::currentUser()->can($test); } } } } else { if (($key = array_search($actionOrAll, $allowedActions, true)) !== false && is_numeric($key)) { //Case 5: Allow numeric array notation (search for array value as action instead of key) return true; } } } } return false; }