public function executeShow(sfWebRequest $request) { $this->forward404Unless($this->inbox = Doctrine::getTable('Inbox')->find(array($request->getParameter('id'))), sprintf('Object inbox does not exist (%s).', $request->getParameter('id'))); $this->comments = Comment::getFor($this->inbox); $this->form = new CommentInboxForm(); $this->form->setCommented($this->inbox); $this->form->setDefault('noVote', 1); $this->inboxed = Doctrine_Query::create()->select()->from('sfGuardUserProfile p')->leftJoin('p.Inboxed i')->where('i.inbox_id = ?', $this->inbox->getId())->execute(); $this->csrf = CSRF::getToken(); }
public function executeMy(sfWebRequest $request) { $this->csrf = CSRF::getToken(); $this->locations = $this->getUser()->getProfile()->getLocation(); }
public function executeShow(sfWebRequest $request) { $this->profile = Doctrine::getTable('sfGuardUserProfile')->createQuery("p")->leftJoin('p.VoteProfile')->leftJoin('p.User')->where('p.id = ?', $request->getParameter('id'))->execute()->getFirst(); $this->forward404Unless($this->profile); $this->view = $request->getParameter('view'); if (!in_array($this->view, array('comments', 'profits', 'locations'))) { $this->view = 'profile'; } //@todo: join commmented objects $this->comments = Doctrine_Query::create()->from('Comment c')->leftJoin('c.VoteComment')->where('c.created_by = ? and c.parent > 0', $this->profile->getId())->andWhere('c.inbox_id is null')->orderBy('c.created_at desc'); $this->comments = Doctrine::getTable('Comment')->filterScope($this->comments, $this->getUser())->execute(); $this->profits = Doctrine_Query::create()->from('Profit p')->leftJoin('p.ProfitDetail d')->leftJoin('p.Location l')->leftJoin('d.Fish f')->leftJoin('d.Style s')->leftJoin('p.CommentProfit')->leftJoin('p.VoteProfit')->andWhere('p.created_by = ?', $this->profile->getId())->orderBy('p.created_at desc'); $this->profits = Doctrine::getTable('Location')->filterScope($this->profits, $this->getUser())->execute(); $this->locations = Doctrine::getTable('Location')->getVisibleLocationsQuery($this->getUser())->leftJoin('l.VoteLocation v')->leftJoin('l.CommentLocation c')->andWhere('l.created_by = ?', $this->profile->getId())->orderBy('l.created_at desc')->execute(); //@todo: add events $this->total = 0; $this->best = array('name' => 'фигавль', 'qty' => 0, 'location' => null); foreach ($this->profits as $profit) { if ($this->best['qty'] < $profit->getWeight()) { $this->best['qty'] = $profit->getWeight(); $this->best['name'] = $profit->getFish(); $this->best['location'] = $profit->getLocation(); } foreach ($profit->getProfitDetail() as $pd) { $this->total += $pd->getQty(); } } $this->csrf = CSRF::getToken(); }