예제 #1
0
 public function actionAdd($isFancy = 0)
 {
     $model = new Vacancy();
     if (isset($_POST[$this->modelName]) && BlockIp::checkAllowIp(Yii::app()->controller->currentUserIpLong)) {
         $model->attributes = $_POST[$this->modelName];
         if ($model->validate()) {
             $model->user_ip = Yii::app()->controller->currentUserIp;
             $model->user_ip_ip2_long = Yii::app()->controller->currentUserIpLong;
             if ($model->save(false)) {
                 $model->name = CHtml::encode($model->name);
                 $model->body = CHtml::encode($model->body);
                 $notifier = new Notifier();
                 $notifier->raiseEvent('onNewReview', $model);
                 if (Yii::app()->user->checkAccess('vacancy_admin')) {
                     Yii::app()->user->setFlash('success', tt('success_send_not_moderation'));
                 } else {
                     Yii::app()->user->setFlash('success', tt('success_send'));
                 }
                 $this->redirect(array('index'));
             }
             $model->unsetAttributes(array('name', 'body', 'verifyCode'));
         } else {
             Yii::app()->user->setFlash('error', tt('failed_send'));
         }
         $model->unsetAttributes(array('verifyCode'));
     }
     if ($isFancy) {
         $this->excludeJs();
         $this->renderPartial('add', array('model' => $model), false, true);
     } else {
         $this->render('add', array('model' => $model));
     }
 }
 public function add()
 {
     if (!empty($_POST)) {
         $obj = new Vacancy();
         $data = Input::only(array('email', 'title', 'text'));
         $validation = $obj->validate($data);
         if ($validation->fails()) {
             return Redirect::refresh()->with('message', array('text' => $validation->errors()->first()))->withInput($data);
         } else {
             $obj->fill($data);
             //				$obj->active = 1;
             $obj->save();
             return Redirect::refresh()->with('message', array('text' => 'Вакансия успешно добавлена'));
         }
     }
     return View::make('vacancies.form');
 }