/** * activate CategoryEntry when it is pending moderation * * @action activate * @param string $entryId * @param int $categoryId * @throws KalturaErrors::INVALID_ENTRY_ID * @throws KalturaErrors::CATEGORY_NOT_FOUND * @throws KalturaErrors::ENTRY_IS_NOT_ASSIGNED_TO_CATEGORY * @throws KalturaErrors::CANNOT_ACTIVATE_CATEGORY_ENTRY */ function activateAction($entryId, $categoryId) { $entry = entryPeer::retrieveByPK($entryId); if (!$entry) { throw new KalturaAPIException(KalturaErrors::INVALID_ENTRY_ID, $entryId); } $category = categoryPeer::retrieveByPK($categoryId); if (!$category) { throw new KalturaAPIException(KalturaErrors::CATEGORY_NOT_FOUND, $categoryId); } $dbCategoryEntry = categoryEntryPeer::retrieveByCategoryIdAndEntryIdNotRejected($categoryId, $entryId); if (!$dbCategoryEntry) { throw new KalturaAPIException(KalturaErrors::ENTRY_IS_NOT_ASSIGNED_TO_CATEGORY); } //validate user is entiteld to activate entry from category if (kEntitlementUtils::getEntitlementEnforcement()) { $categoryKuser = categoryKuserPeer::retrievePermittedKuserInCategory($categoryId, kCurrentContext::getCurrentKsKuserId()); if (!$categoryKuser || $categoryKuser->getPermissionLevel() != CategoryKuserPermissionLevel::MANAGER && $categoryKuser->getPermissionLevel() != CategoryKuserPermissionLevel::MODERATOR) { throw new KalturaAPIException(KalturaErrors::CANNOT_ACTIVATE_CATEGORY_ENTRY); } } if ($dbCategoryEntry->getStatus() != CategoryEntryStatus::PENDING) { throw new KalturaAPIException(KalturaErrors::CANNOT_ACTIVATE_CATEGORY_ENTRY_SINCE_IT_IS_NOT_PENDING); } $dbCategoryEntry->setStatus(CategoryEntryStatus::ACTIVE); $dbCategoryEntry->save(); }