本文整理汇总了PHP中Auth::isAdmin方法的典型用法代码示例。如果您正苦于以下问题:PHP Auth::isAdmin方法的具体用法?PHP Auth::isAdmin怎么用?PHP Auth::isAdmin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Auth
的用法示例。
在下文中一共展示了Auth::isAdmin方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
/**
* Display a listing of the resource.
*
* @return Response
*/
public function index()
{
if ($this->user->employee->canApproveSpecialLeave()) {
if ($this->user->isAdmin()) {
$employee_leaves = EmployeeSpecialLeave::approved()->get();
} else {
$employee_leaves = $this->user->employee->special_leave_recommending_approvals->merge($this->user->employee->special_leave_approved_by);
}
return view('leaves.special.employee_leaves')->with(compact('employee_leaves'));
}
abort(403);
}
示例2: getModule
public static function getModule($module)
{
$auth = new Auth();
$mod = new Module();
$url = new URL();
$config = new Config();
$pm = new PageManager();
if ($url->getRequestedFunction() == 'angular') {
if (!isset($mod->moduleRegister[$module]) && !is_file(realpath(root . DS . "views" . DS) . "/" . $module . ".php") && !$pm->isPage($module)) {
return 'error';
} else {
if (!$auth->isAdmin() && (isset($mod->moduleRegister[$module][1]) && $mod->moduleRegister[$module][1] == 'admin')) {
return 'login';
} else {
if (is_file(realpath(root . DS . "views" . DS) . "/" . $module . ".php")) {
return $module;
} else {
if ($pm->isPage($module)) {
return $pm->deaultPage;
}
}
}
}
} else {
if (!isset($mod->moduleRegister[$module]) && !is_file(realpath(root . DS . "views" . DS) . "/" . $module . ".php")) {
return 'index';
} else {
if (isset($mod->moduleRegister[$module]) && !isset($mod->moduleRegister[$module][1])) {
return 'index';
} else {
if (!$auth->isAdmin() && isset($mod->moduleRegister[$module][1]) && $mod->moduleRegister[$module][1] == 'admin') {
if ($auth->isItAuthUser()) {
return 'error';
} else {
header("Location:" . $config->site_address . "login");
return 'login';
}
} else {
if ($auth->isItAuthUser() && (isset($mod->moduleRegister[$module][1]) && ($mod->moduleRegister[$module][1] == 'auth' || $mod->moduleRegister[$module][1] == 'admin'))) {
return 'dashboard';
} else {
if (is_file(realpath(root . DS . "views" . DS) . "/" . $module . ".php")) {
return $module;
}
}
}
}
}
}
return $mod->moduleRegister[$module][0];
}
示例3: index
/**
* Affiche la liste des instances de la class du modèle associé $model
* @see BaseController::index()
*/
public function index($message = null)
{
global $config;
$baseHref = get_class($this);
if (isset($message)) {
if (is_string($message)) {
$message = new DisplayedMessage($message);
}
$message->setTimerInterval($this->messageTimerInterval);
$this->_showDisplayedMessage($message);
}
$objects = DAO::getAll($this->model);
echo "<table class='table table-striped'>";
echo "<thead><tr> " . $this->model . "</thead>";
echo "<div id='searchbar'>\n\t\t\n <form method='get' action='127.0.0.1/helpdesk/views/faqs/search.php'>\n <input class='champ' type='text' value=''/>\n <input class='bouton' type='button' value='search ' />\n \n </form>\n </div><br>";
echo "<tbody>";
foreach ($objects as $object) {
echo "<tr>";
echo "<td><a href= '" . $baseHref . "/view/" . $object->getId() . "'>{$object}</a> </td>";
if (Auth::isAdmin() == 1) {
echo "<td class='td-center'><a class='btn btn-primary btn-xs' href='" . $baseHref . "/frmUpdate/" . $object->getId() . "'><span class='glyphicon glyphicon-edit' aria-hidden='true'></span></a></td>" . "<td class='td-center'><a class='btn btn-warning btn-xs' href='" . $baseHref . "/delete/" . $object->getId() . "'><span class='glyphicon glyphicon-remove' aria-hidden='true'></span></a></td>";
}
echo "</tr>";
}
echo "</tbody>";
echo "</table>";
if (Auth::isAdmin() == 1) {
echo "<a class='btn btn-primary' href='" . $config["siteUrl"] . $baseHref . "/frm'>Ajouter...</a>";
}
}
示例4: index
/**
* Affiche la liste des instances de la class du modèle associé $model
* @see BaseController::index()
*/
public function index($message = null)
{
global $config;
$baseHref = get_class($this);
if (isset($message)) {
if (is_string($message)) {
$message = new DisplayedMessage($message);
}
$message->setTimerInterval($this->messageTimerInterval);
$this->_showDisplayedMessage($message);
}
$objects = DAO::getAll($this->model);
if ($this->title == "Tickets") {
echo "<table class='table table-condensed'>";
echo "<thead><tr><th>Mes tickets</th><th>Nombres</th></tr></thead>" . "<tbody><tr class='info'><td>Nouveau</td><td>" . $this->NombreTicketNouveau() . "</td></tr>\n\t\t\t\t<tr class='warning'><td>En attente</td><td>" . $this->NombreTicketAttente() . "</td></tr>\n\t\t\t\t<tr class='active'><td>Attribué</td><td>" . $this->NombreTicketAttribuer() . "</td></tr>\n\t\t\t\t<tr class='success'><td>Résolu</td><td>" . $this->NombreTicketResolu() . "</td></tr></tbody></table>";
}
echo "<table class='table table-striped'>";
echo "<thead><tr> " . $this->model . "</thead>";
echo "<tbody>";
foreach ($objects as $object) {
echo "<tr>";
echo "<td><a href= '" . $baseHref . "/view/" . $object->getId() . "'>{$object}</a> </td>";
echo "<td class='td-center'><a class='btn btn-primary btn-xs' href='" . $baseHref . "/frmUpdate/" . $object->getId() . "'><span class='glyphicon glyphicon-edit' aria-hidden='true'></span></a></td>";
if (Auth::isAdmin() == 1) {
echo "<td class='td-center'><a class='btn btn-default btn-xs' title='Modifier le statut' href='" . $baseHref . "/frmUstat/" . $object->getId() . "'><span class='glyphicon glyphicon-pencil' aria-hidden='true'></span></a></td>" . "<td class='td-center'><a class='btn btn-warning btn-xs' href='" . $baseHref . "/delete/" . $object->getId() . "'><span class='glyphicon glyphicon-remove' aria-hidden='true'></span></a></td>";
}
echo "</tr>";
}
echo "</tbody>";
echo "</table>";
echo "<a class='btn btn-primary' href='" . $config["siteUrl"] . $baseHref . "/frm'>Ajouter...</a>";
}
示例5: get
/**
* Get vote(s)
*
* Call examples :
* /vote?filterOp[surver_id][equals]=azerty : get all survey votes
* /vote/<id> : get vote from its id
*
* @param int $id vote id
*
* @return mixed
*
* @throws RestBadParameterException
* @throws RestOwnershipRequiredException
* @throws RestVoteNotFoundException
* @throws RestSurveyNotFoundException
* @throws RestNotAllowedException
*/
public static function get($id = null)
{
if ($id) {
// Trying to get a single vote
try {
$vote = Vote::fromId($id);
} catch (NotFoundException $e) {
throw new RestVoteNotFoundException($id);
}
// Check permission
if (!$vote->author->is(Auth::user()) && !$vote->survey->owner->is(Auth::user()) && !Auth::isAdmin()) {
throw new RestOwnershipRequiredException(Auth::user()->id, 'vote = ' . $vote->id);
}
return self::cast($vote);
}
// Not a single vote ? Must be survey votes then
$request = RestServer::getRequest();
if (!$request->filterOp || !array_key_exists('survey_id', $request->filterOp) || !array_key_exists('equals', $request->filterOp['survey_id'])) {
throw new RestBadParameterException('filterOp[survey_id][equals]');
}
$survey = Survey::fromId($request->filterOp['survey_id']['equals']);
// Check permissions
if (!$survey->can->view || !$survey->can->view_votes) {
throw new RestNotAllowedException('view votes of survey ' . $survey->id);
}
return array_map(function ($vote) {
return self::cast($vote);
}, array_values($survey->votes));
}
示例6: dataForGraph
public function dataForGraph($date, $whitchServer = 0)
{
if (Auth::isAdmin(App::$instance)) {
$settings = new Settings_controller();
$getServerData = $settings->getServerParam($whitchServer);
$serverMaxLoad = $getServerData['capacity'];
$timeSpot1 = date_create($date);
// dump($date);
//prepare return array
$result = [];
//fill array with timespans
//put time to beginning of working day
$timeSpot1->setTime(8, 0);
//define end of the day
$endOfTheDay = clone $timeSpot1;
$endOfTheDay->setTime(20, 0);
//begin rollin
while ($timeSpot1 != $endOfTheDay) {
$timeSpot2 = clone $timeSpot1;
$timeSpot1->modify("+15 minutes");
$loadCounter = $this->getLoadAtPeriod($timeSpot1, $timeSpot2, $whitchServer);
$resultPhp['times'][] = $timeSpot2->format("H:i");
$resultPhp['counters'][] = $loadCounter;
$resultPhp['percents'][] = $this->calculateLoad($loadCounter, $serverMaxLoad);
}
return $resultPhp;
} else {
return [];
}
}
示例7: defaultAction
public function defaultAction()
{
if (!Auth::isAdmin()) {
$this->accessDenied();
return;
}
}
示例8: index
/**
* Affiche la liste des instances de la class du modèle associé $model
* @see BaseController::index()
*/
public function index($message = null)
{
global $config;
$baseHref = get_class($this);
if (isset($message)) {
if (is_string($message)) {
$message = new DisplayedMessage($message);
}
$message->setTimerInterval($this->messageTimerInterval);
$this->_showDisplayedMessage($message);
}
$objects = DAO::getAll($this->model);
echo "<table class='table table-striped'>";
echo "<thead><tr> " . $this->model . "</thead>";
echo "<tbody>";
foreach ($objects as $object) {
echo "<tr>";
echo "<td><a href= '" . $baseHref . "/view/" . $object->getId() . "'>{$object}</a> </td>";
if (Auth::isAdmin() == 1) {
echo "<td class='td-center'><a class='btn btn-primary btn-xs' href='" . $baseHref . "/frmUpdate/" . $object->getId() . "'><span class='glyphicon glyphicon-edit' aria-hidden='true'></span></a></td>" . "<td class='td-center'><a class='btn btn-warning btn-xs' href='" . $baseHref . "/delete/" . $object->getId() . "'><span class='glyphicon glyphicon-remove' aria-hidden='true'></span></a></td>";
}
echo "</tr>";
}
echo "</tbody>";
echo "</table>";
if (Auth::isAdmin() == 1) {
echo "<a class='btn btn-primary' href='" . $config["siteUrl"] . $baseHref . "/frm'>Ajouter...</a>";
}
}
示例9: index
/**
* The index action is the default action of this Wall Module. It prepares the widget
* wall of the user and render the view according to its preferences.
*
* If the current user is not authenticated, it will be redirected to the users/index
* action that will allows you to acces the login form of the application.
*
*/
public function index($continuePurchase = false, $langage = null, $forcebrowser = false)
{
# Try to force users to use firefox
// if(isset($_SESSION['forcebrowser']) && $_SESSION['forcebrowser'] == true){
// $forcebrowser = true;
// }
// if(!ereg("Firefox/",$_SERVER['HTTP_USER_AGENT']) && !$forcebrowser){
// require(DefaultFC::getView('compatibility.tpl'));
// die();
// }else{
// $_SESSION['forcebrowser'] = true;
// }
if (Auth::isAuth()) {
// Determine if the 'category widget' is installed.
if (Widgets::isInstalled('categoryList')) {
$widgetCategory = array('id' => 'categoryList', 'name' => 'Widget Categories');
}
// Determine if the 'tag cloud widget' is installed.
if (Widgets::isInstalled('tagCloud')) {
$widgetCloud = array('id' => 'tagCloud', 'name' => 'Widget Tag Cloud');
}
// Determine if the view must allow the user to manage widgets.
$widgetManagement = false;
if (Auth::isAdmin() || Auth::isGod()) {
$widgetManagement = true;
}
// Determine if the view must show the list of installed widgets or
// a link to the PALETTE Service Browser.
$useServiceBrowser = USE_SERVICE_BROWSER;
$serviceBrowserURI = USE_SERVICE_BROWSER ? SERVICE_BROWSER_URI . 'index.php/Services/Widgets?num=1' : null;
require DefaultFC::getView('index.tpl');
} else {
DefaultFC::redirection('users/index?ref=wall');
}
}
示例10: access
public function access()
{
if (!Auth::isLogged()) {
$this->redirect("/login");
}
if (!Auth::isAdmin()) {
Error::httpError(403);
}
}
示例11: validate_function
/**
* Return if the user can access the update page
* @param User $user the user to evaluate
* @param string $function the requested function
* @return if the user can access the update page
*/
function validate_function(&$user, $function)
{
if (Auth::isAdmin() || $user->get_isadmin()) {
return true;
}
if ($function == 'editPerms' || $function == 'resetPass') {
return $user->is_group_admin();
}
return false;
}
示例12: frm
public function frm($id=NULL){
if(Auth::isAdmin() || ($id == Auth::getUser()->getId())){
$user=$this->getInstance($id);
$groups = DAO::getAll("Groupe");
$listGrp=Gui::select($groups,$user->getGroupe()->getId(),"Sélectionner un Groupe ...");
$this->loadView("user/vAdd",array("user"=>$user, "groups"=>$listGrp));
}else{
$this->forward("users");
}
}
示例13: defaultAction
public function defaultAction()
{
if (!Auth::isAdmin()) {
$this->accessDenied();
return;
}
$pages = new Pages();
$this->view->assign('pagetree', $pages->getChildren());
$this->view->assign('settings', Settings::getAll());
}
示例14: approve
public function approve($request, $response)
{
if (Auth::isAdmin()) {
$leave = Leave::findOrFail($request->id);
$leave->active_token = true;
$leave->save();
return $response->redirect('/dashboard/leave/index', $code = 302);
} else {
return $response->redirect('/dashboard/leave/index', $code = 302);
}
}
示例15: MenuChanger
static function MenuChanger()
{
if (Auth::isAdmin(App::$instance)) {
ST::deployTemplate('menus/admin.inc');
} else {
ST::deployTemplate('menus/user.inc');
}
//под меню добавить слушателя сообщений
ExceptionHandler::messageException();
//выдать путь для js, $init должен быть инициирован выше
ST::setVarPhptoJS(App::$instance->opt->appHttpPath, "appHttpPath");
}