/** * 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; } }
/** * @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 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(); }
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; }