/**
	 * @param String $channelValue
	 */
	private function setChannel($channelValue) {
		$channel = new Pap_Db_Channel();
		$channel->setValue($channelValue);
		$channel->setPapUserId(Gpf_Session::getAuthUser()->getPapUserId());
		try {
			$channel->loadFromData(array(Pap_Db_Table_Channels::VALUE, Pap_Db_Table_Channels::USER_ID));
			$this->banner->setChannel($channel);
		} catch (Gpf_Exception $e) {
		}
	}
    /**
     * @return Gpf_DbEngine_Row
     */
    protected function createEmptyRow(Gpf_Rpc_Params $params) {
        $row = new Pap_Db_Channel();

        $userId = Gpf_Session::getAuthUser()->getPapUserId();

        $row->set(Pap_Db_Table_Channels::USER_ID, $userId);
        $row->set(Pap_Db_Table_Channels::NAME, $this->_("Channel name"));
        $row->set(Pap_Db_Table_Channels::VALUE, $this->generateDefaultValue($userId));
        return $row;
    }
    /**
     * gets channel by channel id
     * @param $channelId
     * @return Pap_Db_Channel
     * @throws Gpf_Exception
     */
    public function getChannelById(Pap_Contexts_Tracking $context, $channelId) {
        if($channelId == '') {
            $this->logAndThrow($context, 'Channel id is empty');
        }
        $user = $context->getUserObject();
        if ($user == null) {
            $this->logAndThrow($context, 'User is not recognized. Channel can not be found');
        }

        if (isset($this->channelsCache[$channelId])) {
            return $this->channelsCache[$channelId];
        }

        $channel = new Pap_Db_Channel();
        $channel->setPrimaryKeyValue($channelId);
        $channel->setPapUserId($user->getId());
        try {
            $channel->loadFromData(array(Pap_Db_Table_Channels::ID, Pap_Db_Table_Channels::USER_ID));
            $context->debug('Channel found: '.$channel->getName());
            $this->channelsCache[$channelId] = $channel;
            return $channel;
        } catch (Gpf_DbEngine_NoRowException $e) {
            $channel->setValue($channelId);
            $channel->loadFromData(array(Pap_Db_Table_Channels::VALUE, Pap_Db_Table_Channels::USER_ID));
            $this->channelsCache[$channelId] = $channel;
            return $channel;
        }
    }
Example #4
0
 /**
  * @return Pap_Db_Channel
  * @throws Gpf_Exception
  */
 public static function loadFromId($channelId, $userId) {
     $channel = new Pap_Db_Channel();
     $channel->setPrimaryKeyValue($channelId);
     $channel->setPapUserId($userId);
     try {
         $channel->loadFromData(array(Pap_Db_Table_Channels::ID, Pap_Db_Table_Channels::USER_ID));
         return $channel;
     } catch (Gpf_DbEngine_NoRowException $e) {
         $channel->setValue($channelId);
         $channel->loadFromData(array(Pap_Db_Table_Channels::VALUE, Pap_Db_Table_Channels::USER_ID));
         return $channel;
     }
 }
 private function createSampleChannel() {
     $channel = new Pap_Db_Channel();
     $channel->setId('11111111');
     $channel->setPapUserId('11111111');
     $channel->setName('Sample advertising channel');
     $channel->setValue('testchnl');
     $channel->save();
 }
 /**
  *
  * @service banner read
  * @param $fields
  */
 public function download(Gpf_Rpc_Params $params){
     $form = new Gpf_Rpc_Form($params);
     $fileid = $form->getFieldValue('fileid');
     $affiliateid = $form->getFieldValue('affiliateid');
     $bannerid = $form->getFieldValue('bannerid');
     $filetypes = $form->getFieldValue('filetypes');
    
     $affiliate = $this->loadAffiliate($affiliateid);
     $banner = $this->loadBanner($bannerid);
     try {
         $channelcode = $form->getFieldValue('channelcode');
         $banner->setChannel(Pap_Db_Channel::loadFromId($channelcode, $affiliate->getId()));
     } catch (Gpf_Exception $e) {
         $channelcode = null;
     }
     
     $unpackedZipFolderPath = $this->getZipFolderUrl() . $fileid;
     $cacheZipFolderPath = $this->getCahcheFolderUrl() . $bannerid . '_' . $affiliateid . '_' . $fileid;
     
     $this->copyFilesToCacheZipFolder($unpackedZipFolderPath, $cacheZipFolderPath);
     
     $this->replaceTemplatesInDirectory($cacheZipFolderPath, $filetypes, $affiliate, $banner, $channelcode);
     
     $archiveName = $this->packBanner($this->getCahcheFolderUrl(),$cacheZipFolderPath , $affiliate, $this->getFileName($fileid));
     
     $download = new Gpf_File_Download_FileSystem($archiveName);
     $download->setAttachment(true);
     return $download;
 }
 private function findChannel($channelId) {
 	$channel = new Pap_Db_Channel();
 	$channel->setPrimaryKeyValue($channelId);
 	$channel->set(Pap_Db_Table_Channels::USER_ID, Gpf_Session::getAuthUser()->getPapUserId());
 	try {
 		$channel->loadFromData(array('channelid', 'userid'));
 		return $channel;
 	} catch(Gpf_Exception $e) {
 	}
 	
 	return null;
 }
Example #8
0
 private function setBannerChannel(Pap_Common_Banner $banner, $channel) {
     $dbChannel = new Pap_Db_Channel();
     $dbChannel->set(Pap_Db_Table_Channels::VALUE, $channel);
     try {
         $dbChannel->loadFromData(array(Pap_Db_Table_Channels::VALUE));
         $banner->setChannel($dbChannel);
     } catch (Exception $e) {
     }
 }
Example #9
0
 protected function getChannelId(){
     if($this->channel != null){
         return $this->channel->getValue();
     }
     return null;
 }
 private function processChannel(Gpf_Rpc_Params $params) {
     $fields = $params->get("fields");
     $channelCode = $this->getField($fields, 'channel');
     $user = $this->getField($fields, 'userid');
     $channel = new Pap_Db_Channel();
     $channel->setValue($channelCode);
     $channel->setPapUserId($user);
     try {
         $channel->loadFromData(array(Pap_Db_Table_Channels::VALUE, Pap_Db_Table_Channels::USER_ID));
     } catch (Gpf_Exception $e) {
         Gpf_Log::error('Unable to load channel from channel code during manual saving transaction');
         return $params;
     }
     $fields = $this->setField($fields, 'channel', $channel->get(Pap_Db_Table_Channels::ID));
     $params->set('fields', $fields);
     return $params;
 }
 /**
  * @return Pap_Db_Channel
  */
 protected function getChannelById($channelId) {
     $channel = new Pap_Db_Channel();
     $channel->setId($channelId);
     try {
         $channel->load();
         return $channel;
     } catch (Gpf_Exception $e) {
         return null;
     }
 }