Example #1
0
 /**
  * Displays a particular model.
  * @param integer $id the ID of the model to be displayed
  */
 public function actionView($id, $replyId = null, $latest = null)
 {
     $page = null;
     $model = $this->loadModel($id);
     if (!is_null($latest) && !Yii::app()->request->isAjaxRequest) {
         $replyId = $model->lastPost->id;
     }
     if (!is_null($replyId) && !Yii::app()->request->isAjaxRequest) {
         $post = TopicReplies::model()->findByPk($replyId);
         if (!is_null($post)) {
             $page = $post->getTopicPage();
         } else {
             $replyId = null;
         }
     }
     $this->noBackdrop = true;
     $topicReply = new TopicReplies();
     if (!isset($_GET['ajax'])) {
         $log = new ViewLog();
         $log->user = Yii::app()->user->getName();
         $log->recordType = get_class($model);
         $log->recordId = $model->id;
         $log->timestamp = time();
         $log->save();
         X2Flow::trigger('RecordViewTrigger', array('model' => $model));
     }
     $dataProvider = new CArrayDataProvider($model->replies, array('id' => 'topic-replies', 'pagination' => array('pageSize' => Topics::PAGE_SIZE)));
     $dataProvider->getPagination()->setItemCount($dataProvider->getTotalItemCount());
     if (!Yii::app()->request->isAjaxRequest && !is_null($page)) {
         $dataProvider->getPagination()->setCurrentPage($page);
     }
     $this->render('view', array('model' => $model, 'replyId' => $replyId, 'dataProvider' => $dataProvider, 'topicReply' => $topicReply, 'page' => is_null($page) ? $dataProvider->getPagination()->getCurrentPage() : $page));
 }
Example #2
0
 /**
  * Displays a particular model.
  *
  * This method is called in child controllers
  * which pass it a model to display and what type of model it is (i.e. Contact,
  * Opportunity, Account).  It also creates an action history and provides appropriate
  * variables to the view.
  *
  * @param mixed $model The model to be displayed (subclass of {@link CActiveRecord} or {@link X2Model}
  * @param String $type The type of the module being displayed
  */
 public function view(&$model, $type = null, $params = array())
 {
     $this->noBackdrop = true;
     // should only happen when the model is known to have X2LinkableBehavior
     if ($type === null) {
         // && $model->asa('X2LinkableBehavior') !== null)
         $type = $model->module;
     }
     if (!isset($_GET['ajax'])) {
         $log = new ViewLog();
         $log->user = Yii::app()->user->getName();
         $log->recordType = get_class($model);
         $log->recordId = $model->id;
         $log->timestamp = time();
         $log->save();
         X2Flow::trigger('RecordViewTrigger', array('model' => $model));
     }
     $this->render('view', array_merge($params, array('model' => $model, 'actionHistory' => $this->getHistory($model, $type), 'currentWorkflow' => $this->getCurrentWorkflow($model->id, $type))));
 }