本文整理汇总了PHP中Scalr_Account_User::getType方法的典型用法代码示例。如果您正苦于以下问题:PHP Scalr_Account_User::getType方法的具体用法?PHP Scalr_Account_User::getType怎么用?PHP Scalr_Account_User::getType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Scalr_Account_User
的用法示例。
在下文中一共展示了Scalr_Account_User::getType方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: hasAccess
/**
* Restricts access to controller's actions
*
* @return boolean Returns true if user has access.
*/
public function hasAccess()
{
if ($this->user) {
// check admin, non-admin
if ($this->user->getType() != Scalr_Account_User::TYPE_SCALR_ADMIN) {
// check controller in permissions
return true;
} else {
return false;
}
} else {
return false;
}
}
示例2: 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}();
}