當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Permission::allow方法代碼示例

本文整理匯總了PHP中Permission::allow方法的典型用法代碼示例。如果您正苦於以下問題:PHP Permission::allow方法的具體用法?PHP Permission::allow怎麽用?PHP Permission::allow使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Permission的用法示例。


在下文中一共展示了Permission::allow方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: isAuthorized

 public function isAuthorized()
 {
     $action = $this->request->param('action');
     $role = Session::getUserRole();
     $resource = "downloads";
     //only for admin
     Permission::allow('admin', $resource, "*");
     //only for normal users
     Permission::allow('user', $resource, "download");
     return Permission::check($role, $resource, $action);
 }
開發者ID:omarelgabry,項目名稱:miniphp,代碼行數:11,代碼來源:DownloadsController.php

示例2: isAuthorized

 public function isAuthorized()
 {
     $action = $this->request->param('action');
     $role = Session::getUserRole();
     $resource = "files";
     //only for admins
     Permission::allow('admin', $resource, ['*']);
     //only for normal users
     Permission::allow('user', $resource, ['index', 'getAll', 'create']);
     Permission::allow('user', $resource, ['delete'], 'owner');
     $fileId = Encryption::decryptIdWithDash($this->request->data("file_id"));
     $config = ["user_id" => Session::getUserId(), "table" => "files", "id" => $fileId];
     return Permission::check($role, $resource, $action, $config);
 }
開發者ID:E01T,項目名稱:miniPHP,代碼行數:14,代碼來源:FilesController.php

示例3: isAuthorized

 public function isAuthorized()
 {
     $action = $this->request->param('action');
     $role = Session::getUserRole();
     $resource = "todo";
     // only for admins
     Permission::allow('admin', $resource, ['*']);
     // only for normal users
     Permission::allow('user', $resource, ['delete'], 'owner');
     $todoId = $this->request->data("todo_id");
     if (!empty($todoId)) {
         $todoId = Encryption::decryptIdWithDash($todoId);
     }
     $config = ["user_id" => Session::getUserId(), "table" => "todo", "id" => $todoId];
     return Permission::check($role, $resource, $action, $config);
 }
開發者ID:mrSerg161,項目名稱:miniPHP,代碼行數:16,代碼來源:TodoController.php

示例4: isAuthorized

 public function isAuthorized()
 {
     $action = $this->request->param('action');
     $role = Session::getUserRole();
     $resource = "posts";
     // only for admins
     Permission::allow('admin', $resource, ['*']);
     // only for normal users
     Permission::allow('user', $resource, ['index', 'view', 'newPost', 'create']);
     Permission::allow('user', $resource, ['update', 'delete'], 'owner');
     $postId = $action === "delete" ? $this->request->param("args")[0] : $this->request->data("post_id");
     if (!empty($postId)) {
         $postId = Encryption::decryptId($postId);
     }
     $config = ["user_id" => Session::getUserId(), "table" => "posts", "id" => $postId];
     return Permission::check($role, $resource, $action, $config);
 }
開發者ID:omarelgabry,項目名稱:miniphp,代碼行數:17,代碼來源:PostsController.php

示例5: isAuthorized

 public function isAuthorized()
 {
     $action = $this->request->param('action');
     $role = Session::getUserRole();
     $resource = "newsfeed";
     // only for admins
     Permission::allow('admin', $resource, ['*']);
     // only for normal users
     Permission::allow('user', $resource, ['index', 'getAll', 'getById', 'create']);
     Permission::allow('user', $resource, ['update', 'delete', 'getUpdateForm'], 'owner');
     $newsfeedId = $this->request->data("newsfeed_id");
     if (!empty($newsfeedId)) {
         $newsfeedId = Encryption::decryptIdWithDash($newsfeedId);
     }
     $config = ["user_id" => Session::getUserId(), "table" => "newsfeed", "id" => $newsfeedId];
     return Permission::check($role, $resource, $action, $config);
 }
開發者ID:mrSerg161,項目名稱:miniPHP,代碼行數:17,代碼來源:NewsFeedController.php

示例6: isAuthorized

 public function isAuthorized()
 {
     $action = $this->request->param('action');
     $role = Session::getUserRole();
     $resource = "posts";
     //only for admins
     Permission::allow('admin', $resource, ['*']);
     //only for normal users
     Permission::allow('user', $resource, ['index', 'view', 'newPost', 'getAll', 'getById', 'create']);
     Permission::allow('user', $resource, ['update', 'delete', 'getUpdateForm'], 'owner');
     $postId = $this->request->data("post_id");
     $config = ["user_id" => Session::getUserId(), "table" => "posts", "id" => $postId];
     return Permission::check($role, $resource, $action, $config);
 }
開發者ID:E01T,項目名稱:miniPHP,代碼行數:14,代碼來源:PostsController.php


注:本文中的Permission::allow方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。