/** * Called on the server side and enables you to populate the object with any data from the DB * * @param KalturaDistributionJobData $distributionJobData */ public function __construct(KalturaDistributionJobData $distributionJobData = null) { parent::__construct($distributionJobData); if (!$distributionJobData) { return; } if (!$distributionJobData->distributionProfile instanceof KalturaFreewheelGenericDistributionProfile) { return; } $this->videoAssetFilePaths = new KalturaStringArray(); // loads all the flavor assets that should be submitted to the remote destination site $flavorAssets = assetPeer::retrieveByIds(explode(',', $distributionJobData->entryDistribution->flavorAssetIds)); foreach ($flavorAssets as $flavorAsset) { $videoAssetFilePath = new KalturaString(); $syncKey = $flavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET); $videoAssetFilePath->value = kFileSyncUtils::getLocalFilePathForKey($syncKey, false); $this->videoAssetFilePaths[] = $videoAssetFilePath; } $thumbAssets = assetPeer::retrieveByIds(explode(',', $distributionJobData->entryDistribution->thumbAssetIds)); if (count($thumbAssets)) { $thumbAsset = reset($thumbAssets); $syncKey = $thumbAssets->getSyncKey(thumbAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET); $this->thumbAssetFilePath = kFileSyncUtils::getLocalFilePathForKey($syncKey, false); } // entry cue points $c = KalturaCriteria::create(CuePointPeer::OM_CLASS); $c->add(CuePointPeer::PARTNER_ID, $distributionJobData->entryDistribution->partnerId); $c->add(CuePointPeer::ENTRY_ID, $distributionJobData->entryDistribution->entryId); $c->add(CuePointPeer::TYPE, AdCuePointPlugin::getCuePointTypeCoreValue(AdCuePointType::AD)); $c->addAscendingOrderByColumn(CuePointPeer::START_TIME); $cuePointsDb = CuePointPeer::doSelect($c); $this->cuePoints = KalturaCuePointArray::fromDbArray($cuePointsDb); }
public function fetchPage($action, $filter, $my_pager, $base_criteria = null) { myDbHelper::$use_alternative_con = myDbHelper::DB_HELPER_CONN_PROPEL2; $keywords = @$_REQUEST["keywords"]; // $sort_alias is what is sent from the browser $sort_alias = $this->sort_alias != null ? $this->sort_alias : @$_REQUEST["sort"]; // $keywords_array = mySearchUtils::getKeywordsFromStr ( $keywords ); if ($base_criteria != null) { $c = $base_criteria; } else { $c = KalturaCriteria::create(entryPeer::OM_CLASS); } $filter->addSearchMatchToCriteria($c, $keywords, $this->getSearchableColumnName()); // each entity can do specific modifications to the criteria $this->modifyCriteria($c); if ($this->skip_count) { $my_pager->attachCriteria($c, $this->getPeerMethod(), $this->getPeerCountMethod()); //$res = $my_pager->fetchPage(null , true , 0); $res = $my_pager->fetchPage(null); // , true , 0); } else { $my_pager->attachCriteria($c, $this->getPeerMethod(), $this->getPeerCountMethod()); $res = $my_pager->fetchPage(); } return $res; }
protected function doGetListResponse(KalturaFilterPager $pager, $type = null) { $this->validateEntryIdFiltered(); if (!is_null($this->userIdEqualCurrent) && $this->userIdEqualCurrent) { $this->userIdEqual = kCurrentContext::getCurrentKsKuserId(); } else { $this->translateUserIds(); } $c = KalturaCriteria::create(CuePointPeer::OM_CLASS); if ($type) { $c->add(CuePointPeer::TYPE, $type); } $entryIds = null; if ($this->entryIdEqual) { $entryIds = array($this->entryIdEqual); } else { if ($this->entryIdIn) { $entryIds = explode(',', $this->entryIdIn); } } if (!is_null($entryIds)) { $entryIds = entryPeer::filterEntriesByPartnerOrKalturaNetwork($entryIds, kCurrentContext::getCurrentPartnerId()); if (!$entryIds) { return array(array(), 0); } $this->entryIdEqual = null; $this->entryIdIn = implode(',', $entryIds); } $cuePointFilter = $this->toObject(); $cuePointFilter->attachToCriteria($c); $pager->attachToCriteria($c); $list = CuePointPeer::doSelect($c); return array($list, $c->getRecordsCount()); }
/** * 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); self::$s_criteria_filter->setFilter($c); }
/** * @action getFeed * @disableTags TAG_WIDGET_SESSION,TAG_ENTITLEMENT_ENTRY,TAG_ENTITLEMENT_CATEGORY * @param int $distributionProfileId * @param string $hash * @return file */ public function getFeedAction($distributionProfileId, $hash) { if (!$this->getPartnerId() || !$this->getPartner()) { throw new KalturaAPIException(KalturaErrors::INVALID_PARTNER_ID, $this->getPartnerId()); } $profile = DistributionProfilePeer::retrieveByPK($distributionProfileId); if (!$profile || !$profile instanceof UverseDistributionProfile) { throw new KalturaAPIException(ContentDistributionErrors::DISTRIBUTION_PROFILE_NOT_FOUND, $distributionProfileId); } if ($profile->getStatus() != KalturaDistributionProfileStatus::ENABLED) { throw new KalturaAPIException(ContentDistributionErrors::DISTRIBUTION_PROFILE_DISABLED, $distributionProfileId); } if ($profile->getUniqueHashForFeedUrl() != $hash) { throw new KalturaAPIException(UverseDistributionErrors::INVALID_FEED_URL); } // "Creates advanced filter on distribution profile $distributionAdvancedSearch = new ContentDistributionSearchFilter(); $distributionAdvancedSearch->setDistributionProfileId($profile->getId()); $distributionAdvancedSearch->setDistributionSunStatus(EntryDistributionSunStatus::AFTER_SUNRISE); $distributionAdvancedSearch->setEntryDistributionStatus(EntryDistributionStatus::READY); $distributionAdvancedSearch->setHasEntryDistributionValidationErrors(false); //Creates entry filter with advanced filter $entryFilter = new entryFilter(); $entryFilter->setStatusEquel(entryStatus::READY); $entryFilter->setModerationStatusNot(entry::ENTRY_MODERATION_STATUS_REJECTED); $entryFilter->setPartnerSearchScope($this->getPartnerId()); $entryFilter->setAdvancedSearch($distributionAdvancedSearch); $baseCriteria = KalturaCriteria::create(entryPeer::OM_CLASS); $baseCriteria->add(entryPeer::DISPLAY_IN_SEARCH, mySearchUtils::DISPLAY_IN_SEARCH_SYSTEM, Criteria::NOT_EQUAL); $entryFilter->attachToCriteria($baseCriteria); $entries = entryPeer::doSelect($baseCriteria); $feed = new UverseFeed('uverse_template.xml'); $feed->setDistributionProfile($profile); $feed->setChannelFields(); $lastBuildDate = $profile->getUpdatedAt(null); foreach ($entries as $entry) { /* @var $entry entry */ $entryDistribution = EntryDistributionPeer::retrieveByEntryAndProfileId($entry->getId(), $profile->getId()); if (!$entryDistribution) { KalturaLog::err('Entry distribution was not found for entry [' . $entry->getId() . '] and profile [' . $profile->getId() . ']'); continue; } $fields = $profile->getAllFieldValues($entryDistribution); $flavorAssets = assetPeer::retrieveByIds(explode(',', $entryDistribution->getFlavorAssetIds())); $flavorAsset = reset($flavorAssets); $flavorAssetRemoteUrl = $entryDistribution->getFromCustomData(UverseEntryDistributionCustomDataField::REMOTE_ASSET_URL); $thumbAssets = assetPeer::retrieveByIds(explode(',', $entryDistribution->getThumbAssetIds())); $feed->addItem($fields, $flavorAsset, $flavorAssetRemoteUrl, $thumbAssets); // we want to find the newest update time between all entries if ($entry->getUpdatedAt(null) > $lastBuildDate) { $lastBuildDate = $entry->getUpdatedAt(null); } } $feed->setChannelLastBuildDate($lastBuildDate); header('Content-Type: text/xml'); echo $feed->getXml(); die; }
/** * @action getFeed * @disableTags TAG_WIDGET_SESSION,TAG_ENTITLEMENT_ENTRY,TAG_ENTITLEMENT_CATEGORY * @param int $distributionProfileId * @param string $hash * @return file */ public function getFeedAction($distributionProfileId, $hash) { if (!$this->getPartnerId() || !$this->getPartner()) { throw new KalturaAPIException(KalturaErrors::INVALID_PARTNER_ID, $this->getPartnerId()); } $profile = DistributionProfilePeer::retrieveByPK($distributionProfileId); if (!$profile || !$profile instanceof SynacorHboDistributionProfile) { throw new KalturaAPIException(ContentDistributionErrors::DISTRIBUTION_PROFILE_NOT_FOUND, $distributionProfileId); } if ($profile->getStatus() != KalturaDistributionProfileStatus::ENABLED) { throw new KalturaAPIException(ContentDistributionErrors::DISTRIBUTION_PROFILE_DISABLED, $distributionProfileId); } if ($profile->getUniqueHashForFeedUrl() != $hash) { throw new KalturaAPIException(SynacorHboDistributionErrors::INVALID_FEED_URL); } // "Creates advanced filter on distribution profile $distributionAdvancedSearch = new ContentDistributionSearchFilter(); $distributionAdvancedSearch->setDistributionProfileId($profile->getId()); $distributionAdvancedSearch->setDistributionSunStatus(EntryDistributionSunStatus::AFTER_SUNRISE); $distributionAdvancedSearch->setEntryDistributionStatus(EntryDistributionStatus::READY); $distributionAdvancedSearch->setEntryDistributionFlag(EntryDistributionDirtyStatus::NONE); $distributionAdvancedSearch->setHasEntryDistributionValidationErrors(false); //Creates entry filter with advanced filter $entryFilter = new entryFilter(); $entryFilter->setStatusEquel(entryStatus::READY); $entryFilter->setModerationStatusNot(entry::ENTRY_MODERATION_STATUS_REJECTED); $entryFilter->setPartnerSearchScope($this->getPartnerId()); $entryFilter->setAdvancedSearch($distributionAdvancedSearch); $baseCriteria = KalturaCriteria::create(entryPeer::OM_CLASS); $baseCriteria->add(entryPeer::DISPLAY_IN_SEARCH, mySearchUtils::DISPLAY_IN_SEARCH_SYSTEM, Criteria::NOT_EQUAL); $entryFilter->attachToCriteria($baseCriteria); $entries = entryPeer::doSelect($baseCriteria); $feed = new SynacorHboFeed('synacor_hbo_feed_template.xml'); $feed->setDistributionProfile($profile); $counter = 0; foreach ($entries as $entry) { /* @var $entry entry */ $entryDistribution = EntryDistributionPeer::retrieveByEntryAndProfileId($entry->getId(), $profile->getId()); if (!$entryDistribution) { KalturaLog::err('Entry distribution was not found for entry [' . $entry->getId() . '] and profile [' . $profile->getId() . ']'); continue; } $fields = $profile->getAllFieldValues($entryDistribution); $flavorAssets = assetPeer::retrieveByIds(explode(',', $entryDistribution->getFlavorAssetIds())); $thumbAssets = assetPeer::retrieveByIds(explode(',', $entryDistribution->getThumbAssetIds())); $additionalAssets = assetPeer::retrieveByIds(explode(',', $entryDistribution->getAssetIds())); $feed->addItem($fields, $entry, $flavorAssets, $thumbAssets, $additionalAssets); $counter++; //to avoid the cache exceeding the memory size if ($counter >= 100) { kMemoryManager::clearMemory(); $counter = 0; } } header('Content-Type: text/xml'); echo $feed->getXml(); die; }
/** * @param $partnerId * @param $entryId */ protected function getCuePoints($partnerId, $entryId) { $c = KalturaCriteria::create(CuePointPeer::OM_CLASS); $c->add(CuePointPeer::PARTNER_ID, $partnerId); $c->add(CuePointPeer::ENTRY_ID, $entryId); $c->add(CuePointPeer::TYPE, AdCuePointPlugin::getCuePointTypeCoreValue(AdCuePointType::AD)); $c->addAscendingOrderByColumn(CuePointPeer::START_TIME); return CuePointPeer::doSelect($c); }
public static function setDefaultCriteriaFilter() { if (self::$s_criteria_filter == null) { self::$s_criteria_filter = new criteriaFilter(); } $c = KalturaCriteria::create(kuserPeer::OM_CLASS); $c->addAnd(kuserPeer::STATUS, KuserStatus::DELETED, KalturaCriteria::NOT_EQUAL); self::$s_criteria_filter->setFilter($c); }
/** * Creates default criteria filter */ public static function setDefaultCriteriaFilter() { if (self::$s_criteria_filter == null) { self::$s_criteria_filter = new criteriaFilter(); } $c = KalturaCriteria::create(KuserKgroupPeer::OM_CLASS); $c->addAnd(KuserKgroupPeer::STATUS, array(KuserKgroupStatus::DELETED), Criteria::NOT_IN); $c->addAnd(KuserKgroupPeer::PARTNER_ID, kCurrentContext::getCurrentPartnerId(), Criteria::EQUAL); self::$s_criteria_filter->setFilter($c); }
/** * Called on the server side and enables you to populate the object with any data from the DB * * @param KalturaDistributionJobData $distributionJobData */ public function __construct(KalturaDistributionJobData $distributionJobData = null) { parent::__construct($distributionJobData); if (!$distributionJobData) { return; } if (!$distributionJobData->distributionProfile instanceof KalturaHuluDistributionProfile) { return; } // loads all the flavor assets that should be submitted to the remote destination site $flavorAssets = assetPeer::retrieveByIds(explode(',', $distributionJobData->entryDistribution->flavorAssetIds)); if (count($flavorAssets)) { $flavorAsset = reset($flavorAssets); $syncKey = $flavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET); $this->videoAssetFilePath = kFileSyncUtils::getLocalFilePathForKey($syncKey, false); } $thumbAssets = assetPeer::retrieveByIds(explode(',', $distributionJobData->entryDistribution->thumbAssetIds)); if (count($thumbAssets)) { $thumbAsset = reset($thumbAssets); $syncKey = $thumbAsset->getSyncKey(thumbAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET); $this->thumbAssetFilePath = kFileSyncUtils::getLocalFilePathForKey($syncKey, false); } $additionalAssets = assetPeer::retrieveByIds(explode(',', $distributionJobData->entryDistribution->assetIds)); $this->captionLocalPaths = new KalturaStringArray(); if (count($additionalAssets)) { $captionAssetFilePathArray = array(); foreach ($additionalAssets as $additionalAsset) { $assetType = $additionalAsset->getType(); $syncKey = $additionalAsset->getSyncKey(CaptionAsset::FILE_SYNC_ASSET_SUB_TYPE_ASSET); if (kFileSyncUtils::fileSync_exists($syncKey)) { if ($assetType == CaptionPlugin::getAssetTypeCoreValue(CaptionAssetType::CAPTION) || $assetType == AttachmentPlugin::getAssetTypeCoreValue(AttachmentAssetType::ATTACHMENT)) { $string = new KalturaString(); $string->value = kFileSyncUtils::getLocalFilePathForKey($syncKey, false); $this->captionLocalPaths[] = $string; } } } } $tempFieldValues = unserialize($this->fieldValues); $pattern = '/[^A-Za-z0-9_\\-]/'; $seriesTitle = preg_replace($pattern, '', $tempFieldValues[HuluDistributionField::SERIES_TITLE]); $seasonNumber = preg_replace($pattern, '', $tempFieldValues[HuluDistributionField::SEASON_NUMBER]); $videoEpisodeNumber = preg_replace($pattern, '', $tempFieldValues[HuluDistributionField::VIDEO_EPISODE_NUMBER]); $videoTitle = preg_replace($pattern, '', $tempFieldValues[HuluDistributionField::VIDEO_TITLE]); $this->fileBaseName = $seriesTitle . '-' . $seasonNumber . '-' . $videoEpisodeNumber . '-' . $videoTitle; // entry cue points $c = KalturaCriteria::create(CuePointPeer::OM_CLASS); $c->add(CuePointPeer::PARTNER_ID, $distributionJobData->entryDistribution->partnerId); $c->add(CuePointPeer::ENTRY_ID, $distributionJobData->entryDistribution->entryId); $c->add(CuePointPeer::TYPE, AdCuePointPlugin::getCuePointTypeCoreValue(AdCuePointType::AD)); $c->addAscendingOrderByColumn(CuePointPeer::START_TIME); $cuePointsDb = CuePointPeer::doSelect($c); $this->cuePoints = KalturaCuePointArray::fromDbArray($cuePointsDb); }
public static function setDefaultCriteriaFilter() { if (self::$s_criteria_filter == null) { self::$s_criteria_filter = new criteriaFilter(); } $c = KalturaCriteria::create(UserEntryPeer::OM_CLASS); // when session is not admin, allow access to user's userEntries only if (kCurrentContext::$ks && !kCurrentContext::$is_admin_session) { $c->addAnd(UserEntryPeer::KUSER_ID, kCurrentContext::getCurrentKsKuserId()); } self::$s_criteria_filter->setFilter($c); }
function resolveCategoryTag(Tag $tag) { $c = KalturaCriteria::create(categoryPeer::OM_CLASS); $c->add(categoryPeer::PARTNER_ID, $tag->getPartnerId()); $categoryFilter = new categoryFilter(); $categoryFilter->set('_mlikeand_tags', $tag->getTag()); $categoryFilter->attachToCriteria($c); $count = $c->getRecordsCount(); if (!$count) { $tag->delete(); } }
/** * 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); }
protected function doGetListResponse(KalturaFilterPager $pager, array $types = null) { $this->validateEntryIdFiltered(); myDbHelper::$use_alternative_con = myDbHelper::DB_HELPER_CONN_PROPEL2; // verify access to the relevant entries - either same partner as the KS or kaltura network if ($this->entryIdEqual) { $entryIds = array($this->entryIdEqual); } else { if ($this->entryIdIn) { $entryIds = explode(',', $this->entryIdIn); } else { throw new KalturaAPIException(KalturaErrors::PROPERTY_VALIDATION_CANNOT_BE_NULL, 'KalturaAssetFilter::entryIdEqual/KalturaAssetFilter::entryIdIn'); } } $entryIds = array_slice($entryIds, 0, baseObjectFilter::getMaxInValues()); $c = KalturaCriteria::create(entryPeer::OM_CLASS); $c->addAnd(entryPeer::ID, $entryIds, Criteria::IN); $criterionPartnerOrKn = $c->getNewCriterion(entryPeer::PARTNER_ID, kCurrentContext::getCurrentPartnerId()); $criterionPartnerOrKn->addOr($c->getNewCriterion(entryPeer::DISPLAY_IN_SEARCH, mySearchUtils::DISPLAY_IN_SEARCH_KALTURA_NETWORK)); $c->addAnd($criterionPartnerOrKn); $dbEntries = entryPeer::doSelect($c); if (!$dbEntries) { return array(array(), 0); } $entryIds = array(); foreach ($dbEntries as $dbEntry) { $entryIds[] = $dbEntry->getId(); } $this->entryIdEqual = null; $this->entryIdIn = implode(',', $entryIds); // get the flavors $flavorAssetFilter = new AssetFilter(); $this->toObject($flavorAssetFilter); $c = new Criteria(); $flavorAssetFilter->attachToCriteria($c); if ($types) { $c->add(assetPeer::TYPE, $types, Criteria::IN); } $pager->attachToCriteria($c); $list = assetPeer::doSelect($c); $resultCount = count($list); if ($resultCount && $resultCount < $pager->pageSize) { $totalCount = ($pager->pageIndex - 1) * $pager->pageSize + $resultCount; } else { KalturaFilterPager::detachFromCriteria($c); $totalCount = assetPeer::doCount($c); } myDbHelper::$use_alternative_con = null; return array($list, $totalCount); }
public function getListResponse(KalturaFilterPager $pager, KalturaDetachedResponseProfile $responseProfile = null) { $entryFilter = new QuizEntryFilter(); $entryFilter->setPartnerSearchScope(baseObjectFilter::MATCH_KALTURA_NETWORK_AND_PRIVATE); $this->toObject($entryFilter); $c = KalturaCriteria::create(entryPeer::OM_CLASS); if ($pager) { $pager->attachToCriteria($c); } $entryFilter->attachToCriteria($c); $list = entryPeer::doSelect($c); $response = new KalturaQuizListResponse(); $response->objects = KalturaQuizArray::fromDbArray($list, $responseProfile); $response->totalCount = $c->getRecordsCount(); return $response; }
public function getListResponse(KalturaFilterPager $pager, KalturaDetachedResponseProfile $responseProfile = null) { if ($this->orderBy === null) { $this->orderBy = KalturaCategoryOrderBy::DEPTH_ASC; } $categoryFilter = $this->toObject(); $c = KalturaCriteria::create(categoryPeer::OM_CLASS); $categoryFilter->attachToCriteria($c); $pager->attachToCriteria($c); $dbList = categoryPeer::doSelect($c); $totalCount = $c->getRecordsCount(); $list = KalturaCategoryArray::fromDbArray($dbList, $responseProfile); $response = new KalturaCategoryListResponse(); $response->objects = $list; $response->totalCount = $totalCount; return $response; }
/** * @action search * * Action to search tags using a string of 3 letters or more. * @param KalturaTagFilter $tagFilter * @param KalturaFilterPager $pager * @return KalturaTagListResponse */ public function searchAction(KalturaTagFilter $tagFilter, KalturaFilterPager $pager = null) { if (!$tagFilter) { $tagFilter = new KalturaTagFilter(); } if (!$pager) { $pager = new KalturaFilterPager(); } $tagFilter->validate(); $c = KalturaCriteria::create(TagPeer::OM_CLASS); $tagCoreFilter = new TagFilter(); $tagFilter->toObject($tagCoreFilter); $tagCoreFilter->attachToCriteria($c); $pager->attachToCriteria($c); $tags = TagPeer::doSelect($c); $searchResponse = new KalturaTagListResponse(); $searchResponse->objects = KalturaTagArray::fromDbArray($tags); $searchResponse->totalCount = $c->getRecordsCount(); return $searchResponse; }
public function __construct($feedId) { myDbHelper::$use_alternative_con = myDbHelper::DB_HELPER_CONN_PROPEL3; $microTimeStart = microtime(true); KalturaLog::info("syndicationFeedRenderer- initialize "); // initialize the database for all services DbManager::setConfig(kConf::getDB()); DbManager::initialize(); $syndicationFeedDB = syndicationFeedPeer::retrieveByPK($feedId); if (!$syndicationFeedDB) { throw new Exception("Feed Id not found"); } $tmpSyndicationFeed = KalturaSyndicationFeedFactory::getInstanceByType($syndicationFeedDB->getType()); $tmpSyndicationFeed->fromObject($syndicationFeedDB); $this->syndicationFeed = $tmpSyndicationFeed; // add partner to default criteria categoryPeer::addPartnerToCriteria($this->syndicationFeed->partnerId, true); flavorAssetPeer::addPartnerToCriteria($this->syndicationFeed->partnerId, true); $this->baseCriteria = KalturaCriteria::create(entryPeer::OM_CLASS); $startDateCriterion = $this->baseCriteria->getNewCriterion(entryPeer::START_DATE, time(), Criteria::LESS_EQUAL); $startDateCriterion->addOr($this->baseCriteria->getNewCriterion(entryPeer::START_DATE, null)); $this->baseCriteria->addAnd($startDateCriterion); $endDateCriterion = $this->baseCriteria->getNewCriterion(entryPeer::END_DATE, time(), Criteria::GREATER_EQUAL); $endDateCriterion->addOr($this->baseCriteria->getNewCriterion(entryPeer::END_DATE, null)); $this->baseCriteria->addAnd($endDateCriterion); $entryFilter = new entryFilter(); $entryFilter->setPartnerSearchScope($this->syndicationFeed->partnerId); $entryFilter->setStatusEquel(entryStatus::READY); $entryFilter->setTypeIn(array(entryType::MEDIA_CLIP, entryType::MIX)); $entryFilter->setModerationStatusNot(entry::ENTRY_MODERATION_STATUS_REJECTED); $entryFilter->setDurationGreaterThan(0); $entryFilter->attachToCriteria($this->baseCriteria); if ($this->syndicationFeed->playlistId) { $this->entryFilters = myPlaylistUtils::getPlaylistFiltersById($this->syndicationFeed->playlistId); } else { $this->entryFilters = array(); } $microTimeEnd = microtime(true); KalturaLog::info("syndicationFeedRenderer- initialization done [" . ($microTimeEnd - $microTimeStart) . "]"); }
/** * Retrieve category(ies) by referenceId * @param string $v * @return array */ public static function getByReferenceId($v) { $c = KalturaCriteria::create(self::OM_CLASS); $c->addAnd(categoryPeer::REFERENCE_ID, $v); $objects = self::doSelect($c); return $objects; }
/** * creates all required jobs according to entry distribution dirty flags * * @action createRequiredJobs */ function createRequiredJobsAction() { // serach all records that their next report time arrived $criteria = KalturaCriteria::create(EntryDistributionPeer::OM_CLASS); $criteria->add(EntryDistributionPeer::NEXT_REPORT, time(), Criteria::LESS_EQUAL); $entryDistributions = EntryDistributionPeer::doSelect($criteria); foreach ($entryDistributions as $entryDistribution) { $distributionProfile = DistributionProfilePeer::retrieveByPK($entryDistribution->getDistributionProfileId()); if ($distributionProfile) { kContentDistributionManager::submitFetchEntryDistributionReport($entryDistribution, $distributionProfile); } else { KalturaLog::err("Distribution profile [" . $entryDistribution->getDistributionProfileId() . "] not found for entry distribution [" . $entryDistribution->getId() . "]"); } } // serach all records that arrived their sunrise time and requires submittion $criteria = KalturaCriteria::create(EntryDistributionPeer::OM_CLASS); $criteria->add(EntryDistributionPeer::DIRTY_STATUS, EntryDistributionDirtyStatus::SUBMIT_REQUIRED); $criteria->add(EntryDistributionPeer::SUNRISE, time(), Criteria::LESS_EQUAL); $entryDistributions = EntryDistributionPeer::doSelect($criteria); foreach ($entryDistributions as $entryDistribution) { $distributionProfile = DistributionProfilePeer::retrieveByPK($entryDistribution->getDistributionProfileId()); if ($distributionProfile) { kContentDistributionManager::submitAddEntryDistribution($entryDistribution, $distributionProfile); } else { KalturaLog::err("Distribution profile [" . $entryDistribution->getDistributionProfileId() . "] not found for entry distribution [" . $entryDistribution->getId() . "]"); } } // serach all records that arrived their sunrise time and requires enable $criteria = KalturaCriteria::create(EntryDistributionPeer::OM_CLASS); $criteria->add(EntryDistributionPeer::DIRTY_STATUS, EntryDistributionDirtyStatus::ENABLE_REQUIRED); $criteria->add(EntryDistributionPeer::SUNRISE, time(), Criteria::LESS_EQUAL); $entryDistributions = EntryDistributionPeer::doSelect($criteria); foreach ($entryDistributions as $entryDistribution) { $distributionProfile = DistributionProfilePeer::retrieveByPK($entryDistribution->getDistributionProfileId()); if ($distributionProfile) { kContentDistributionManager::submitEnableEntryDistribution($entryDistribution, $distributionProfile); } else { KalturaLog::err("Distribution profile [" . $entryDistribution->getDistributionProfileId() . "] not found for entry distribution [" . $entryDistribution->getId() . "]"); } } // serach all records that arrived their sunset time and requires deletion $criteria = KalturaCriteria::create(EntryDistributionPeer::OM_CLASS); $criteria->add(EntryDistributionPeer::DIRTY_STATUS, EntryDistributionDirtyStatus::DELETE_REQUIRED); $criteria->add(EntryDistributionPeer::SUNSET, time(), Criteria::LESS_EQUAL); $entryDistributions = EntryDistributionPeer::doSelect($criteria); foreach ($entryDistributions as $entryDistribution) { $distributionProfile = DistributionProfilePeer::retrieveByPK($entryDistribution->getDistributionProfileId()); if ($distributionProfile) { kContentDistributionManager::submitDeleteEntryDistribution($entryDistribution, $distributionProfile); } else { KalturaLog::err("Distribution profile [" . $entryDistribution->getDistributionProfileId() . "] not found for entry distribution [" . $entryDistribution->getId() . "]"); } } // serach all records that arrived their sunset time and requires disable $criteria = KalturaCriteria::create(EntryDistributionPeer::OM_CLASS); $criteria->add(EntryDistributionPeer::DIRTY_STATUS, EntryDistributionDirtyStatus::DISABLE_REQUIRED); $criteria->add(EntryDistributionPeer::SUNSET, time(), Criteria::LESS_EQUAL); $entryDistributions = EntryDistributionPeer::doSelect($criteria); foreach ($entryDistributions as $entryDistribution) { $distributionProfile = DistributionProfilePeer::retrieveByPK($entryDistribution->getDistributionProfileId()); if ($distributionProfile) { kContentDistributionManager::submitDisableEntryDistribution($entryDistribution, $distributionProfile); } else { KalturaLog::err("Distribution profile [" . $entryDistribution->getDistributionProfileId() . "] not found for entry distribution [" . $entryDistribution->getId() . "]"); } } }
public static function executeDynamicPlaylist($partner_id, $xml, $filter = null, $detailed = true, $pager = null) { list($total_results, $list_of_filters) = self::getPlaylistFilterListStruct($xml); $entry_filters = array(); if (!$list_of_filters) { return null; } // TODO - for now we assume that there are more or equal filters in the XML than the ones from the request $filterLimit = null; if ($filter && $filter->getLimit() > 0) { $filterLimit = $filter->getLimit(); // Get the max results from the limit of the first filter $total_results = min($total_results, $filterLimit); // Clear this limit so it won't overcloud the limits of $entry_filter_xml rules $filter->setLimit(null); } $numFiltersInList = count($list_of_filters); for ($i = 0; $i < $numFiltersInList; $i++) { $entry_filter_xml = $list_of_filters[$i]; /* @var $entry_filter_xml SimpleXMLElement */ // in general this service can fetch entries from kaltura networks. // for each filter we should decide if thie assumption is true... $allow_partner_only = true; self::replaceContextTokens($entry_filter_xml); // compile all the filters - only then execute them if not yet reached the total_results // TODO - optimize - maybe create them only when needed. - For now it's safer to compile all even if not needed. $entry_filter = new entryFilter(); // add the desired prefix "_" because the XML is not expected to have it while the entryFilter class expects it $entry_filter->fillObjectFromXml($entry_filter_xml, "_"); // make sure there is alway a limit for each filter - if not an explicit one - the system limit should be used if ($entry_filter->getLimit() == null || $entry_filter->getLimit() < 1) { $entry_filter->setLimit(self::TOTAL_RESULTS); } // merge the current_filter with the correcponding extra_filter // allow the extra_filter to override properties of the current filter if ($filter) { if ($filterLimit && $i == $numFiltersInList - 1) { // Hack (in order to preserve old behavior): // If the filter contained a limit, we'll add it to the last XML filter on the list // in order to make sure the number of requested ($limit) entries will be supplied. // This handles requests of a $limit which is higher than the total sum of inner XML filter limits. $filter->setLimit($filterLimit); } $entry_filter->fillObjectFromObject($filter, myBaseObject::CLONE_FIELD_POLICY_THIS, myBaseObject::CLONE_POLICY_PREFER_NEW, null, null, false); $entry_filter->setPartnerSearchScope(baseObjectFilter::MATCH_KALTURA_NETWORK_AND_PRIVATE); } self::updateEntryFilter($entry_filter, $partner_id, true); $entry_filters[] = $entry_filter; } if ($pager) { $startOffset = $pager->calcOffset(); $pageSize = $pager->calcPageSize(); if ($startOffset > $total_results) { return array(); } $total_results = min($total_results, $startOffset + $pageSize); } $entry_ids_list = array(); foreach ($entry_filters as $entry_filter) { $current_limit = max(0, $total_results - count($entry_ids_list)); // if the current_limit is < 0 - set it to be 0 // no need to fetch any more results if ($current_limit <= 0) { break; } $c = KalturaCriteria::create(entryPeer::OM_CLASS); // don't fetch the same entries twice - filter out all the entries that were already fetched if ($entry_ids_list) { $c->add(entryPeer::ID, $entry_ids_list, Criteria::NOT_IN); } $filter_limit = $entry_filter->getLimit(); if ($filter_limit > $current_limit) { // set a smaller limit incase the filter's limit is to high $entry_filter->setLimit($current_limit); } // read the _eq_display_in_search field but ignore it because it's part of a more complex criterion $display_in_search = $entry_filter->get("_eq_display_in_search"); if ($display_in_search >= 2) { $entry_filter->set("_eq_display_in_search", null); } $entry_filter->attachToCriteria($c); // add some hard-coded criteria $c->addAnd(entryPeer::TYPE, array(entryType::MEDIA_CLIP, entryType::MIX, entryType::LIVE_STREAM), Criteria::IN); // search only for clips or roughcuts $c->addAnd(entryPeer::STATUS, entryStatus::READY); // search only for READY entries $c->addAnd(entryPeer::DISPLAY_IN_SEARCH, mySearchUtils::DISPLAY_IN_SEARCH_SYSTEM, Criteria::NOT_EQUAL); if ($display_in_search >= 2) { // We don't allow searching in the KalturaNEtwork anymore (mainly for performance reasons) // allow only assets for the partner $c->addAnd(entryPeer::PARTNER_ID, $partner_id); // /* $crit = $c->getNewCriterion ( entryPeer::PARTNER_ID , $partner_id ); $crit->addOr ( $c->getNewCriterion ( entryPeer::DISPLAY_IN_SEARCH , $display_in_search ) ); $c->addAnd ( $crit ); */ } if (!self::$isAdminKs) { self::addSchedulingToCriteria($c); } self::addModerationToCriteria($c); $c = entryPeer::prepareEntitlementCriteriaAndFilters($c); $entry_ids_list_for_filter = $c->getFetchedIds(); // update total count and merge current result with the global list $entry_ids_list = array_merge($entry_ids_list, $entry_ids_list_for_filter); } if ($pager) { // Keep the paged entries only $entry_ids_list = array_slice($entry_ids_list, $startOffset, $pageSize); } // Disable entitlement, which was already applied in entryPeer::prepareEntitlementCriteriaAndFilters() // otherwise we will hit the 150 entries limit from SphinxCriterion KalturaCriterion::disableTag(KalturaCriterion::TAG_ENTITLEMENT_ENTRY); $db_entry_list = entryPeer::retrieveByPKs($entry_ids_list); KalturaCriterion::restoreTag(KalturaCriterion::TAG_ENTITLEMENT_ENTRY); // Map the entries to their IDs $entry_map = array(); foreach ($db_entry_list as $entry) { $entry_map[$entry->getId()] = $entry; } // Build entry_list according to the playlist order $entry_list = array(); foreach ($entry_ids_list as $entryId) { $entry_list[] = $entry_map[$entryId]; } return $entry_list; }
/** * count cue point objects by filter * * @action count * @param KalturaCuePointFilter $filter * @return int */ function countAction(KalturaCuePointFilter $filter = null) { if (!$filter) { $filter = new KalturaCuePointFilter(); } $c = KalturaCriteria::create(CuePointPeer::OM_CLASS); if ($this->getCuePointType()) { $c->add(CuePointPeer::TYPE, $this->getCuePointType()); } $cuePointFilter = $filter->toObject(); $cuePointFilter->attachToCriteria($c); $c->applyFilters(); return $c->getRecordsCount(); }
/** * @param KalturaFilterPager $pager * @return KalturaCriteria */ public function prepareEntriesCriteriaFilter(KalturaFilterPager $pager = null) { // because by default we will display only READY entries, and when deleted status is requested, we don't want this to disturb entryPeer::allowDeletedInCriteriaFilter(); $c = KalturaCriteria::create(entryPeer::OM_CLASS); if ($this->idEqual == null && $this->redirectFromEntryId == null) { $this->setDefaultStatus(); $this->setDefaultModerationStatus($this); if ($this->parentEntryIdEqual == null) { $c->add(entryPeer::DISPLAY_IN_SEARCH, mySearchUtils::DISPLAY_IN_SEARCH_SYSTEM, Criteria::NOT_EQUAL); } } $this->fixFilterUserId($this); $entryFilter = new entryFilter(); $entryFilter->setPartnerSearchScope(baseObjectFilter::MATCH_KALTURA_NETWORK_AND_PRIVATE); $this->toObject($entryFilter); if ($pager) { $pager->attachToCriteria($c); } $entryFilter->attachToCriteria($c); return $c; }
public function getListResponse(KalturaFilterPager $pager, KalturaDetachedResponseProfile $responseProfile = null) { $this->validateUserIdOrGroupIdFiltered(); if ($this->groupIdEqual) { $partnerId = kCurrentContext::getCurrentPartnerId(); $c = new Criteria(); $c->add(kuserPeer::PARTNER_ID, $partnerId); $c->add(kuserPeer::PUSER_ID, $this->groupIdEqual); $c->add(kuserPeer::TYPE, KuserType::GROUP); if (kCurrentContext::$ks_partner_id == Partner::BATCH_PARTNER_ID) { //batch should be able to get categoryUser of deleted users. kuserPeer::setUseCriteriaFilter(false); } // in case of more than one deleted kusers - get the last one $c->addDescendingOrderByColumn(kuserPeer::UPDATED_AT); $kuser = kuserPeer::doSelectOne($c); kuserPeer::setUseCriteriaFilter(true); if (!$kuser) { $response = new KalturaGroupUserListResponse(); $response->objects = new KalturaGroupUserArray(); $response->totalCount = 0; return $response; } $this->groupIdEqual = $kuser->getId(); } if ($this->userIdEqual) { $partnerId = kCurrentContext::getCurrentPartnerId(); $c = new Criteria(); $c->add(kuserPeer::PARTNER_ID, $partnerId); $c->add(kuserPeer::PUSER_ID, $this->userIdEqual); $c->add(kuserPeer::TYPE, KuserType::USER); $kuser = kuserPeer::doSelectOne($c); if (!$kuser) { $response = new KalturaGroupUserListResponse(); $response->objects = new KalturaGroupUserArray(); $response->totalCount = 0; return $response; } $this->userIdEqual = $kuser->getId(); } if ($this->userIdIn) { $usersIds = explode(',', $this->userIdIn); $partnerId = kCurrentContext::getCurrentPartnerId(); $c = new Criteria(); $c->add(kuserPeer::PARTNER_ID, $partnerId, Criteria::EQUAL); $c->add(kuserPeer::PUSER_ID, $usersIds, Criteria::IN); $c->add(kuserPeer::TYPE, KuserType::USER); $kusers = kuserPeer::doSelect($c); if (!$kusers) { $response = new KalturaGroupUserListResponse(); $response->objects = new KalturaGroupUserArray(); $response->totalCount = 0; return $response; } $usersIds = array(); foreach ($kusers as $kuser) { /* @var $kuser kuser */ $usersIds[] = $kuser->getId(); } $this->userIdIn = implode(',', $usersIds); } if ($this->groupIdIn) { $groupIdIn = explode(',', $this->groupIdIn); $partnerId = kCurrentContext::getCurrentPartnerId(); $c = new Criteria(); $c->add(kuserPeer::PARTNER_ID, $partnerId, Criteria::EQUAL); $c->add(kuserPeer::PUSER_ID, $groupIdIn, Criteria::IN); $c->add(kuserPeer::TYPE, KuserType::GROUP); $kusers = kuserPeer::doSelect($c); if (!$kusers) { $response = new KalturaGroupUserListResponse(); $response->objects = new KalturaGroupUserArray(); $response->totalCount = 0; return $response; } $groupIdIn = array(); foreach ($kusers as $kuser) { /* @var $kuser kuser */ $groupIdIn[] = $kuser->getId(); } $this->groupIdIn = implode(',', $groupIdIn); } $kuserKgroupFilter = $this->toObject(); $c = KalturaCriteria::create(KuserKgroupPeer::OM_CLASS); $kuserKgroupFilter->attachToCriteria($c); $pager->attachToCriteria($c); $c->applyFilters(); $list = KuserKgroupPeer::doSelect($c); $newList = KalturaGroupUserArray::fromDbArray($list, $responseProfile); $response = new KalturaGroupUserListResponse(); $response->objects = $newList; $resultCount = count($newList); if ($resultCount && $resultCount < $pager->pageSize) { $totalCount = ($pager->pageIndex - 1) * $pager->pageSize + $resultCount; } else { KalturaFilterPager::detachFromCriteria($c); $totalCount = KuserKgroupPeer::doCount($c); } $response->totalCount = $totalCount; return $response; }
/** * This is not a regular service. * Because the caller is not a partner but rather a 3rd party provider that wishs to query our system, * The security is slightly different and the respons is in the format of mRss which is related to entries only. */ public function executeImpl($partner_id, $subp_id, $puser_id, $partner_prefix, $puser_kuser) { myDbHelper::$use_alternative_con = myDbHelper::DB_HELPER_CONN_PROPEL2; header("Content-Type: text/xml; charset=utf-8"); // TODO - verify permissions for viewing lists // validate the ks of the caller $code = $this->getP("code"); if ($code != 'fsalh5423a43g') { return "<xml></xml>"; die; } $detailed = $this->getP("detailed", false); $limit = $this->getP("page_size", 100); $limit = $this->maxPageSize($limit); $operated_partner_id = $this->getP("operated_partner_id"); $page = $this->getP("page", 1); $offset = ($page - 1) * $limit; // kuserPeer::setUseCriteriaFilter( false ); if ($operated_partner_id) { entryPeer::setUseCriteriaFilter(true); } else { entryPeer::setUseCriteriaFilter(false); } // FOR now - display only 2 partners // 2460 - dorimedia $partner_list = array(593, 2460); $c = KalturaCriteria::create(entryPeer::OM_CLASS); $c->addAnd(entryPeer::STATUS, entryStatus::READY); // for now display only entries that are part of the kaltura network // $c->addAnd ( entryPeer::DISPLAY_IN_SEARCH , mySearchUtils::DISPLAY_IN_SEARCH_KALTURA_NETWORK ); // filter $filter = new entryFilter(); $fields_set = $filter->fillObjectFromRequest($this->getInputParams(), "filter_", null); $this->setExtraFilters($filter); $offset = ($page - 1) * $limit; $c->setLimit($limit); if ($offset > 0) { $c->setOffset($offset); } $filter->attachToCriteria($c); //if ($order_by != -1) entryPeer::setOrder( $c , $order_by ); $c->addAnd(entryPeer::PARTNER_ID, $partner_list, Criteria::IN); $start_1 = microtime(true); if ($detailed) { // for some entry types - there are no kshow or kusers - don't join even when detailed if ($this->joinOnDetailed()) { $list = entryPeer::doSelectJoinAll($c); } else { $list = entryPeer::doSelect($c); } $level = objectWrapperBase::DETAIL_LEVEL_DETAILED; } else { $list = entryPeer::doSelect($c); $level = objectWrapperBase::DETAIL_LEVEL_REGULAR; } $count = $c->getRecordsCount(); $end_1 = microtime(true); KalturaLog::log("benchmark db: [" . ($end_1 - $start_1) . "]"); $result_count = count($list); $start_2 = microtime(true); $mrss_renderer = new kalturaRssRenderer(kalturaRssRenderer::TYPE_TABOOLA); $str = $mrss_renderer->renderMrssFeed($list, $page, $result_count); $end_2 = microtime(true); KalturaLog::log("benchmark render: [" . ($end_2 - $start_2) . "]"); echo $str; // don't return to the rest of the implementation - the base class manipulates the content. die; }
/** return array('status' => $status, 'message' => $message, 'objects' => $objects); objects - array of 'thumb' 'title' 'description' 'id' - unique id to be passed to getMediaInfo */ public function searchMedia($media_type, $searchText, $page, $pageSize, $authData = null, $extraData = null) { $page_size = $pageSize > 20 ? 20 : $pageSize; $page--; if ($page < 0) { $page = 0; } $status = "ok"; $message = ''; $objects = array(); $should_serach = true; if (defined("KALTURA_API_V3")) { $kuser = kuserPeer::getKuserByPartnerAndUid(self::$partner_id, self::$puser_id); $should_serach = true; $kuser_id = $kuser->getId(); } else { $puser_kuser = PuserKuserPeer::retrieveByPartnerAndUid(self::$partner_id, self::$subp_id, self::$puser_id, true); if (!$puser_kuser) { // very bad - does not exist in system $should_serach = false; } else { $kuser = $puser_kuser->getKuser(); if (!$kuser) { $should_serach = false; } else { $kuser_id = $kuser->getId(); } } } // echo "[" . self::$partner_id . "],[". self::$subp_id . "],[" . self::$puser_id . "],[$kuser_id]"; if ($should_serach) { $c = KalturaCriteria::create(entryPeer::OM_CLASS); $c->add(entryPeer::KUSER_ID, $kuser_id); $c->add(entryPeer::MEDIA_TYPE, $media_type); $c->add(entryPeer::TYPE, entryType::MEDIA_CLIP); // $keywords_array = mySearchUtils::getKeywordsFromStr ( $searchText ); $filter = new entryFilter(); $filter->setPartnerSearchScope(self::$partner_id); $filter->addSearchMatchToCriteria($c, $searchText, entry::getSearchableColumnName()); $c->setLimit($pageSize); $c->setOffset($page * $pageSize); $entry_results = entryPeer::doSelect($c); //JoinAll( $c ); $number_of_results = $c->getRecordsCount(); $number_of_pages = (int) ($number_of_results / $pageSize); if ($number_of_results % $pageSize != 0) { $number_of_pages += 1; } // if there are some left-overs - there must be a nother page // add thumbs when not image or video $should_add_thumbs = $media_type != entry::ENTRY_MEDIA_TYPE_AUDIO; foreach ($entry_results as $entry) { // send the id as the url $object = array("id" => $entry->getId(), "url" => $entry->getDataUrl(), "tags" => $entry->getTags(), "title" => $entry->getName(), "description" => $entry->getDescription()); if ($should_add_thumbs) { $object["thumb"] = $entry->getThumbnailUrl(); } $objects[] = $object; } } return array('status' => $status, 'message' => $message, 'objects' => $objects, "needMediaInfo" => self::$NEED_MEDIA_INFO); }
public function validateForUpdate($sourceObject, $propertiesToSkip = array()) { /* @var $sourceObject accessControl */ $this->validatePropertyMinMaxLength('name', 1, 128, true); $this->validate(); if ($this->systemName) { $c = KalturaCriteria::create(accessControlPeer::OM_CLASS); $c->add(accessControlPeer::ID, $sourceObject->getId(), Criteria::NOT_EQUAL); $c->add(accessControlPeer::SYSTEM_NAME, $this->systemName); if (accessControlPeer::doCount($c)) { throw new KalturaAPIException(KalturaErrors::SYSTEM_NAME_ALREADY_EXISTS, $this->systemName); } } return parent::validateForUpdate($sourceObject, $propertiesToSkip); }
/** * Returns all live entries that were live in the past X hours */ protected function getLiveEntries(WSLiveReportsClient $client, $partnerId, KalturaFilterPager $pager) { // Get live entries list /** @var WSLiveEntriesListResponse */ $response = $client->getLiveEntries($partnerId); if ($response->totalCount == 0) { return null; } // Hack to overcome the bug of single value $entryIds = $response->entries; if (!is_array($entryIds)) { $entryIds = array(); $entryIds[] = $response->entries; } // Order entries by first broadcast $baseCriteria = KalturaCriteria::create(entryPeer::OM_CLASS); $filter = new entryFilter(); $filter->setTypeEquel(KalturaEntryType::LIVE_STREAM); $filter->setIdIn($entryIds); $filter->setPartnerSearchScope(baseObjectFilter::MATCH_KALTURA_NETWORK_AND_PRIVATE); $filter->attachToCriteria($baseCriteria); $baseCriteria->addAscendingOrderByColumn("entry.name"); $pager->attachToCriteria($baseCriteria); $entries = entryPeer::doSelect($baseCriteria); $entryIds = array(); foreach ($entries as $entry) { $entryIds[] = $entry->getId(); } $totalCount = $baseCriteria->getRecordsCount(); return array($entryIds, $totalCount); }
public function getEntitledKusers() { $entitledKusersPublish = explode(',', $this->getEntitledKusersPublish()); $entitledKusersEdit = explode(',', $this->getEntitledKusersEdit()); $entitledKusersNoPrivacyContext = array_merge($entitledKusersPublish, $entitledKusersEdit); $entitledKusersNoPrivacyContext[] = $this->getKuserId(); foreach ($entitledKusersNoPrivacyContext as $key => $value) { if (!$value) { unset($entitledKusersNoPrivacyContext[$key]); } } $entitledKusers = array(); if (count(array_unique($entitledKusersNoPrivacyContext))) { $entitledKusers[kEntitlementUtils::ENTRY_PRIVACY_CONTEXT] = array_unique($entitledKusersNoPrivacyContext); } $allCategoriesIds = $this->getAllCategoriesIds(true); if (!count($allCategoriesIds)) { return kEntitlementUtils::ENTRY_PRIVACY_CONTEXT . '_' . implode(' ' . kEntitlementUtils::ENTRY_PRIVACY_CONTEXT . '_', $entitledKusersNoPrivacyContext); } $categoryGroupSize = kConf::get('max_number_of_memebrs_to_be_indexed_on_entry'); $partner = $this->getPartner(); if ($partner && $partner->getCategoryGroupSize()) { $categoryGroupSize = $partner->getCategoryGroupSize(); } //get categories for this entry that have small amount of members. $c = KalturaCriteria::create(categoryPeer::OM_CLASS); $c->add(categoryPeer::ID, $allCategoriesIds, Criteria::IN); $c->add(categoryPeer::MEMBERS_COUNT, $categoryGroupSize, Criteria::LESS_EQUAL); $c->add(categoryPeer::ENTRIES_COUNT, kConf::get('category_entries_count_limit_to_be_indexed'), Criteria::LESS_EQUAL); $c->dontCount(); KalturaCriterion::disableTag(KalturaCriterion::TAG_ENTITLEMENT_CATEGORY); $categories = categoryPeer::doSelect($c); KalturaCriterion::restoreTag(KalturaCriterion::TAG_ENTITLEMENT_CATEGORY); //get all memebrs foreach ($categories as $category) { if (!count($category->getMembers())) { continue; } $privacyContexts = explode(',', $category->getPrivacyContexts()); if (!count($privacyContexts)) { $privacyContexts = array(kEntitlementUtils::DEFAULT_CONTEXT . $this->getPartnerId()); } foreach ($privacyContexts as $privacyContext) { $privacyContext = trim($privacyContext); if (isset($entitledKusers[$privacyContext])) { $entitledKusers[$privacyContext] = array_merge($entitledKusers[$privacyContext], $category->getMembers()); } else { $entitledKusers[$privacyContext] = $category->getMembers(); } } } $entitledKusersByContexts = array(); foreach ($entitledKusers as $privacyContext => $kusers) { $entitledKusersByContexts[] = $privacyContext . '_' . implode(' ' . $privacyContext . '_', $kusers); } return implode(' ', $entitledKusersByContexts); }
/** * @return int */ public function getDirectChildrenCount() { if ($this->isNew()) { return 0; } $ret = parent::getDirectChildrenCount(); if (!is_null($ret)) { return $ret; } $c = KalturaCriteria::create(CuePointPeer::OM_CLASS); $c->add(CuePointPeer::PARENT_ID, $this->getId()); $c->applyFilters(); return $c->getRecordsCount(); }