本文整理汇总了PHP中category::getInheritanceType方法的典型用法代码示例。如果您正苦于以下问题:PHP category::getInheritanceType方法的具体用法?PHP category::getInheritanceType怎么用?PHP category::getInheritanceType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类category
的用法示例。
在下文中一共展示了category::getInheritanceType方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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);
}
}
示例2: validateCategory
/**
* validate category fields
* 1. category that inherit memebers canno 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())) {
if ($this->appearInList != KalturaAppearInListType::PARTNER_ONLY && $this->appearInList != null || $this->moderation != KalturaNullableBoolean::FALSE_VALUE && $this->moderation != null || $this->inheritanceType != KalturaInheritanceType::MANUAL && $this->inheritanceType != null || $this->privacy != KalturaPrivacyType::ALL && $this->privacy != null || $this->owner != null || $this->userJoinPolicy != KalturaUserJoinPolicyType::NOT_ALLOWED && $this->userJoinPolicy != null || $this->contributionPolicy != KalturaContributionPolicyType::ALL && $this->contributionPolicy != null || $this->defaultPermissionLevel != KalturaCategoryUserPermissionLevel::MEMBER && $this->defaultPermissionLevel !== null) {
if ($this->parentId != null) {
$parentCategory = categoryPeer::retrieveByPK($this->parentId);
if (!$parentCategory) {
throw new KalturaAPIException(KalturaErrors::CATEGORY_NOT_FOUND, $this->parentId);
}
if ($parentCategory->getPrivacyContexts() == '') {
throw new KalturaAPIException(KalturaErrors::CANNOT_UPDATE_CATEGORY_ENTITLEMENT_FIELDS_WITH_NO_PRIVACY_CONTEXT);
}
} else {
throw new KalturaAPIException(KalturaErrors::CANNOT_UPDATE_CATEGORY_ENTITLEMENT_FIELDS_WITH_NO_PRIVACY_CONTEXT);
}
}
}
if ($this->inheritanceType != KalturaInheritanceType::MANUAL && $this->inheritanceType != null || $this->inheritanceType == null && $sourceObject && $sourceObject->getInheritanceType() != KalturaInheritanceType::MANUAL) {
if (!$sourceObject && $this->owner != null || $sourceObject && $this->owner != null && $this->owner != $sourceObject->getKuserId() || !$sourceObject && $this->userJoinPolicy != null || $sourceObject && $this->userJoinPolicy != null && $this->userJoinPolicy != $sourceObject->getUserJoinPolicy() || !$sourceObject && $this->defaultPermissionLevel != null || $sourceObject && $this->defaultPermissionLevel != null && $this->defaultPermissionLevel != $sourceObject->getDefaultPermissionLevel()) {
throw new KalturaAPIException(KalturaErrors::CATEGORY_INHERIT_MEMBERS_CANNOT_UPDATE_INHERITED_ATTRIBUTES);
}
}
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::INVALID_FIELD_VALUE, 'owner');
}
$partnerId = kCurrentContext::$partner_id ? kCurrentContext::$partner_id : kCurrentContext::$ks_partner_id;
kuserPeer::createKuserForPartner($partnerId, $this->owner);
}
}