本文整理匯總了PHP中kEntitlementUtils::getCategoryModeration方法的典型用法代碼示例。如果您正苦於以下問題:PHP kEntitlementUtils::getCategoryModeration方法的具體用法?PHP kEntitlementUtils::getCategoryModeration怎麽用?PHP kEntitlementUtils::getCategoryModeration使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類kEntitlementUtils
的用法示例。
在下文中一共展示了kEntitlementUtils::getCategoryModeration方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: addAction
/**
* Add new CategoryEntry
*
* @action add
* @param KalturaCategoryEntry $categoryEntry
* @throws KalturaErrors::INVALID_ENTRY_ID
* @throws KalturaErrors::CATEGORY_NOT_FOUND
* @throws KalturaErrors::CANNOT_ASSIGN_ENTRY_TO_CATEGORY
* @throws KalturaErrors::CATEGORY_ENTRY_ALREADY_EXISTS
* @return KalturaCategoryEntry
*/
function addAction(KalturaCategoryEntry $categoryEntry)
{
$categoryEntry->validateForInsert();
$entry = entryPeer::retrieveByPK($categoryEntry->entryId);
if (!$entry) {
throw new KalturaAPIException(KalturaErrors::INVALID_ENTRY_ID, $categoryEntry->entryId);
}
$category = categoryPeer::retrieveByPK($categoryEntry->categoryId);
if (!$category) {
throw new KalturaAPIException(KalturaErrors::CATEGORY_NOT_FOUND, $categoryEntry->categoryId);
}
$categoryEntries = categoryEntryPeer::retrieveActiveAndPendingByEntryId($categoryEntry->entryId);
$maxCategoriesPerEntry = $entry->getMaxCategoriesPerEntry();
if (count($categoryEntries) >= $maxCategoriesPerEntry) {
throw new KalturaAPIException(KalturaErrors::MAX_CATEGORIES_FOR_ENTRY_REACHED, $maxCategoriesPerEntry);
}
//validate user is entiteld to assign entry to this category
if (kEntitlementUtils::getEntitlementEnforcement() && $category->getContributionPolicy() != ContributionPolicyType::ALL) {
$categoryKuser = categoryKuserPeer::retrievePermittedKuserInCategory($categoryEntry->categoryId, kCurrentContext::getCurrentKsKuserId());
if (!$categoryKuser) {
KalturaLog::err("User [" . kCurrentContext::getCurrentKsKuserId() . "] is not a member of the category [{$categoryEntry->categoryId}]");
throw new KalturaAPIException(KalturaErrors::CANNOT_ASSIGN_ENTRY_TO_CATEGORY);
}
if ($categoryKuser->getPermissionLevel() == CategoryKuserPermissionLevel::MEMBER) {
KalturaLog::err("User [" . kCurrentContext::getCurrentKsKuserId() . "] permission level [" . $categoryKuser->getPermissionLevel() . "] on category [{$categoryEntry->categoryId}] is not member [" . CategoryKuserPermissionLevel::MEMBER . "]");
throw new KalturaAPIException(KalturaErrors::CANNOT_ASSIGN_ENTRY_TO_CATEGORY);
}
if (!$categoryKuser->hasPermission(PermissionName::CATEGORY_EDIT) && !$categoryKuser->hasPermission(PermissionName::CATEGORY_CONTRIBUTE) && $entry->getKuserId() != kCurrentContext::getCurrentKsKuserId() && $entry->getCreatorKuserId() != kCurrentContext::getCurrentKsKuserId()) {
throw new KalturaAPIException(KalturaErrors::CANNOT_ASSIGN_ENTRY_TO_CATEGORY);
}
}
$categoryEntryExists = categoryEntryPeer::retrieveByCategoryIdAndEntryId($categoryEntry->categoryId, $categoryEntry->entryId);
if ($categoryEntryExists && $categoryEntryExists->getStatus() == CategoryEntryStatus::ACTIVE) {
throw new KalturaAPIException(KalturaErrors::CATEGORY_ENTRY_ALREADY_EXISTS);
}
if (!$categoryEntryExists) {
$dbCategoryEntry = new categoryEntry();
} else {
$dbCategoryEntry = $categoryEntryExists;
}
$categoryEntry->toInsertableObject($dbCategoryEntry);
$dbCategoryEntry->setStatus(CategoryEntryStatus::ACTIVE);
if (kEntitlementUtils::getEntitlementEnforcement() && $category->getModeration()) {
$categoryKuser = categoryKuserPeer::retrievePermittedKuserInCategory($categoryEntry->categoryId, kCurrentContext::getCurrentKsKuserId());
if (!$categoryKuser || $categoryKuser->getPermissionLevel() != CategoryKuserPermissionLevel::MANAGER && $categoryKuser->getPermissionLevel() != CategoryKuserPermissionLevel::MODERATOR) {
$dbCategoryEntry->setStatus(CategoryEntryStatus::PENDING);
}
}
if (kEntitlementUtils::getCategoryModeration() && $category->getModeration()) {
$dbCategoryEntry->setStatus(CategoryEntryStatus::PENDING);
}
$partnerId = kCurrentContext::$partner_id ? kCurrentContext::$partner_id : kCurrentContext::$ks_partner_id;
$dbCategoryEntry->setPartnerId($partnerId);
$dbCategoryEntry->save();
//need to select the entry again - after update
$entry = entryPeer::retrieveByPK($categoryEntry->entryId);
myNotificationMgr::createNotification(kNotificationJobData::NOTIFICATION_TYPE_ENTRY_UPDATE, $entry);
$categoryEntry = new KalturaCategoryEntry();
$categoryEntry->fromObject($dbCategoryEntry, $this->getResponseProfile());
return $categoryEntry;
}