当前位置: 首页>>代码示例>>PHP>>正文


PHP kEntitlementUtils::getCategoryModeration方法代码示例

本文整理汇总了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;
 }
开发者ID:GElkayam,项目名称:server,代码行数:72,代码来源:CategoryEntryService.php


注:本文中的kEntitlementUtils::getCategoryModeration方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。