/**
  * 
  * @param int $objectType
  * @param string $objectId
  * @return ISyncableFile
  */
 public static function retrieveObject($objectType, $objectId)
 {
     $object = null;
     switch ($objectType) {
         case FileSyncObjectType::ENTRY:
             entryPeer::setUseCriteriaFilter(false);
             $object = entryPeer::retrieveByPK($objectId);
             entryPeer::setUseCriteriaFilter(true);
             break;
         case FileSyncObjectType::UICONF:
             uiConfPeer::setUseCriteriaFilter(false);
             $object = uiConfPeer::retrieveByPK($objectId);
             uiConfPeer::setUseCriteriaFilter(true);
             break;
         case FileSyncObjectType::BATCHJOB:
             BatchJobPeer::setUseCriteriaFilter(false);
             $object = BatchJobPeer::retrieveByPK($objectId);
             BatchJobPeer::setUseCriteriaFilter(true);
             break;
         case FileSyncObjectType::FLAVOR_ASSET:
             assetPeer::setUseCriteriaFilter(false);
             $object = assetPeer::retrieveById($objectId);
             assetPeer::setUseCriteriaFilter(true);
             break;
         case FileSyncObjectType::SYNDICATION_FEED:
             syndicationFeedPeer::setUseCriteriaFilter(false);
             $object = syndicationFeedPeer::retrieveByPK($objectId);
             syndicationFeedPeer::setUseCriteriaFilter(true);
             break;
         case FileSyncObjectType::CONVERSION_PROFILE:
             conversionProfile2Peer::setUseCriteriaFilter(false);
             $object = conversionProfile2Peer::retrieveByPK($objectId);
             conversionProfile2Peer::setUseCriteriaFilter(true);
             break;
         case FileSyncObjectType::FILE_ASSET:
             conversionProfile2Peer::setUseCriteriaFilter(false);
             $object = FileAssetPeer::retrieveByPK($objectId);
             conversionProfile2Peer::setUseCriteriaFilter(true);
             break;
     }
     if ($object == null) {
         $object = KalturaPluginManager::loadObject('ISyncableFile', $objectType, array('objectId' => $objectId));
     }
     if ($object == null) {
         $error = __METHOD__ . " Cannot find object type [" . $objectType . "] with object_id [" . $objectId . "]";
         KalturaLog::err($error);
         throw new kFileSyncException($error);
     }
     return $object;
 }
 /**
  * @return string $xsl
  */
 public function getXsl()
 {
     if ($this->xsl) {
         return $this->xsl;
     }
     if (!$this->getFeedId()) {
         return null;
     }
     $feed = syndicationFeedPeer::retrieveByPK($this->getFeedId());
     if (!$feed || !$feed instanceof genericSyndicationFeed) {
         return null;
     }
     $syncKey = $feed->getSyncKey(genericSyndicationFeed::FILE_SYNC_SYNDICATION_FEED_XSLT);
     $this->xsl = kFileSyncUtils::file_get_contents($syncKey, true, false);
     return $this->xsl;
 }
 /**
  * Delete Syndication Feed by ID
  * 
  * @action delete
  * @param string $id
  */
 public function deleteAction($id)
 {
     $syndicationFeedDB = syndicationFeedPeer::retrieveByPK($id);
     if (!$syndicationFeedDB) {
         throw new KalturaAPIException(KalturaErrors::ENTRY_ID_NOT_FOUND, $id);
     }
     $syndicationFeedDB->setStatus(KalturaSyndicationFeedStatus::DELETED);
     $syndicationFeedDB->save();
 }
 /**
  * @param SyndicationDistributionProfile $syndicationDistributionProfile
  */
 public static function onSyndicationDistributionProfileDeleted(SyndicationDistributionProfile $syndicationDistributionProfile)
 {
     // deletes the feed
     $feed = syndicationFeedPeer::retrieveByPK($syndicationDistributionProfile->getFeedId());
     if (!$feed) {
         return;
     }
     if ($feed->getDisplayInSearch() == mySearchUtils::DISPLAY_IN_SEARCH_SYSTEM) {
         $feed->setStatus(syndicationFeed::SYNDICATION_DELETED);
         $feed->save();
     }
     // deletes the playlist
     $playlist = entryPeer::retrieveByPK($feed->getPlaylistId());
     if ($playlist && $playlist->getDisplayInSearch() == mySearchUtils::DISPLAY_IN_SEARCH_SYSTEM) {
         $playlist->setStatus(entryStatus::DELETED);
         $playlist->save();
     }
 }
 /**
  *  request conversion for all entries that doesnt have the required flavor param
  *  returns a comma-separated ids of conversion jobs
  *
  *  @action requestConversion
  *  @param string $feedId
  *  @return string
  * @throws KalturaErrors::INVALID_FEED_ID
  */
 public function requestConversionAction($feedId)
 {
     $syndicationFeedDB = syndicationFeedPeer::retrieveByPK($feedId);
     if (!$syndicationFeedDB) {
         throw new KalturaAPIException(KalturaErrors::INVALID_FEED_ID, $feedId);
     }
     // find entry ids that already converted to the flavor
     $feedRendererWithTheFlavor = new KalturaSyndicationFeedRenderer($feedId);
     $feedRendererWithTheFlavor->addFlavorParamsAttachedFilter();
     $entriesWithTheFlavor = $feedRendererWithTheFlavor->getEntriesIds();
     // create filter of the entries that not converted
     $entryFilter = new entryFilter();
     $entryFilter->setIdNotIn($entriesWithTheFlavor);
     // create feed with the new filter
     $feedRendererToConvert = new KalturaSyndicationFeedRenderer($feedId);
     $feedRendererToConvert->addFilter($entryFilter);
     $createdJobsIds = array();
     $flavorParamsId = $feedRendererToConvert->syndicationFeed->flavorParamId;
     while ($entry = $feedRendererToConvert->getNextEntry()) {
         $originalFlavorAsset = assetPeer::retrieveOriginalByEntryId($entry->getId());
         if (!is_null($originalFlavorAsset)) {
             $err = "";
             $job = kBusinessPreConvertDL::decideAddEntryFlavor(null, $entry->getId(), $flavorParamsId, $err);
             if ($job && is_object($job)) {
                 $createdJobsIds[] = $job->getId();
             }
         }
     }
     return implode(',', $createdJobsIds);
 }
Beispiel #6
0
<?php

if ($argc != 4) {
    echo "Arguments missing.\n\n";
    echo "Usage: php " . __FILE__ . " {feed id} {encoding} {realrun / dryrun}\n";
    exit;
}
$feedId = $argv[1];
$encoding = $argv[2];
$dryRun = $argv[3] != 'realrun';
require_once __DIR__ . '/../bootstrap.php';
KalturaStatement::setDryRun($dryRun);
$feed = syndicationFeedPeer::retrieveByPK($feedId);
$mrssParameters = $feed->getMrssParameters();
if (!$mrssParameters) {
    $mrssParameters = new kMrssParameters();
    $mrssParameters->setItemXpathsToExtend(array());
}
$mrssParameters->setEncoding($encoding);
$feed->setMrssParameters($mrssParameters);
$feed->save();
KalturaLog::debug('Done');
 public function __construct($feedId, $feedProcessingKey = null, $ks = null)
 {
     $this->feedProcessingKey = $feedProcessingKey;
     myDbHelper::$use_alternative_con = myDbHelper::DB_HELPER_CONN_PROPEL3;
     $microTimeStart = microtime(true);
     KalturaLog::info("syndicationFeedRenderer- initialize ");
     $this->syndicationFeedDb = $syndicationFeedDB = syndicationFeedPeer::retrieveByPK($feedId);
     if (!$syndicationFeedDB) {
         throw new Exception("Feed Id not found");
     }
     kCurrentContext::initKsPartnerUser($ks, $syndicationFeedDB->getPartnerId(), '');
     kPermissionManager::init();
     kEntitlementUtils::initEntitlementEnforcement($syndicationFeedDB->getPartnerId(), $syndicationFeedDB->getEnforceEntitlement());
     if (!is_null($syndicationFeedDB->getPrivacyContext()) && $syndicationFeedDB->getPrivacyContext() != '') {
         kEntitlementUtils::setPrivacyContextSearch($syndicationFeedDB->getPrivacyContext());
     }
     $tmpSyndicationFeed = KalturaSyndicationFeedFactory::getInstanceByType($syndicationFeedDB->getType());
     $tmpSyndicationFeed->fromObject($syndicationFeedDB);
     $this->syndicationFeed = $tmpSyndicationFeed;
     // add partner to default criteria
     myPartnerUtils::addPartnerToCriteria('category', $this->syndicationFeed->partnerId, true);
     myPartnerUtils::addPartnerToCriteria('asset', $this->syndicationFeed->partnerId, true);
     myPartnerUtils::resetPartnerFilter('entry');
     $this->baseCriteria = clone entryPeer::getDefaultCriteriaFilter();
     $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);
     $this->baseCriteria->addAnd(entryPeer::PARTNER_ID, $this->syndicationFeed->partnerId);
     $this->baseCriteria->addAnd(entryPeer::STATUS, entryStatus::READY);
     $this->baseCriteria->addAnd(entryPeer::TYPE, array(entryType::MEDIA_CLIP, entryType::MIX), Criteria::IN);
     $this->baseCriteria->addAnd(entryPeer::MODERATION_STATUS, array(entry::ENTRY_MODERATION_STATUS_REJECTED, entry::ENTRY_MODERATION_STATUS_PENDING_MODERATION), Criteria::NOT_IN);
     if ($this->syndicationFeed->playlistId) {
         $this->entryFilters = myPlaylistUtils::getPlaylistFiltersById($this->syndicationFeed->playlistId);
         foreach ($this->entryFilters as $entryFilter) {
             $entryFilter->setPartnerSearchScope(baseObjectFilter::MATCH_KALTURA_NETWORK_AND_PRIVATE);
             // partner scope already attached
         }
         $playlist = entryPeer::retrieveByPK($this->syndicationFeed->playlistId);
         if ($playlist) {
             if ($playlist->getMediaType() != entry::ENTRY_MEDIA_TYPE_XML) {
                 $this->staticPlaylist = true;
                 $this->staticPlaylistEntriesIdsOrder = explode(',', $playlist->getDataContent());
             }
         }
     } else {
         $this->entryFilters = array();
     }
     $microTimeEnd = microtime(true);
     KalturaLog::info("syndicationFeedRenderer- initialization done [" . ($microTimeEnd - $microTimeStart) . "]");
 }
 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();
     $this->syndicationFeedDB = $syndicationFeedDB = syndicationFeedPeer::retrieveByPK($feedId);
     if (!$syndicationFeedDB) {
         throw new Exception("Feed Id not found");
     }
     kEntitlementUtils::initEntitlementEnforcement($syndicationFeedDB->getPartnerId(), $syndicationFeedDB->getEnforceEntitlement());
     if (!is_null($syndicationFeedDB->getPrivacyContext()) && $syndicationFeedDB->getPrivacyContext() != '') {
         kEntitlementUtils::setPrivacyContextSearch($syndicationFeedDB->getPrivacyContext());
     }
     $tmpSyndicationFeed = KalturaSyndicationFeedFactory::getInstanceByType($syndicationFeedDB->getType());
     $tmpSyndicationFeed->fromObject($syndicationFeedDB);
     $this->syndicationFeed = $tmpSyndicationFeed;
     // add partner to default criteria
     categoryPeer::addPartnerToCriteria($this->syndicationFeed->partnerId, true);
     assetPeer::addPartnerToCriteria($this->syndicationFeed->partnerId, true);
     entryPeer::setDefaultCriteriaFilter();
     $this->baseCriteria = entryPeer::getDefaultCriteriaFilter();
     $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->setModerationStatusNotIn(array(entry::ENTRY_MODERATION_STATUS_REJECTED, entry::ENTRY_MODERATION_STATUS_PENDING_MODERATION));
     $entryFilter->attachToCriteria($this->baseCriteria);
     if ($this->syndicationFeed->playlistId) {
         $this->entryFilters = myPlaylistUtils::getPlaylistFiltersById($this->syndicationFeed->playlistId);
         foreach ($this->entryFilters as $entryFilter) {
             $entryFilter->setPartnerSearchScope(baseObjectFilter::MATCH_KALTURA_NETWORK_AND_PRIVATE);
             // partner scope already attached
         }
         $playlist = entryPeer::retrieveByPK($this->syndicationFeed->playlistId);
         if ($playlist) {
             if ($playlist->getMediaType() != entry::ENTRY_MEDIA_TYPE_XML) {
                 $this->staticPlaylist = true;
                 $this->staticPlaylistEntriesIdsOrder = explode(',', $playlist->getDataContent());
             }
         }
     } else {
         $this->entryFilters = array();
     }
     $microTimeEnd = microtime(true);
     KalturaLog::info("syndicationFeedRenderer- initialization done [" . ($microTimeEnd - $microTimeStart) . "]");
 }
 private function renderKalturaFeed()
 {
     $syndicationFeedDB = syndicationFeedPeer::retrieveByPK($this->syndicationFeed->id);
     if (!$syndicationFeedDB) {
         throw new Exception("Feed Id not found");
     }
     //header xml
     echo kSyndicationFeedManager::getMrssHeader($this->syndicationFeed->name, $this->syndicationFeed->feedLandingPage, $this->syndicationFeed->feedDescription, $syndicationFeedDB);
     //items
     while ($entry = $this->getNextEntry()) {
         // in case no video player is requested by user and the entry is mix, skip it
         if ($entry->getType() === entryType::MIX && !$this->syndicationFeed->allowEmbed) {
             continue;
         }
         echo kSyndicationFeedManager::getMrssEntry($entry, $syndicationFeedDB, $this->syndicationFeed->landingPage);
     }
     echo kSyndicationFeedManager::getMrssFooter($this->syndicationFeed->name, $this->syndicationFeed->feedLandingPage, $this->syndicationFeed->feedDescription, $syndicationFeedDB);
 }