本文整理汇总了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;
}