public function checkAccess() { if (!session::isAdmin()) { moduleloader::setStatus(403); return false; } return true; }
public function indexAction() { if (session::isAdmin()) { http::locationHeader('/event/admin/index?all=1'); } if (session::isUser()) { http::locationHeader('/event/user/index'); } }
/** * method for getting admin options * @param string $url base url * @param string $id the item * @param string $options * @return string $str menu options */ public static function getAdminOptions($url, $id, $options = null) { $str = ''; if (session::isAdmin()) { $str .= html::createLink("{$url}/edit/{$id}", lang::translate('Edit')); $str .= MENU_SUB_SEPARATOR; $str .= html::createLink("{$url}/delete/{$id}", lang::translate('Delete')); } if (isset($options['view'])) { $str .= MENU_SUB_SEPARATOR; $str .= html::createLink("{$url}/view/{$id}", lang::translate('View')); } return $str; }
/** * checks if menu should be displayed to the user depending * on the users credentials * @param array $item menu item * @return boolean $res true if we display and false if we don't */ public static function checkMenuAuth($item = array()) { if (!empty($item['auth'])) { // anon if ($item['auth'] == 'anon') { return true; } // anon_only if ($item['auth'] == 'anon_only') { if (session::isUser()) { return false; } else { return true; } } // if set we need at least a user if (!session::isUser()) { return false; } // if admin is set we need admin if (!session::isAdmin() && $item['auth'] == 'admin') { return false; } // we need super if (!session::isSuper() && $item['auth'] == 'super') { return false; } return true; } return true; }