Example #1
0
 /**
  * @param Vacancy $vacancy
  */
 private function deactivateVacancy(Vacancy $vacancy)
 {
     $vacancy->status = Vacancy::STATUS_CLOSED;
     $vacancy->updated_by = 0;
     $vacancy->hash = md5(microtime(true) . $vacancy->user_id);
     $vacancy->save(false);
 }
Example #2
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');
 }
 /**
  * POST Form for save the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function doSave()
 {
     $validator = Validator::make(Input::all(), Vacancy::$rules);
     if ($validator->passes()) {
         $id = Input::get('id');
         if (isset($id) && $id > 0) {
             $vacancy = Vacancy::find($id);
         } else {
             $vacancy = new Vacancy();
         }
         $vacancy->title = Input::get('title');
         $vacancy->description = Input::get('description');
         $vacancy->category_id = Input::get('category');
         $vacancy->company_id = Input::get('company');
         $vacancy->city_id = Input::get('city');
         $vacancy->user_id = Auth::user()->id;
         $vacancy->save();
         return Redirect::route('vacancy-list')->with('message', 'Vacancy was changed successfully.');
     } else {
         return Redirect::route('vacancy-edit')->with('message', 'The following errors occurred')->withErrors($validator)->withInput();
     }
 }