コード例 #1
0
 /**
  * @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;
 }
 protected function getEntryFilter($extraData)
 {
     $entry_filter = new entryFilter();
     // This is the old way to search within a partner - allow both
     $entry_filter->setByName("_eq_partner_id", $extraData);
     // this is the better way -
     $entry_filter->setPartnerSearchScope($extraData);
     return $entry_filter;
 }
コード例 #4
0
ファイル: UverseService.php プロジェクト: DBezemer/server
 protected function getEntryFilter($context, $keepScheduling = true)
 {
     // "Creates advanced filter on distribution profile
     $distributionAdvancedSearch = new ContentDistributionSearchFilter();
     $distributionAdvancedSearch->setDistributionProfileId($this->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);
     return $entryFilter;
 }
コード例 #5
0
 public function __construct($feedId)
 {
     myDbHelper::$use_alternative_con = myDbHelper::DB_HELPER_CONN_PROPEL3;
     $microTimeStart = microtime(true);
     KalturaLog::info("syndicationFeedRenderer- initialize ");
     // initialize the database for all services
     DbManager::setConfig(kConf::getDB());
     DbManager::initialize();
     $syndicationFeedDB = syndicationFeedPeer::retrieveByPK($feedId);
     if (!$syndicationFeedDB) {
         throw new Exception("Feed Id not found");
     }
     $tmpSyndicationFeed = KalturaSyndicationFeedFactory::getInstanceByType($syndicationFeedDB->getType());
     $tmpSyndicationFeed->fromObject($syndicationFeedDB);
     $this->syndicationFeed = $tmpSyndicationFeed;
     // add partner to default criteria
     categoryPeer::addPartnerToCriteria($this->syndicationFeed->partnerId, true);
     flavorAssetPeer::addPartnerToCriteria($this->syndicationFeed->partnerId, true);
     $this->baseCriteria = KalturaCriteria::create(entryPeer::OM_CLASS);
     $startDateCriterion = $this->baseCriteria->getNewCriterion(entryPeer::START_DATE, time(), Criteria::LESS_EQUAL);
     $startDateCriterion->addOr($this->baseCriteria->getNewCriterion(entryPeer::START_DATE, null));
     $this->baseCriteria->addAnd($startDateCriterion);
     $endDateCriterion = $this->baseCriteria->getNewCriterion(entryPeer::END_DATE, time(), Criteria::GREATER_EQUAL);
     $endDateCriterion->addOr($this->baseCriteria->getNewCriterion(entryPeer::END_DATE, null));
     $this->baseCriteria->addAnd($endDateCriterion);
     $entryFilter = new entryFilter();
     $entryFilter->setPartnerSearchScope($this->syndicationFeed->partnerId);
     $entryFilter->setStatusEquel(entryStatus::READY);
     $entryFilter->setTypeIn(array(entryType::MEDIA_CLIP, entryType::MIX));
     $entryFilter->setModerationStatusNot(entry::ENTRY_MODERATION_STATUS_REJECTED);
     $entryFilter->setDurationGreaterThan(0);
     $entryFilter->attachToCriteria($this->baseCriteria);
     if ($this->syndicationFeed->playlistId) {
         $this->entryFilters = myPlaylistUtils::getPlaylistFiltersById($this->syndicationFeed->playlistId);
     } else {
         $this->entryFilters = array();
     }
     $microTimeEnd = microtime(true);
     KalturaLog::info("syndicationFeedRenderer- initialization done [" . ($microTimeEnd - $microTimeStart) . "]");
 }
コード例 #6
0
 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;
 }
 /**
  * @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;
 }
コード例 #8
0
 private static function executeQueryByType($partner_id, $report_type, $report_flavor, reportsInputFilter $input_filter, $page_size, $page_index, $order_by, $object_ids = null, $offset = null)
 {
     $start = microtime(true);
     try {
         $add_search_text = false;
         $has_object_ids = false;
         if ($input_filter instanceof endUserReportsInputFilter) {
             $has_object_ids = $input_filter->categories;
         }
         $has_object_ids = $has_object_ids || $object_ids;
         if (is_numeric($report_type)) {
             $file_path = myReportsSqlFileMgr::getSqlFilePath(self::$type_map[$report_type], self::$flavor_map[$report_flavor], $add_search_text, $has_object_ids ? true : false, $input_filter);
         } else {
             if (strpos($report_type, ".") === 0 || strpos($report_type, "/") === 0 || strpos($report_type, "http") === 0) {
                 throw new kCoreException("Will not search for invalid report_type [{$report_type}", kCoreException::INVALID_QUERY);
             }
             $file_path = dirname(__FILE__) . "/" . $report_type . ".sql";
         }
         $sql_raw_content = file_get_contents($file_path);
         if (!$sql_raw_content) {
             $pluginInstances = KalturaPluginManager::getPluginInstances('IKalturaReportProvider');
             foreach ($pluginInstances as $pluginInstance) {
                 $res = $pluginInstance->getReportResult($partner_id, $report_type, $report_flavor, $object_ids, $order_by);
                 if (!is_null($res)) {
                     return $res;
                 }
             }
             throw new kCoreException("Cannot find sql for [{$report_type}] [{$report_flavor}] at [{$file_path}]", kCoreException::QUERY_NOT_FOUND);
         }
         $entryFilter = new entryFilter();
         $entryFilter->setPartnerSearchScope($partner_id);
         $shouldSelectFromSearchEngine = false;
         $category_ids_clause = "1=1";
         if ($input_filter instanceof endUserReportsInputFilter) {
             if ($input_filter->playbackContext || $input_filter->ancestorPlaybackContext) {
                 $categoryFilter = new categoryFilter();
                 if ($input_filter->playbackContext && $input_filter->ancestorPlaybackContext) {
                     $categoryIds = category::CATEGORY_ID_THAT_DOES_NOT_EXIST;
                 } else {
                     if ($input_filter->playbackContext) {
                         $categoryFilter->set("_in_full_name", $input_filter->playbackContext);
                     }
                     if ($input_filter->ancestorPlaybackContext) {
                         $categoryFilter->set("_matchor_likex_full_name", $input_filter->ancestorPlaybackContext);
                     }
                     $c = KalturaCriteria::create(categoryPeer::OM_CLASS);
                     $categoryFilter->attachToCriteria($c);
                     $c->applyFilters();
                     $categoryIdsFromDB = $c->getFetchedIds();
                     if (count($categoryIdsFromDB)) {
                         $categoryIds = implode(",", $categoryIdsFromDB);
                     } else {
                         $categoryIds = category::CATEGORY_ID_THAT_DOES_NOT_EXIST;
                     }
                 }
                 $category_ids_clause = "ev.context_id in ( {$categoryIds} )";
             }
         }
         if ($input_filter->categories) {
             $entryFilter->set("_matchor_categories", $input_filter->categories);
             $shouldSelectFromSearchEngine = true;
         }
         if ($input_filter->keywords) {
             if ($input_filter->search_in_tags) {
                 $entryFilter->set("_free_text", $input_filter->keywords);
             } else {
                 $entryFilter->set("_like_admin_tags", $input_filter->keywords);
             }
             $shouldSelectFromSearchEngine = true;
         }
         $entryIdsFromDB = array();
         if ($shouldSelectFromSearchEngine) {
             $c = KalturaCriteria::create(entryPeer::OM_CLASS);
             $entryFilter->attachToCriteria($c);
             $c->applyFilters();
             $entryIdsFromDB = $c->getFetchedIds();
             if ($c->getRecordsCount() > count($entryIdsFromDB)) {
                 throw new kCoreException('Search is to general', kCoreException::SEARCH_TOO_GENERAL);
             }
             if (!count($entryIdsFromDB)) {
                 $entryIdsFromDB[] = entry::ENTRY_ID_THAT_DOES_NOT_EXIST;
             }
         }
         $obj_ids_clause = null;
         if ($object_ids) {
             //the object ids are not supposed to include single quotes - if they do have them - remove them
             $object_ids = str_replace("'", '', $object_ids);
             // quote all the objects with SINGLE-QUOTES
             $object_ids_str = "'" . str_replace(",", "','", $object_ids) . "'";
             if ($report_type == self::REPORT_TYPE_CONTENT_CONTRIBUTIONS) {
                 $obj_ids_clause = "en.entry_media_source_id in ( {$object_ids_str})";
             } else {
                 if ($report_type == self::REPORT_TYPE_TOP_SYNDICATION) {
                     $obj_ids_clause = "ev.domain_id in ( {$object_ids_str})";
                 } else {
                     if ($report_type == self::REPORT_TYPE_MAP_OVERLAY) {
                         $obj_ids_clause = "ev.country_id in ( {$object_ids_str})";
                     } else {
                         if ($report_type == self::REPORT_TYPE_ADMIN_CONSOLE) {
                             $obj_ids_clause = "dim_partner.partner_id in ( {$object_ids_str})";
                         } else {
                             if ($report_type == self::REPORT_TYPE_PARTNER_USAGE || $report_type == self::REPORT_TYPE_VAR_USAGE || $report_type == self::REPORT_TYPE_PEAK_STORAGE) {
                                 $obj_ids_clause = "partner_id in ({$object_ids_str})";
                             } else {
                                 if ($report_type == self::REPORT_TYPE_PLATFORMS) {
                                     $obj_ids_clause = "device in ({$object_ids_str})";
                                 } else {
                                     $objectIds = explode(',', $object_ids);
                                     $entryIds = "'" . implode("','", array_merge($objectIds, $entryIdsFromDB)) . "'";
                                     $obj_ids_clause = "ev.entry_id in ( {$entryIds} )";
                                 }
                             }
                         }
                     }
                 }
             }
         } elseif (count($entryIdsFromDB)) {
             $entryIds = "'" . implode("','", $entryIdsFromDB) . "'";
             $obj_ids_clause = "ev.entry_id in ( {$entryIds} )";
         }
         if ($input_filter instanceof endUserReportsInputFilter && $input_filter->userIds != null && ($report_type == self::REPORT_TYPE_USER_USAGE || $report_type == self::REPORT_TYPE_SPECIFIC_USER_USAGE)) {
             $userFilter = new kuserFilter();
             $userFilter->set("_in_puser_id", $input_filter->userIds);
             $c = KalturaCriteria::create(kuserPeer::OM_CLASS);
             $userFilter->attachToCriteria($c);
             $c->applyFilters();
             $userIdsFromDB = $c->getFetchedIds();
             if (count($userIdsFromDB)) {
                 $kuserIds = implode(",", $userIdsFromDB);
             } else {
                 $kuserIds = kuser::KUSER_ID_THAT_DOES_NOT_EXIST;
             }
             $obj_ids_clause = "u.kuser_id in ( {$kuserIds} )";
         }
         if (is_numeric($report_type)) {
             $order_by = self::getOrderBy(self::$type_map[$report_type], $order_by);
         }
         $query = self::getReplacedSql($sql_raw_content, $partner_id, $input_filter, $page_size, $page_index, $order_by, $obj_ids_clause, $category_ids_clause, $offset);
         if (is_numeric($report_type)) {
             $query_header = "/* -- " . self::$type_map[$report_type] . " " . self::$flavor_map[$report_flavor] . " -- */\n";
         } else {
             $query_header = "/* -- " . $report_type . " -- */\n";
         }
         KalturaLog::log("\n{$query_header}{$query}");
         $res = self::executeQuery($query);
         $end = microtime(true);
         KalturaLog::log("Query took [" . ($end - $start) . "]");
         return $res;
     } catch (Exception $ex) {
         KalturaLog::log($ex->getMessage());
         // TODO - write proeper error
         if ($ex->getCode() == kCoreException::SEARCH_TOO_GENERAL) {
         }
         throw $ex;
         throw new Exception("Error while processing report for [{$partner_id} , {$report_type} , {$report_flavor}]");
     }
 }
コード例 #9
0
 public function postInsert(PropelPDO $con = null)
 {
     parent::postInsert($con);
     if (!$this->getFeedId() || !$this->getId()) {
         return;
     }
     $podcastFeed = syndicationFeedPeer::retrieveByPK($this->getFeedId());
     if (!$podcastFeed || !$podcastFeed instanceof genericSyndicationFeed) {
         return;
     }
     // "Creates advanced filter on distribution profile
     $distributionAdvancedSearch = new ContentDistributionSearchFilter();
     $distributionAdvancedSearch->setDistributionProfileId($this->getId());
     $distributionAdvancedSearch->setDistributionSunStatus(EntryDistributionSunStatus::AFTER_SUNRISE);
     $distributionAdvancedSearch->setEntryDistributionStatus(EntryDistributionStatus::READY);
     $distributionAdvancedSearch->setEntryDistributionFlag(EntryDistributionDirtyStatus::NONE);
     //Creates entry filter with advanced filter
     $entryFilter = new entryFilter();
     $entryFilter->setPartnerSearchScope($this->getPartnerId());
     $entryFilter->setAdvancedSearch($distributionAdvancedSearch);
     // Creates playlist with entry filter
     $playlistXml = new SimpleXMLElement("<playlist/>");
     $filtersXml = $playlistXml->addChild("filters");
     $filterXml = $filtersXml->addChild("filter");
     $entryFilter->toXml($filterXml);
     $playlistContent = $playlistXml->asXML();
     // creates playlist based on the filter XML
     $playlist = new entry();
     $playlist->setKuserId(kCurrentContext::$uid);
     $playlist->setCreatorKuserId(kCurrentContext::$uid);
     $playlist->setDisplayInSearch(mySearchUtils::DISPLAY_IN_SEARCH_SYSTEM);
     $playlist->setPartnerId($this->getPartnerId());
     $playlist->setStatus(entryStatus::READY);
     $playlist->setKshowId(null);
     $playlist->setType(entryType::PLAYLIST);
     $playlist->setMediaType(entry::ENTRY_MEDIA_TYPE_XML);
     $playlist->setDataContent($playlistContent);
     $playlist->save();
     KalturaLog::log("Playlist [" . $playlist->getId() . "] created");
     // creates feed based on the playlist
     $podcastFeed->setPlaylistId($playlist->getId());
     $podcastFeed->save();
 }
コード例 #10
0
 public function addFilter(entryFilter $entryFilter)
 {
     if ($this->executed) {
         return;
     }
     $entryFilter->setPartnerSearchScope(baseObjectFilter::MATCH_KALTURA_NETWORK_AND_PRIVATE);
     // partner scope already attached
     $entryFilter->attachToCriteria($this->baseCriteria);
 }
コード例 #11
0
ファイル: category.php プロジェクト: dozernz/server
 /**
  * reset category's directEntriesCount by calculate it.
  */
 public function reSetDirectEntriesCount()
 {
     $baseCriteria = KalturaCriteria::create(entryPeer::OM_CLASS);
     $filter = new entryFilter();
     $filter->setPartnerSearchScope(baseObjectFilter::MATCH_KALTURA_NETWORK_AND_PRIVATE);
     $filter->setCategoriesIdsMatchAnd($this->getId());
     $filter->setLimit(1);
     $filter->attachToCriteria($baseCriteria);
     $baseCriteria->applyFilters();
     $count = $baseCriteria->getRecordsCount();
     $this->setDirectEntriesCount($count);
 }
コード例 #12
0
 /**
  * @param KalturaBaseEntryFilter $filter
  * @param KalturaFilterPager $pager
  * @param string $partnerIdForScope
  * @return KalturaCriteria
  */
 protected function prepareEntriesCriteriaFilter(KalturaBaseEntryFilter $filter = null, KalturaFilterPager $pager = null, $partnerIdForScope)
 {
     if (!$filter) {
         $filter = new KalturaBaseEntryFilter();
     }
     // because by default we will display only READY entries, and when deleted status is requested, we don't want this to disturb
     entryPeer::allowDeletedInCriteriaFilter();
     // when session is not admin, allow access to user entries only
     if (!$this->getKs() || !$this->getKs()->isAdmin()) {
         $filter->userIdEqual = $this->getKuser()->getPuserId();
     }
     $this->setDefaultStatus($filter);
     $this->setDefaultModerationStatus($filter);
     $this->fixFilterUserId($filter);
     $this->fixFilterDuration($filter);
     $entryFilter = new entryFilter();
     if (is_null($partnerIdForScope)) {
         $entryFilter->setPartnerSearchScope($this->getPartnerId());
     } else {
         $entryFilter->setPartnerSearchScope($partnerIdForScope);
     }
     $filter->toObject($entryFilter);
     $c = KalturaCriteria::create(entryPeer::OM_CLASS);
     if ($pager) {
         $pager->attachToCriteria($c);
     }
     $entryFilter->attachToCriteria($c);
     return $c;
 }
 /**
  * @action getFeed
  * @disableTags TAG_WIDGET_SESSION,TAG_ENTITLEMENT_ENTRY,TAG_ENTITLEMENT_CATEGORY
  * @param int $distributionProfileId
  * @param string $hash
  * @param int $page
  * @param int $period
  * @param string $state
  * @param bool $ignoreScheduling
  * @return file
  */
 public function getFeedAction($distributionProfileId, $hash, $page = 1, $period = -1, $state = '', $ignoreScheduling = false)
 {
     if (!$this->getPartnerId() || !$this->getPartner()) {
         throw new KalturaAPIException(KalturaErrors::INVALID_PARTNER_ID, $this->getPartnerId());
     }
     $profile = DistributionProfilePeer::retrieveByPK($distributionProfileId);
     /* @var $profile DoubleClickDistributionProfile */
     if (!$profile || !$profile instanceof DoubleClickDistributionProfile) {
         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(DoubleClickDistributionErrors::INVALID_FEED_URL);
     }
     if (!$page || $page < 1) {
         $page = 1;
     }
     $stateLastEntryCreatedAt = null;
     $stateLastEntryIds = array();
     if ($state) {
         $stateDecoded = base64_decode($state);
         if (strpos($stateDecoded, '|') !== false) {
             $stateExploded = explode('|', $stateDecoded);
             $stateLastEntryCreatedAt = $stateExploded[0];
             $stateLastEntryIdsStr = $stateExploded[1];
             $stateLastEntryIds = explode(',', $stateLastEntryIdsStr);
         }
     }
     // "Creates advanced filter on distribution profile
     $distributionAdvancedSearch = new ContentDistributionSearchFilter();
     $distributionAdvancedSearch->setDistributionProfileId($profile->getId());
     if ($ignoreScheduling !== true && $profile->getIgnoreSchedulingInFeed() !== true) {
         $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);
     $entryFilter->set('_order_by', '-created_at');
     if ($period && $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);
     $totalCount = $baseCriteria->getRecordsCount();
     // Add the state data to proceed to next page
     if ($stateLastEntryCreatedAt) {
         $entryFilter->set('_lte_created_at', $stateLastEntryCreatedAt);
     }
     if ($stateLastEntryIds) {
         $entryFilter->set('_notin_id', $stateLastEntryIds);
     }
     $baseCriteria = KalturaCriteria::create(entryPeer::OM_CLASS);
     $baseCriteria->add(entryPeer::DISPLAY_IN_SEARCH, mySearchUtils::DISPLAY_IN_SEARCH_SYSTEM, Criteria::NOT_EQUAL);
     $baseCriteria->setLimit($profile->getItemsPerPage() + 1);
     // get +1 to check if we have next page
     $entryFilter->attachToCriteria($baseCriteria);
     $entries = entryPeer::doSelect($baseCriteria);
     $hasNextPage = false;
     if (count($entries) === $profile->getItemsPerPage() + 1) {
         // we tried to get (itemsPerPage + 1) entries, meaning we have another page
         $hasNextPage = true;
         unset($entries[$profile->getItemsPerPage()]);
     }
     // Find the state
     $entryIds = array();
     $nextPageStateLastEntryCreatedAt = $stateLastEntryCreatedAt;
     $nextPageStateLastEntryIds = $stateLastEntryIds;
     foreach ($entries as $entry) {
         $entryIds[] = $entry->getId();
         if ($nextPageStateLastEntryCreatedAt > $entry->getCreatedAt(null)) {
             $nextPageStateLastEntryIds = array();
         }
         $nextPageStateLastEntryIds[] = $entry->getId();
         $nextPageStateLastEntryCreatedAt = $entry->getCreatedAt(null);
     }
     // Construct the feed
     $feed = new DoubleClickFeed('doubleclick_template.xml', $profile);
     $feed->setTotalResult($totalCount);
     $feed->setStartIndex(($page - 1) * $profile->getItemsPerPage() + 1);
     $feed->setSelfLink($this->getUrl($distributionProfileId, $hash, $page, $period, $stateLastEntryCreatedAt, $stateLastEntryIds));
     if ($hasNextPage) {
         $feed->setNextLink($this->getUrl($distributionProfileId, $hash, $page + 1, $period, $nextPageStateLastEntryCreatedAt, $nextPageStateLastEntryIds));
     }
     $profileUpdatedAt = $profile->getUpdatedAt(null);
     $cacheDir = kConf::get("global_cache_dir") . "feeds/dist_{$distributionProfileId}/";
     foreach ($entries as $entry) {
         // check cache
         $cacheFileName = $cacheDir . myContentStorage::dirForId($entry->getIntId(), $entry->getId() . ".xml");
         $updatedAt = max($profileUpdatedAt, $entry->getUpdatedAt(null));
         if (file_exists($cacheFileName) && $updatedAt < filemtime($cacheFileName)) {
             $xml = file_get_contents($cacheFileName);
         } else {
             /* @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()));
             $cuePoints = $this->getCuePoints($entry->getPartnerId(), $entry->getId());
             $xml = $feed->getItemXml($fields, $flavorAssets, $thumbAssets, $cuePoints);
             mkdir(dirname($cacheFileName), 0777, true);
             file_put_contents($cacheFileName, $xml);
         }
         $feed->addItemXml($xml);
     }
     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 UverseClickToOrderDistributionProfile) {
         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(UverseClickToOrderDistributionErrors::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);
     $baseCriteria->addDescendingOrderByColumn(entryPeer::UPDATED_AT);
     $entries = entryPeer::doSelect($baseCriteria);
     $feed = new UverseClickToOrderFeed('feed_template.xml');
     $feed->setDistributionProfile($profile);
     //setting background images
     $wideBackgroundImageEntryId = $profile->getBackgroundImageWide();
     $standardBackgroundImageEntryId = $profile->getBackgroundImageStandard();
     $widedBackgroundImageUrl = $this->getImageUrl($wideBackgroundImageEntryId, '854', '480');
     $standardBackgroundImageUrl = $this->getImageUrl($standardBackgroundImageEntryId, '640', '480');
     $feed->setBackgroudImage($widedBackgroundImageUrl, $standardBackgroundImageUrl);
     //getting array of all related entries (categories that will appear in the xml)
     $relatedEntriesArray = array();
     //going through all entries and preparing an array with all related entries (categories) directing to the entires
     foreach ($entries as $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);
         $relatedEntryId = $fields[UverseClickToOrderDistributionField::CATEGORY_ENTRY_ID];
         if (!isset($relatedEntriesArray[$relatedEntryId])) {
             $relatedEntry = entryPeer::retrieveByPK($relatedEntryId);
             $relatedEntrySortValue = $this->getRelatedEntrySortValue($profile, $relatedEntryId);
             $relatedEntriesArray[$relatedEntryId] = array();
             $relatedEntriesArray[$relatedEntryId]['sortValue'] = $relatedEntrySortValue;
             $relatedEntriesArray[$relatedEntryId]['updatedAt'] = $relatedEntry->getUpdatedAt();
             $relatedEntriesArray[$relatedEntryId]['relatedEntryId'] = $relatedEntryId;
         }
         $flavorAssets = array_map('trim', explode(',', $entryDistribution->getFlavorAssetIds()));
         $flavorAssetId = isset($flavorAssets[0]) ? $flavorAssets[0] : null;
         $flavorAsset = assetPeer::retrieveById($flavorAssetId);
         $flavorUrl = $flavorAsset ? $flavorAsset->getDownloadUrl() : $entry->getDownloadUrl();
         $thumbAssets = array_map('trim', explode(',', $entryDistribution->getThumbAssetIds()));
         $thumbAssetId = isset($thumbAssets[0]) ? $thumbAssets[0] : null;
         $thumbAsset = assetPeer::retrieveById($thumbAssetId);
         $thumbUrl = $thumbAsset ? $thumbAsset->getDownloadUrl() : $entry->getThumbnailUrl();
         $relatedEntriesArray[$relatedEntryId][] = array('id' => $entry->getId(), 'thumbnailUrl' => $thumbUrl, 'downloadUrl' => $flavorUrl, 'updatedAt' => $entry->getUpdatedAt(), 'sortValue' => $profile->getFieldValue($entryDistribution, UverseClickToOrderDistributionField::SORT_ITEMS_BY_FIELD));
     }
     //sorting the related entries.
     usort($relatedEntriesArray, array($this, 'sortItems'));
     //removing the values that where used for sorting.
     foreach ($relatedEntriesArray as $key => $relatedEntry) {
         $relatedEntryId = $relatedEntry['relatedEntryId'];
         unset($relatedEntry['relatedEntryId']);
         unset($relatedEntry['sortValue']);
         unset($relatedEntry['updatedAt']);
         unset($relatedEntriesArray[$key]);
         $relatedEntriesArray[$relatedEntryId] = $relatedEntry;
     }
     //retreive each category and add it to the xml
     foreach ($relatedEntriesArray as $relatedEntryId => $entriesUnderCategory) {
         //getting the related entry id object
         $relatedEntryObject = entryPeer::retrieveByPK($relatedEntryId);
         if (!$relatedEntryObject) {
             KalturaLog::err('Related Entry [' . $relatedEntryId . '] was not found');
             continue;
         }
         $categoryName = $relatedEntryObject->getName();
         $categoryFile = $relatedEntryObject->getThumbnailUrl() . '/width/' . $fields[UverseClickToOrderDistributionField::CATEGORY_IMAGE_WIDTH] . '/height/' . $fields[UverseClickToOrderDistributionField::CATEGORY_IMAGE_HEIGHT];
         $categoryNode = $feed->addCategory($categoryName, $categoryFile);
         usort($entriesUnderCategory, array($this, 'sortItems'));
         //getting all entries under a category
         foreach ($entriesUnderCategory as $entryInfo) {
             $entryId = $entryInfo['id'];
             $thumbnailFile = $entryInfo['thumbnailUrl'];
             $flavorFile = $entryInfo['downloadUrl'];
             //getting entry's fileds array
             $entryDistribution = EntryDistributionPeer::retrieveByEntryAndProfileId($entryId, $profile->getId());
             $fields = $profile->getAllFieldValues($entryDistribution);
             $feed->addItem($fields, $categoryNode, $thumbnailFile, $flavorFile);
         }
     }
     header('Content-Type: text/xml');
     echo $feed->getXml();
     die;
 }
 /**
  * @param KalturaBaseEntryFilter $filter
  * @param KalturaFilterPager $pager
  * @return KalturaCriteria
  */
 protected function prepareEntriesCriteriaFilter(KalturaBaseEntryFilter $filter = null, KalturaFilterPager $pager = null)
 {
     if (!$filter) {
         $filter = new KalturaBaseEntryFilter();
     }
     // because by default we will display only READY entries, and when deleted status is requested, we don't want this to disturb
     entryPeer::allowDeletedInCriteriaFilter();
     $this->setDefaultStatus($filter);
     $this->setDefaultModerationStatus($filter);
     $this->fixFilterUserId($filter);
     $this->fixFilterDuration($filter);
     $entryFilter = new entryFilter();
     $entryFilter->setPartnerSearchScope(baseObjectFilter::MATCH_KALTURA_NETWORK_AND_PRIVATE);
     $filter->toObject($entryFilter);
     $c = KalturaCriteria::create(entryPeer::OM_CLASS);
     if ($pager) {
         $pager->attachToCriteria($c);
     }
     $entryFilter->attachToCriteria($c);
     $c->add(entryPeer::DISPLAY_IN_SEARCH, mySearchUtils::DISPLAY_IN_SEARCH_SYSTEM, Criteria::NOT_EQUAL);
     // when session is not admin and without list:* privilege, allow access to user entries only
     //moved to Additional criteria on entryPeer
     //moved it init service.
     /*if (!$this->getKs() || (!$this->getKs()->isAdmin() && !$this->getKs()->verifyPrivileges(ks::PRIVILEGE_LIST, ks::PRIVILEGE_WILDCARD)))
     		{
     			KalturaCriterion::enableTag(KalturaCriterion::TAG_WIDGET_SESSION);*/
     /*$filter->userIdEqual = $this->getKuser()->getPuserId();
     		
     			$crit = $c->getNewCriterion(entryPeer::KUSER_ID , $this->getKuser()->getId(), Criteria::EQUAL);
     			$c->addAnd($crit);*/
     /*}*/
     return $c;
 }
コード例 #16
0
 /**
 	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);
 }
コード例 #17
0
ファイル: entryPeer.php プロジェクト: DBezemer/server
 public static function retrieveChildEntriesByEntryIdAndPartnerId($parentId, $partnerId)
 {
     $c = KalturaCriteria::create(entryPeer::OM_CLASS);
     $filter = new entryFilter();
     $filter->setParentEntryIdEqual($parentId);
     $filter->setPartnerSearchScope($partnerId);
     $filter->setDisplayInSearchEquel(mySearchUtils::DISPLAY_IN_SEARCH_SYSTEM);
     $filter->attachToCriteria($c);
     return self::doSelect($c);
 }
コード例 #18
0
 /**
  * @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;
 }
 /**
  * List base entries by filter according to reference id
  * 
  * @action listByReferenceId
  * @param string $refId Entry Reference ID
  * @param KalturaFilterPager $pager Pager
  * @throws KalturaErrors::MISSING_MANDATORY_PARAMETER
  */
 function listByReferenceId($refId, KalturaFilterPager $pager = null)
 {
     if (!$refId) {
         //if refId wasn't provided return an error of missing parameter
         throw new KalturaAPIException(KalturaErrors::MISSING_MANDATORY_PARAMETER, $refId);
     }
     if (!$pager) {
         $pager = new KalturaFilterPager();
     }
     $entryFilter = new entryFilter();
     $entryFilter->setPartnerSearchScope(baseObjectFilter::MATCH_KALTURA_NETWORK_AND_PRIVATE);
     //setting reference ID
     $entryFilter->set('_eq_reference_id', $refId);
     $c = KalturaCriteria::create(entryPeer::OM_CLASS);
     $pager->attachToCriteria($c);
     $entryFilter->attachToCriteria($c);
     $c->add(entryPeer::DISPLAY_IN_SEARCH, mySearchUtils::DISPLAY_IN_SEARCH_SYSTEM, Criteria::NOT_EQUAL);
     KalturaCriterion::disableTag(KalturaCriterion::TAG_WIDGET_SESSION);
     $list = entryPeer::doSelect($c);
     KalturaCriterion::restoreTag(KalturaCriterion::TAG_WIDGET_SESSION);
     $totalCount = $c->getRecordsCount();
     $newList = KalturaBaseEntryArray::fromEntryArray($list, false);
     $response = new KalturaBaseEntryListResponse();
     $response->objects = $newList;
     $response->totalCount = $totalCount;
     return $response;
 }
コード例 #20
0
 public static function toQueryString(entry $playlist, $should_append_filter_to_url = false)
 {
     $query = "playlist_id={$playlist->getId()}";
     if ($playlist->getMediaType() != entry::ENTRY_MEDIA_TYPE_XML) {
         return $query;
     }
     if (!$should_append_filter_to_url) {
         return $query;
     }
     $xml = $playlist->getDataContent();
     list($total_results, $list_of_filters) = self::getPlaylistFilterListStruct($xml);
     $entry_filters = array();
     $partner_id = $playlist->getPartnerId();
     // add ks=_KS_ for the playlist to replace it before hitting the executePlaylist
     $query .= "&fp=f";
     // make sure the filter prefix is short
     if (!$list_of_filters) {
         return $query;
     }
     $i = 1;
     // the extra_filter is 1-based
     foreach ($list_of_filters as $entry_filter_xml) {
         $prefix = "f{$i}_";
         // 	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;
         // 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);
         }
         $entry_filter->setPartnerSearchScope(baseObjectFilter::MATCH_KALTURA_NETWORK_AND_PRIVATE);
         self::updateEntryFilter($entry_filter, $partner_id);
         //$entry_filters[] = $entry_filter;
         $fields = $entry_filter->fields;
         foreach ($fields as $field => $value) {
             if ($value) {
                 $query .= "&" . $prefix . $field . "=" . $value;
             }
         }
         $i++;
     }
     return $query;
 }
コード例 #21
0
ファイル: LiveStreamService.php プロジェクト: dozernz/server
 /**
  * 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;
 }
コード例 #22
0
 /**
  * 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);
 }
コード例 #23
0
 private function hasWidevineFlavorAssetsWithSameWvAssetIdInOtherEntries($wvAssetId, $entryId)
 {
     $entryFilter = new entryFilter();
     $entryFilter->fields['_like_plugins_data'] = WidevinePlugin::getWidevineAssetIdSearchData($wvAssetId);
     $entryFilter->setPartnerSearchScope(baseObjectFilter::MATCH_KALTURA_NETWORK_AND_PRIVATE);
     $c = KalturaCriteria::create(entryPeer::OM_CLASS);
     $entryFilter->attachToCriteria($c);
     $c->add(entryPeer::ID, $entryId, Criteria::NOT_EQUAL);
     $c->applyFilters();
     $entriesCount = $c->getRecordsCount();
     if ($entriesCount) {
         KalturaLog::debug('Found active flavors for WV asset id [' . $wvAssetId . ']');
         return true;
     } else {
         return false;
     }
 }