Example #1
0
 public function actionEmployerRegister()
 {
     $model = new User();
     // uncomment the following code to enable ajax-based validation
     /*
      if(isset($_POST['ajax']) && $_POST['ajax']==='user-EmployerRegister-form')
      {
     echo CActiveForm::validate($model);
     Yii::app()->end();
     }
     */
     if (isset($_POST['User'])) {
         $model->attributes = $_POST['User'];
         //print "<pre>";print_r($model);print "</pre>";return;
         if ($model->validate()) {
             if ($this->actionVerifyEmployerRegistration() != "") {
                 $this->render('EmployerRegister');
             }
             //Form inputs are valid
             //Populate user attributes
             $model->FK_usertype = 2;
             $model->registration_date = new CDbExpression('NOW()');
             $model->activation_string = $this->genRandomString(10);
             $model->image_url = '/JobFair/images/profileimages/user-default.png';
             //Hash the password before storing it into the database
             $hasher = new PasswordHash(8, false);
             $model->password = $hasher->HashPassword($model->password);
             //Save user into database. Account still needs to be activated
             //save employers company info
             if ($model->save($runValidation = false)) {
                 $companyInfo = new CompanyInfo();
                 $companyInfo->attributes = $_POST['CompanyInfo'];
                 $companyInfo->description = $this->mynl2br($_POST['CompanyInfo']['description']);
                 $companyInfo->FK_userid = $model->id;
                 $companyInfo->save($runValidation = false);
                 $basicInfo = new BasicInfo();
                 $basicInfo->attributes = $_POST['BasicInfo'];
                 $basicInfo->about_me = $this->mynl2br($_POST['BasicInfo']['about_me']);
                 $basicInfo->userid = $model->id;
                 $basicInfo->city = $companyInfo->city;
                 $basicInfo->state = $companyInfo->state;
                 $basicInfo->save(false);
             }
             $link = 'http://' . Yii::app()->request->getServerName() . '/JobFair/index.php/profile/employer/user/' . $model->username;
             $link2 = 'http://' . Yii::app()->request->getServerName() . '/JobFair/index.php/profile/employer/user/' . $model->username;
             $message = $model->username . " just joined VJF, click here to view their profile.";
             User::sendAllStudentVerificationAlart($model->id, $model->username, $model->email, $message, $link);
             $message1 = "There is a new employer named " . $model->username . " that is waiting for acctivation";
             $admins = User::model()->findAllByAttributes(array('FK_usertype' => 3));
             User::sendAdminNotificationNewEmpolyer($model, $admins, $link2, $message1);
             $message = "You have successfully registered. Once your account has been approved, you will receive an email stating your account is active.";
             $message .= "<br/>Your username: {$model->username}";
             User::sendEmail($model->email, "Registration Notification", "Registration Notification", $message);
             $this->render('NewEmployer');
             return;
         }
     }
     $this->render('EmployerRegister', array('model' => $model));
 }
Example #2
0
 public function actionPost()
 {
     $model = new Job();
     if (isset($_POST['Job'])) {
         if (!($this->actionVerifyJobPost() == "")) {
             $this->render('post', array('model' => $model));
         }
         $model->attributes = $_POST['Job'];
         $model->FK_poster = User::getCurrentUser()->id;
         date_default_timezone_set('America/New_York');
         $model->comp_name = CompanyInfo::getCompanyNamesUser(User::getCurrentUser()->id);
         $model->post_date = date('Y-m-d H:i:s');
         $model->description = $this->mynl2br($_POST['Job']['description']);
         $model->save(false);
         if (isset($_POST['Skill'])) {
             $this->actionSaveSkills($model->id);
         }
         $link = 'http://' . Yii::app()->request->getServerName() . '/JobFair/index.php/job/view/jobid/' . $model->id;
         //$link = 'http://localhost/JobFair/JobFair/index.php/job/view/jobid/'.$model->id;
         $message = User::getCurrentUser()->username . " just posted a new job: " . $model->title . ". Click here to view the post. ";
         User::sendAllStudentVerificationAlart($model->FK_poster, $model->fKPoster->username, $model->fKPoster->email, $message, $link);
         $this->redirect("/JobFair/index.php/Job/studentmatch/jobid/" . $model->id);
     }
     $this->render('post', array('model' => $model));
 }