public function syncCategories() { if (!$this->is_categories_modified) { return; } if (!kEntitlementUtils::getEntitlementEnforcement() || !kEntitlementUtils::isKsPrivacyContextSet()) { categoryEntryPeer::syncEntriesCategories($this, $this->is_categories_names_modified); } parent::save(); $this->is_categories_modified = false; }
/** * Index CategoryEntry by Id * * @action index * @param string $entryId * @param int $categoryId * @param bool $shouldUpdate * @throws KalturaErrors::ENTRY_IS_NOT_ASSIGNED_TO_CATEGORY * @return int */ function indexAction($entryId, $categoryId, $shouldUpdate = true) { if (kEntitlementUtils::getEntitlementEnforcement()) { throw new KalturaAPIException(KalturaErrors::CANNOT_INDEX_OBJECT_WHEN_ENTITLEMENT_IS_ENABLE); } $dbCategoryEntry = categoryEntryPeer::retrieveByCategoryIdAndEntryId($categoryId, $entryId); if (!$dbCategoryEntry) { throw new KalturaAPIException(KalturaErrors::ENTRY_IS_NOT_ASSIGNED_TO_CATEGORY); } if (!$shouldUpdate) { $dbCategoryEntry->setUpdatedAt(time()); $dbCategoryEntry->save(); return $dbCategoryEntry->getIntId(); } $dbCategoryEntry->reSetCategoryFullIds(); $dbCategoryEntry->save(); $entry = entryPeer::retrieveByPK($dbCategoryEntry->getEntryId()); if ($entry) { $categoryEntries = categoryEntryPeer::retrieveActiveByEntryId($entryId); $categoriesIds = array(); foreach ($categoryEntries as $categoryEntry) { $categoriesIds[] = $categoryEntry->getCategoryId(); } $categories = categoryPeer::retrieveByPKs($categoriesIds); $isCategoriesModified = false; $categoriesFullName = array(); foreach ($categories as $category) { if ($category->getPrivacyContexts() == null) { $categoriesFullName[] = $category->getFullName(); $isCategoriesModified = true; } } $entry->setCategories(implode(',', $categoriesFullName)); categoryEntryPeer::syncEntriesCategories($entry, $isCategoriesModified); $entry->save(); } return $dbCategoryEntry->getId(); }