public function actionUpdateStatus() { $ids = Yii::app()->request->getPost('ids'); $status = Yii::app()->request->getPost('status'); $models = Follow::model()->findAllByPk($ids); if(!array_key_exists($status, Follow::getStatuses())) throw new CHttpException(404, FollowModule::t('Ошибка')); if(!empty($models)) { foreach ($models as $follow) { $follow->status = $status; $follow->save(); } } echo FollowModule::t('Status changed successfully'); }
<?php /** * Create/update follow * * @var $model Follow */ $title = FollowModule::t('Edit followers'); $this->breadcrumbs = array( 'Home'=>$this->createUrl('/admin'), FollowModule::t('Followers')=>$this->createUrl('index'), CHtml::encode($model->email), ); $this->pageHeader = $title; ?> <div class="form wide padding-all"> <?php echo $form; ?> </div>
<?php echo $form->error($follow,'email'); ?> </div> <?php endif; ?> <div class="row"> <?php echo $form->labelEx($follow,'text'); ?> <?php echo $form->textArea($follow,'text', array('rows'=>5)); ?> <?php echo $form->error($follow,'text'); ?> </div> <?php if(Yii::app()->user->isGuest): ?> <div class="row"> <?php echo CHtml::activeLabelEx($follow, 'verifyCode')?> <?php $this->widget('CCaptcha', array( 'clickableImage'=>true, 'showRefreshButton'=>false, )) ?> <br/> <label> </label> <?php echo CHtml::activeTextField($follow, 'verifyCode')?> <?php echo $form->error($follow,'verifyCode'); ?> </div> <?php endif ?> <div class="row buttons"> <?php echo CHtml::submitButton(FollowModule::t('Send')); ?> </div> <?php $this->endWidget(); ?><!-- /form --> </div> </div>
array( 'label'=>FollowModule::t('Confirmed'), 'url'=>'#', 'linkOptions'=>array( 'onClick'=>'return setFollowStatus(1, this);', ) ), array( 'label'=>FollowModule::t('Waiting for approval'), 'url'=>'#', 'linkOptions'=>array( 'onClick'=>'return setFollowStatus(0, this);', ) ), array( 'label'=>FollowModule::t('Spam'), 'url'=>'#', 'linkOptions'=>array( 'onClick'=>'return setFollowStatus(2, this);', ) ), ), 'columns' => array( array( 'class'=>'CCheckBoxColumn', ), array( 'class'=>'SGridIdColumn', 'name'=>'id', ), array(
/** * @static * @return array */ public static function getStatuses() { return array( self::STATUS_WAITING => FollowModule::t('Waiting for approval'), self::STATUS_APPROVED => FollowModule::t('Confirmed'), self::STATUS_SPAM => FollowModule::t('Spam'), ); }