public function execute() { $this->forceSystemAuthentication(); myDbHelper::$use_alternative_con = null; $go = $this->getP("go"); $filter = new ConversionProfileFilter(); $this->list = array(); $fields_set = $filter->fillObjectFromRequest($_REQUEST, "filter_", null); if ($go) { $c = new Criteria(); // filter $filter->attachToCriteria($c); //if ($order_by != -1) kshowPeer::setOrder( $c , $order_by ); $this->list = ConversionProfilePeer::doSelect($c); } $the_conv = myConversionProfileUtils::getConversionProfile($filter->get("_eq_partner_id"), $filter->get("_eq_profile_type")); $selected = false; if ($the_conv) { foreach ($this->list as &$conv) { if ($conv->getId() == $the_conv->getId()) { $selected = true; $conv->selected = true; } } } // is none was selected - need to add the_conv to the list if (!$selected && $the_conv) { $the_conv->selected = true; $this->list[] = $the_conv; } $this->filter = $filter; }
/** * return the ConversionProfile for this entry is specified on the entry or for the partner * the is_flv is important for deciding on the actual set of conversion params * * @param string $entry_id * @return conversionProfile2 */ public static function getConversionProfile2ForEntry($entry_id) { $entry = entryPeer::retrieveByPK($entry_id); if (!$entry) { return null; } // conversion quality is an alias for conersion_profile_type ('low' , 'med' , 'hi' , 'hd' ... ) $conversion_profile_2_id = $entry->getConversionProfileId(); $conversion_quality = ""; KalturaLog::log("conversion_profile_2_id [{$conversion_profile_2_id}]"); if (is_null($conversion_profile_2_id) || $conversion_profile_2_id <= 0) { // this is assumed to be the old conversion profile $conversion_quality = $entry->getConversionQuality(); $partner_id = $entry->getPartnerId(); // try to extract the conversion profile from the partner $partner = PartnerPeer::retrieveByPK($partner_id); if (!$partner) { throw new Exception("Cannot find partner for entry [{$entry_id}]"); } KalturaLog::log("conversion_quality [{$conversion_quality}]"); $partner_kmc_version = $partner->getKmcVersion(); if (is_null($partner_kmc_version) || version_compare($partner_kmc_version, "2", "<")) { // if old kmc - the fallback conversion_quality is the one on the partner->getDefConversionProfileType if (is_null($conversion_quality) || $conversion_quality <= 0) { // search for the default one on the partner $old_conversion_profile = self::getCurrentConversionProfile($partner->getId()); } else { // load old profile from the given conversion_quality $old_conversion_profile = myConversionProfileUtils::getConversionProfile($partner_id, $conversion_quality); } if (!$old_conversion_profile) { throw new Exception("Cannot find conversion profile for entry_id [{$entry_id}] OLD conversion_quality [{$conversion_quality}]"); } // this is a partner working with OLD KMC // - we need to create the new conversion profile from the old one $new_conversion_profile = myConversionProfileUtils::createConversionProfile2FromConversionProfile($old_conversion_profile); } else { // if new kmc_version - the fallback conversion_quality is the one on the partner->getDefaultConversionProfileId if (is_null($conversion_quality) || $conversion_quality <= 0) { // search for the default one on the partner $conversion_quality = $partner->getDefaultConversionProfileId(); } // partner with new KMC version - use the $conversion_quality as if it was the conversionProfile2 id $new_conversion_profile = conversionProfile2Peer::retrieveByPk($conversion_quality); } // set the new conversionProfileId on the entry if ($new_conversion_profile) { $entry->setConversionProfileId($new_conversion_profile->getId()); $entry->save(); } } else { $new_conversion_profile = conversionProfile2Peer::retrieveByPk($conversion_profile_2_id); } // if there is no new conversion_profile OR the new_conversion_profile doesn't belong to the current partner (and doesn't belong to partner 0 - the partner all default profiules belong to) // - this indicates an error ! if (!$new_conversion_profile || $new_conversion_profile->getPartnerId() != $entry->getPartnerId() && $new_conversion_profile->getPartnerId() != 0) { throw new Exception("Cannot find conversion profile for entry_id [{$entry_id}] OLD conversion_quality [{$conversion_quality}] NEW conversion_profile_2_id [{$conversion_profile_2_id}]"); } return $new_conversion_profile; }
if (DEBUG) { KalturaLog::debug("This was dry-run, going to set partner with DefaultConversionProfileId: " . $partner->getDefaultConversionProfileId()); die; } else { // set new id as defaultConversionProfileId $partner->setDefaultConversionProfileId($oldCp->getConversionProfile2Id()); KalturaLog::debug("Partner was set with DefaultConversionProfileId: " . $partner->getDefaultConversionProfileId()); $partner->setKmcVersion('4'); $partner->save(); die; } } else { // no currentConversionProfileType, lets see what on default $defConversionProfileType = $partner->getFromCustomData('defConversionProfileType'); if (!is_null($defConversionProfileType)) { $oldCp = myConversionProfileUtils::getConversionProfile($partner->getId(), $defConversionProfileType); if (!$oldCp->getConversionProfile2Id() && $oldCp->getPartnerId() == $partner->getId()) { if (DEBUG) { KalturaLog::debug("This was dry-run, going to convert old default conversion profile according to defConversionProfileType"); die; } else { myConversionProfileUtils::createConversionProfile2FromConversionProfile($oldCp); // set new id on defaultConversionProfileId $partner->setDefaultConversionProfileId($oldCp->getConversionProfile2Id()); $partner->setKmcVersion('4'); $partner->save(); KalturaLog::debug("converted old default conversion profile. new DefaultConversionProfileId is: " . $partner->getDefaultConversionProfileId()); die; } } }