protected function getEntryFilter($context, $keepScheduling = true) { $keepScheduling = $keepScheduling === true && $this->profile->getIgnoreSchedulingInFeed() !== true; $entryFilter = parent::getEntryFilter($context, $keepScheduling); $entryFilter->set('_order_by', '-created_at'); if ($context->period && $context->period > 0) { $entryFilter->set('_gte_updated_at', time() - 24 * 60 * 60); } // last 24 hours // Dummy query to get the total count $baseCriteria = KalturaCriteria::create(entryPeer::OM_CLASS); $baseCriteria->add(entryPeer::DISPLAY_IN_SEARCH, mySearchUtils::DISPLAY_IN_SEARCH_SYSTEM, Criteria::NOT_EQUAL); $baseCriteria->setLimit(1); $entryFilter->attachToCriteria($baseCriteria); $entries = entryPeer::doSelect($baseCriteria); $context->totalCount = $baseCriteria->getRecordsCount(); // Add the state data to proceed to next page $this->fillStateDependentFields($context); if ($context->stateLastEntryCreatedAt) { $entryFilter->set('_lte_created_at', $context->stateLastEntryCreatedAt); } if ($context->stateLastEntryIds) { $entryFilter->set('_notin_id', $context->stateLastEntryIds); } return $entryFilter; }
/** * @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; }
/** * @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; }
function getEntries($con, $lastEntry, $entryLimitEachLoop) { $c = new Criteria(); $c->add(entryPeer::INT_ID, $lastEntry, Criteria::GREATER_THAN); $c->addAnd(entryPeer::TYPE, entryType::LIVE_STREAM); $c->addAscendingOrderByColumn(entryPeer::INT_ID); $c->setLimit($entryLimitEachLoop); return entryPeer::doSelect($c, $con); }
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; }
protected function executeImpl(kshow $kshow) { $asset_type = $this->getRequestParameter("type", entry::ENTRY_MEDIA_TYPE_VIDEO); if ($asset_type > entry::ENTRY_MEDIA_TYPE_AUDIO || $asset_type < entry::ENTRY_MEDIA_TYPE_VIDEO) { // TODO - // trying to fetch invalid media type } $show_entry_id = $kshow->getShowEntryId(); $intro_id = $kshow->getIntroId(); $c = new Criteria(); $c->add(entryPeer::KUSER_ID, kuser::KUSER_KALTURA); $c->add(entryPeer::TYPE, kuser::KUSER_KALTURA); $this->entry_list = entryPeer::doSelect($c); if ($this->entry_list == NULL) { $this->entry_list = array(); } }
/** * Will display errornous entries */ public function execute() { $this->forceSystemAuthentication(); entryPeer::setUseCriteriaFilter(false); // find entries with status error $c = new Criteria(); $c->add(entryPeer::STATUS, entryStatus::ERROR_CONVERTING); $this->error_converting = entryPeer::doSelect($c); $date_format = 'Y-m-d H:i:s'; $this->several_minutes_ago = time() - 5 * 60; // 5 minutes ago //mktime(0, 0, 0, date("m"), date("d"), date("Y")); $start_date = date($date_format, $this->several_minutes_ago); $c = new Criteria(); $c->add(entryPeer::STATUS, array(entryStatus::IMPORT, entryStatus::PRECONVERT), Criteria::IN); $c->add(entryPeer::UPDATED_AT, $start_date, Criteria::LESS_THAN); $this->error_waiting_too_long = entryPeer::doSelect($c); $this->start_date = $start_date; }
public function createMetadata($kshow_id) { // echo ( "createMetadata for [$kshow_id]\n" ); $kshow = kshowPeer::retrieveByPK($kshow_id); $show_entry_id = $kshow->getShowEntryId(); $intro_id = $kshow->getIntroId(); // fetch all entries for a kshow without the kshow entry or the intro // the order is ascending by creation date of the entry // if ordering by ascending ID - the intro will always be first $c = new Criteria(); $c->add(entryPeer::KSHOW_ID, $kshow_id); $c->add(entryPeer::ID, array($show_entry_id, $intro_id), Criteria::NOT_IN); // $c->addDescendingOrderByColumn('(' . entryPeer::ID . '=' . $intro_id . ')'); $c->addAscendingOrderByColumn(entryPeer::ID); // $c->add ( entryPeer::STATUS , entryStatus::READY ); // $c->addAscendingOrderByColumn( entryPeer::CREATED_AT ); $entry_list = entryPeer::doSelect($c); // echo ( "kshow [$kshow_id] has " . count ( $entry_list ) . " entries\n" ); return $this->createMetadataForList($entry_list); }
public static function retrievEntriesByRoughcutIds($entry_criteria, $roughcut_ids) { // first get all the roughcuts $c = new Criteria(); // myCriteria::addComment( $c , __METHOD__ ); $c->addAnd(roughcutEntryPeer::ROUGHCUT_ID, $roughcut_ids, Criteria::IN); $res = roughcutEntryPeer::doSelect($c); if ($res) { $entry_ids = array(); foreach ($res as $roughcut_entry) { $entry_ids[] = $roughcut_entry->getEntryId(); } // now fetch all the relevant entries if ($entry_criteria == null) { $entry_criteria = new Criteria(); } $entry_criteria->add(entryPeer::ID, $entry_ids, Criteria::IN); return entryPeer::doSelect($entry_criteria); } return array(); }
/** * @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 AttUverseDistributionProfile) { 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(AttUverseDistributionErrors::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 AttUverseDistributionFeedHelper('feed_template.xml', $profile); $channelTitle = $profile->getChannelTitle(); $counter = 0; foreach ($entries as $entry) { /* @var $entry entry */ /* @var $entryDistribution Entrydistribution */ $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); //flavors assets and remote flavor asset file urls $flavorAssets = assetPeer::retrieveByIds(explode(',', $entryDistribution->getFromCustomData(AttUverseEntryDistributionCustomDataField::DISTRIBUTED_FLAVOR_IDS))); $remoteAssetFileUrls = unserialize($entryDistribution->getFromCustomData(AttUverseEntryDistributionCustomDataField::REMOTE_ASSET_FILE_URLS)); //thumb assets and remote thumb asset file urls $thumbAssets = assetPeer::retrieveByIds(explode(',', $entryDistribution->getFromCustomData(AttUverseEntryDistributionCustomDataField::DISTRIBUTED_THUMBNAIL_IDS))); $remoteThumbailFileUrls = unserialize($entryDistribution->getFromCustomData(AttUverseEntryDistributionCustomDataField::REMOTE_THUMBNAIL_FILE_URLS)); //thumb assets and remote thumb asset file urls $captionAssets = assetPeer::retrieveByIds(explode(',', $entryDistribution->getFromCustomData(AttUverseEntryDistributionCustomDataField::DISTRIBUTED_CAPTION_IDS))); $feed->addItem($fields, $flavorAssets, $remoteAssetFileUrls, $thumbAssets, $remoteThumbailFileUrls, $captionAssets); $counter++; //to avoid the cache exceeding the memory size if ($counter >= 100) { kMemoryManager::clearMemory(); $counter = 0; } } //set channel title if (isset($fields)) { $channelTitle = $fields[AttUverseDistributionField::CHANNEL_TITLE]; } $feed->setChannelTitle($channelTitle); header('Content-Type: text/xml'); echo str_replace('&', '&', html_entity_decode($feed->getXml(), ENT_QUOTES, 'UTF-8')); die; }
/** * Gets an array of entry objects which contain a foreign key that references this object. * * If this collection has already been initialized with an identical Criteria, it returns the collection. * Otherwise if this kuser has previously been saved, it will retrieve * related entrys from storage. If this kuser is new, it will return * an empty collection or the current collection, the criteria is ignored on a new object. * * @param PropelPDO $con * @param Criteria $criteria * @return array entry[] * @throws PropelException */ public function getentrys($criteria = null, PropelPDO $con = null) { if ($criteria === null) { $criteria = new Criteria(kuserPeer::DATABASE_NAME); } elseif ($criteria instanceof Criteria) { $criteria = clone $criteria; } if ($this->collentrys === null) { if ($this->isNew()) { $this->collentrys = array(); } else { $criteria->add(entryPeer::KUSER_ID, $this->id); entryPeer::addSelectColumns($criteria); $this->collentrys = entryPeer::doSelect($criteria, $con); } } else { // criteria has no effect for a new object if (!$this->isNew()) { // the following code is to determine if a new query is // called for. If the criteria is the same as the last // one, just return the collection. $criteria->add(entryPeer::KUSER_ID, $this->id); entryPeer::addSelectColumns($criteria); if (!isset($this->lastentryCriteria) || !$this->lastentryCriteria->equals($criteria)) { $this->collentrys = entryPeer::doSelect($criteria, $con); } } } $this->lastentryCriteria = $criteria; return $this->collentrys; }
public static function sendAlertsForNewRoughcut($kshow, $likuser_id, $user_screenname) { $kshow_id = $kshow->getId(); // Send an email alert to producer if ($kshow->getProducerId() != $likuser_id) { // don't send producer alerts when the producer is the editor alertPeer::sendEmailIfNeeded($kshow->getProducerId(), alert::KALTURAS_PRODUCED_ALERT_TYPE_ROUGHCUT_CREATED, array('screenname' => $user_screenname, 'kshow_name' => $kshow->getName(), 'kshow_id' => $kshow->getId())); } // TODO: efficiency: see if there is a wa to search for contributors based on some other method than full entry table scan // Send email alerts to contributors $c = new Criteria(); $c->add(entryPeer::KSHOW_ID, $kshow_id); $c->add(entryPeer::KUSER_ID, $likuser_id, Criteria::NOT_EQUAL); // the current user knows they just edited $c->addAnd(entryPeer::KUSER_ID, $kshow->getProducerId(), Criteria::NOT_EQUAL); // the producer knows they just edited $c->add(entryPeer::TYPE, entryType::MEDIA_CLIP); $c->addGroupByColumn(entryPeer::KUSER_ID); $entries = entryPeer::doSelect($c); $already_received_alert_array = array(); foreach ($entries as $entry) { alertPeer::sendEmailIfNeeded($entry->getKuserId(), alert::KALTURAS_PARTOF_ALERT_TYPE_ROUGHCUT_CREATED, array('screenname' => $user_screenname, 'kshow_name' => $kshow->getName(), 'kshow_id' => $kshow->getId())); $already_received_alert_array[$entry->getKuserId()] = true; } // send email alert to subscribers $c = new Criteria(); $c->add(KshowKuserPeer::KSHOW_ID, $kshow_id); //only subsribers of this show $c->add(KshowKuserPeer::KUSER_ID, $likuser_id, Criteria::NOT_EQUAL); // the current user knows they just edited $c->add(KshowKuserPeer::SUBSCRIPTION_TYPE, KshowKuser::KSHOW_SUBSCRIPTION_NORMAL); // this table stores other relations too $subscriptions = KshowKuserPeer::doSelect($c); foreach ($subscriptions as $subscription) { if (!isset($already_received_alert_array[$subscription->getKuserId()])) { // don't send emails to subscribed users who are also contributors alertPeer::sendEmailIfNeeded($subscription->getKuserId(), alert::KALTURAS_SUBSCRIBEDTO_ALERT_TYPE_ROUGHCUT_CREATED, array('screenname' => $user_screenname, 'kshow_name' => $kshow->getName(), 'kshow_id' => $kshow->getId())); } } }
/** * 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); }
/** * Authenticate live-stream entry against stream token and partner limitations * * @action authenticate * @param string $entryId Live stream entry id * @param string $token Live stream broadcasting token * @return KalturaLiveStreamEntry The authenticated live stream entry * * @throws KalturaErrors::ENTRY_ID_NOT_FOUND * @throws KalturaErrors::LIVE_STREAM_INVALID_TOKEN */ function authenticateAction($entryId, $token) { $dbEntry = entryPeer::retrieveByPK($entryId); if (!$dbEntry || $dbEntry->getType() != entryType::LIVE_STREAM) { throw new KalturaAPIException(KalturaErrors::ENTRY_ID_NOT_FOUND, $entryId); } /* @var $dbEntry LiveStreamEntry */ if ($dbEntry->getStreamPassword() != $token) { throw new KalturaAPIException(KalturaErrors::LIVE_STREAM_INVALID_TOKEN, $entryId); } $mediaServer = $dbEntry->getMediaServer(true); if ($mediaServer) { $url = null; $protocol = null; foreach (array(KalturaPlaybackProtocol::HLS, KalturaPlaybackProtocol::APPLE_HTTP) as $hlsProtocol) { $config = $dbEntry->getLiveStreamConfigurationByProtocol($hlsProtocol, requestUtils::PROTOCOL_HTTP, null, true); if ($config) { $url = $config->getUrl(); $protocol = $hlsProtocol; break; } } if ($url) { KalturaLog::info('Determining status of live stream URL [' . $url . ']'); $dpda = new DeliveryProfileDynamicAttributes(); $dpda->setEntryId($entryId); $dpda->setFormat($protocol); $deliveryProfile = DeliveryProfilePeer::getLiveDeliveryProfileByHostName(parse_url($url, PHP_URL_HOST), $dpda); if ($deliveryProfile && $deliveryProfile->isLive($url)) { throw new KalturaAPIException(KalturaErrors::LIVE_STREAM_ALREADY_BROADCASTING, $entryId, $mediaServer->getHostname()); } } } // fetch current stream live params $liveParamsIds = flavorParamsConversionProfilePeer::getFlavorIdsByProfileId($dbEntry->getConversionProfileId()); $usedLiveParamsIds = array(); foreach ($liveParamsIds as $liveParamsId) { $usedLiveParamsIds[$liveParamsId] = array($entryId); } // fetch all live entries that currently are live $baseCriteria = KalturaCriteria::create(entryPeer::OM_CLASS); $filter = new entryFilter(); $filter->setIsLive(true); $filter->setIdNotIn(array($entryId)); $filter->setPartnerSearchScope(baseObjectFilter::MATCH_KALTURA_NETWORK_AND_PRIVATE); $filter->attachToCriteria($baseCriteria); $entries = entryPeer::doSelect($baseCriteria); $maxInputStreams = $this->getPartner()->getMaxLiveStreamInputs(); if (!$maxInputStreams) { $maxInputStreams = kConf::get('partner_max_live_stream_inputs', 'local', 10); } KalturaLog::debug("Max live stream inputs [{$maxInputStreams}]"); $maxTranscodedStreams = 0; if (PermissionPeer::isValidForPartner(PermissionName::FEATURE_KALTURA_LIVE_STREAM_TRANSCODE, $this->getPartnerId())) { $maxTranscodedStreams = $this->getPartner()->getMaxLiveStreamOutputs(); if (!$maxTranscodedStreams) { $maxTranscodedStreams = kConf::get('partner_max_live_stream_outputs', 'local', 10); } } KalturaLog::debug("Max live stream outputs [{$maxTranscodedStreams}]"); $totalInputStreams = count($entries) + 1; if ($totalInputStreams > $maxInputStreams + $maxTranscodedStreams) { KalturaLog::debug("Live input stream [{$totalInputStreams}]"); throw new KalturaAPIException(KalturaErrors::LIVE_STREAM_EXCEEDED_MAX_PASSTHRU, $entryId); } $entryIds = array($entryId); foreach ($entries as $liveEntry) { /* @var $liveEntry LiveEntry */ $entryIds[] = $liveEntry->getId(); $liveParamsIds = array_map('intval', explode(',', $liveEntry->getFlavorParamsIds())); foreach ($liveParamsIds as $liveParamsId) { if (isset($usedLiveParamsIds[$liveParamsId])) { $usedLiveParamsIds[$liveParamsId][] = $liveEntry->getId(); } else { $usedLiveParamsIds[$liveParamsId] = array($liveEntry->getId()); } } } $liveParams = assetParamsPeer::retrieveByPKs(array_keys($usedLiveParamsIds)); $passthruEntries = null; $transcodedEntries = null; foreach ($liveParams as $liveParamsItem) { /* @var $liveParamsItem LiveParams */ if ($liveParamsItem->hasTag(liveParams::TAG_INGEST)) { $passthruEntries = array_intersect(is_array($passthruEntries) ? $passthruEntries : $entryIds, $usedLiveParamsIds[$liveParamsItem->getId()]); } else { $transcodedEntries = array_intersect(is_array($transcodedEntries) ? $transcodedEntries : $entryIds, $usedLiveParamsIds[$liveParamsItem->getId()]); } } $passthruEntries = array_diff($passthruEntries, $transcodedEntries); $passthruEntriesCount = count($passthruEntries); $transcodedEntriesCount = count($transcodedEntries); KalturaLog::debug("Live transcoded entries [{$transcodedEntriesCount}], max live transcoded streams [{$maxTranscodedStreams}]"); if ($transcodedEntriesCount > $maxTranscodedStreams) { throw new KalturaAPIException(KalturaErrors::LIVE_STREAM_EXCEEDED_MAX_TRANSCODED, $entryId); } $maxInputStreams += $maxTranscodedStreams - $transcodedEntriesCount; KalturaLog::debug("Live params inputs [{$passthruEntriesCount}], max live stream inputs [{$maxInputStreams}]"); if ($passthruEntriesCount > $maxInputStreams) { throw new KalturaAPIException(KalturaErrors::LIVE_STREAM_EXCEEDED_MAX_PASSTHRU, $entryId); } $entry = KalturaEntryFactory::getInstanceByType($dbEntry->getType()); $entry->fromObject($dbEntry, $this->getResponseProfile()); return $entry; }
public static function createMakeoverRoughcut($kshow_id) { $c = new Criteria(); $c->add(entryPeer::KSHOW_ID, $kshow_id); $c->add(entryPeer::TYPE, entryType::MEDIA_CLIP); $c->add(entryPeer::STATUS, entryStatus::READY); $entries = entryPeer::doSelect($c); $kshow = kshowPeer::retrieveByPK($kshow_id); self::createKEditorMetadata($kshow, $kshow->getShowEntry(), $entries); }
if ($argc != 2) { echo "Arguments missing.\n\n"; echo "Usage: php removePartnerEntries.php {partner id}\n"; exit; } $partnerId = $argv[1]; set_time_limit(0); ini_set("memory_limit", "1024M"); define('ROOT_DIR', realpath(dirname(__FILE__) . '/../../')); require_once ROOT_DIR . '/infra/bootstrap_base.php'; require_once ROOT_DIR . '/infra/KAutoloader.php'; KAutoloader::addClassPath(KAutoloader::buildPath(KALTURA_ROOT_PATH, "vendor", "propel", "*")); KAutoloader::addClassPath(KAutoloader::buildPath(KALTURA_ROOT_PATH, "plugins", "metadata", "*")); KAutoloader::setClassMapFilePath('../cache/classMap.cache'); KAutoloader::register(); error_reporting(E_ALL); KalturaLog::setLogger(new KalturaStdoutLogger()); $typesToDelete = array(entryType::DATA, entryType::DOCUMENT); $dbConf = kConf::getDB(); DbManager::setConfig($dbConf); DbManager::initialize(); $c = new Criteria(); $c->add(entryPeer::PARTNER_ID, $partnerId); $c->add(entryPeer::TYPE, $typesToDelete, Criteria::IN); $entries = entryPeer::doSelect($c); foreach ($entries as $entry) { KalturaLog::debug("Deletes entry [" . $entry->getId() . "]"); myEntryUtils::deleteEntry($entry, $partnerId); } KalturaLog::debug("Done");
$c->addAnd(BatchJobPeer::STATUS, $nonFinalBatchStatuses, Criteria::IN); $batchCount = BatchJobPeer::doCount($c, false, myDbHelper::getConnection(myDbHelper::DB_HELPER_CONN_PROPEL3)); if ($batchCount >= $maxConcurrentJobs) { sleep(30); continue; } $curLimit = $maxConcurrentJobs - $batchCount; $currentExported = 0; $c = new Criteria(); $c->add(entryPeer::PARTNER_ID, $partnerId); if ($lastCreatedAt) { $c->addAnd(entryPeer::CREATED_AT, $lastCreatedAt, Criteria::LESS_EQUAL); } $c->addDescendingOrderByColumn(entryPeer::CREATED_AT); $c->setLimit($curLimit); $entries = entryPeer::doSelect($c, myDbHelper::getConnection(myDbHelper::DB_HELPER_CONN_PROPEL3)); foreach ($entries as $entry) { if (in_array($entry->getId(), $processedIds)) { continue; } $processedIds[] = $entry->getId(); $lastCreatedAt = $entry->getCreatedAt(null); $keys = array(); $keys[] = $entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_ISM); $keys[] = $entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_ISMC); $flavors = assetPeer::retrieveReadyFlavorsByEntryId($entry->getId()); foreach ($flavors as $flavor) { if (!$flavorParamsArr || in_array($flavor->getFlavorParamsId(), $flavorParamsArr)) { $keys[] = $flavor->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET); } }
DbManager::setConfig($dbConf); DbManager::initialize(); if (count($argv) !== 2) { die('pleas provide partner id as input' . PHP_EOL . 'to run script: ' . basename(__FILE__) . ' X' . PHP_EOL . 'whereas X is partner id' . PHP_EOL); } $partner_id = @$argv[1]; $partner = PartnerPeer::retrieveByPK($partner_id); if (!$partner) { die('no such partner.' . PHP_EOL); } $partner->setAppearInSearch(mySearchUtils::DISPLAY_IN_SEARCH_KALTURA_NETWORK); $partner->save(); $c = new Criteria(); $c->add(entryPeer::PARTNER_ID, $partner_id); $c->add(entryPeer::DISPLAY_IN_SEARCH, mySearchUtils::DISPLAY_IN_SEARCH_PARTNER_ONLY); $c->addOr(entryPeer::DISPLAY_IN_SEARCH, mySearchUtils::DISPLAY_IN_SEARCH_NONE); $c->setLimit(200); $con = myDbHelper::getConnection(myDbHelper::DB_HELPER_CONN_PROPEL2); $entries = entryPeer::doSelect($c, $con); $changedEntriesCounter = 0; while (count($entries)) { $changedEntriesCounter += count($entries); foreach ($entries as $entry) { echo "changed DISPLAY_IN_SEARCH for entry: " . $entry->getId() . "\n"; $entry->setDisplayInSearch(mySearchUtils::DISPLAY_IN_SEARCH_KALTURA_NETWORK); $entry->save(); } entryPeer::clearInstancePool(); $entries = entryPeer::doSelect($c, $con); } echo "Done. {$changedEntriesCounter} entries where changed";
/** return array('status' => $status, 'message' => $message, 'objects' => $objects); objects - array of 'thumb' 'title' 'description' 'id' - unique id to be passed to getMediaInfo this service will first return the relevant kshows, then find the relevant roughcuts and finally fetch the entries */ public function searchMedia($media_type, $searchText, $page, $pageSize, $authData = null, $extraData = null) { myDbHelper::$use_alternative_con = myDbHelper::DB_HELPER_CONN_PROPEL2; // this bellow will bypass the partner filter - at the end of the code the filter will return to be as was before $kshow_criteria = kshowPeer::getCriteriaFilter()->getFilter(); $original_kshow_partner_to_filter = $kshow_criteria->get(kshowPeer::PARTNER_ID); $kshow_criteria->remove(kshowPeer::PARTNER_ID); $entry_criteria = entryPeer::getCriteriaFilter()->getFilter(); $original_entry_partner_to_filter = $entry_criteria->get(entryPeer::PARTNER_ID); $entry_criteria->remove(entryPeer::PARTNER_ID); $page_size = $pageSize > self::MAX_PAGE_SIZE ? self::MAX_PAGE_SIZE : $pageSize; $status = "ok"; $message = ''; $kshow_filter = $this->getKshowFilter($extraData); $limit = $pageSize; $offset = $pageSize * ($page - 1); // $page starts from 1 // $keywords_array = mySearchUtils::getKeywordsFromStr ( $searchText ); // TODO_ change mechanism ! //$search_mechanism = self::KALTURA_SERVICE_CRITERIA_FROM_KSHOW; $search_mechanism = self::KALTURA_SERVICE_CRITERIA_FROM_ROUGHCUT; // TODO - optimize the first part of the entry_id search // cache once we know the kshow_ids / roughcuts - this will make paginating much faster $kshow_crit = new Criteria(); $kshow_crit->clearSelectColumns()->clearOrderByColumns(); $kshow_crit->addSelectColumn(kshowPeer::ID); $kshow_crit->addSelectColumn(kshowPeer::SHOW_ENTRY_ID); $kshow_crit->setLimit(self::$s_default_count_limit); $kshow_filter->addSearchMatchToCriteria($kshow_crit, $searchText, kshow::getSearchableColumnName()); if ($search_mechanism == self::KALTURA_SERVICE_CRITERIA_FROM_KSHOW) { $kshow_crit->add(kshowPeer::ENTRIES, 1, criteria::GREATER_EQUAL); } $rs = kshowPeer::doSelectStmt($kshow_crit); $kshow_arr = array(); $roughcut_arr = array(); $res = $rs->fetchAll(); foreach ($res as $record) { $kshow_arr[] = $record[0]; $roughcut_arr[] = $record[1]; } // // old code from doSelectRs // while($rs->next()) // { // $kshow_arr[] = $rs->getString(1); // $roughcut_arr[] = $rs->getString(2); // } $crit = new Criteria(); $crit->setOffset($offset); $crit->setLimit($limit); $crit->add(entryPeer::TYPE, entryType::MEDIA_CLIP); $crit->add(entryPeer::MEDIA_TYPE, $media_type); if ($search_mechanism == self::KALTURA_SERVICE_CRITERIA_FROM_KSHOW) { $crit->add(entryPeer::KSHOW_ID, $kshow_arr, Criteria::IN); $entry_results = entryPeer::doSelect($crit); } elseif ($search_mechanism == self::KALTURA_SERVICE_CRITERIA_FROM_ROUGHCUT) { // $entry_results = roughcutEntryPeer::retrievByRoughcutIds ( $crit , $roughcut_arr , true ); $entry_results = roughcutEntryPeer::retrievEntriesByRoughcutIds($crit, $roughcut_arr); } // after the query - return the filter to what it was before $entry_criteria->addAnd(entryPeer::PARTNER_ID, $original_entry_partner_to_filter); $kshow_criteria->addAnd(kshowPeer::PARTNER_ID, $original_kshow_partner_to_filter); $objects = array(); // add thumbs when not image or video $should_add_thumbs = $media_type != entry::ENTRY_MEDIA_TYPE_AUDIO; foreach ($entry_results as $obj) { if ($search_mechanism == self::KALTURA_SERVICE_CRITERIA_FROM_KSHOW) { $entry = $obj; } else { //$entry = $obj->getEntry(); $entry = $obj; } /* @var $entry entry */ // use the id as the url - it will help using this entry id in addentry $object = array("id" => $entry->getId(), "url" => $entry->getDataUrl(), "tags" => $entry->getTags(), "title" => $entry->getName(), "description" => $entry->getTags(), "flash_playback_type" => $entry->getMediaTypeName()); if ($should_add_thumbs) { $object["thumb"] = $entry->getThumbnailUrl(); } $objects[] = $object; } return array('status' => $status, 'message' => $message, 'objects' => $objects, "needMediaInfo" => self::$NEED_MEDIA_INFO); }
/** * Will investigate a single entry */ public function execute() { $this->forceSystemAuthentication(); myDbHelper::$use_alternative_con = myDbHelper::DB_HELPER_CONN_PROPEL2; entryPeer::setUseCriteriaFilter(false); $this->result = NULL; $fast = $this->getRequestParameter("fast", "") != ""; $this->fast = $fast; $kshow_id = $this->getRequestParameter("kshow_id"); $this->kshow_id = $kshow_id; $this->kshow = NULL; $entry_id = $this->getRequestParameter("entry_id"); $this->entry_id = $entry_id; $this->entry = NULL; $this->error = $this->getRequestParameter("error"); $this->bg_entry = NULL; if (!empty($kshow_id)) { $c = new Criteria(); $c->add(kshowPeer::ID, $kshow_id); $kshows = kshowPeer::doSelect($c); $kshow = new kshow(); if (!$kshows) { $this->result = "No kshow [{$kshow_id}] in DB"; return; } $kshow_original = $kshows[0]; $kshow_original->getShowEntry(); // pre fetch $kshow_original->getIntro(); // pre fetch $this->kshow_original = $kshows[0]; $this->kshow = new genericObjectWrapper($this->kshow_original, true); $alredy_exist_entries = array(); $alredy_exist_entries[] = $kshow_original->getShowEntryId(); if ($kshow_original->getIntroId()) { $alredy_exist_entries[] = $kshow_original->getIntroId(); } $skin_obj = $this->kshow_original->getSkinObj(); $bg_entry_id = $skin_obj->get("bg_entry_id"); if ($bg_entry_id) { $alredy_exist_entries[] = $bg_entry_id; $this->bg_entry = new genericObjectWrapper(entryPeer::retrieveByPK($bg_entry_id), true); } $c = new Criteria(); $c->add(entryPeer::ID, $alredy_exist_entries, Criteria::NOT_IN); $c->setLimit(100); $this->kshow_entries = $this->kshow_original->getEntrysJoinKuser($c); return; //return "KshowSuccess"; } if (empty($entry_id)) { return; } entryPeer::setUseCriteriaFilter(false); // from entry table $c = new Criteria(); $c->add(entryPeer::ID, $entry_id); //$entries = entryPeer::doSelectJoinAll ( $c ); $entries = entryPeer::doSelect($c); if (!$entries) { $this->result = "No entry [{$entry_id}] in DB"; return; } $this->entry = new genericObjectWrapper($entries[0], true); // from conversion table $c = new Criteria(); $c->add(conversionPeer::ENTRY_ID, $entry_id); $original_conversions = conversionPeer::doSelect($c); //$this->conversions = array() ; // $this->conversions = $original_conversions; //new genericObjectWrapper( $original_conversions ); // find all relevant batches in DB // from batch_job table $c = new Criteria(); //$c->add ( BatchJobPeer::DATA , "%\"entryId\";i:" . $entry_id . ";%" , Criteria::LIKE ); $c->add(BatchJobPeer::ENTRY_ID, $entry_id); $original_batch_jobs = BatchJobPeer::doSelect($c); $this->batch_jobs = $original_batch_jobs; // new genericObjectWrapper( $original_batch_jobs ); // use this as a refernece of all the directories // myBatchFileConverterServer::init( true ); $entry_patttern = "/" . $entry_id . "\\..*/"; $getFileData_method = array('kFile', 'getFileData'); $getFileDataWithContent_method = array('kFile', 'getFileDataWithContent'); // find all relevant files on disk $c = new Criteria(); $c->add(FileSyncPeer::OBJECT_TYPE, FileSyncObjectType::ENTRY); $c->add(FileSyncPeer::OBJECT_ID, $entry_id); // order by OBJECT SUB TYPE $c->addAscendingOrderByColumn(FileSyncPeer::OBJECT_SUB_TYPE); $this->file_syncs = FileSyncPeer::doSelect($c); $file_sync_links = array(); $flavors = assetPeer::retrieveFlavorsByEntryId($entry_id); $flavor_ids = array(); $this->flavors = array(); foreach ($flavors as $f) { $flavor_ids[] = $f->getId(); $f->getflavorParamsOutputs(); $f->getflavorParams(); $f->getmediaInfos(); $this->flavors[] = $f; } // find all relevant files on disk $c = new Criteria(); $c->add(FileSyncPeer::OBJECT_TYPE, FileSyncObjectType::FLAVOR_ASSET); $c->add(FileSyncPeer::OBJECT_ID, $flavor_ids, Criteria::IN); // order by OBJECT SUB TYPE $c->addAscendingOrderByColumn(FileSyncPeer::OBJECT_SUB_TYPE); $flavors_file_syncs = FileSyncPeer::doSelect($c); $this->flavors_file_syncs = array(); foreach ($flavors as $flav) { foreach ($flavors_file_syncs as $f) { if ($f->getLinkedId()) { $file_sync_links[] = $f->getLinkedId(); } if ($f->getObjectId() == $flav->getId()) { $this->flavors_file_syncs[$flav->getId()][] = $f; } } } if ($this->file_syncs) { $this->file_syncs_by_sub_type = array(); foreach ($this->file_syncs as $fs) { if ($fs->getLinkedId()) { $file_sync_links[] = $fs->getLinkedId(); } $sub_type = $fs->getObjectSubType(); if (!isset($this->file_syncs_by_sub_type[$sub_type])) { // create the array $this->file_syncs_by_sub_type[$sub_type] = array(); } $this->file_syncs_by_sub_type[$sub_type][] = $fs; } } else { $this->file_syncs_by_sub_type = array(); } $file_sync_criteria = new Criteria(); $file_sync_criteria->add(FileSyncPeer::ID, $file_sync_links, Criteria::IN); $this->file_sync_links = FileSyncPeer::doSelect($file_sync_criteria); $track_entry_c = new Criteria(); $track_entry_c->add(TrackEntryPeer::ENTRY_ID, $entry_id); $track_entry_list = TrackEntryPeer::doSelect($track_entry_c); $more_interesting_track_entries = array(); foreach ($track_entry_list as $track_entry) { if ($track_entry->getTrackEventTypeId() == TrackEntry::TRACK_ENTRY_EVENT_TYPE_ADD_ENTRY) { $more_interesting_track_entries[] = $track_entry->getParam3Str(); } } $track_entry_list2 = array(); //very heavy query, skip this /* // add all the track_entry objects that are related (joined on PARAM_3_STR) $track_entry_c2 = new Criteria(); $track_entry_c2->add ( TrackEntryPeer::TRACK_EVENT_TYPE_ID , TrackEntry::TRACK_ENTRY_EVENT_TYPE_UPLOADED_FILE ); $track_entry_c2->add ( TrackEntryPeer::PARAM_3_STR , $more_interesting_track_entries , Criteria::IN ); $track_entry_list2 = TrackEntryPeer::doSelect ( $track_entry_c2 ); */ // first add the TRACK_ENTRY_EVENT_TYPE_UPLOADED_FILE - they most probably happend before the rest $this->track_entry_list = array_merge($track_entry_list2, $track_entry_list); }
protected function doGetListResponse(KalturaFilterPager $pager) { myDbHelper::$use_alternative_con = myDbHelper::DB_HELPER_CONN_PROPEL3; $disableWidgetSessionFilters = false; if ($this && ($this->idEqual != null || $this->idIn != null || $this->referenceIdEqual != null || $this->redirectFromEntryId != null || $this->referenceIdIn != null || $this->parentEntryIdEqual != null)) { $disableWidgetSessionFilters = true; } $c = $this->prepareEntriesCriteriaFilter($pager); if ($disableWidgetSessionFilters) { KalturaCriterion::disableTag(KalturaCriterion::TAG_WIDGET_SESSION); } $list = entryPeer::doSelect($c); $totalCount = $c->getRecordsCount(); if ($disableWidgetSessionFilters) { KalturaCriterion::restoreTag(KalturaCriterion::TAG_WIDGET_SESSION); } myDbHelper::$use_alternative_con = null; return array($list, $totalCount); }
private function getLicenseRequestEntry($keyId, $entryId = null) { $entry = null; $keyId = strtolower($keyId); if (!$keyId) { throw new KalturaAPIException(KalturaErrors::MISSING_MANDATORY_PARAMETER, "keyId"); } if ($entryId) { $entry = entryPeer::retrieveByPK($entryId); if (!$entry) { throw new KalturaAPIException(KalturaErrors::ENTRY_ID_NOT_FOUND, $entryId); } $entryKeyId = $this->getEntryKeyId($entry->getId()); if ($entryKeyId != $keyId) { throw new KalturaAPIException(KalturaPlayReadyErrors::KEY_ID_DONT_MATCH, $keyId, $entryKeyId); } } else { $entryFilter = new entryFilter(); $entryFilter->fields['_like_plugins_data'] = PlayReadyPlugin::getPlayReadyKeyIdSearchData($keyId); $entryFilter->setPartnerSearchScope(baseObjectFilter::MATCH_KALTURA_NETWORK_AND_PRIVATE); $c = KalturaCriteria::create(entryPeer::OM_CLASS); $entryFilter->attachToCriteria($c); $c->applyFilters(); $entries = entryPeer::doSelect($c); if ($entries && count($entries) > 0) { $entry = $entries[0]; } if (!$entry) { throw new KalturaAPIException(KalturaPlayReadyErrors::ENTRY_NOT_FOUND_BY_KEY_ID, $keyId); } } return $entry; }
public static function executeStaticPlaylistFromEntryIds(array $entry_id_list, $entry_filter = null, $detailed = true, $pager = null) { // if exists extra_filters - use the first one to filter the entry_id_list $c = KalturaCriteria::create(entryPeer::OM_CLASS); $filter = new entryFilter(); $filter->setIdIn($entry_id_list); $filter->setStatusEquel(entryStatus::READY); $filter->setPartnerSearchScope(baseObjectFilter::MATCH_KALTURA_NETWORK_AND_PRIVATE); $filter->attachToCriteria($c); if (!self::$isAdminKs) { self::addSchedulingToCriteria($c); } self::addModerationToCriteria($c); if ($entry_filter) { if ($entry_filter->getLimit() > 0) { $limit = $entry_filter->getLimit(); } $entry_filter->setLimit(null); // read the _eq_display_in_search field but ignore it because it's part of a more complex criterion - see bellow $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->setPartnerSearchScope(baseObjectFilter::MATCH_KALTURA_NETWORK_AND_PRIVATE); $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 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 ($detailed) { $unsorted_entry_list = entryPeer::doSelectJoinkuser($c); } else { $unsorted_entry_list = entryPeer::doSelect($c); } // maybe join with kuser to add some data about the contributor // now sort the list according to $entry_id_list $entry_list = array(); // build a map where the key is the id of the entry $id_list = self::buildIdMap($unsorted_entry_list); if ($pager) { $pageSize = $pager->calcPageSize(); $startOffset = $pager->calcOffset(); } // VERY STRANGE !! &$entry_id must be with a & or else the values of the array change !!! foreach ($entry_id_list as &$entry_id) { if ($entry_id != "") { $current_entry = @$id_list[$entry_id]; if ($current_entry) { if (isset($limit) && $limit-- === 0) { break; } if ($pager) { if ($startOffset > 0) { $startOffset--; continue; } else { if ($pageSize > 0) { $pageSize--; } else { break; } } } // add to the entry_list only when the entry_id is not empty $entry_list[] = $current_entry; } } } if (count($entry_list) == 0) { return null; } return $entry_list; }
protected function listEntriesByFilter(KalturaBaseEntryFilter $filter = null, KalturaFilterPager $pager = null) { myDbHelper::$use_alternative_con = myDbHelper::DB_HELPER_CONN_PROPEL3; $disableWidgetSessionFilters = false; if ($filter && ($filter->idEqual != null || $filter->idIn != null || $filter->referenceIdEqual != null || $filter->referenceIdIn != null)) { $disableWidgetSessionFilters = true; } if (!$pager) { $pager = new KalturaFilterPager(); } $c = $this->prepareEntriesCriteriaFilter($filter, $pager); if ($disableWidgetSessionFilters) { KalturaCriterion::disableTag(KalturaCriterion::TAG_WIDGET_SESSION); } $list = entryPeer::doSelect($c); $totalCount = $c->getRecordsCount(); if ($disableWidgetSessionFilters) { KalturaCriterion::restoreTag(KalturaCriterion::TAG_WIDGET_SESSION); } return array($list, $totalCount); }
protected function validateMaxLengthCategoryName($categoryEntryId, $action) { $validationErrors = array(); $c = new Criteria(); $c->addAnd(entryPeer::ID, $categoryEntryId, Criteria::EQUAL); $categoryEntryIdObject = entryPeer::doSelect($c); if ($categoryEntryIdObject) { $relatedEntryName = $categoryEntryIdObject[0]->getName(); if (strlen($relatedEntryName) > self::CATEGORY_ENTRY_NAME_MAXIMUM_LENGTH) { KalturaLog::debug('related category name exceeds the maximum length of ' . self::CATEGORY_ENTRY_NAME_MAXIMUM_LENGTH . ' characters'); $errorMsg = 'related category name exceeds the maximum length of ' . self::CATEGORY_ENTRY_NAME_MAXIMUM_LENGTH . ' characters'; $validationError = $this->createValidationError($action, DistributionErrorType::INVALID_DATA); $validationError->setValidationErrorType(DistributionValidationErrorType::CUSTOM_ERROR); $validationError->setValidationErrorParam($errorMsg); $validationError->setDescription($errorMsg); $validationErrors[] = $validationError; } } return $validationErrors; }
/** * Queries for the entries from which we will generate the filter * @param string $orderBy The field according to we'd like to sort the results * @param int $limit the maximal number of results */ protected function getEntries($context, $orderBy = null, $limit = null) { $baseCriteria = KalturaCriteria::create(entryPeer::OM_CLASS); $baseCriteria->add(entryPeer::DISPLAY_IN_SEARCH, mySearchUtils::DISPLAY_IN_SEARCH_SYSTEM, Criteria::NOT_EQUAL); if (!is_null($limit)) { $baseCriteria->setLimit($limit); } if (!is_null($orderBy)) { $baseCriteria->addDescendingOrderByColumn($orderBy); } $entryFilter = $this->getEntryFilter($context, $context->keepScheduling); $entryFilter->attachToCriteria($baseCriteria); return entryPeer::doSelect($baseCriteria); }
/** * 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 static function copyEntriesByType(Partner $fromPartner, Partner $toPartner, $entryType, $dontCopyUsers = false) { KalturaLog::log("Copying entries from partner [" . $fromPartner->getId() . "] to partner [" . $toPartner->getId() . "] with type [" . $entryType . "]"); entryPeer::setUseCriteriaFilter(false); $c = new Criteria(); $c->addAnd(entryPeer::PARTNER_ID, $fromPartner->getId()); $c->addAnd(entryPeer::TYPE, $entryType); $c->addAnd(entryPeer::STATUS, entryStatus::READY); $c->addDescendingOrderByColumn(entryPeer::CREATED_AT); $entries = entryPeer::doSelect($c); entryPeer::setUseCriteriaFilter(true); foreach ($entries as $entry) { myEntryUtils::copyEntry($entry, $toPartner, $dontCopyUsers); } }