public function actionUpdateStatus() { $ids = Yii::app()->request->getPost('ids'); $status = Yii::app()->request->getPost('status'); $models = Comment::model()->findAllByPk($ids); if (!array_key_exists($status, Comment::getStatuses())) { throw new CHttpException(404, Yii::t('CommentsModule.admin', 'Ошибка проверки статуса.')); } if (!empty($models)) { foreach ($models as $comment) { $comment->status = $status; $comment->save(); } } echo Yii::t('CommentsModule', 'Статус успешно изменен'); }
<div class="col-md-11 col-sm-10"> <?php echo $form->textArea($model, 'text', array( 'class'=>'form-control', 'rows'=>5, 'placeholder'=>'Отзыв' )); ?> </div> </div> <!-- / .form-group --> <div class="form-group"> <?php echo $form->label($model, 'status', array('class'=>'col-md-1 col-sm-2 control-label')); ?> <div class="col-md-11 col-sm-10"> <?php echo $form->dropDownList($model, 'status', Comment::getStatuses(), array( 'encode'=>false, // 'empty'=>'Выбрать', 'class'=>'form-control', )); ?> </div> </div> <div style="margin-bottom: 0;" class="form-group"> <div class="col-md-offset-1 col-md-11 col-sm-offset-2 col-sm-10"> <button class="btn btn-primary" type="submit"><?php echo $model->isNewRecord ? 'Создать' : 'Сохранить'; ?></button>
<?php /** * Product comments * * @var $model StoreProduct */ Yii::import('comments.models.Comment'); $module = Yii::app()->getModule('comments'); $comments = new Comment('search'); if (!empty($_GET['Comment'])) { $comments->attributes = $_GET['Comment']; } $comments->class_name = 'application.modules.store.models.StoreProduct'; $comments->object_pk = $model->id; // Fix sort url $dataProvider = $comments->search(); $dataProvider->pagination->pageSize = Yii::app()->settings->get('core', 'productsPerPageAdmin'); $dataProvider->sort->route = 'applyCommentsFilter'; $dataProvider->pagination->route = 'applyCommentsFilter'; $this->widget('ext.sgridview.SGridView', array('dataProvider' => $dataProvider, 'id' => 'productCommentsListGrid', 'filter' => $comments, 'ajaxUrl' => Yii::app()->createUrl('/store/admin/products/applyCommentsFilter', array('id' => $model->id)), 'enableHistory' => false, 'columns' => array(array('class' => 'CCheckBoxColumn'), array('class' => 'SGridIdColumn', 'name' => 'id'), array('name' => 'name', 'type' => 'raw', 'value' => 'CHtml::link(CHtml::encode($data->name), array("/comments/admin/comments/update", "id"=>$data->id))'), array('name' => 'email'), array('name' => 'text', 'value' => 'Comment::truncate($data, 100)'), array('name' => 'status', 'filter' => Comment::getStatuses(), 'value' => '$data->statusTitle'), array('name' => 'created'), array('class' => 'CButtonColumn', 'updateButtonUrl' => 'Yii::app()->createUrl("/comments/admin/comments/update", array("id"=>$data->id))', 'deleteButtonUrl' => 'Yii::app()->createUrl("/comments/admin/comments/delete", array("id"=>$data->id))', 'template' => '{update}{delete}'))));
/* array( 'name' => 'name', 'type' => 'raw', 'value' => 'CHtml::link(CHtml::encode($data->name), array("update", "id"=>$data->id))', ), array( 'name'=>'email', ), */ array( 'header' => 'Отзыв', 'name'=>'text', // 'value'=>'Comment::truncate($data, 100)' ), array( 'name'=>'status', 'filter'=>Comment::getStatuses(), 'value'=>'$data->statusTitle', ), array( 'header' => 'Объект', 'type'=>'raw', 'value'=>'CHtml::link($data->getOwner_title(), $data->getViewUrlAdmin(), array("target"=>"_blank"))', 'filter'=>false ), array( 'header' => 'Дата', 'name'=>'created', 'filter'=>false
<?php /** * Display comments list * * @var $model Comment **/ Yii::app()->clientScript->registerScriptFile($this->module->assetsUrl . '/admin/comments.index.js'); $this->pageHeader = Yii::t('CommentsModule.core', 'Комментарии'); $this->breadcrumbs = array('Home' => $this->createUrl('/admin'), Yii::t('CommentsModule.core', 'Комментарии')); $this->widget('ext.sgridview.SGridView', array('dataProvider' => $dataProvider, 'id' => 'commentsListGrid', 'filter' => $model, 'customActions' => array(array('label' => Yii::t('CommentsModule.core', 'Подтвержден'), 'url' => '#', 'linkOptions' => array('onClick' => 'return setCommentsStatus(1, this);')), array('label' => Yii::t('CommentsModule.core', 'Ждет одобрения'), 'url' => '#', 'linkOptions' => array('onClick' => 'return setCommentsStatus(0, this);')), array('label' => Yii::t('CommentsModule.core', 'Спам'), 'url' => '#', 'linkOptions' => array('onClick' => 'return setCommentsStatus(2, this);'))), 'columns' => array(array('class' => 'CCheckBoxColumn'), array('class' => 'SGridIdColumn', 'name' => 'id'), array('name' => 'name', 'type' => 'raw', 'value' => 'CHtml::link(CHtml::encode($data->name), array("update", "id"=>$data->id))'), array('name' => 'email'), array('name' => 'text', 'value' => 'Comment::truncate($data, 100)'), array('name' => 'status', 'filter' => Comment::getStatuses(), 'value' => '$data->statusTitle'), array('name' => 'owner_title', 'filter' => false), 'ip_address', array('name' => 'created'), array('class' => 'CButtonColumn', 'template' => '{update}{delete}'))));
<?php /** * Comment form */ Yii::import('zii.widgets.jui.CJuiDatePicker'); return array('id' => 'commentUpdateForm', 'elements' => array('tab1' => array('type' => 'form', 'title' => '', 'elements' => array('status' => array('type' => 'dropdownlist', 'items' => Comment::getStatuses()), 'name' => array('type' => 'text'), 'email' => array('type' => 'text'), 'text' => array('type' => 'textarea', 'style' => 'height:200px'), 'created' => array('type' => 'CJuiDatePicker', 'options' => array('dateFormat' => 'yy-mm-dd ' . date('H:i:s'))), 'updated' => array('type' => 'CJuiDatePicker', 'options' => array('dateFormat' => 'yy-mm-dd ' . date('H:i:s')))))));