private function fetchNextPage() { $this->entriesCurrentPage = null; $this->clearMemory(); if ($this->currentCriteria) { if ($this->lastEntryIntId && $this->lastEntryCreatedAt) { $this->currentCriteria->add(entryPeer::INT_ID, $this->lastEntryIntId, Criteria::LESS_THAN); $this->currentCriteria->add(entryPeer::CREATED_AT, $this->lastEntryCreatedAt, Criteria::LESS_EQUAL); } } else { $this->currentCriteria = $this->getNextCriteria(); if (!$this->currentCriteria) { return; } } $nextPage = entryPeer::doSelect($this->currentCriteria); if (!count($nextPage)) { $this->currentCriteria = $this->getNextCriteria(); if (!$this->currentCriteria) { return; } $nextPage = entryPeer::doSelect($this->currentCriteria); } if (!count($nextPage)) { // finished all criterias and pages return; } $this->entriesCurrentPage = $nextPage; }
/** * 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); }
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()); }
/** * Adds conditions, matches and where clauses to the query * @param IKalturaIndexQuery $query */ public function applyCondition(IKalturaDbQuery $query) { switch ($this->getComparison()) { case KalturaSearchConditionComparison::EQUAL: $comparison = ' = '; break; case KalturaSearchConditionComparison::GREATER_THAN: $comparison = ' > '; break; case KalturaSearchConditionComparison::GREATER_THAN_OR_EQUAL: $comparison = ' >= '; break; case KalturaSearchConditionComparison::LESS_THAN: $comparison = " < "; break; case KalturaSearchConditionComparison::LESS_THAN_OR_EQUAL: $comparison = " <= "; break; case KalturaSearchConditionComparison::NOT_EQUAL: $comparison = " <> "; break; default: KalturaLog::ERR("Missing comparison type"); return; } $field = $this->getField(); $value = $this->getValue(); $fieldValue = $this->getFieldValue($field); if (is_null($fieldValue)) { KalturaLog::err('Unknown field [' . $field . ']'); return; } $newCondition = $fieldValue . $comparison . KalturaCriteria::escapeString($value); $query->addCondition($newCondition); }
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; }
/** * 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 function addColumnWhere($column, $value, $comparison) { $criterion = $this->criteria->getNewCriterion($column, $value, $comparison); if ($this->getConjunction() == self::ODER) { $this->addOr($criterion); } else { $this->addAnd($criterion); } }
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); }
/** * Adds conditions, matches and where clauses to the query * @param IKalturaDbQuery $query */ public function applyCondition(IKalturaDbQuery $query) { if (!$query instanceof IKalturaIndexQuery) { return; } $matchText = '"' . KalturaCriteria::escapeString($this->value) . '"'; if ($this->not) { $matchText = '!' . $matchText; } $query->addMatch("@{$this->field} (" . $matchText . ")"); }
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(); } }
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); }
/** * 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); }
private function fetchNextPage() { if ($this->executed && $this->staticPlaylist) { return; } $this->entriesCurrentPage = null; kMemoryManager::clearMemory(); if ($this->currentCriteria) { if ($this->lastEntryCreatedAt) { $this->currentCriteria->add($this->getOrderByColumn(), $this->lastEntryCreatedAt, Criteria::LESS_EQUAL); } if (count($this->lastEntryIds)) { $this->currentCriteria->add(entryPeer::ID, $this->lastEntryIds, Criteria::NOT_IN); } } else { $this->currentCriteria = $this->getNextCriteria(); if (!$this->currentCriteria) { return; } } $nextPage = entryPeer::doSelect($this->currentCriteria); if (!count($nextPage)) { $this->currentCriteria = $this->getNextCriteria(); if (!$this->currentCriteria) { return; } $nextPage = entryPeer::doSelect($this->currentCriteria); } if (!count($nextPage)) { // finished all criterias and pages return; } if ($this->staticPlaylist) { //order the entries by static (AKA manual) entries order $nextPageEntries = array(); foreach ($nextPage as $entry) { $nextPageEntries[$entry->getId()] = $entry; } $nextPage = array(); foreach ($this->staticPlaylistEntriesIdsOrder as $entryId) { if (isset($nextPageEntries[$entryId])) { $nextPage[] = $nextPageEntries[$entryId]; } } } $this->entriesCurrentPage = $nextPage; reset($this->entriesCurrentPage); }
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 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); }
/** * 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); }
/** * 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; }
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; }
/** * * @param entry $clipEntry new entry to copy and adjust cue points from root entry to */ public static function copyCuePointsToClipEntry(entry $clipEntry) { $clipAtts = self::getClipAttributesFromEntry($clipEntry); if (!is_null($clipAtts)) { $sourceEntry = entryPeer::retrieveByPK($clipEntry->getSourceEntryId()); if (is_null($sourceEntry)) { KalturaLog::info("Didn't copy cuePoints for entry [{$clipEntry->getId()}] because source entry [" . $clipEntry->getSourceEntryId() . "] wasn't found"); return; } $sourceEntryDuration = $sourceEntry->getLengthInMsecs(); $clipStartTime = $clipAtts->getOffset(); if (is_null($clipStartTime)) { $clipStartTime = 0; } $clipDuration = $clipAtts->getDuration(); if (is_null($clipDuration)) { $clipDuration = $sourceEntryDuration; } $c = new KalturaCriteria(); $c->add(CuePointPeer::ENTRY_ID, $clipEntry->getSourceEntryId()); if ($clipDuration < $sourceEntryDuration) { $c->addAnd(CuePointPeer::START_TIME, $clipStartTime + $clipDuration, KalturaCriteria::LESS_EQUAL); } if ($clipStartTime > 0) { $c->addAnd(CuePointPeer::START_TIME, $clipStartTime, KalturaCriteria::GREATER_EQUAL); $c->addOr(CuePointPeer::START_TIME, 0, KalturaCriteria::EQUAL); } $c->addAscendingOrderByColumn(CuePointPeer::CREATED_AT); $rootEntryCuePointsToCopy = CuePointPeer::doSelect($c); if (count($rootEntryCuePointsToCopy) <= self::MAX_CUE_POINTS_TO_COPY_TO_CLIP) { foreach ($rootEntryCuePointsToCopy as $cuePoint) { $cuePoint->copyToClipEntry($clipEntry, $clipStartTime, $clipDuration); } } else { KalturaLog::alert("Can't copy cuePoints for entry [{$clipEntry->getId()}] because cuePoints count exceeded max limit of [" . self::MAX_CUE_POINTS_TO_COPY_TO_CLIP . "]"); } } }
/** * 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; }