本文整理汇总了PHP中kEntitlementUtils::getEntitlementEnforcement方法的典型用法代码示例。如果您正苦于以下问题:PHP kEntitlementUtils::getEntitlementEnforcement方法的具体用法?PHP kEntitlementUtils::getEntitlementEnforcement怎么用?PHP kEntitlementUtils::getEntitlementEnforcement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kEntitlementUtils
的用法示例。
在下文中一共展示了kEntitlementUtils::getEntitlementEnforcement方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setDefaultCriteriaFilter
public static function setDefaultCriteriaFilter()
{
if (self::$s_criteria_filter == null) {
self::$s_criteria_filter = new criteriaFilter();
}
$c = KalturaCriteria::create(categoryPeer::OM_CLASS);
$partnerId = kCurrentContext::$ks_partner_id ? kCurrentContext::$ks_partner_id : kCurrentContext::$partner_id;
if ($partnerId != Partner::BATCH_PARTNER_ID) {
$c->add(self::STATUS, array(CategoryStatus::DELETED, CategoryStatus::PURGED), Criteria::NOT_IN);
} else {
$c->add(self::STATUS, CategoryStatus::PURGED, Criteria::NOT_EQUAL);
}
if (kEntitlementUtils::getEntitlementEnforcement()) {
//add context as filter
$privacyContextCrit = $c->getNewCriterion(self::PRIVACY_CONTEXTS, kEntitlementUtils::getKsPrivacyContext(), KalturaCriteria::IN_LIKE);
$privacyContextCrit->addTag(KalturaCriterion::TAG_ENTITLEMENT_CATEGORY);
$c->addAnd($privacyContextCrit);
$crit = $c->getNewCriterion(self::DISPLAY_IN_SEARCH, DisplayInSearchType::PARTNER_ONLY, Criteria::EQUAL);
$crit->addTag(KalturaCriterion::TAG_ENTITLEMENT_CATEGORY);
$kuser = null;
$ksString = kCurrentContext::$ks ? kCurrentContext::$ks : '';
if ($ksString != '') {
$partnerId = kCurrentContext::$partner_id ? kCurrentContext::$partner_id : kCurrentContext::$ks_partner_id;
$kuser = kuserPeer::getActiveKuserByPartnerAndUid($partnerId, kCurrentContext::$ks_uid);
}
if ($kuser) {
$membersCrit = $c->getNewCriterion(self::MEMBERS, $kuser->getId(), Criteria::LIKE);
$membersCrit->addTag(KalturaCriterion::TAG_ENTITLEMENT_CATEGORY);
$crit->addOr($membersCrit);
}
$c->addAnd($crit);
}
self::$s_criteria_filter->setFilter($c);
}
示例2: validateForResponseProfile
public function validateForResponseProfile()
{
if (kEntitlementUtils::getEntitlementEnforcement()) {
if (PermissionPeer::isValidForPartner(PermissionName::FEATURE_ENABLE_RESPONSE_PROFILE_USER_CACHE, kCurrentContext::getCurrentPartnerId())) {
KalturaResponseProfileCacher::useUserCache();
return;
}
throw new KalturaAPIException(KalturaErrors::CANNOT_LIST_RELATED_ENTITLED_WHEN_ENTITLEMENT_IS_ENABLE, get_class($this));
}
}
示例3: setDefaultCriteriaFilter
/**
* Creates default criteria filter
*/
public static function setDefaultCriteriaFilter()
{
if (self::$s_criteria_filter == null) {
self::$s_criteria_filter = new criteriaFilter();
}
$c = KalturaCriteria::create(self::OM_CLASS);
if (kEntitlementUtils::getEntitlementEnforcement()) {
$privacyContexts = kEntitlementUtils::getKsPrivacyContextArray();
$c->addAnd(self::PRIVACY_CONTEXT, $privacyContexts, Criteria::IN);
}
$c->addAnd(self::INSTANCE_COUNT, 0, Criteria::GREATER_THAN);
self::$s_criteria_filter->setFilter($c);
}
示例4: getListResponse
public function getListResponse(KalturaFilterPager $pager, KalturaDetachedResponseProfile $responseProfile = null)
{
if (kEntitlementUtils::getEntitlementEnforcement() && (is_null($this->objectIdIn) && is_null($this->objectIdEqual))) {
throw new KalturaAPIException(MetadataErrors::MUST_FILTER_ON_OBJECT_ID);
}
if (!$this->metadataObjectTypeEqual) {
throw new KalturaAPIException(MetadataErrors::MUST_FILTER_ON_OBJECT_TYPE);
}
if ($this->metadataObjectTypeEqual == MetadataObjectType::CATEGORY) {
if ($this->objectIdEqual) {
$categoryIds = array($this->objectIdEqual);
} else {
if ($this->objectIdIn) {
$categoryIds = explode(',', $this->objectIdIn);
}
}
if ($categoryIds) {
$categories = categoryPeer::retrieveByPKs($categoryIds);
if (!count($categories)) {
KalturaLog::debug("No categories found");
$response = new KalturaMetadataListResponse();
$response->objects = new KalturaMetadataArray();
$response->totalCount = 0;
return $response;
}
$categoryIds = array();
foreach ($categories as $category) {
$categoryIds[] = $category->getId();
}
$this->objectIdEqual = null;
$this->objectIdIn = implode(',', $categoryIds);
}
}
$metadataFilter = $this->toObject();
$c = KalturaCriteria::create(MetadataPeer::OM_CLASS);
$metadataFilter->attachToCriteria($c);
$pager->attachToCriteria($c);
$list = MetadataPeer::doSelect($c);
$response = new KalturaMetadataListResponse();
$response->objects = KalturaMetadataArray::fromDbArray($list, $responseProfile);
if ($c instanceof SphinxMetadataCriteria) {
$response->totalCount = $c->getRecordsCount();
} elseif ($pager->pageIndex == 1 && count($response->objects) < $pager->pageSize) {
$response->totalCount = count($response->objects);
} else {
$pager->detachFromCriteria($c);
$response->totalCount = MetadataPeer::doCount($c);
}
return $response;
}
示例5: getObjectSpecificCacheKey
private static function getObjectSpecificCacheKey(IBaseObject $object, $responseProfileKey)
{
$userRoles = kPermissionManager::getCurrentRoleIds();
sort($userRoles);
$objectType = get_class($object);
$objectId = $object->getPrimaryKey();
$partnerId = $object->getPartnerId();
$profileKey = $responseProfileKey;
$protocol = infraRequestUtils::getProtocol();
$ksType = kCurrentContext::getCurrentSessionType();
$userRoles = implode('-', $userRoles);
$host = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : '';
$entitlement = (int) kEntitlementUtils::getEntitlementEnforcement();
return "obj_rp{$profileKey}_p{$partnerId}_o{$objectType}_i{$objectId}_h{$protocol}_k{$ksType}_u{$userRoles}_w{$host}_e{$entitlement}";
}
示例6: setDefaultCriteriaFilter
public static function setDefaultCriteriaFilter()
{
if (self::$s_criteria_filter == null) {
self::$s_criteria_filter = new criteriaFilter();
}
$c = KalturaCriteria::create(categoryPeer::OM_CLASS);
$partnerId = kCurrentContext::$ks_partner_id ? kCurrentContext::$ks_partner_id : kCurrentContext::$partner_id;
if ($partnerId != Partner::BATCH_PARTNER_ID || self::$ignoreDeleted) {
$c->add(self::STATUS, array(CategoryStatus::DELETED, CategoryStatus::PURGED), Criteria::NOT_IN);
} else {
$c->add(self::STATUS, CategoryStatus::PURGED, Criteria::NOT_EQUAL);
}
if (kEntitlementUtils::getEntitlementEnforcement()) {
//add context as filter
$privacyContextCrit = $c->getNewCriterion(self::PRIVACY_CONTEXTS, kEntitlementUtils::getKsPrivacyContext(), KalturaCriteria::IN_LIKE);
$privacyContextCrit->addTag(KalturaCriterion::TAG_ENTITLEMENT_CATEGORY);
$c->addAnd($privacyContextCrit);
$crit = $c->getNewCriterion(self::DISPLAY_IN_SEARCH, DisplayInSearchType::PARTNER_ONLY, Criteria::EQUAL);
$crit->addTag(KalturaCriterion::TAG_ENTITLEMENT_CATEGORY);
$kuser = null;
$ksString = kCurrentContext::$ks ? kCurrentContext::$ks : '';
if ($ksString != '') {
$kuser = kCurrentContext::getCurrentKsKuser();
}
if ($kuser) {
// get the groups that the user belongs to in case she is not associated to the category directly
$kgroupIds = KuserKgroupPeer::retrieveKgroupIdsByKuserId($kuser->getId());
$kgroupIds[] = $kuser->getId();
$membersCrit = $c->getNewCriterion(self::MEMBERS, $kgroupIds, KalturaCriteria::IN_LIKE);
$membersCrit->addTag(KalturaCriterion::TAG_ENTITLEMENT_CATEGORY);
$crit->addOr($membersCrit);
}
$c->addAnd($crit);
}
self::$s_criteria_filter->setFilter($c);
}
示例7: filterSelectResults
/**
* Override in order to filter objects returned from doSelect.
*
* @param array $selectResults The array of objects to filter.
* @param Criteria $criteria
*/
public static function filterSelectResults(&$selectResults, Criteria $criteria)
{
if (empty($selectResults)) {
return;
}
$partnerId = kCurrentContext::getCurrentPartnerId();
$partner = PartnerPeer::retrieveByPK($partnerId);
if ($partner && $partner->getShouldApplyAccessControlOnEntryMetadata() && !kCurrentContext::$is_admin_session) {
if (is_null(self::$accessControlScope)) {
self::$accessControlScope = new accessControlScope();
self::$accessControlScope->setContexts(array(ContextType::METADATA));
}
$selectResults = array_filter($selectResults, array('entryPeer', 'filterByAccessControl'));
if ($criteria instanceof KalturaCriteria) {
$criteria->setRecordsCount(count($selectResults));
}
}
$removedRecordsCount = 0;
if (!kEntitlementUtils::getEntitlementEnforcement() && !is_null(kCurrentContext::$ks) || !self::$filerResults || !kEntitlementUtils::getInitialized()) {
// if initEntitlement hasn't run - skip filters.
return parent::filterSelectResults($selectResults, $criteria);
}
if (is_null(kCurrentContext::$ks) && count($selectResults)) {
$entry = $selectResults[0];
$partner = $entry->getPartner();
if (!$partner) {
throw new kCoreException('entry partner not found');
}
if (!$partner->getDefaultEntitlementEnforcement() || !PermissionPeer::isValidForPartner(PermissionName::FEATURE_ENTITLEMENT, $partner->getId())) {
return parent::filterSelectResults($selectResults, $criteria);
}
}
foreach ($selectResults as $key => $entry) {
if (!kEntitlementUtils::isEntryEntitled($entry)) {
unset($selectResults[$key]);
$removedRecordsCount++;
}
}
if ($criteria instanceof KalturaCriteria) {
$recordsCount = $criteria->getRecordsCount();
$criteria->setRecordsCount($recordsCount - $removedRecordsCount);
}
self::$filerResults = false;
parent::filterSelectResults($selectResults, $criteria);
}
示例8: validateCategory
/**
* validate category fields
* 1. category that inherit memebers cannot set values to inherited fields.
* 2. validate the owner id exists as kuser
*
* @param category $sourceObject
*/
private function validateCategory(category $sourceObject = null)
{
if ($this->privacyContext != null && kEntitlementUtils::getEntitlementEnforcement()) {
throw new KalturaAPIException(KalturaErrors::CANNOT_UPDATE_CATEGORY_PRIVACY_CONTEXT);
}
if (!$this->privacyContext && (!$sourceObject || !$sourceObject->getPrivacyContexts())) {
$isInheritedPrivacyContext = true;
if ($this->parentId != null) {
$parentCategory = categoryPeer::retrieveByPK($this->parentId);
if (!$parentCategory) {
throw new KalturaAPIException(KalturaErrors::CATEGORY_NOT_FOUND, $this->parentId);
}
if ($parentCategory->getPrivacyContexts() == '') {
$isInheritedPrivacyContext = false;
}
} else {
$isInheritedPrivacyContext = false;
}
if (!$isInheritedPrivacyContext) {
if ($this->appearInList != KalturaAppearInListType::PARTNER_ONLY && !$this->isNull('appearInList')) {
throw new KalturaAPIException(KalturaErrors::CANNOT_SET_APPEAR_IN_LIST_FIELD_WITH_NO_PRIVACY_CONTEXT);
}
if ($this->inheritanceType != KalturaInheritanceType::MANUAL && !$this->isNull('inheritanceType')) {
throw new KalturaAPIException(KalturaErrors::CANNOT_SET_INHERITANCE_TYPE_FIELD_WITH_NO_PRIVACY_CONTEXT);
}
if ($this->privacy != KalturaPrivacyType::ALL && !$this->isNull('privacy')) {
throw new KalturaAPIException(KalturaErrors::CANNOT_SET_PRIVACY_FIELD_WITH_NO_PRIVACY_CONTEXT);
}
if (!$this->isNull('owner')) {
throw new KalturaAPIException(KalturaErrors::CANNOT_SET_OWNER_FIELD_WITH_NO_PRIVACY_CONTEXT);
}
if ($this->userJoinPolicy != KalturaUserJoinPolicyType::NOT_ALLOWED && !$this->isNull('userJoinPolicy')) {
throw new KalturaAPIException(KalturaErrors::CANNOT_SET_USER_JOIN_POLICY_FIELD_WITH_NO_PRIVACY_CONTEXT);
}
if ($this->contributionPolicy != KalturaContributionPolicyType::ALL && !$this->isNull('contributionPolicy')) {
throw new KalturaAPIException(KalturaErrors::CANNOT_SET_CONTIRUBUTION_POLICY_FIELD_WITH_NO_PRIVACY_CONTEXT);
}
if ($this->defaultPermissionLevel != KalturaCategoryUserPermissionLevel::MEMBER && !$this->isNull('defaultPermissionLevel')) {
throw new KalturaAPIException(KalturaErrors::CANNOT_SET_DEFAULT_PERMISSION_LEVEL_FIELD_WITH_NO_PRIVACY_CONTEXT);
}
}
}
if ($this->inheritanceType != KalturaInheritanceType::MANUAL && $this->inheritanceType != null || $this->inheritanceType == null && $sourceObject && $sourceObject->getInheritanceType() != KalturaInheritanceType::MANUAL) {
if ($this->owner != null) {
if (!$sourceObject) {
throw new KalturaAPIException(KalturaErrors::CANNOT_SET_OWNER_WHEN_CATEGORY_INHERIT_MEMBERS);
} elseif ($this->owner != $sourceObject->getKuserId()) {
throw new KalturaAPIException(KalturaErrors::CANNOT_SET_OWNER_WHEN_CATEGORY_INHERIT_MEMBERS);
}
}
if ($this->userJoinPolicy != null) {
if (!$sourceObject) {
throw new KalturaAPIException(KalturaErrors::CANNOT_SET_USER_JOIN_POLICY_WHEN_CATEGORY_INHERIT_MEMBERS);
} elseif ($this->userJoinPolicy != $sourceObject->getUserJoinPolicy()) {
throw new KalturaAPIException(KalturaErrors::CANNOT_SET_USER_JOIN_POLICY_WHEN_CATEGORY_INHERIT_MEMBERS);
}
}
if ($this->defaultPermissionLevel != null) {
if (!$sourceObject) {
throw new KalturaAPIException(KalturaErrors::CANNOT_SET_DEFAULT_PERMISSION_LEVEL_WHEN_CATEGORY_INHERIT_MEMBERS);
} elseif ($this->defaultPermissionLevel != $sourceObject->getDefaultPermissionLevel()) {
throw new KalturaAPIException(KalturaErrors::CANNOT_SET_DEFAULT_PERMISSION_LEVEL_WHEN_CATEGORY_INHERIT_MEMBERS);
}
}
}
if (!is_null($sourceObject)) {
$partnerId = kCurrentContext::$partner_id ? kCurrentContext::$partner_id : kCurrentContext::$ks_partner_id;
$partner = PartnerPeer::retrieveByPK($partnerId);
if (!$partner || $partner->getFeaturesStatusByType(IndexObjectType::LOCK_CATEGORY)) {
throw new KalturaAPIException(KalturaErrors::CATEGORIES_LOCKED);
}
}
if ($this->owner && $this->owner != '' && !$this->owner instanceof KalturaNullField) {
if (!preg_match(kuser::PUSER_ID_REGEXP, $this->owner)) {
throw new KalturaAPIException(KalturaErrors::CANNOT_SET_OWNER_FIELD_WITH_USER_ID, $this->owner);
}
$partnerId = kCurrentContext::$partner_id ? kCurrentContext::$partner_id : kCurrentContext::$ks_partner_id;
kuserPeer::createKuserForPartner($partnerId, $this->owner);
}
}
示例9: indexAction
/**
* Index CategoryUser by userid and category id
*
* @action index
* @param string $userId
* @param int $categoryId
* @param bool $shouldUpdate
* @throws KalturaErrors::INVALID_CATEGORY_USER_ID
* @return int
*/
public function indexAction($userId, $categoryId, $shouldUpdate = true)
{
if (kEntitlementUtils::getEntitlementEnforcement()) {
throw new KalturaAPIException(KalturaErrors::CANNOT_INDEX_OBJECT_WHEN_ENTITLEMENT_IS_ENABLE);
}
$partnerId = kCurrentContext::$partner_id ? kCurrentContext::$partner_id : kCurrentContext::$ks_partner_id;
$kuser = kuserPeer::getActiveKuserByPartnerAndUid($partnerId, $userId);
if (!$kuser) {
throw new KalturaAPIException(KalturaErrors::INVALID_USER_ID);
}
$dbCategoryKuser = categoryKuserPeer::retrievePermittedKuserInCategory($categoryId, $kuser->getId(), null, false);
if (!$dbCategoryKuser) {
throw new KalturaAPIException(KalturaErrors::INVALID_CATEGORY_USER_ID);
}
if (!$shouldUpdate) {
$dbCategoryKuser->setUpdatedAt(time());
$dbCategoryKuser->save();
return $dbCategoryKuser->getId();
}
$dbCategoryKuser->reSetCategoryFullIds();
$dbCategoryKuser->reSetScreenName();
$dbCategoryKuser->save();
return $dbCategoryKuser->getId();
}
示例10: indexAction
/**
* Index metadata by id, will also index the related object
*
* @action index
* @param string $id
* @param bool $shouldUpdate
* @return int
*/
function indexAction($id, $shouldUpdate)
{
if (kEntitlementUtils::getEntitlementEnforcement()) {
throw new KalturaAPIException(KalturaErrors::CANNOT_INDEX_OBJECT_WHEN_ENTITLEMENT_IS_ENABLE);
}
$dbMetadata = MetadataPeer::retrieveByPK($id);
if (!$dbMetadata) {
throw new KalturaAPIException(MetadataErrors::METADATA_NOT_FOUND, $id);
}
$dbMetadata->indexToSearchIndex();
$relatedObject = kMetadataManager::getObjectFromPeer($dbMetadata);
if ($relatedObject && $relatedObject instanceof IIndexable) {
$relatedObject->indexToSearchIndex();
}
return $dbMetadata->getId();
}
示例11: validateForUpdate
public function validateForUpdate($sourceObject, $propertiesToSkip = null)
{
/* @var $sourceObject categoryKuser */
$category = categoryPeer::retrieveByPK($sourceObject->getCategoryId());
if (!$category) {
throw new KalturaAPIException(KalturaErrors::CATEGORY_NOT_FOUND, $sourceObject->getCategoryId());
}
if ($this->permissionNames && $this->permissionNames != $sourceObject->getPermissionNames()) {
if ($sourceObject->getKuserId() == $category->getKuserId()) {
if (strpos($this->permissionNames, PermissionName::CATEGORY_EDIT) === false) {
throw new KalturaAPIException(KalturaErrors::CANNOT_UPDATE_CATEGORY_USER_OWNER);
}
}
}
$currentKuserCategoryKuser = categoryKuserPeer::retrievePermittedKuserInCategory($sourceObject->getCategoryId(), kCurrentContext::getCurrentKsKuserId());
if (kEntitlementUtils::getEntitlementEnforcement() && (!$currentKuserCategoryKuser || !$currentKuserCategoryKuser->hasPermission(PermissionName::CATEGORY_EDIT))) {
throw new KalturaAPIException(KalturaErrors::CANNOT_UPDATE_CATEGORY_USER, $sourceObject->getCategoryId());
}
return parent::validateForUpdate($sourceObject, $propertiesToSkip);
}
示例12: moveAction
/**
* Move categories that belong to the same parent category to a target categroy - enabled only for ks with disable entitlement
*
* @action move
* @param string $categoryIds
* @param int $targetCategoryParentId
* @return KalturaCategoryListResponse
*/
function moveAction($categoryIds, $targetCategoryParentId)
{
if (kEntitlementUtils::getEntitlementEnforcement()) {
throw new KalturaAPIException(KalturaErrors::CANNOT_MOVE_CATEGORIES_FROM_DIFFERENT_PARENT_CATEGORY);
}
if ($this->getPartner()->getFeaturesStatusByType(IndexObjectType::LOCK_CATEGORY)) {
throw new KalturaAPIException(KalturaErrors::CATEGORIES_LOCKED);
}
$categories = explode(',', $categoryIds);
$dbCategories = array();
$parentId = category::CATEGORY_ID_THAT_DOES_NOT_EXIST;
foreach ($categories as $categoryId) {
if ($categoryId == '') {
continue;
}
$dbCategory = categoryPeer::retrieveByPK($categoryId);
if (!$dbCategory) {
throw new KalturaAPIException(KalturaErrors::CATEGORY_NOT_FOUND, $categoryId);
}
if ($parentId == category::CATEGORY_ID_THAT_DOES_NOT_EXIST) {
$parentId = $dbCategory->getParentId();
}
if ($parentId != $dbCategory->getParentId()) {
throw new KalturaAPIException(KalturaErrors::CANNOT_MOVE_CATEGORIES_FROM_DIFFERENT_PARENT_CATEGORY);
}
$dbCategories[] = $dbCategory;
}
// if $targetCategoryParentId = 0 - it means that categories should be with no parent category
if ($targetCategoryParentId != 0) {
$dbTargetCategory = categoryPeer::retrieveByPK($targetCategoryParentId);
if (!$dbTargetCategory) {
throw new KalturaAPIException(KalturaErrors::CATEGORY_NOT_FOUND, $targetCategoryParentId);
}
}
foreach ($dbCategories as $dbCategory) {
$dbCategory->setParentId($targetCategoryParentId);
$dbCategory->save();
}
}
示例13: validateForInsert
public function validateForInsert($propertiesToSkip = array())
{
$category = categoryPeer::retrieveByPK($this->categoryId);
if (!$category) {
throw new KalturaAPIException(KalturaErrors::CATEGORY_NOT_FOUND, $this->categoryId);
}
if ($category->getInheritanceType() == InheritanceType::INHERIT) {
throw new KalturaAPIException(KalturaErrors::CATEGORY_INHERIT_MEMBERS, $this->categoryId);
}
$partnerId = kCurrentContext::$partner_id ? kCurrentContext::$partner_id : kCurrentContext::$ks_partner_id;
$kuser = kuserPeer::getKuserByPartnerAndUid($partnerId, $this->userId);
if ($kuser) {
$categoryKuser = categoryKuserPeer::retrieveByCategoryIdAndKuserId($this->categoryId, $kuser->getId());
if ($categoryKuser) {
throw new KalturaAPIException(KalturaErrors::CATEGORY_USER_ALREADY_EXISTS);
}
}
$currentKuserCategoryKuser = categoryKuserPeer::retrieveByCategoryIdAndActiveKuserId($this->categoryId, kCurrentContext::$ks_kuser_id);
if ((!$currentKuserCategoryKuser || $currentKuserCategoryKuser->getPermissionLevel() != CategoryKuserPermissionLevel::MANAGER) && $category->getUserJoinPolicy() == UserJoinPolicyType::NOT_ALLOWED && kEntitlementUtils::getEntitlementEnforcement()) {
throw new KalturaAPIException(KalturaErrors::CATEGORY_USER_JOIN_NOT_ALLOWED, $this->categoryId);
}
//if user doesn't exists - create it
$partnerId = kCurrentContext::$partner_id ? kCurrentContext::$partner_id : kCurrentContext::$ks_partner_id;
$kuser = kuserPeer::getKuserByPartnerAndUid($partnerId, $this->userId);
if (!$kuser) {
if (!preg_match(kuser::PUSER_ID_REGEXP, $this->userId)) {
throw new KalturaAPIException(KalturaErrors::INVALID_FIELD_VALUE, 'userId');
}
kuserPeer::createKuserForPartner($partnerId, $this->userId);
}
return parent::validateForInsert($propertiesToSkip);
}
示例14: getListResponse
public function getListResponse(KalturaFilterPager $pager, KalturaDetachedResponseProfile $responseProfile = null)
{
if ($this->entryIdEqual == null && $this->categoryIdIn == null && $this->categoryIdEqual == null && (kEntitlementUtils::getEntitlementEnforcement() || !kCurrentContext::$is_admin_session)) {
throw new KalturaAPIException(KalturaErrors::MUST_FILTER_ON_ENTRY_OR_CATEGORY);
}
if (kEntitlementUtils::getEntitlementEnforcement()) {
//validate entitl for entry
if ($this->entryIdEqual != null) {
$entry = entryPeer::retrieveByPK($this->entryIdEqual);
if (!$entry) {
throw new KalturaAPIException(KalturaErrors::ENTRY_ID_NOT_FOUND, $this->entryIdEqual);
}
}
//validate entitl for entryIn
if ($this->entryIdIn != null) {
$entry = entryPeer::retrieveByPKs($this->entryIdIn);
if (!$entry) {
throw new KalturaAPIException(KalturaErrors::ENTRY_ID_NOT_FOUND, $this->entryIdIn);
}
}
//validate entitl categories
if ($this->categoryIdIn != null) {
$categoryIdInArr = explode(',', $this->categoryIdIn);
if (!categoryKuserPeer::areCategoriesAllowed($categoryIdInArr)) {
$categoryIdInArr = array_unique($categoryIdInArr);
}
$entitledCategories = categoryPeer::retrieveByPKs($categoryIdInArr);
if (!count($entitledCategories) || count($entitledCategories) != count($categoryIdInArr)) {
throw new KalturaAPIException(KalturaErrors::CATEGORY_NOT_FOUND, $this->categoryIdIn);
}
$categoriesIdsUnlisted = array();
foreach ($entitledCategories as $category) {
if ($category->getDisplayInSearch() == DisplayInSearchType::CATEGORY_MEMBERS_ONLY) {
$categoriesIdsUnlisted[] = $category->getId();
}
}
if (count($categoriesIdsUnlisted)) {
if (!categoryKuserPeer::areCategoriesAllowed($categoriesIdsUnlisted)) {
throw new KalturaAPIException(KalturaErrors::CATEGORY_NOT_FOUND, $this->categoryIdIn);
}
}
}
//validate entitl category
if ($this->categoryIdEqual != null) {
$category = categoryPeer::retrieveByPK($this->categoryIdEqual);
if (!$category && kCurrentContext::$master_partner_id != Partner::BATCH_PARTNER_ID) {
throw new KalturaAPIException(KalturaErrors::CATEGORY_NOT_FOUND, $this->categoryIdEqual);
}
if ($category->getDisplayInSearch() == DisplayInSearchType::CATEGORY_MEMBERS_ONLY && !categoryKuserPeer::retrievePermittedKuserInCategory($category->getId(), kCurrentContext::getCurrentKsKuserId())) {
throw new KalturaAPIException(KalturaErrors::CATEGORY_NOT_FOUND, $this->categoryIdEqual);
}
}
}
$categoryEntryFilter = $this->toObject();
$c = KalturaCriteria::create(categoryEntryPeer::OM_CLASS);
$categoryEntryFilter->attachToCriteria($c);
if (!kEntitlementUtils::getEntitlementEnforcement() || $this->entryIdEqual == null) {
$pager->attachToCriteria($c);
}
$dbCategoriesEntry = categoryEntryPeer::doSelect($c);
if (kEntitlementUtils::getEntitlementEnforcement() && count($dbCategoriesEntry) && $this->entryIdEqual != null) {
//remove unlisted categories: display in search is set to members only
$categoriesIds = array();
foreach ($dbCategoriesEntry as $dbCategoryEntry) {
$categoriesIds[] = $dbCategoryEntry->getCategoryId();
}
$c = KalturaCriteria::create(categoryPeer::OM_CLASS);
$c->add(categoryPeer::ID, $categoriesIds, Criteria::IN);
$pager->attachToCriteria($c);
$c->applyFilters();
$categoryIds = $c->getFetchedIds();
foreach ($dbCategoriesEntry as $key => $dbCategoryEntry) {
if (!in_array($dbCategoryEntry->getCategoryId(), $categoryIds)) {
KalturaLog::debug('Category [' . print_r($dbCategoryEntry->getCategoryId(), true) . '] is not listed to user');
unset($dbCategoriesEntry[$key]);
}
}
$totalCount = $c->getRecordsCount();
} else {
$resultCount = count($dbCategoriesEntry);
if ($resultCount && $resultCount < $pager->pageSize) {
$totalCount = ($pager->pageIndex - 1) * $pager->pageSize + $resultCount;
} else {
KalturaFilterPager::detachFromCriteria($c);
$totalCount = categoryEntryPeer::doCount($c);
}
}
$categoryEntrylist = KalturaCategoryEntryArray::fromDbArray($dbCategoriesEntry, $responseProfile);
$response = new KalturaCategoryEntryListResponse();
$response->objects = $categoryEntrylist;
$response->totalCount = $totalCount;
// no pager since category entry is limited to ENTRY::MAX_CATEGORIES_PER_ENTRY
return $response;
}
示例15: rejectAction
/**
* activate CategoryEntry when it is pending moderation
*
* @action reject
* @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 rejectAction($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::retrieveByCategoryIdAndEntryId($categoryId, $entryId);
if (!$dbCategoryEntry) {
throw new KalturaAPIException(KalturaErrors::ENTRY_IS_NOT_ASSIGNED_TO_CATEGORY);
}
//validate user is entiteld to reject 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_REJECT_CATEGORY_ENTRY);
}
}
if ($dbCategoryEntry->getStatus() != CategoryEntryStatus::PENDING) {
throw new KalturaAPIException(KalturaErrors::CANNOT_REJECT_CATEGORY_ENTRY_SINCE_IT_IS_NOT_PENDING);
}
$dbCategoryEntry->setStatus(CategoryEntryStatus::REJECTED);
$dbCategoryEntry->save();
}