public static function fromCategoryArray($arr)
 {
     $newArr = new KalturaCategoryArray();
     foreach ($arr as $obj) {
         $nObj = new KalturaCategory();
         $nObj->fromObject($obj);
         $newArr[] = $nObj;
     }
     return $newArr;
 }
 public static function fromDbArray($arr, KalturaDetachedResponseProfile $responseProfile = null)
 {
     $newArr = new KalturaCategoryArray();
     foreach ($arr as $obj) {
         $nObj = new KalturaCategory();
         $nObj->fromObject($obj, $responseProfile);
         $newArr[] = $nObj;
     }
     return $newArr;
 }
 function update($id, KalturaCategory $category)
 {
     $kparams = array();
     $this->client->addParam($kparams, "id", $id);
     $this->client->addParam($kparams, "category", $category->toParams());
     $this->client->queueServiceActionCall("category", "update", $kparams);
     if ($this->client->isMultiRequest()) {
         return null;
     }
     $resultObject = $this->client->doQueue();
     $this->client->throwExceptionIfError($resultObject);
     $this->client->validateObjectType($resultObject, "KalturaCategory");
     return $resultObject;
 }
Beispiel #4
0
 /**
  * Update Category
  * 
  * @action update
  * @param int $id
  * @param KalturaCategory $category
  * @return KalturaCategory
  */
 function updateAction($id, KalturaCategory $category)
 {
     $categoryDb = categoryPeer::retrieveByPK($id);
     if (!$categoryDb) {
         throw new KalturaAPIException(KalturaErrors::CATEGORY_NOT_FOUND, $id);
     }
     if ($category->name !== null) {
         $category->validatePropertyMinLength("name", 1);
         $category->validatePropertyMaxLength("name", categoryPeer::MAX_CATEGORY_NAME);
     }
     if ($category->parentId !== null) {
         $category->validateParentId($category);
     }
     if ($this->getPartner()->isCategoriesLocked()) {
         throw new KalturaAPIException(KalturaErrors::CATEGORIES_LOCKED, Partner::CATEGORIES_LOCK_TIMEOUT);
     }
     try {
         $this->getPartner()->lockCategories();
         $category->toUpdatableObject($categoryDb);
         $categoryDb->save();
         $this->getPartner()->unlockCategories();
     } catch (Exception $ex) {
         $this->getPartner()->unlockCategories();
         if ($ex instanceof kCoreException) {
             $this->handleCoreException($ex, $categoryDb, $category);
         } else {
             throw $ex;
         }
     }
     $category = new KalturaCategory();
     $category->fromObject($categoryDb);
     return $category;
 }
Beispiel #5
0
 /**
  * Update Category
  * 
  * @action update
  * @param int $id
  * @param KalturaCategory $category
  * @return KalturaCategory
  */
 function updateAction($id, KalturaCategory $category)
 {
     if ($category->owner == '') {
         $category->owner = null;
     }
     $categoryDb = categoryPeer::retrieveByPK($id);
     if (!$categoryDb) {
         throw new KalturaAPIException(KalturaErrors::CATEGORY_NOT_FOUND, $id);
     }
     if ($category->privacyContext != null && $category->privacyContext != '') {
         $privacyContexts = explode(',', $category->privacyContext);
         foreach ($privacyContexts as $privacyContext) {
             if (!preg_match('/^[a-zA-Z\\d]+$/', $privacyContext) || strlen($privacyContext) < 4) {
                 KalturaLog::err('Invalid privacy context: ' . print_r($privacyContext, true));
                 throw new KalturaAPIException(KalturaErrors::PRIVACY_CONTEXT_INVALID_STRING, $privacyContext);
             }
         }
     }
     //it is possible to not all of the sub tree is updated,
     //and updateing fileds that will add batch job to reindex categories - might not update all sub categories.
     //batch to index categories or to move categories might miss this category to be moved or index
     if ($category->parentId != null && $category->parentId != $categoryDb->getParentId() && $this->getPartner()->getFeaturesStatusByType(IndexObjectType::LOCK_CATEGORY)) {
         throw new KalturaAPIException(KalturaErrors::CATEGORIES_LOCKED);
     }
     if (kEntitlementUtils::getEntitlementEnforcement()) {
         $currentKuserCategoryKuser = categoryKuserPeer::retrievePermittedKuserInCategory($categoryDb->getId(), kCurrentContext::getCurrentKsKuserId(), array(PermissionName::CATEGORY_EDIT));
         if (!$currentKuserCategoryKuser || $currentKuserCategoryKuser->getPermissionLevel() != CategoryKuserPermissionLevel::MANAGER) {
             throw new KalturaAPIException(KalturaErrors::NOT_ENTITLED_TO_UPDATE_CATEGORY);
         }
     }
     try {
         $category->toUpdatableObject($categoryDb);
         $categoryDb->save();
     } catch (Exception $ex) {
         if ($ex instanceof kCoreException) {
             $this->handleCoreException($ex, $categoryDb, $category);
         } else {
             throw $ex;
         }
     }
     $category = new KalturaCategory();
     $category->fromObject($categoryDb, $this->getResponseProfile());
     return $category;
 }