/**
  * 批量操作
  *
  */
 public function actionBatch()
 {
     if ($this->method() == 'GET') {
         $command = trim($_GET['command']);
         $ids = intval($_GET['id']);
     } else {
         if ($this->method() == 'POST') {
             $command = trim($_POST['command']);
             $ids = $_POST['id'];
         } else {
             $this->message('errorBack', Yii::t('admin', 'Only POST Or GET'));
         }
     }
     empty($ids) && $this->message('error', Yii::t('admin', 'No Select'));
     switch ($command) {
         case 'Delete':
             //删除邮件
             foreach ((array) $ids as $id) {
                 $maillogModel = MailLog::model()->findByPk($id);
                 if ($maillogModel) {
                     $maillogModel->delete();
                 }
             }
             break;
         default:
             throw new CHttpException(404, Yii::t('admin', 'Error Operation'));
             break;
     }
     $this->message('success', Yii::t('admin', 'Batch Operate Success'), $this->createUrl('index'));
 }
 /**
  * 判断数据是否存在
  * 
  * return \$this->model
  */
 public function loadModel()
 {
     if ($this->model === null) {
         if (isset($_GET['id'])) {
             $this->model = MailLog::model()->findbyPk($_GET['id']);
         }
         if ($this->model === null) {
             throw new CHttpException(404, Yii::t('common', 'The requested page does not exist.'));
         }
     }
     return $this->model;
 }
Beispiel #3
0
 public function run()
 {
     $ids = Yii::app()->request->getParam('id');
     $command = Yii::app()->request->getParam('command');
     empty($ids) && $this->controller->message('error', Yii::t('admin', 'No Select'));
     if (!is_array($ids)) {
         $ids = array($ids);
     }
     $criteria = new CDbCriteria();
     $criteria->addInCondition('id', $ids);
     switch ($command) {
         case 'delete':
             //删除
             MailLog::model()->deleteAll($criteria);
             break;
         default:
             $this->controller->message('error', Yii::t('admin', 'Error Operation'));
     }
     $this->controller->message('success', Yii::t('admin', 'Batch Operate Success'));
 }