/**
  * View specific discussion
  *
  * @param void
  * @return null
  */
 function view()
 {
     if ($this->active_discussion->isNew()) {
         $this->httpError(HTTP_ERR_NOT_FOUND);
     }
     // if
     if (!$this->active_discussion->canView($this->logged_user)) {
         $this->httpError(HTTP_ERR_FORBIDDEN);
     }
     // if
     if ($this->active_discussion->getIsPinned()) {
         $this->wireframe->addPageMessage(lang('<strong>Pinned</strong> - This discussion is pinned'), 'pinned');
     }
     // if
     if ($this->request->isApiCall()) {
         $this->serveData($this->active_discussion, 'discussion', array('describe_comments' => true));
     } else {
         ProjectObjectViews::log($this->active_discussion, $this->logged_user);
         $parent = $this->active_discussion->getParent();
         if (instance_of($parent, 'Category')) {
             $this->active_category = $parent;
             $this->smarty->assign('active_category', $parent);
         }
         // if
         $page = (int) $this->request->get('page');
         if ($page < 1) {
             $page = 1;
         }
         // if
         list($comments, $pagination) = $this->active_discussion->paginateComments($page, $this->active_discussion->comments_per_page, $this->logged_user->getVisibility());
         $this->smarty->assign(array('category' => $this->active_discussion->getParent(), 'comments' => $comments, 'pagination' => $pagination, 'counter' => ($page - 1) * $this->active_discussion->comments_per_page, 'subscribers' => $this->active_discussion->getSubscribers(), 'object_id' => $this->active_discussion->getId()));
     }
     // if
 }
예제 #2
0
 /**
  * Adds an object to the instance pool.
  *
  * Propel keeps cached copies of objects in an instance pool when they are retrieved
  * from the database.  In some cases -- especially when you override doSelect*()
  * methods in your stub classes -- you may need to explicitly add objects
  * to the cache in order to ensure that the same objects are always returned by doSelect*()
  * and retrieveByPK*() calls.
  *
  * @param      Discussion $value A Discussion object.
  * @param      string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
  */
 public static function addInstanceToPool(Discussion $obj, $key = null)
 {
     if (Propel::isInstancePoolingEnabled()) {
         if ($key === null) {
             $key = (string) $obj->getId();
         }
         // if key === null
         self::$instances[$key] = $obj;
     }
 }