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