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


PHP Scalr_Account_User::isTeamUserInEnvironment方法代碼示例

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


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

示例1: callActionMethod

 public function callActionMethod($method)
 {
     if ($this->request->getRequestType() == Scalr_UI_Request::REQUEST_TYPE_API) {
         $apiMethodCheck = false;
         if (method_exists($this, 'getApiDefinitions')) {
             $api = $this::getApiDefinitions();
             $m = str_replace('Action', '', $method);
             if (in_array($m, $api)) {
                 $apiMethodCheck = true;
             }
         }
         if (!$apiMethodCheck) {
             throw new Scalr_UI_Exception_NotFound();
         }
     }
     if ($this->user) {
         if ($this->user->getType() == Scalr_Account_User::TYPE_TEAM_USER) {
             if (!$this->user->isTeamUserInEnvironment($this->getEnvironmentId(), Scalr_Account_Team::PERMISSIONS_OWNER) && !$this->user->isTeamUserInEnvironment($this->getEnvironmentId(), Scalr_Account_Team::PERMISSIONS_FULL)) {
                 if (method_exists($this, 'getPermissionDefinitions')) {
                     // rules defined for this controller
                     $cls = get_class($this);
                     $clsShort = str_replace('Scalr_UI_Controller_', '', $cls);
                     $methodShort = str_replace('Action', '', $method);
                     $clsPermissions = $cls::getPermissionDefinitions();
                     $permissions = $this->user->getGroupPermissions($this->getEnvironmentId());
                     if (array_key_exists($clsShort, $permissions)) {
                         // rules for user and such controller
                         $perm = $permissions[$clsShort];
                         if (!in_array('FULL', $perm, true)) {
                             // user doesn't has full privilegies
                             if (array_key_exists($methodShort, $clsPermissions)) {
                                 // standalone rule for this method
                                 if (!in_array($clsPermissions[$methodShort], $perm)) {
                                     throw new Scalr_Exception_InsufficientPermissions();
                                 }
                             } else {
                                 // VIEW rule
                                 if (!in_array('VIEW', $perm)) {
                                     throw new Scalr_Exception_InsufficientPermissions();
                                 }
                             }
                         }
                     } else {
                         throw new Scalr_Exception_InsufficientPermissions();
                     }
                 }
             }
         }
     }
     $this->{$method}();
 }
開發者ID:rakesh-mohanta,項目名稱:scalr,代碼行數:51,代碼來源:Controller.php


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