Exemple #1
0
 /**
  * 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;
 }
<?php

/**
 * @package deployment
 * 
 * Update integration->notify permission name and related objects
 */
$script = realpath(dirname(__FILE__) . '/../../../../') . '/alpha/scripts/utils/permissions/addPermissionsAndItems.php';
$config = realpath(dirname(__FILE__)) . '/../../../permissions/partner.0.ini';
passthru("php {$script} {$config}");
$config = realpath(dirname(__FILE__)) . '/../../../permissions/service.integration.integration.ini';
passthru("php {$script} {$config}");
require_once dirname(__FILE__) . "/../../../../" . "alpha/scripts/bootstrap.php";
$userRole = UserRolePeer::getByNameAndPartnerId(kIntegrationFlowManager::EXTERNAL_INTEGRATION_SERVICES_ROLE_NAME, PartnerPeer::GLOBAL_PARTNER);
$permissionNamesStr = $userRole->getPermissionNames();
$permissionNamesArr = explode(",", $permissionNamesStr);
$permissionNamesArr = array_map('trim', $permissionNamesArr);
$index = array_search("VOICEBASE_ACTIONS", $permissionNamesArr);
if ($index !== false) {
    unset($permissionNamesArr[$index]);
}
$permissionNamesArr[] = "INTEGRATION_ACTIONS";
$permissionNamesStr = implode(",", $permissionNamesArr);
$userRole->setPermissionNames($permissionNamesStr);
$userRole->save();