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