当前位置: 首页>>代码示例>>PHP>>正文


PHP hasPermission函数代码示例

本文整理汇总了PHP中hasPermission函数的典型用法代码示例。如果您正苦于以下问题:PHP hasPermission函数的具体用法?PHP hasPermission怎么用?PHP hasPermission使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了hasPermission函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: add

 /**
  * Submit a comment to an article
  * @param Int $id
  */
 public function add($id = false)
 {
     requirePermission("canAddComment");
     if (!$id) {
         die;
     }
     // Check if article exist and if you can comment it
     if ($this->news_model->articleExists($id, true) && $this->user->isOnline()) {
         $message = $this->input->post('content');
         if (strlen($message) > 0 && $message && strlen($message) <= 255) {
             // Format the comment
             $comment = array("timestamp" => time(), "article_id" => $id, "author_id" => $this->user->getId(), "content" => $message, "is_gm" => hasPermission('postCommentAsStaff') ? 1 : 0);
             $this->comments_model->addComment($comment);
             // Add log
             $this->logger->createLog('Added comment', $id);
             $this->plugins->onAddComment($id, $message);
             // Get last comment
             $comment_arr = $this->comments_model->getLastComment($id);
             // Add values
             $comment_arr['profile'] = $this->template->page_url . "profile/" . $comment_arr['author_id'];
             $comment_arr['avatar'] = $this->user->getAvatar($comment_arr['author_id'], "small");
             $comment_arr['author'] = $this->user->getNickname($comment_arr['author_id']);
             $comment_arr['content'] = $this->template->format($message, true, true, true, 45);
             $comment_arr['url'] = $this->template->page_url;
             $comment_arr['is_gm'] = $comment['is_gm'];
             // Clear cache
             $this->cache->delete('news_*.cache');
             $this->cache->delete('comments_' . $id . '_*.cache');
             // Load the comment template, also check if we are a staff member
             $data = array('comments' => array($comment_arr), 'user_is_gm' => hasPermission('postCommentAsStaff'), 'url' => $this->template->page_url);
             die($this->template->loadPage("comments.tpl", $data));
         }
     }
 }
开发者ID:GlassFace,项目名称:FusionCMS,代码行数:38,代码来源:comments.php

示例2: get

 public function get($id = false)
 {
     // Is it loaded via ajax or not?
     if ($id === false) {
         $id = 0;
         $die = false;
     } else {
         $die = true;
     }
     $cache = $this->cache->get("shoutbox_" . $id . "_" . getLang());
     if ($cache !== false) {
         $shouts = $cache;
     } else {
         // Load the shouts
         $shouts = $this->shoutbox_model->getShouts($id, $this->config->item('shouts_per_page'));
         // Format the shout data
         foreach ($shouts as $key => $value) {
             $shouts[$key]['nickname'] = $this->internal_user_model->getNickname($shouts[$key]['author']);
             $shouts[$key]['content'] = $this->template->format($shouts[$key]['content'], true, true, true, 40);
         }
         $this->cache->save("shoutbox_" . $id . "_" . getLang(), $shouts);
     }
     foreach ($shouts as $key => $value) {
         $shouts[$key]['date'] = $this->template->formatTime(time() - $shouts[$key]['date']);
     }
     // Prepare the data
     $data = array("module" => "sidebox_shoutbox", "shouts" => $shouts, "url" => $this->template->page_url, "user_is_gm" => hasPermission("removeShout", "sidebox_shoutbox"));
     $shouts = $this->template->loadPage("shouts.tpl", $data);
     // To be or not to be, that's the question :-)
     if ($die) {
         die($shouts);
     } else {
         return $shouts;
     }
 }
开发者ID:GlassFace,项目名称:FusionCMS,代码行数:35,代码来源:shoutbox.php

示例3: __construct

 public function __construct()
 {
     parent::__construct();
     if (!hasPermission('access_help_page')) {
         redirect(BASE_URL . 'dashboard/');
     }
 }
开发者ID:jmcismail,项目名称:tinyPHP,代码行数:7,代码来源:Help.php

示例4: index

 public function index()
 {
     requirePermission("view");
     $this->template->setTitle(lang("user_panel", "ucp"));
     $cache = $this->cache->get("profile_characters_" . $this->user->getId());
     if ($cache !== false) {
         $characters = $cache;
     } else {
         $characters_data = array("characters" => $this->realms->getTotalCharacters(), "realms" => $this->realms->getRealms(), "url" => $this->template->page_url, "realmObj" => $this->realms);
         $characters = $this->template->loadPage("ucp_characters.tpl", $characters_data);
         $this->cache->save("profile_characters_" . $this->user->getId(), $characters, 60 * 60);
     }
     $links = $this->menu_model->getMenuLinks();
     if ($links) {
         foreach ($links as $key => $value) {
             // Check if we have  the permission, otherwise unset the row
             if ($value['permission'] != '') {
                 if (hasPermission($value['permission'], $value['permissionModule']) !== true) {
                     unset($links[$key]);
                     continue;
                 }
             }
             // Add the website path if internal link
             if (!preg_match("/https?:\\/\\//", $value['link'])) {
                 $links[$key]['link'] = $this->template->page_url . $value['link'];
             }
             $links[$key]['name'] = langColumn($links[$key]['name']);
         }
     }
     $data = array("username" => $this->user->getNickname(), "expansion" => $this->realms->getEmulator()->getExpansionName($this->external_account_model->getExpansion()), "vp" => $this->internal_user_model->getVp(), "dp" => $this->internal_user_model->getDp(), "url" => $this->template->page_url, "location" => $this->internal_user_model->getLocation(), "groups" => $this->acl_model->getGroupsByUser($this->user->getId()), "register_date" => $this->user->getRegisterDate(), "status" => $this->user->getAccountStatus(), "characters" => $characters, "avatar" => $this->user->getAvatar($this->user->getId()), "id" => $this->user->getId(), "menu_links" => $links, "config" => array("vote" => $this->config->item('ucp_vote'), "donate" => $this->config->item('ucp_donate'), "store" => $this->config->item('ucp_store'), "settings" => $this->config->item('ucp_settings'), "expansion" => $this->config->item('ucp_expansion'), "teleport" => $this->config->item('ucp_teleport'), "admin" => $this->config->item('ucp_admin'), "gm" => $this->config->item('ucp_gm')));
     $this->template->view($this->template->loadPage("page.tpl", array("module" => "default", "headline" => lang("user_panel", "ucp"), "content" => $this->template->loadPage("ucp.tpl", $data))), "modules/ucp/css/ucp.css");
 }
开发者ID:saqar,项目名称:FusionCMS-themes-and-modules,代码行数:32,代码来源:ucp.php

示例5: save

 public function save($id = false)
 {
     if (!hasPermission("editAccounts")) {
         die("UI.alert('You do not have permission to edit accounts')");
     }
     if (!$id || !is_numeric($id)) {
         die;
     }
     $external_account_data[column("account", "expansion")] = $this->input->post("expansion");
     $external_account_data[column("account", "email")] = $this->input->post("email");
     if (hasPermission("editPermissions")) {
         $this->acl_model->removePermissionsFromUser($id);
         foreach ($_POST as $k => $v) {
             if ($v !== '' && !in_array($k, array("vp", "dp", "nickname", "email", "group", "expansion", "password", "gm_level"))) {
                 $permissionParts = explode("-", $k);
                 // UserID, permissionName, moduleName
                 $this->acl_model->assignPermissionToUser($id, $permissionParts[1], $permissionParts[0], $v);
             }
         }
     }
     // Make sure to check if we got something filled in here.
     if ($this->input->post("password")) {
         $external_account_data[column("account", "password")] = $this->realms->getEmulator()->encrypt($this->user->getUsername($id), $this->input->post("password"));
     }
     $external_account_access_data[column("account_access", "gmlevel")] = $this->input->post("gm_level");
     $internal_account_data["vp"] = $this->input->post("vp");
     $internal_account_data["dp"] = $this->input->post("dp");
     $internal_account_data["nickname"] = $this->input->post("nickname");
     if (!$external_account_data[column("account", "email")] || !$internal_account_data["nickname"]) {
         die("UI.alert('The fields can\\'t be empty')");
     }
     $this->accounts_model->save($id, $external_account_data, $external_account_access_data, $internal_account_data);
     die('UI.alert("The account has been saved")');
 }
开发者ID:GlassFace,项目名称:FusionCMS,代码行数:34,代码来源:accounts.php

示例6: authorize

 /**
  * Determine if the user is authorized to make this request.
  *
  * @return bool
  */
 public function authorize()
 {
     $hackedRoute = 'admin.page_category.update';
     if (!is_null($this->segment(4))) {
         $hackedRoute .= '#####' . $this->segment(3);
     }
     return hasPermission($hackedRoute);
 }
开发者ID:erenmustafaozdal,项目名称:laravel-page-module,代码行数:13,代码来源:UpdateRequest.php

示例7: __construct

 public function __construct()
 {
     parent::__construct();
     $this->_auth = new \tinyPHP\Classes\Libraries\Cookies();
     if (!hasPermission('manage_roles')) {
         redirect(BASE_URL . 'dashboard/');
     }
 }
开发者ID:jmcismail,项目名称:tinyPHP,代码行数:8,代码来源:Role.php

示例8: getAddService

function getAddService()
{
    include 'func/hasPerm.php';
    if (hasPermission("addService")) {
        if (isset($_POST['nazwa']) && ($_POST['nazwa'] == "" || $_POST['id_uslugi'] == "" || $_POST['serwer_id'] == "" || $_POST['opis'] == "" || $_POST['zdjecie'] == "" || $_POST['sms_tresc'] == "" || $_POST['sms_numer'] == "" || $_POST['sms_cena'] == "" || $_POST['api_konta'] == "" || $_POST['api_sms'] == "")) {
            echo '
							<div class="alert alert-danger" role="alert">
							  Zostawiłeś puste pola! Spróbuj ponownie!
							</div>
					';
            echoServiceForm();
        } else {
            if (!isset($_POST['nazwa'])) {
                echoServiceForm();
            } else {
                if (ctype_alnum($_POST['nazwa'])) {
                    include '../config/mysql.php';
                    $sql = "INSERT INTO services (server_id, nazwa, tresc, numer, koszt_sms, payment, acc_api, param, krotki_opis, img)\n\t\t\t\t\t\t\tVALUES ('" . $_POST['serwer_id'] . "', '" . $_POST['nazwa'] . "', '" . $_POST['sms_tresc'] . "',  '" . $_POST['sms_numer'] . "',  '" . $_POST['sms_cena'] . "',  '" . $_POST['payment_id'] . "',  '" . $_POST['api_konta'] . "',  '" . $_POST['api_sms'] . "',  '" . $_POST['opis'] . "',  '" . $_POST['zdjecie'] . "')";
                    if ($conn->query($sql) === TRUE) {
                        echo '
										<div class="alert alert-success" role="alert">
										  Usługa została dodana!<br>
										  Możesz teraz przystąpić do testowania!
										</div>
								';
                        echo '<meta http-equiv="refresh" content="3; url=index.php" />';
                    } else {
                        echo '
										<div class="alert alert-danger" role="alert">
										  Wystąpił błąd podczas dodawania wpisu do bazy danych!
										</div>
								';
                    }
                } else {
                    echo '
							
							<div class="alert alert-danger" role="alert">
							  Podałeś nie poprawne dane!
							</div>
							
							';
                    echoServiceForm();
                }
            }
        }
    } else {
        echo '
			
					<div class="alert alert-danger" role="alert">
					 	Nie masz uprawnień do dodawania usług!
					</div>
			
			';
    }
}
开发者ID:kiukiu123,项目名称:KukuShop,代码行数:55,代码来源:services_add.php

示例9: getAddServer

function getAddServer()
{
    include 'func/hasPerm.php';
    if (hasPermission("addServer")) {
        if (isset($_POST['nazwa']) && ($_POST['nazwa'] == "" || $_POST['serv_id'] == "" || $_POST['serv_ip'] == "" || $_POST['port_q'] == "" || $_POST['port_r'] == "" || $_POST['pass_r'] == "")) {
            echo '
							<div class="alert alert-danger" role="alert">
							  Zostawiłeś puste pola! Spróbuj ponownie!
							</div>
					';
            echoForm();
        } else {
            if (!isset($_POST['nazwa'])) {
                echoForm();
            } else {
                if (is_numeric($_POST['port_q']) && is_numeric($_POST['port_r']) && ctype_alnum($_POST['nazwa']) && ctype_alnum($_POST['serv_id']) && ctype_alnum($_POST['pass_r']) && ip2long($_POST['serv_ip']) !== false) {
                    include '../config/mysql.php';
                    $sql = "INSERT INTO servers (server_id, nazwa, ip, port_query, port_rcon, pasw_rcon)\n\t\t\t\t\t\t\tVALUES ('" . $_POST['serv_id'] . "', '" . $_POST['nazwa'] . "', '" . $_POST['serv_ip'] . "',  '" . $_POST['port_q'] . "',  '" . $_POST['port_r'] . "',  '" . $_POST['pass_r'] . "')";
                    if ($conn->query($sql) === TRUE) {
                        echo '
										<div class="alert alert-success" role="alert">
										  Nowy serwer został dodany!<br>
										  Możesz teraz przystąpić do dodawania usług.
										</div>
								';
                        echo '<meta http-equiv="refresh" content="3; url=index.php?page=serverList" />';
                    } else {
                        echo '
										<div class="alert alert-danger" role="alert">
										  Wystąpił błąd podczas dodawania wpisu do bazy danych!
										</div>
								';
                    }
                } else {
                    echo '
							
							<div class="alert alert-danger" role="alert">
							  Porty muszą być cyframi, nazwa, ID serwera oraz hasło RCON nie może zawierać znaków specjalnych, lub IP jest nie poprawne.
							</div>
							
							';
                }
            }
        }
    } else {
        echo '
			
					<div class="alert alert-danger" role="alert">
					 	Nie masz uprawnień do dodawania serwerów!
					</div>
			
			';
    }
}
开发者ID:kiukiu123,项目名称:KukuShop,代码行数:54,代码来源:add_server.php

示例10: menuInit

 /**
  * init menus
  *
  * @param string $type
  */
 public function menuInit($type)
 {
     Menu::make($type, function ($menu) use($type) {
         $menus = $type . 'Menus';
         foreach ($this->{$menus} as $action) {
             $action::addMenu($menu);
         }
     })->filter(function ($item) {
         if (is_null($item->data('permissions'))) {
             return true;
         }
         return $this->user->is_super_admin || hasPermission($item->data('permissions')) ?: false;
     });
 }
开发者ID:erenmustafaozdal,项目名称:laravel-modules-core,代码行数:19,代码来源:MenuMiddleware.php

示例11: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $route = Route::currentRouteName();
     $method = $request->method();
     $parameters = Route::current()->parameters();
     $hackedRoute = routeHack($route, $parameters);
     // if user destroy route
     if ($method == 'GET' && in_array($route, $this->userDestroyRoutes) && !is_null(Request::route('users')) && Request::route('users')->id === Sentinel::getUser()->id) {
         abort(403);
     }
     //        dd($hackedRoute);
     if ($method == 'GET' && !in_array($route, $this->exceptRoutes) && !Sentinel::getUser()->is_super_admin && ((!in_array($route, $this->userRoutes) || is_null(Request::route('users')) || Request::route('users')->id !== Sentinel::getUser()->id) && !hasPermission($hackedRoute))) {
         abort(403);
     }
     return $next($request);
 }
开发者ID:erenmustafaozdal,项目名称:laravel-modules-base,代码行数:23,代码来源:Permission.php

示例12: setRoutes

 /**
  * set routes
  *
  * @return void
  */
 private function setRoutes()
 {
     foreach ($this->myModules as $module) {
         $scModule = snake_case($module, '-');
         $subModules = config("{$scModule}.permissions");
         if (!is_null($subModules)) {
             foreach ($subModules as $sub => $routes) {
                 $hasRoutes = array_filter(array_keys($routes['routes']), function ($item) {
                     return hasPermission($item);
                 });
                 if (count($hasRoutes) > 0) {
                     $this->routes[$scModule . '_' . $sub] = $routes;
                 }
             }
         }
     }
 }
开发者ID:erenmustafaozdal,项目名称:laravel-modules-base,代码行数:22,代码来源:PermissionService.php

示例13: hasPermissions

function hasPermissions($permissions, $conjuction = 'and')
{
    if ($conjuction == 'and') {
        foreach ($permissions as $permission) {
            if (!hasPermission($permission)) {
                return false;
            }
        }
        return true;
    } elseif ($conjuction == 'or') {
        foreach ($permissions as $permission) {
            if (hasPermission($permission)) {
                return true;
            }
        }
        return false;
    } else {
        throw new Exception("Illegal grammatical conjuction: {$conjuction}");
    }
}
开发者ID:hlacos,项目名称:lara-mvcms,代码行数:20,代码来源:helpers.php

示例14: index

 public function index()
 {
     if (isAdmin() || hasPermission('roles.content.CUD')) {
         //            echo "valid";
         if (strtolower($_SERVER['REQUEST_METHOD']) == 'post') {
             $to_do_with_post = $_POST["todo"];
             /*echo $to_do_with_post;*/
             /*print_r($this->input->post());*/
             if (isset($to_do_with_post)) {
                 if ($to_do_with_post == 'insert_roles') {
                     $this->_insertRoles($this->input->post());
                 }
             }
         } else {
             $this->load->view('index.php');
         }
     } else {
         echo "Please login first. Or you do not have the permission [access roles]";
     }
 }
开发者ID:nkscoder,项目名称:chawri,代码行数:20,代码来源:User_roles.php

示例15: boot

 /**
  * Register any application authentication / authorization services.
  *
  * @param  \Illuminate\Contracts\Auth\Access\Gate  $gate
  * @return void
  */
 public function boot(GateContract $gate)
 {
     $this->registerPolicies($gate);
     // The current user must be on the same crew as the user being destroyed, unless the current user is a Global Admin
     $gate->define('destroy_user', function ($current_user, $user_to_destroy) {
         return $current_user->crew_id === $user_to_destroy->crew_id;
     })->before(function ($current_user, $ability) {
         // Global Admin users will always be granted this permission
         if ($current_user->isGlobalAdmin()) {
             return true;
         }
     });
     // The current user must be on the same crew as the Crew object passed in AND have the specified User->permission
     // If $action is null, User->hasPermission($action) will return TRUE
     $gate->define('performActionForCrew', function ($current_user, $target_crew, $action = null) {
         return $current_user->crew_id === $target_crew->id && $current_user . hasPermission($action);
     })->before(function ($current_user, $ability) {
         // Global Admin users will always be granted this permission
         if ($current_user->isGlobalAdmin()) {
             return true;
         }
     });
     // The current user must be a Crew Admin for the target Crew
     $gate->define('actAsAdminForCrew', function ($current_user, $target_crew) {
         // Allow $target_crew to be passed in as either a Crew object OR an Integer crew_id
         // If $target_crew is NULL, return FALSE.... UNLESS the $current_user is a Global Admin
         if (is_object($target_crew)) {
             return $current_user->isAdminForCrew($target_crew->id);
         } elseif (is_numeric($target_crew)) {
             return $current_user->isAdminForCrew(intval($target_crew));
         } else {
             return false;
         }
         // An invalid data type was passed in for $target_crew (only integer or Crew Object are allowed)
     })->before(function ($current_user, $ability) {
         // Global Admin users will always be granted this permission
         if ($current_user->isGlobalAdmin()) {
             return true;
         }
     });
 }
开发者ID:evanhsu,项目名称:rescuecircle,代码行数:47,代码来源:AuthServiceProvider.php


注:本文中的hasPermission函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。