Пример #1
0
 protected function doGetListResponse(KalturaFilterPager $pager, array $types = null)
 {
     $this->validateEntryIdFiltered();
     myDbHelper::$use_alternative_con = myDbHelper::DB_HELPER_CONN_PROPEL2;
     // verify access to the relevant entries - either same partner as the KS or kaltura network
     if ($this->entryIdEqual) {
         $entryIds = array($this->entryIdEqual);
     } else {
         if ($this->entryIdIn) {
             $entryIds = explode(',', $this->entryIdIn);
         } else {
             throw new KalturaAPIException(KalturaErrors::PROPERTY_VALIDATION_CANNOT_BE_NULL, 'KalturaAssetFilter::entryIdEqual/KalturaAssetFilter::entryIdIn');
         }
     }
     $entryIds = array_slice($entryIds, 0, baseObjectFilter::getMaxInValues());
     $c = KalturaCriteria::create(entryPeer::OM_CLASS);
     $c->addAnd(entryPeer::ID, $entryIds, Criteria::IN);
     $criterionPartnerOrKn = $c->getNewCriterion(entryPeer::PARTNER_ID, kCurrentContext::getCurrentPartnerId());
     $criterionPartnerOrKn->addOr($c->getNewCriterion(entryPeer::DISPLAY_IN_SEARCH, mySearchUtils::DISPLAY_IN_SEARCH_KALTURA_NETWORK));
     $c->addAnd($criterionPartnerOrKn);
     $dbEntries = entryPeer::doSelect($c);
     if (!$dbEntries) {
         return array(array(), 0);
     }
     $entryIds = array();
     foreach ($dbEntries as $dbEntry) {
         $entryIds[] = $dbEntry->getId();
     }
     $this->entryIdEqual = null;
     $this->entryIdIn = implode(',', $entryIds);
     // get the flavors
     $flavorAssetFilter = new AssetFilter();
     $this->toObject($flavorAssetFilter);
     $c = new Criteria();
     $flavorAssetFilter->attachToCriteria($c);
     if ($types) {
         $c->add(assetPeer::TYPE, $types, Criteria::IN);
     }
     $pager->attachToCriteria($c);
     $list = assetPeer::doSelect($c);
     $resultCount = count($list);
     if ($resultCount && $resultCount < $pager->pageSize) {
         $totalCount = ($pager->pageIndex - 1) * $pager->pageSize + $resultCount;
     } else {
         KalturaFilterPager::detachFromCriteria($c);
         $totalCount = assetPeer::doCount($c);
     }
     myDbHelper::$use_alternative_con = null;
     return array($list, $totalCount);
 }
Пример #2
0
 protected function doGetListResponse(KalturaFilterPager $pager, array $types = null)
 {
     $this->validateEntryIdFiltered();
     myDbHelper::$use_alternative_con = myDbHelper::DB_HELPER_CONN_PROPEL2;
     // verify access to the relevant entries - either same partner as the KS or kaltura network
     if ($this->entryIdEqual) {
         $entryIds = array($this->entryIdEqual);
     } else {
         if ($this->entryIdIn) {
             $entryIds = explode(',', $this->entryIdIn);
         } else {
             throw new KalturaAPIException(KalturaErrors::PROPERTY_VALIDATION_CANNOT_BE_NULL, 'KalturaAssetFilter::entryIdEqual/KalturaAssetFilter::entryIdIn');
         }
     }
     $entryIds = entryPeer::filterEntriesByPartnerOrKalturaNetwork($entryIds, kCurrentContext::getCurrentPartnerId());
     if (!$entryIds) {
         return array(array(), 0);
     }
     $this->entryIdEqual = null;
     $this->entryIdIn = implode(',', $entryIds);
     // get the flavors
     $flavorAssetFilter = new AssetFilter();
     $this->toObject($flavorAssetFilter);
     $c = new Criteria();
     $flavorAssetFilter->attachToCriteria($c);
     if ($types) {
         $c->add(assetPeer::TYPE, $types, Criteria::IN);
     }
     $pager->attachToCriteria($c);
     $list = assetPeer::doSelect($c);
     $resultCount = count($list);
     if ($resultCount && $resultCount < $pager->pageSize) {
         $totalCount = ($pager->pageIndex - 1) * $pager->pageSize + $resultCount;
     } else {
         KalturaFilterPager::detachFromCriteria($c);
         $totalCount = assetPeer::doCount($c);
     }
     myDbHelper::$use_alternative_con = null;
     return array($list, $totalCount);
 }
 /**
  * List attachment Assets by filter and pager
  * 
  * @action list
  * @param KalturaAssetFilter $filter
  * @param KalturaFilterPager $pager
  * @return KalturaAttachmentAssetListResponse
  */
 function listAction(KalturaAssetFilter $filter = null, KalturaFilterPager $pager = null)
 {
     if (!$filter) {
         $filter = new KalturaAssetFilter();
     }
     if (!$pager) {
         $pager = new KalturaFilterPager();
     }
     $attachmentAssetFilter = new AssetFilter();
     $filter->toObject($attachmentAssetFilter);
     $c = new Criteria();
     $attachmentAssetFilter->attachToCriteria($c);
     $types = KalturaPluginManager::getExtendedTypes(assetPeer::OM_CLASS, AttachmentPlugin::getAssetTypeCoreValue(AttachmentAssetType::ATTACHMENT));
     $c->add(assetPeer::TYPE, $types, Criteria::IN);
     $totalCount = assetPeer::doCount($c);
     $pager->attachToCriteria($c);
     $dbList = assetPeer::doSelect($c);
     $list = KalturaAttachmentAssetArray::fromDbArray($dbList);
     $response = new KalturaAttachmentAssetListResponse();
     $response->objects = $list;
     $response->totalCount = $totalCount;
     return $response;
 }
Пример #4
0
 private static function getSourceFlavorAssets(flavorAsset $flavorAsset, flavorParamsOutput $flavor)
 {
     $srcFlavorParamsIds = explode(',', trim($flavor->getSourceAssetParamsIds()));
     $c = new Criteria();
     $c->add(assetPeer::ENTRY_ID, $flavorAsset->getEntryId());
     $c->add(assetPeer::STATUS, array(flavorAsset::ASSET_STATUS_READY, flavorAsset::ASSET_STATUS_NOT_APPLICABLE, flavorAsset::ASSET_STATUS_EXPORTING), Criteria::IN);
     $c->add(assetPeer::FLAVOR_PARAMS_ID, $srcFlavorParamsIds, Criteria::IN);
     $readyAndNonApplicableAssetsCount = assetPeer::doCount($c);
     KalturaLog::info('Verify source flavors are ready: number of ready and NA assets [' . $readyAndNonApplicableAssetsCount . '], number of source params ids [' . count($srcFlavorParamsIds) . ']');
     if ($readyAndNonApplicableAssetsCount < count($srcFlavorParamsIds)) {
         KalturaLog::info('Not all source flavors are ready, changing status to WAIT_FOR_CONVERT');
         $flavorAsset->setStatus(flavorAsset::ASSET_STATUS_WAIT_FOR_CONVERT);
         $flavorAsset->setDescription("Source flavor assets are not ready");
         $flavorAsset->save();
         return false;
     }
     $srcFlavors = assetPeer::retrieveLocalReadyByEntryIdAndFlavorParams($flavorAsset->getEntryId(), $srcFlavorParamsIds);
     if (!count($srcFlavors)) {
         //assuming all source flavors are Not Applicable
         KalturaLog::log("Flavor [" . $flavorAsset->getFlavorParamsId() . "] is set to N/A since all it's sources are N/A");
         $flavorAsset->setStatus(flavorAsset::ASSET_STATUS_NOT_APPLICABLE);
         $flavorAsset->save();
         return false;
     }
     return $srcFlavors;
 }
Пример #5
0
 /**
  * Returns the number of related asset objects.
  *
  * @param      Criteria $criteria
  * @param      boolean $distinct
  * @param      PropelPDO $con
  * @return     int Count of related asset objects.
  * @throws     PropelException
  */
 public function countassets(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
 {
     if ($criteria === null) {
         $criteria = new Criteria(entryPeer::DATABASE_NAME);
     } else {
         $criteria = clone $criteria;
     }
     if ($distinct) {
         $criteria->setDistinct();
     }
     $count = null;
     if ($this->collassets === null) {
         if ($this->isNew()) {
             $count = 0;
         } else {
             $criteria->add(assetPeer::ENTRY_ID, $this->id);
             $count = assetPeer::doCount($criteria, false, $con);
         }
     } else {
         // criteria has no effect for a new object
         if (!$this->isNew()) {
             // the following code is to determine if a new query is
             // called for.  If the criteria is the same as the last
             // one, just return count of the collection.
             $criteria->add(assetPeer::ENTRY_ID, $this->id);
             if (!isset($this->lastassetCriteria) || !$this->lastassetCriteria->equals($criteria)) {
                 $count = assetPeer::doCount($criteria, false, $con);
             } else {
                 $count = count($this->collassets);
             }
         } else {
             $count = count($this->collassets);
         }
     }
     return $count;
 }
Пример #6
0
 public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null)
 {
     self::getInstance();
     return parent::doCount($criteria, $distinct, $con);
 }
Пример #7
0
function handleFlvSrcAssetsWithMbrTag(Partner $partner, $should_do_flavors_to_web = NULL, $force_upgrade = NULL)
{
    $c = new Criteria();
    $c->add(assetPeer::PARTNER_ID, $partner->getId());
    $c->add(assetPeer::TAGS, 'mbr');
    $c->add(assetPeer::FILE_EXT, 'flv');
    $c->add(assetPeer::FLAVOR_PARAMS_ID, 0);
    assetPeer::setDefaultCriteriaFilter(false);
    $flavorsCount = assetPeer::doCount($c);
    assetPeer::setDefaultCriteriaFilter(true);
    if ($flavorsCount && $should_do_flavors_to_web != 'convert_flavors' && $should_do_flavors_to_web != 'skip_flavors') {
        KalturaLog::debug("found {$flavorsCount} flavors with only 'mbr' tag.\n\n\t\t\t\t\t\tif you want to convert them run: php {$argv[0]} {$argv[1]} convert_flavors \n\n\t\t\t\t\t\tif you don't want to convert them, run: php {$argv[0]} {$argv[1]} skip_flavors");
        if ($force_upgrade == 'force') {
            convertFlavorsTags($partner, $c);
            if (DEBUG) {
                KalturaLog::debug("This was dry-run, exiting");
                die;
            } else {
                KalturaLog::debug("{$flavorsCount} flavors were fixed, going to upgrade partner");
            }
        } else {
            die;
        }
    } else {
        if ($flavorsCount && $should_do_flavors_to_web == 'skip_flavors') {
            KalturaLog::debug("Not converting flavors tags and going on");
            if (DEBUG) {
                KalturaLog::debug("This was a dry-run, exiting");
                die;
            }
        } else {
            if ($flavorsCount && $should_do_flavors_to_web == 'convert_flavors') {
                convertFlavorsTags($partner, $c);
                if (DEBUG) {
                    KalturaLog::debug("This was a dry-run, exiting");
                    die;
                }
            } else {
                KalturaLog::debug("There was no flavor tags to convert");
            }
        }
    }
}
 /**
  * List Flavor Assets by filter and pager
  * 
  * @action list
  * @param KalturaAssetFilter $filter
  * @param KalturaFilterPager $pager
  * @return KalturaFlavorAssetListResponse
  */
 function listAction(KalturaAssetFilter $filter = null, KalturaFilterPager $pager = null)
 {
     myDbHelper::$use_alternative_con = myDbHelper::DB_HELPER_CONN_PROPEL2;
     if (!$filter) {
         $filter = new KalturaAssetFilter();
     }
     if (!$pager) {
         $pager = new KalturaFilterPager();
     }
     // verify access to the relevant entries - either same partner as the KS or kaltura network
     if ($filter->entryIdEqual) {
         $entryIds = array($filter->entryIdEqual);
     } else {
         if ($filter->entryIdIn) {
             $entryIds = explode(',', $filter->entryIdIn);
         } else {
             throw new KalturaAPIException(KalturaErrors::PROPERTY_VALIDATION_CANNOT_BE_NULL, 'KalturaAssetFilter::entryIdEqual/KalturaAssetFilter::entryIdIn');
         }
     }
     $c = KalturaCriteria::create(entryPeer::OM_CLASS);
     $c->addAnd(entryPeer::ID, $entryIds, Criteria::IN);
     $criterionPartnerOrKn = $c->getNewCriterion(entryPeer::PARTNER_ID, $this->getPartnerId());
     $criterionPartnerOrKn->addOr($c->getNewCriterion(entryPeer::DISPLAY_IN_SEARCH, mySearchUtils::DISPLAY_IN_SEARCH_KALTURA_NETWORK));
     $c->addAnd($criterionPartnerOrKn);
     KalturaCriterion::disableTag(KalturaCriterion::TAG_WIDGET_SESSION);
     $dbEntries = entryPeer::doSelect($c);
     KalturaCriterion::restoreTag(KalturaCriterion::TAG_WIDGET_SESSION);
     if (!$dbEntries) {
         throw new KalturaAPIException(KalturaErrors::ENTRY_ID_NOT_FOUND, implode(',', $entryIds));
     }
     $entryIds = array();
     foreach ($dbEntries as $dbEntry) {
         $entryIds[] = $dbEntry->getId();
     }
     $filter->entryIdEqual = null;
     $filter->entryIdIn = implode(',', $entryIds);
     // get the flavors
     $flavorAssetFilter = new AssetFilter();
     $filter->toObject($flavorAssetFilter);
     $c = new Criteria();
     $flavorAssetFilter->attachToCriteria($c);
     $flavorTypes = KalturaPluginManager::getExtendedTypes(assetPeer::OM_CLASS, assetType::FLAVOR);
     $c->add(assetPeer::TYPE, $flavorTypes, Criteria::IN);
     $totalCount = assetPeer::doCount($c);
     $pager->attachToCriteria($c);
     $dbList = assetPeer::doSelect($c);
     $list = KalturaFlavorAssetArray::fromDbArray($dbList);
     $response = new KalturaFlavorAssetListResponse();
     $response->objects = $list;
     $response->totalCount = $totalCount;
     return $response;
 }