public function loadFlavorParamsIds()
 {
     $conversionProfileIds = array();
     // find all profile ids
     foreach ($this as $conversionProfile) {
         $conversionProfileIds[] = $conversionProfile->id;
     }
     // get all params relations by the profile ids list
     $c = new Criteria();
     $c->add(flavorParamsConversionProfilePeer::CONVERSION_PROFILE_ID, $conversionProfileIds, Criteria::IN);
     $allParams = flavorParamsConversionProfilePeer::doSelect($c);
     $paramsIdsPerProfile = array();
     // group the params by profile id
     foreach ($allParams as $item) {
         if (!isset($paramsIdsPerProfile[$item->getConversionProfileId()])) {
             $paramsIdsPerProfile[$item->getConversionProfileId()] = array();
         }
         $paramsIdsPerProfile[$item->getConversionProfileId()][] = $item->getFlavorParamsId();
     }
     // assign the params ids to the profiles
     foreach ($this as $conversionProfile) {
         if (isset($paramsIdsPerProfile[$conversionProfile->id])) {
             $conversionProfile->flavorParamsIds = implode(",", $paramsIdsPerProfile[$conversionProfile->id]);
         }
     }
 }
 public function getListResponse(KalturaFilterPager $pager, KalturaDetachedResponseProfile $responseProfile = null)
 {
     $assetParamsConversionProfileFilter = $this->toObject();
     $c = new Criteria();
     $assetParamsConversionProfileFilter->attachToCriteria($c);
     $totalCount = flavorParamsConversionProfilePeer::doCount($c);
     $pager->attachToCriteria($c);
     $dbList = flavorParamsConversionProfilePeer::doSelect($c);
     $list = KalturaConversionProfileAssetParamsArray::fromDbArray($dbList, $responseProfile);
     $response = new KalturaConversionProfileAssetParamsListResponse();
     $response->objects = $list;
     $response->totalCount = $totalCount;
     return $response;
 }
 /**
  * Lists asset parmas of conversion profile by ID
  * 
  * @action list
  * @param KalturaConversionProfileAssetParamsFilter $filter
  * @param KalturaFilterPager $pager
  * @return KalturaConversionProfileAssetParamsListResponse
  */
 public function listAction(KalturaConversionProfileAssetParamsFilter $filter = null, KalturaFilterPager $pager = null)
 {
     if (!$filter) {
         $filter = new KalturaConversionProfileAssetParamsFilter();
     }
     if (!$pager) {
         $pager = new KalturaFilterPager();
     }
     $assetParamsConversionProfileFilter = $filter->toObject();
     $c = new Criteria();
     $assetParamsConversionProfileFilter->attachToCriteria($c);
     $totalCount = flavorParamsConversionProfilePeer::doCount($c);
     $pager->attachToCriteria($c);
     $dbList = flavorParamsConversionProfilePeer::doSelect($c);
     $list = KalturaConversionProfileAssetParamsArray::fromDbArray($dbList);
     $response = new KalturaConversionProfileAssetParamsListResponse();
     $response->objects = $list;
     $response->totalCount = $totalCount;
     return $response;
 }
예제 #4
0
 public static function copyConversionProfiles(Partner $fromPartner, Partner $toPartner, $permissionRequiredOnly = false)
 {
     $copiedList = array();
     KalturaLog::log("Copying conversion profiles from partner [" . $fromPartner->getId() . "] to partner [" . $toPartner->getId() . "]");
     $c = new Criteria();
     $c->add(conversionProfile2Peer::PARTNER_ID, $fromPartner->getId());
     $conversionProfiles = conversionProfile2Peer::doSelect($c);
     foreach ($conversionProfiles as $conversionProfile) {
         /* @var $conversionProfile conversionProfile2 */
         if ($permissionRequiredOnly && !count($conversionProfile->getRequiredCopyTemplatePermissions())) {
             continue;
         }
         if (!self::isPartnerPermittedForCopy($toPartner, $conversionProfile->getRequiredCopyTemplatePermissions())) {
             continue;
         }
         $newConversionProfile = $conversionProfile->copy();
         $newConversionProfile->setPartnerId($toPartner->getId());
         try {
             $newConversionProfile->save();
         } catch (Exception $e) {
             KalturaLog::info("Exception occured, conversion profile was not copied. Message: [" . $e->getMessage() . "]");
             continue;
         }
         KalturaLog::log("Copied [" . $conversionProfile->getId() . "], new id is [" . $newConversionProfile->getId() . "]");
         $copiedList[$conversionProfile->getId()] = $newConversionProfile->getId();
         $c = new Criteria();
         $c->add(flavorParamsConversionProfilePeer::CONVERSION_PROFILE_ID, $conversionProfile->getId());
         $fpcpList = flavorParamsConversionProfilePeer::doSelect($c);
         foreach ($fpcpList as $fpcp) {
             $flavorParamsId = $fpcp->getFlavorParamsId();
             $flavorParams = assetParamsPeer::retrieveByPK($flavorParamsId);
             if ($flavorParams && $flavorParams->getPartnerId() === 0) {
                 $newFpcp = $fpcp->copy();
                 $newFpcp->setConversionProfileId($newConversionProfile->getId());
                 $newFpcp->save();
             }
         }
     }
     // make sure conversion profile is set on the new partner in case it was missed/skiped in the conversionProfile2::copy method
     if (!$toPartner->getDefaultConversionProfileId()) {
         $fromPartnerDefaultProfile = $fromPartner->getDefaultConversionProfileId();
         if ($fromPartnerDefaultProfile && key_exists($fromPartnerDefaultProfile, $copiedList)) {
             $toPartner->setDefaultConversionProfileId($copiedList[$fromPartnerDefaultProfile]);
         }
     }
     if (!$toPartner->getDefaultLiveConversionProfileId()) {
         $fromPartnerDefaultLiveProfile = $fromPartner->getDefaultLiveConversionProfileId();
         if ($fromPartnerDefaultLiveProfile && key_exists($fromPartnerDefaultLiveProfile, $copiedList)) {
             $toPartner->setDefaultLiveConversionProfileId($copiedList[$fromPartnerDefaultLiveProfile]);
         }
     }
     $toPartner->save();
 }
예제 #5
0
 /**
  * Gets an array of flavorParamsConversionProfile objects which contain a foreign key that references this object.
  *
  * If this collection has already been initialized with an identical Criteria, it returns the collection.
  * Otherwise if this assetParams has previously been saved, it will retrieve
  * related flavorParamsConversionProfiles from storage. If this assetParams is new, it will return
  * an empty collection or the current collection, the criteria is ignored on a new object.
  *
  * @param      PropelPDO $con
  * @param      Criteria $criteria
  * @return     array flavorParamsConversionProfile[]
  * @throws     PropelException
  */
 public function getflavorParamsConversionProfiles($criteria = null, PropelPDO $con = null)
 {
     if ($criteria === null) {
         $criteria = new Criteria(assetParamsPeer::DATABASE_NAME);
     } elseif ($criteria instanceof Criteria) {
         $criteria = clone $criteria;
     }
     if ($this->collflavorParamsConversionProfiles === null) {
         if ($this->isNew()) {
             $this->collflavorParamsConversionProfiles = array();
         } else {
             $criteria->add(flavorParamsConversionProfilePeer::FLAVOR_PARAMS_ID, $this->id);
             flavorParamsConversionProfilePeer::addSelectColumns($criteria);
             $this->collflavorParamsConversionProfiles = flavorParamsConversionProfilePeer::doSelect($criteria, $con);
         }
     } else {
         // criteria has no effect for a new object
         if (!$this->isNew()) {
             // the following code is to determine if a new query is
             // called for.  If the criteria is the same as the last
             // one, just return the collection.
             $criteria->add(flavorParamsConversionProfilePeer::FLAVOR_PARAMS_ID, $this->id);
             flavorParamsConversionProfilePeer::addSelectColumns($criteria);
             if (!isset($this->lastflavorParamsConversionProfileCriteria) || !$this->lastflavorParamsConversionProfileCriteria->equals($criteria)) {
                 $this->collflavorParamsConversionProfiles = flavorParamsConversionProfilePeer::doSelect($criteria, $con);
             }
         }
     }
     $this->lastflavorParamsConversionProfileCriteria = $criteria;
     return $this->collflavorParamsConversionProfiles;
 }
 /**
  * Retrieve multiple objects by pkey.
  *
  * @param      array $pks List of primary keys
  * @param      PropelPDO $con the connection to use
  * @throws     PropelException Any exceptions caught during processing will be
  *		 rethrown wrapped into a PropelException.
  */
 public static function retrieveByPKs($pks, PropelPDO $con = null)
 {
     $objs = null;
     if (empty($pks)) {
         $objs = array();
     } else {
         $criteria = new Criteria(flavorParamsConversionProfilePeer::DATABASE_NAME);
         $criteria->add(flavorParamsConversionProfilePeer::ID, $pks, Criteria::IN);
         $objs = flavorParamsConversionProfilePeer::doSelect($criteria, $con);
     }
     return $objs;
 }
예제 #7
0
 /**
  * @param assetParams $assetParam
  */
 protected function assetParamDeleted(assetParams $assetParam)
 {
     //In Case Flavor Deleted Belongs To Partner 0 Exit Without Deleteing
     if ($assetParam->getPartnerId() == 0) {
         KalturaLog::log("Deleting Flavor Param Of Partner 0 Is Restricted");
         return;
     }
     $c = new Criteria();
     $c->setLimit(100);
     $c->add(flavorParamsConversionProfilePeer::FLAVOR_PARAMS_ID, $assetParam->getId());
     for (;;) {
         $flavorParamsConversionProfiles = flavorParamsConversionProfilePeer::doSelect($c);
         foreach ($flavorParamsConversionProfiles as $flavorParamsConversionProfile) {
             /* @var $flavorParamsConversionProfile flavorParamsConversionProfile */
             $flavorParamsConversionProfile->delete();
         }
         if (count($flavorParamsConversionProfiles) < 100) {
             break;
         }
         flavorParamsConversionProfilePeer::clearInstancePool();
     }
     KalturaLog::info("Flavor Params Conversion Profile Relations were deleted for flavor param id [" . $assetParam->getId() . "]");
 }
 public static function copyConversionProfiles(Partner $fromPartner, Partner $toPartner)
 {
     $copiedList = array();
     KalturaLog::log("Copying conversion profiles from partner [" . $fromPartner->getId() . "] to partner [" . $toPartner->getId() . "]");
     $c = new Criteria();
     $c->add(conversionProfile2Peer::PARTNER_ID, $fromPartner->getId());
     $conversionProfiles = conversionProfile2Peer::doSelect($c);
     foreach ($conversionProfiles as $conversionProfile) {
         $newConversionProfile = $conversionProfile->copy();
         $newConversionProfile->setPartnerId($toPartner->getId());
         $newConversionProfile->save();
         KalturaLog::log("Copied [" . $conversionProfile->getId() . "], new id is [" . $newConversionProfile->getId() . "]");
         $copiedList[$conversionProfile->getId()] = $newConversionProfile->getId();
         $c = new Criteria();
         $c->add(flavorParamsConversionProfilePeer::CONVERSION_PROFILE_ID, $conversionProfile->getId());
         $fpcpList = flavorParamsConversionProfilePeer::doSelect($c);
         foreach ($fpcpList as $fpcp) {
             $flavorParamsId = $fpcp->getFlavorParamsId();
             $flavorParams = assetParamsPeer::retrieveByPK($flavorParamsId);
             if ($flavorParams && $flavorParams->getPartnerId() === 0) {
                 $newFpcp = $fpcp->copy();
                 $newFpcp->setConversionProfileId($newConversionProfile->getId());
                 $newFpcp->save();
             }
         }
     }
     $toPartner->save();
     // make sure conversion profile is set on the new partner in case it was missed/skiped in the conversionProfile2::copy method
     if (!$toPartner->getDefaultConversionProfileId()) {
         $fromPartnerDefaultProfile = $fromPartner->getDefaultConversionProfileId();
         if ($fromPartnerDefaultProfile && key_exists($fromPartnerDefaultProfile, $copiedList)) {
             $toPartner->setDefaultConversionProfileId($copiedList[$fromPartnerDefaultProfile]);
             $toPartner->save();
         }
     }
 }
 /**
  * 
  * @param int $conversionProfileId
  * @param $con
  * 
  * @return array
  */
 public static function retrieveByConversionProfile($conversionProfileId, $con = null)
 {
     $criteria = new Criteria();
     $criteria->add(flavorParamsConversionProfilePeer::CONVERSION_PROFILE_ID, $conversionProfileId);
     return flavorParamsConversionProfilePeer::doSelect($criteria, $con);
 }
예제 #10
0
 /**
  * Delete the relation of flavorParams <> conversionProfile2
  * 
  * @param conversionProfile2 $conversionProfileDb
  * @param string|array $notInFlavorIds comma sepeartaed id that should not be deleted
  */
 protected function deleteFlavorParamsRelation(conversionProfile2 $conversionProfileDb, $notInFlavorIds = null)
 {
     $c = new Criteria();
     $c->add(flavorParamsConversionProfilePeer::CONVERSION_PROFILE_ID, $conversionProfileDb->getId());
     if ($notInFlavorIds) {
         if (!is_array($notInFlavorIds)) {
             $notInFlavorIds = explode(',', $notInFlavorIds);
         }
         $c->add(flavorParamsConversionProfilePeer::FLAVOR_PARAMS_ID, $notInFlavorIds, Criteria::NOT_IN);
     }
     $flavorParamsConversionProfiles = flavorParamsConversionProfilePeer::doSelect($c);
     foreach ($flavorParamsConversionProfiles as $flavorParamsConversionProfile) {
         /* @var $flavorParamsConversionProfile flavorParamsConversionProfile */
         $flavorParamsConversionProfile->delete();
     }
 }
예제 #11
0
 private static function deleteTemporaryFlavors($entryId)
 {
     $originalflavorAsset = assetPeer::retrieveOriginalByEntryId($entryId);
     if ($originalflavorAsset && $originalflavorAsset->getStatus() == flavorAsset::FLAVOR_ASSET_STATUS_TEMP) {
         $originalflavorAsset->setStatus(flavorAsset::FLAVOR_ASSET_STATUS_DELETED);
         $originalflavorAsset->setDeletedAt(time());
         $originalflavorAsset->save();
     }
     $conversionProfile = myPartnerUtils::getConversionProfile2ForEntry($entryId);
     if (!$conversionProfile) {
         return;
     }
     $criteria = new Criteria();
     $criteria->add(flavorParamsConversionProfilePeer::CONVERSION_PROFILE_ID, $conversionProfile->getId());
     $criteria->add(flavorParamsConversionProfilePeer::DELETE_POLICY, AssetParamsDeletePolicy::DELETE);
     $tempFlavorsParams = flavorParamsConversionProfilePeer::doSelect($criteria);
     foreach ($tempFlavorsParams as $tempFlavorsParam) {
         $tempFlavorAsset = assetPeer::retrieveByEntryIdAndParams($entryId, $tempFlavorsParam->getFlavorParamsId());
         if ($tempFlavorAsset) {
             $tempFlavorAsset->setStatus(flavorAsset::FLAVOR_ASSET_STATUS_DELETED);
             $tempFlavorAsset->setDeletedAt(time());
             $tempFlavorAsset->save();
         }
     }
 }