本文整理匯總了PHP中PermissionPeer::checkValidPermissionsForRole方法的典型用法代碼示例。如果您正苦於以下問題:PHP PermissionPeer::checkValidPermissionsForRole方法的具體用法?PHP PermissionPeer::checkValidPermissionsForRole怎麽用?PHP PermissionPeer::checkValidPermissionsForRole使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類PermissionPeer
的用法示例。
在下文中一共展示了PermissionPeer::checkValidPermissionsForRole方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: updateAction
/**
* Updates an existing user role object.
*
* @action update
* @param int $userRoleId The user role's unique identifier
* @param KalturaUserRole $userRole The user role's unique identifier
* @return KalturaUserRole The updated user role object
*
* @throws KalturaErrors::INVALID_OBJECT_ID
* @throws KalturaErrors::PERMISSION_NOT_FOUND
*/
public function updateAction($userRoleId, KalturaUserRole $userRole)
{
/* critera is used here instead of retrieveByPk on purpose!
if the current context is assigned to a partner 0 role, then retrieveByPk will return it from cache even though partner 0 is not in
the partner group for the current action and context */
$c = new Criteria();
$c->addAnd(UserRolePeer::ID, $userRoleId, Criteria::EQUAL);
if ($this->partnerGroup() != myPartnerUtils::ALL_PARTNERS_WILD_CHAR) {
$c->addAnd(UserRolePeer::PARTNER_ID, explode(',', $this->partnerGroup()), Criteria::IN);
}
$dbUserRole = UserRolePeer::doSelectOne($c);
if (!$dbUserRole) {
throw new KalturaAPIException(KalturaErrors::INVALID_OBJECT_ID, $userRoleId);
}
// cannot update name to a name that already exists
if ($userRole->name && $userRole->name != $dbUserRole->getName()) {
if (UserRolePeer::getByNameAndPartnerId($userRole->name, $this->getPartnerId())) {
throw new KalturaAPIException(KalturaErrors::ROLE_NAME_ALREADY_EXISTS);
}
}
if (!is_null($userRole->permissionNames) && !$userRole->permissionNames instanceof KalturaNullField) {
try {
PermissionPeer::checkValidPermissionsForRole($userRole->permissionNames, $this->getPartnerId());
} catch (kPermissionException $e) {
$code = $e->getCode();
if ($code == kPermissionException::PERMISSION_NOT_FOUND) {
throw new KalturaAPIException(KalturaErrors::PERMISSION_NOT_FOUND, $e->getMessage());
}
}
}
$dbUserRole = $userRole->toUpdatableObject($dbUserRole);
$dbUserRole->save();
$userRole = new KalturaUserRole();
$userRole->fromObject($dbUserRole, $this->getResponseProfile());
return $userRole;
}