<commit_before><?php

require_once ( "kalturaAction.class.php" );

class kmc4Action extends kalturaAction
{
	const CURRENT_KMC_VERSION = 4;
	
	private $confs = array();
	
	const SYSTEM_DEFAULT_PARTNER = 0;
	
	private function getPartnersArray($partnerIds)
	{
		$allowed = array();
		$c = new Criteria();
		$c->addAnd(PartnerPeer::ID, $partnerIds, Criteria::IN);
		$c->addAnd(PartnerPeer::STATUS, Partner::PARTNER_STATUS_ACTIVE, Criteria::EQUAL);
		PartnerPeer::setUseCriteriaFilter(false);
		$partners = PartnerPeer::doSelect($c);
		PartnerPeer::setUseCriteriaFilter(true);
		foreach ($partners as $partner)
		{
			if (!in_array($partner->getId(), array(PartnerPeer::GLOBAL_PARTNER, Partner::ADMIN_CONSOLE_PARTNER_ID, Partner::BATCH_PARTNER_ID))) {
				$allowed[] = array('id' => $partner->getId(), 'name' => $partner->getName());
			}
		}
		return $allowed;
	}
	
	public function execute ( ) 
	{
		
		sfView::SUCCESS;

	/** check parameters and verify user is logged-in **/
		$this->partner_id = $this->getP ( "pid" );
		$this->subp_id = $this->getP ( "subpid", ((int)$this->partner_id)*100 );
		$this->uid = $this->getP ( "uid" );
		$this->ks = $this->getP ( "kmcks" );
		if(!$this->ks)
		{
			// if kmcks from cookie doesn't exist, try ks from REQUEST
			$this->ks = $this->getP('ks');
		}
		$this->screen_name = $this->getP ( "screen_name" );
		$this->email = $this->getP ( "email" );

		
		/** if no KS found, redirect to login page **/
		if (!$this->ks)
		{
			$this->redirect( "kmc/kmc" );
			die();
		}
		$ksObj = kSessionUtils::crackKs($this->ks);
		
	/** END - check parameters and verify user is logged-in **/
		
	/** Get array of allowed partners for the current user **/
		$currentUser = kuserPeer::getKuserByPartnerAndUid($this->partner_id, $ksObj->user, true);
		if($currentUser) {
			$this->allowedPartners = $this->getPartnersArray($currentUser->getAllowedPartnerIds());
			$this->full_name = $currentUser->getFullName();
		}

	/** load partner from DB, and set templatePartnerId **/
		$this->partner = $partner = null;
		$this->templatePartnerId = self::SYSTEM_DEFAULT_PARTNER;
		if ($this->partner_id !== NULL)
		{
			$this->partner = $partner = PartnerPeer::retrieveByPK($this->partner_id);
			kmcUtils::redirectPartnerToCorrectKmc($partner, $this->ks, $this->uid, $this->screen_name, $this->email, self::CURRENT_KMC_VERSION);
			$this->templatePartnerId = $this->partner ? $this->partner->getTemplatePartnerId() : self::SYSTEM_DEFAULT_PARTNER;
		}
	/** END - load partner from DB, and set templatePartnerId **/

	/** set default flags **/
		$this->allow_reports = false;
		$this->payingPartner = 'false';
		$this->embed_code  = "";
		$this->enable_live_streaming = 'false';
		$this->kmc_enable_custom_data = 'false';
		$this->kdp508_players = array();
		$this->first_login = false;
		$this->enable_vast = 'false';
	/** END - set default flags **/
	
	/** set values for template **/
	$this->service_url = myPartnerUtils::getHost($this->partner_id);
	$this->host = str_replace ( "http://" , "" , $this->service_url );
	$this->cdn_url = myPartnerUtils::getCdnHost($this->partner_id);
	$this->cdn_host = str_replace ( "http://" , "" , $this->cdn_url );
	$this->rtmp_host = myPartnerUtils::getRtmpUrl($this->partner_id);
	$this->flash_dir = $this->cdn_url . myContentStorage::getFSFlashRootPath ();
	
	// Decide if to hide akamai delivery type
	$this->hideAkamaiHDNetwork = $partner->getDisableAkamaiHDNetwork();
		
	/** set embed_code value **/
		if ( $this->partner_id !== null )
		{
			$widget = widgetPeer::retrieveByPK( "_" . $this->partner_id );
			if ( $widget )
			{
				$this->embed_code = $widget->getWidgetHtml( "kaltura_player" );
				
				$ui_conf = $widget->getuiConf();
			}
		}
	/** END - set embed_code value **/

	/** set payingPartner flag **/
		if($partner && $partner->getPartnerPackage() != PartnerPackages::PARTNER_PACKAGE_FREE)
		{
			$this->payingPartner = 'true';
		}
	/** END - set payingPartner flag **/
		
	/** set enable_live_streaming flag **/
		if(kConf::get('kmc_content_enable_live_streaming') && $partner)
		{
			if ($partner->getLiveStreamEnabled())
			{
				$this->enable_live_streaming = 'true';
			}
		}
	/** END - set enable_live_streaming flag **/

	/** get partner languae **/ 
		if ($partner->getKMCLanguage())
			$this->language = $partner->getKMCLanguage();
	/** END - get partner languae **/		
		
	/** set enable_live_streaming flag **/
		if($partner && $partner->getEnableVast())
		{<commit_msg>PHP Notice:  Undefined variable: language in kmc4Success.php on line 140<commit_after><?php

require_once ( "kalturaAction.class.php" );

class kmc4Action extends kalturaAction
{
	const CURRENT_KMC_VERSION = 4;
	
	private $confs = array();
	
	const SYSTEM_DEFAULT_PARTNER = 0;
	
	private function getPartnersArray($partnerIds)
	{
		$allowed = array();
		$c = new Criteria();
		$c->addAnd(PartnerPeer::ID, $partnerIds, Criteria::IN);
		$c->addAnd(PartnerPeer::STATUS, Partner::PARTNER_STATUS_ACTIVE, Criteria::EQUAL);
		PartnerPeer::setUseCriteriaFilter(false);
		$partners = PartnerPeer::doSelect($c);
		PartnerPeer::setUseCriteriaFilter(true);
		foreach ($partners as $partner)
		{
			if (!in_array($partner->getId(), array(PartnerPeer::GLOBAL_PARTNER, Partner::ADMIN_CONSOLE_PARTNER_ID, Partner::BATCH_PARTNER_ID))) {
				$allowed[] = array('id' => $partner->getId(), 'name' => $partner->getName());
			}
		}
		return $allowed;
	}
	
	public function execute ( ) 
	{
		
		sfView::SUCCESS;

	/** check parameters and verify user is logged-in **/
		$this->partner_id = $this->getP ( "pid" );
		$this->subp_id = $this->getP ( "subpid", ((int)$this->partner_id)*100 );
		$this->uid = $this->getP ( "uid" );
		$this->ks = $this->getP ( "kmcks" );
		if(!$this->ks)
		{
			// if kmcks from cookie doesn't exist, try ks from REQUEST
			$this->ks = $this->getP('ks');
		}
		$this->screen_name = $this->getP ( "screen_name" );
		$this->email = $this->getP ( "email" );

		
		/** if no KS found, redirect to login page **/
		if (!$this->ks)
		{
			$this->redirect( "kmc/kmc" );
			die();
		}
		$ksObj = kSessionUtils::crackKs($this->ks);
		
	/** END - check parameters and verify user is logged-in **/
		
	/** Get array of allowed partners for the current user **/
		$currentUser = kuserPeer::getKuserByPartnerAndUid($this->partner_id, $ksObj->user, true);
		if($currentUser) {
			$this->allowedPartners = $this->getPartnersArray($currentUser->getAllowedPartnerIds());
			$this->full_name = $currentUser->getFullName();
		}

	/** load partner from DB, and set templatePartnerId **/
		$this->partner = $partner = null;
		$this->templatePartnerId = self::SYSTEM_DEFAULT_PARTNER;
		if ($this->partner_id !== NULL)
		{
			$this->partner = $partner = PartnerPeer::retrieveByPK($this->partner_id);
			kmcUtils::redirectPartnerToCorrectKmc($partner, $this->ks, $this->uid, $this->screen_name, $this->email, self::CURRENT_KMC_VERSION);
			$this->templatePartnerId = $this->partner ? $this->partner->getTemplatePartnerId() : self::SYSTEM_DEFAULT_PARTNER;
		}
	/** END - load partner from DB, and set templatePartnerId **/

	/** set default flags **/
		$this->allow_reports = false;
		$this->payingPartner = 'false';
		$this->embed_code  = "";
		$this->enable_live_streaming = 'false';
		$this->kmc_enable_custom_data = 'false';
		$this->kdp508_players = array();
		$this->first_login = false;
		$this->enable_vast = 'false';
	/** END - set default flags **/
	
	/** set values for template **/
	$this->service_url = myPartnerUtils::getHost($this->partner_id);
	$this->host = str_replace ( "http://" , "" , $this->service_url );
	$this->cdn_url = myPartnerUtils::getCdnHost($this->partner_id);
	$this->cdn_host = str_replace ( "http://" , "" , $this->cdn_url );
	$this->rtmp_host = myPartnerUtils::getRtmpUrl($this->partner_id);
	$this->flash_dir = $this->cdn_url . myContentStorage::getFSFlashRootPath ();
	
	// Decide if to hide akamai delivery type
	$this->hideAkamaiHDNetwork = $partner->getDisableAkamaiHDNetwork();
		
	/** set embed_code value **/
		if ( $this->partner_id !== null )
		{
			$widget = widgetPeer::retrieveByPK( "_" . $this->partner_id );
			if ( $widget )
			{
				$this->embed_code = $widget->getWidgetHtml( "kaltura_player" );
				
				$ui_conf = $widget->getuiConf();
			}
		}
	/** END - set embed_code value **/

	/** set payingPartner flag **/
		if($partner && $partner->getPartnerPackage() != PartnerPackages::PARTNER_PACKAGE_FREE)
		{
			$this->payingPartner = 'true';
		}
	/** END - set payingPartner flag **/
		
	/** set enable_live_streaming flag **/
		if(kConf::get('kmc_content_enable_live_streaming') && $partner)
		{
			if ($partner->getLiveStreamEnabled())
			{
				$this->enable_live_streaming = 'true';
			}
		}
	/** END - set enable_live_streaming flag **/

	/** get partner languae **/
		$this->language = null; 
		if ($partner->getKMCLanguage())
			$this->language = $partner->getKMCLanguage();
	/** END - get partner languae **/		
		
	/** set enable_live_streaming flag **/
		if($partner && $partner->getEnableVast())
		{
{'fraction_non_alphanumeric': 0.17998000222197533, 'fraction_numerical': 0.0024441728696811466, 'mean_word_length': 4.227642276422764, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 166, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '978568', 'n_tokens_mistral': 3530, 'n_tokens_neox': 3201, 'n_words': 577}