/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new FingerprintBan(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['FingerprintBan'])) { $model->attributes = $_POST['FingerprintBan']; if ($model->save()) { $this->redirect(array('view', 'id' => $model->id)); } } $this->render('create', array('model' => $model)); }
public function actionSetFingerprintBad() { if (empty($_POST)) { $this->redirect(Yii::app()->request->urlReferrer); } $fb = new FingerprintBan(); $fb->attributes = $_POST['FingerprintBan']; if (isset($_POST['delete'])) { $cnt = FingerprintBan::model()->deleteAllByAttributes(array('type' => $fb->type, 'value' => $fb->value)); if ($cnt) { Yii::app()->user->setFlash('success', Yii::t('test', 'Удалена {n} запись| Удалено {n} записи | Удалено {n} записей', $cnt)); } else { Yii::app()->user->setFlash('error', "Подходящих записей не найдено"); } $this->redirect(Yii::app()->request->urlReferrer); } $fb->time_start = time(); if (isset($_POST['ban'])) { $fb->status_bad = Anketa::BAD_STATUS_BAN; } else { if (isset($_POST['clone'])) { $fb->status_bad = Anketa::BAD_STATUS_CLONE; } else { die('NO VALID STATUS'); } } if ($fb->save()) { $txt = $fb->status_bad == Anketa::BAD_STATUS_BAN ? ' Бан ' : ' Клон '; $txt .= $fb->isNewRecord ? ' добавлен ' : ' обновлен '; Yii::app()->user->setFlash('success', $txt); } else { $txt = ''; foreach ($fb->getErrors() as $error) { $txt .= print_r($error, true) . '<br>'; } Yii::app()->user->setFlash('error', $txt); } $this->redirect(Yii::app()->request->urlReferrer); }