public function getEntryMrssDoc(EntryDistribution $entryDistribution)
 {
     $entry = entryPeer::retrieveByPK($entryDistribution->getEntryId());
     // set the default criteria to use the current entry distribution partner id (it is restored later)
     // this is needed for related entries under kMetadataMrssManager which is using retrieveByPK without the correct partner id filter
     $oldEntryCriteria = entryPeer::getCriteriaFilter()->getFilter();
     entryPeer::setDefaultCriteriaFilter();
     entryPeer::addPartnerToCriteria($this->getPartnerId(), true);
     try {
         $mrss = null;
         $mrssParams = new kMrssParameters();
         if ($this->getItemXpathsToExtend()) {
             $mrssParams->setItemXpathsToExtend($this->getItemXpathsToExtend());
         }
         $mrss = kMrssManager::getEntryMrssXml($entry, $mrss, $mrssParams);
         $mrssStr = $mrss->asXML();
     } catch (Exception $e) {
         // restore the original criteria so it will not get stuck due to the exception
         entryPeer::getCriteriaFilter()->setFilter($oldEntryCriteria);
         throw $e;
     }
     // restore the original criteria
     entryPeer::getCriteriaFilter()->setFilter($oldEntryCriteria);
     $mrssObj = new DOMDocument();
     if (!$mrssObj->loadXML($mrssStr)) {
         throw new Exception('Entry mrss xml is not valid');
     }
     return $mrssObj;
 }
<?php

require_once dirname(__FILE__) . '/../bootstrap.php';
$f = fopen("php://stdin", "r");
$count = 0;
$sphinxMgr = new kSphinxSearchManager();
$dbConf = kConf::getDB();
DbManager::setConfig($dbConf);
DbManager::initialize();
$connection = Propel::getConnection();
while ($s = trim(fgets($f))) {
    $sep = strpos($s, "\t") ? "\t" : " ";
    list($entryId, $plays, $views) = explode($sep, $s);
    myPartnerUtils::resetAllFilters();
    entryPeer::setDefaultCriteriaFilter();
    $entry = entryPeer::retrieveByPK($entryId);
    if (is_null($entry)) {
        KalturaLog::err('Couldn\'t find entry [' . $entryId . ']');
        continue;
    }
    if ($entry->getViews() != $views || $entry->getPlays() != $plays) {
        $entry->setViews($views);
        $entry->setPlays($plays);
        KalturaLog::debug('Successfully saved entry [' . $entryId . ']');
        try {
            // update entry without setting the updated at
            $updateSql = "UPDATE entry set views='{$views}',plays='{$plays}' WHERE id='{$entryId}'";
            $stmt = $connection->prepare($updateSql);
            $stmt->execute();
            $affectedRows = $stmt->rowCount();
            KalturaLog::log("AffectedRows: " . $affectedRows);
 /**
  * Returns the default criteria filter
  *
  * @return     criteriaFilter The default criteria filter.
  */
 public static function &getCriteriaFilter()
 {
     if (self::$s_criteria_filter == null) {
         entryPeer::setDefaultCriteriaFilter();
     }
     return self::$s_criteria_filter;
 }
예제 #4
0
 /**
  * Returns the default criteria filter
  *
  * @return     criteriaFilter The default criteria filter.
  */
 public static function &getCriteriaFilter()
 {
     if (self::$s_criteria_filter == null) {
         entryPeer::setDefaultCriteriaFilter();
     }
     $partnerCriteria = myPartnerUtils::getPartnerCriteriaParams('entry');
     if ($partnerCriteria) {
         call_user_func_array(array('entryPeer', 'addPartnerToCriteria'), $partnerCriteria);
     }
     return self::$s_criteria_filter;
 }
 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) . "]");
 }
예제 #6
0
 /**
  * Serves the file content
  * 
  * @action serveByFlavorParamsId
  * @serverOnly
  * @param string $entryId Document entry id
  * @param string $flavorParamsId Flavor params id
  * @param bool $forceProxy force to get the content without redirect
  * 
  * @throws KalturaErrors::ENTRY_ID_NOT_FOUND
  * @throws KalturaErrors::FLAVOR_ASSET_IS_NOT_READY
  * @throws KalturaErrors::FLAVOR_ASSET_ID_NOT_FOUND
  */
 public function serveByFlavorParamsIdAction($entryId, $flavorParamsId = null, $forceProxy = false)
 {
     KalturaResponseCacher::disableCache();
     entryPeer::setDefaultCriteriaFilter();
     $dbEntry = entryPeer::retrieveByPK($entryId);
     if (!$dbEntry || $dbEntry->getType() != entryType::DOCUMENT) {
         throw new KalturaAPIException(KalturaErrors::ENTRY_ID_NOT_FOUND, $entryId);
     }
     $ksObj = $this->getKs();
     $ks = $ksObj ? $ksObj->getOriginalString() : null;
     $securyEntryHelper = new KSecureEntryHelper($dbEntry, $ks, null);
     $securyEntryHelper->validateForDownload();
     $flavorAsset = null;
     assetPeer::resetInstanceCriteriaFilter();
     if ($flavorParamsId) {
         $flavorAsset = assetPeer::retrieveByEntryIdAndParams($entryId, $flavorParamsId);
         if (!$flavorAsset) {
             throw new KalturaAPIException(KalturaErrors::FLAVOR_ASSET_IS_NOT_READY, $flavorParamsId);
         }
     } else {
         $flavorAsset = assetPeer::retrieveOriginalByEntryId($entryId);
         if (!$flavorAsset) {
             throw new KalturaAPIException(KalturaErrors::FLAVOR_ASSET_ID_NOT_FOUND, $flavorParamsId);
         }
     }
     $fileName = $dbEntry->getName() . '.' . $flavorAsset->getFileExt();
     return $this->serveFlavorAsset($flavorAsset, $fileName, $forceProxy);
 }
 protected function getFieldValuesXml(EntryDistribution $entryDistribution, $fieldName = null)
 {
     $entry = entryPeer::retrieveByPKNoFilter($entryDistribution->getEntryId());
     if (!$entry) {
         KalturaLog::err('Entry not found with ID [' . $entry->getId() . ']');
         return null;
     }
     // set the default criteria to use the current entry distribution partner id (it is restored later)
     // this is needed for related entries under kMetadataMrssManager which is using retrieveByPK without the correct partner id filter
     $oldEntryCriteria = entryPeer::getCriteriaFilter()->getFilter();
     entryPeer::setDefaultCriteriaFilter();
     entryPeer::addPartnerToCriteria($entryDistribution->getPartnerId(), true);
     try {
         $mrss = null;
         $mrssParams = new kMrssParameters();
         if ($this->getItemXpathsToExtend()) {
             $mrssParams->setItemXpathsToExtend($this->getItemXpathsToExtend());
         }
         $mrss = kMrssManager::getEntryMrssXml($entry, $mrss, $mrssParams);
         $mrssStr = $mrss->asXML();
     } catch (Exception $e) {
         // restore the original criteria so it will not get stuck due to the exception
         entryPeer::getCriteriaFilter()->setFilter($oldEntryCriteria);
         throw $e;
     }
     // restore the original criteria
     entryPeer::getCriteriaFilter()->setFilter($oldEntryCriteria);
     if (!$mrssStr) {
         KalturaLog::err('No MRSS returned for entry [' . $entry->getId() . ']');
         return null;
     }
     $mrssObj = new DOMDocument();
     if (!$mrssObj->loadXML($mrssStr)) {
         KalturaLog::err('Error loading MRSS XML object for entry [' . $entry->getId() . ']');
         return null;
     }
     $xslObj = new DOMDocument();
     $xslStr = $this->getFieldValuesXslt($entryDistribution, $fieldName);
     $xslStr = trim($xslStr);
     if (!$xslObj->loadXML($xslStr)) {
         KalturaLog::err('Error loading distribution profile XSLT for profile ID [' . $this->getId() . ']');
         return null;
     }
     $proc = new XSLTProcessor();
     $proc->registerPHPFunctions(kConf::get('xslt_enabled_php_functions'));
     $proc->importStyleSheet($xslObj);
     $resultXmlObj = $proc->transformToDoc($mrssObj);
     if (!$resultXmlObj) {
         KalturaLog::err('Error transforming XML for distribution profile [' . $this->getId() . '] and entry id [' . $entry->getId() . ']');
         return null;
     }
     /* DEBUG logs
     		KalturaLog::log('entry mrss = '.$mrssStr);
     		KalturaLog::log('profile xslt = '.$xslStr);
     		*/
     KalturaLog::debug('Result XML: ' . $resultXmlObj->saveXML());
     return $resultXmlObj;
 }
 /**
  * @return string path value
  * @param entry $entry
  * @param string $xslStr
  */
 protected function getPathValue(entry $entry, $xslStr)
 {
     // set the default criteria to use the current entry distribution partner id (it is restored later)
     // this is needed for related entries under kMetadataMrssManager which is using retrieveByPK without the correct partner id filter
     $oldEntryCriteria = entryPeer::getCriteriaFilter()->getFilter();
     entryPeer::setDefaultCriteriaFilter();
     entryPeer::addPartnerToCriteria($entry->getPartnerId(), true);
     $mrss = null;
     $mrss = kMrssManager::getEntryMrssXml($entry, $mrss);
     $mrssStr = $mrss->asXML();
     // restore the original criteria
     entryPeer::getCriteriaFilter()->setFilter($oldEntryCriteria);
     if (!$mrssStr) {
         KalturaLog::err('No MRSS returned for entry [' . $entry->getId() . ']');
         return null;
     }
     $mrssObj = new DOMDocument();
     if (!$mrssObj->loadXML($mrssStr)) {
         KalturaLog::err('Error loading MRSS XML object for entry [' . $entry->getId() . ']');
         return null;
     }
     $xslObj = new DOMDocument();
     $xslStr = trim($xslStr);
     if (!$xslObj->loadXML($xslStr)) {
         KalturaLog::err('Error loading XSL');
         return null;
     }
     $proc = new XSLTProcessor();
     $proc->registerPHPFunctions(kConf::get('xslt_enabled_php_functions'));
     $proc->importStyleSheet($xslObj);
     $resultXmlObj = $proc->transformToDoc($mrssObj);
     if (!$resultXmlObj) {
         KalturaLog::err('Error transforming XML for entry id [' . $entry->getId() . ']');
         return null;
     }
     /* DEBUG logs
     		KalturaLog::log('entry mrss = '.$mrssStr);
     		KalturaLog::log('profile xslt = '.$xslStr);
     		*/
     KalturaLog::debug('Result XML: ' . $resultXmlObj->saveXML());
     $xpath = new DOMXPath($resultXmlObj);
     $fieldElement = $xpath->query("//path_value")->item(0);
     if (!$fieldElement) {
         KalturaLog::err('Cannot find element <path_value> in XML');
         return null;
     }
     $fieldValue = $fieldElement->nodeValue;
     return $fieldValue;
 }
 /**
  * Serves the file content
  * 
  * @action serveByFlavorParamsId
  * @param string $entryId Document entry id
  * @param string $flavorParamsId Flavor params id
  * @param bool $forceProxy force to get the content without redirect
  * @return file
  * 
  * @throws KalturaErrors::ENTRY_ID_NOT_FOUND
  * @throws KalturaErrors::FLAVOR_ASSET_IS_NOT_READY
  * @throws KalturaErrors::FLAVOR_ASSET_ID_NOT_FOUND
  */
 public function serveByFlavorParamsIdAction($entryId, $flavorParamsId = null, $forceProxy = false)
 {
     // temporary workaround for getting the referrer from a url with the format ....&forceProxy/true/referrer/...
     $referrer = null;
     if (isset($_GET["forceProxy"]) && kString::beginsWith($_GET["forceProxy"], "true/referrer/")) {
         $referrer = substr($_GET["forceProxy"], strlen("true/referrer/"));
         $referrer = base64_decode($referrer);
     }
     KalturaResponseCacher::disableCache();
     entryPeer::setDefaultCriteriaFilter();
     $dbEntry = entryPeer::retrieveByPK($entryId);
     if (!$dbEntry || $dbEntry->getType() != entryType::DOCUMENT) {
         throw new KalturaAPIException(KalturaErrors::ENTRY_ID_NOT_FOUND, $entryId);
     }
     $ksObj = $this->getKs();
     $ks = $ksObj ? $ksObj->getOriginalString() : null;
     $securyEntryHelper = new KSecureEntryHelper($dbEntry, $ks, $referrer, accessControlContextType::DOWNLOAD);
     $securyEntryHelper->validateForDownload();
     $flavorAsset = null;
     if ($flavorParamsId) {
         $flavorAsset = assetPeer::retrieveByEntryIdAndParams($entryId, $flavorParamsId);
         if (!$flavorAsset) {
             throw new KalturaAPIException(KalturaErrors::FLAVOR_ASSET_IS_NOT_READY, $flavorParamsId);
         }
     } else {
         $flavorAsset = assetPeer::retrieveOriginalByEntryId($entryId);
         if (!$flavorAsset) {
             throw new KalturaAPIException(KalturaErrors::FLAVOR_ASSET_ID_NOT_FOUND, $flavorParamsId);
         }
     }
     $fileName = $dbEntry->getName() . '.' . $flavorAsset->getFileExt();
     return $this->serveFlavorAsset($flavorAsset, $fileName, $forceProxy);
 }