public static function copyConversionProfiles(Partner $fromPartner, Partner $toPartner)
 {
     $copiedList = array();
     KalturaLog::log("copyConversionProfiles - 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("copyConversionProfiles - 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();
             assetParamsPeer::resetInstanceCriteriaFilter();
             $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();
         }
     }
 }
 public function validateFlavorParamsIds()
 {
     $flavorParamsIds = $this->getFlavorParamsAsArray();
     assetParamsPeer::resetInstanceCriteriaFilter();
     $flavorParams = assetParamsPeer::retrieveByPKs($flavorParamsIds);
     $sourceFound = false;
     $indexedFlavorParams = array();
     foreach ($flavorParams as $flavorParamsItem) {
         if ($flavorParamsItem->hasTag(flavorParams::TAG_SOURCE)) {
             if ($sourceFound) {
                 throw new KalturaAPIException(KalturaErrors::FLAVOR_PARAMS_SOURCE_DUPLICATE);
             }
             $sourceFound = true;
         }
         $indexedFlavorParams[$flavorParamsItem->getId()] = $flavorParamsItem;
     }
     $foundFlavorParams = array();
     foreach ($flavorParamsIds as $id) {
         if (!isset($indexedFlavorParams[$id])) {
             throw new KalturaAPIException(KalturaErrors::FLAVOR_PARAMS_ID_NOT_FOUND, $id);
         }
         if (in_array($id, $foundFlavorParams)) {
             throw new KalturaAPIException(KalturaErrors::FLAVOR_PARAMS_DUPLICATE, $id);
         }
         $foundFlavorParams[] = $id;
     }
 }