Ejemplo n.º 1
0
 public function actionSetSessionVar()
 {
     if (isset($_POST['uid'])) {
         $university = new University();
         if (!is_numeric($_POST['uid'])) {
             $max_id = University::model()->find(array('order' => 'did DESC'));
             $university->name = $_POST['uid'];
             $university->did = $max_id->did + 1;
             $university->validate();
             $university->save();
         } else {
             $university->did = $_POST['uid'];
         }
         $_SESSION['uid'] = $university->did;
     }
     if (isset($_POST['did'])) {
         $degree = new Degree();
         if (!is_numeric($_POST['did'])) {
             $max_id = Degree::model()->find(array('order' => 'did DESC'));
             $degree->name = $_POST['did'];
             $degree->did = $max_id->did + 1;
             $degree->university_id = $_SESSION['uid'];
             $degree->validate();
             $degree->save();
         } else {
             $degree->did = $_POST['did'];
         }
         $_SESSION['did'] = $degree->did;
     }
 }
Ejemplo n.º 2
0
 public function actionDialoge()
 {
     $model = new University();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['University'])) {
         $model->attributes = $_POST['University'];
         if ($model->save()) {
             $this->redirect(array('university/sylform', 'id' => $model->uid));
         }
     }
     Yii::app()->clientScript->scriptMap['jquery.js'] = false;
     $this->renderPartial('create', array('model' => $model));
 }
Ejemplo n.º 3
0
 /**
  * Register University
  * 
  * @return View
  */
 public function registerUniversity()
 {
     if (!is_null(Input::get('g-recaptcha-response'))) {
         $recaptcha = new \ReCaptcha\ReCaptcha(Config::get('recaptcha.private_key'));
         $resp = $recaptcha->verify(Input::get('g-recaptcha-response'), Request::server('REMOTE_ADDR'));
         if ($resp->isSuccess()) {
             $user = new User();
             $user->user = trim(strtolower(Input::get('university_email')));
             $user->password = Hash::make(Input::get('university_password'));
             $user->rank = "university";
             $user->last_activity = null;
             try {
                 $user->save();
             } catch (MongoDuplicateKeyException $e) {
                 return Redirect::back()->withErrors(array('error' => Lang::get('register_university.email_duplicated')));
             }
             $user = User::first(['user' => $user->user]);
             $university = new University();
             $university->_id = $user->_id;
             $university->name = trim(Input::get('university_name'));
             $university->email = trim(strtolower(Input::get('university_email')));
             $university->acronym = strtoupper(trim(Input::get('university_acronym')));
             $university->profile_image = null;
             $university->save();
             return Redirect::to('/')->with('message', Lang::get('register_university.register_true'));
         } else {
             $errors = $resp->getErrorCodes();
             return Redirect::back()->withErrors(array('error' => Lang::get('register_student.message_captcha') . ' [' . $errors[0] . ']'));
         }
     } else {
         return Redirect::back()->withErrors(array('error' => Lang::get('register_student.message_captcha') . ' [ 99 ]'));
     }
 }