/** * approve a comment - so set its status to 1 **/ public function approve() { $comment = new CmsComment(Request::get("id")); if ($comment->update_attributes(array("status" => 1))) { Session::add_message("Comment approved"); } $this->redirect_to(array("action" => "index")); }
public function actionDelete($id) { $model = CmsComment::model()->findByPk($id); if (Yii::app()->user->id == $model->user_id) { if (CmsComment::model()->deleteByPk($id)) { $this->redirect(array('/page/view', 'id' => $model->page_id)); } } }
public function actionDeleteComment() { if ($id = Yii::app()->request->getParam('id')) { if ($id == Yii::app()->user->id) { return $this->sendResponse(self::STATUS_OK, CmsComment::model()->deleteByPk($id)); } } else { return $this->sendResponse(self::STATUS_INTERNAL_SERVER_ERROR, "Запись не удалена"); } }
public function addComment(CmsComment $comment) { $this->comments[] = $comment; $comment->setArticle($this); }
?> </div> <hr/> </div> </div> <div class="row"> <div class="thumbnail textCom"> <?php echo CmsComment::model()->countByAttributes(array('page_id' => $model->id, 'status' => 1)); ?> коментариев <?php $flag = CmsSetting::model()->findByPk(1); if (!Yii::app()->user->isGuest || Yii::app()->user->isGuest && $flag->gost_com) { ?> <a class="linkCom" id="linkComId"><i class="fa fa-pencil-square-o"> Оставить Комментарий</i></a> <?php } ?> </div> </div> <?php if ($model->status != 0 && $model->status != 1) {
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer $id the ID of the model to be loaded * @return CmsComment the loaded model * @throws CHttpException */ public function loadModel($id) { $model = CmsComment::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
<div id="graph" style="display: none"> <?php $this->Widget('ext.graph.highcharts.HighchartsWidget', array('options' => array('title' => array('text' => 'График активности пользователя'), 'xAxis' => array('categories' => array('Январь', 'Февраль', 'Март', 'Апрель', 'Май', 'Июнь', 'Июль', 'Август', 'Сентябрь', 'Октябрь', 'Ноябрь', 'Декабырь')), 'yAxis' => array('title' => array('text' => 'Количество статей')), 'series' => array(array('name' => $model->username, 'data' => CmsSetting::ar_kol($id)))))); ?> </div> <div id="MyPage"> <?php if (Yii::app()->user->id == $id) { $a = array('created', 'status'); } else { $a = array('created'); } $this->widget('zii.widgets.CListView', array('dataProvider' => CmsPage::MyPages($id), 'itemView' => '_view_pages', 'emptyText' => 'В данной категории нет статей', 'sorterHeader' => 'Сортировать по :', 'sortableAttributes' => $a)); ?> </div> <div id="MyComment"> <?php $this->widget('zii.widgets.CListView', array('dataProvider' => CmsComment::MyComments($id), 'itemView' => '_view_comments', 'emptyText' => 'В данной категории нет статей', 'sorterHeader' => 'Сортировать по :', 'template' => '{items}{pager}', 'sortableAttributes' => array('created', 'page_id'))); ?> </div> <br> <br> <br>
<span> <?php switch ($data->user->role) { case 1: echo CHtml::link($data->user->username, array('UserPersonal/index', 'id' => $data->user->id)); break; case 2: echo CHtml::link('Модератор', array('UserPersonal/index', 'id' => $data->user->id)); break; case 3: echo CHtml::link(CHtml::openTag('i', array('class' => 'fa fa-user')) . ' ' . ' ' . 'Администратор' . '</i>', array('UserPersonal/index', 'id' => $data->user->id)); break; } ?> / <?php echo CHtml::link(CHtml::openTag('i', array('class' => 'fa fa-calendar')) . ' ' . ' ' . date('j F Y', $data->created) . '</i>', array('page/PageCriteria', 'data' => date('Y-m-j', $data->created))); ?> / <?php echo CHtml::link(CHtml::openTag('i', array('class' => 'fa fa-comment')) . ' ' . CmsComment::model()->countByAttributes(array('page_id' => $data->id)) . ' ' . "Комментариев" . '</i>', array('page/view', 'id' => $data->id)); ?> </span> </div> </div> </div>