Example #1
0
 public function actionSend($username = null, $reply = null, $selfReply = null)
 {
     $user = new User();
     $model = new Message();
     $message = null;
     $users = array();
     $models = User::model()->findAll(array('condition' => 'FK_usertype = 1'));
     foreach ($models as $aUser) {
         $users[] = array('label' => CHtml::image($aUser->image_url, '', array('width' => '20px')) . '  ' . $aUser->first_name . ' ' . $aUser->last_name, 'value' => "\"" . $aUser->first_name . " " . $aUser->last_name . "\" <" . $aUser->username . ">");
     }
     if (isset($_POST['Message'])) {
         $model->attributes = $_POST['Message'];
         $model->FK_sender = Yii::app()->user->name;
         date_default_timezone_set('America/New_York');
         $model->date = date('Y-m-d H:i:s');
         $model->userImage = $model->fKSender->image_url;
         $model->subject = $_POST['Message']['subject'];
         $receivers = $this->getReceivers($_POST["receiver"]);
         $receiverCount = count($receivers);
         for ($i = 0; $i < $receiverCount; $i++) {
             $model->FK_receiver = $receivers[$i];
             if (User::model()->find("username=:username", array(':username' => $model->FK_receiver)) != null) {
                 $model->save();
             }
             $model = new Message();
             $model->attributes = $_POST['Message'];
             $model->FK_sender = Yii::app()->user->name;
             $model->date = date('Y-m-d H:i:s');
             $model->userImage = $model->fKSender->image_url;
             $model->subject = $_POST['Message']['subject'];
         }
         User::sendUserNotificationMessageAlart(Yii::app()->user->id, $model->FK_receiver, 'http://' . Yii::app()->request->getServerName() . '/JobFair/index.php/message', 3);
         $link = CHtml::link('here', 'http://' . Yii::app()->request->getServerName() . '/JobFair/index.php/message');
         $recive = User::model()->find("username=:username", array(':username' => $model->FK_receiver));
         if ($recive != NULL) {
             $message = "You just got a message from {$model->FK_sender}<br/> '{$model->message}'<br/> Access the message {$link}";
             //$html = User::replaceMessage($recive->username, $message);
             User::sendEmail($recive->email, "Virtual Job Fair Message", "Message from Virtual Job Fair", $message);
             //User::sendEmailMessageNotificationAlart($recive->email, $recive->username, $model->FK_sender, $message);
         }
         $this->redirect("/JobFair/index.php/message");
         return;
     }
     if ($reply != null) {
         $message = Message::model()->findByPK($reply);
         if (Yii::app()->user->name == $message->FK_sender) {
             $username = $message->FK_receiver;
         } else {
             $username = $message->FK_sender;
         }
         $model->subject = $message->subject;
         $model->message = "\n\n\nOn " . $message->date . ", " . $message->FK_sender . " wrote:\n" . $message->message;
     }
     $this->render('send', array('user' => $user, 'users' => $users, 'model' => $model, 'username' => $username));
 }
 public function actionScheduleInterview()
 {
     $original_string = "qwertyuiopasdfghjklzxcvbnm123456789";
     $lastid = VideoInterview::model()->find(array('order' => 'id DESC'));
     if ($lastid != null) {
         $key = $lastid->id + 1 . "VJFID" . rand(1, 10000000);
     } else {
         $key = 1 . "VJFID" . rand(1, 10000000);
     }
     $refid = Notification::model()->find(array('order' => 'id DESC'));
     $username = Yii::app()->user->name;
     $sender_id = User::model()->find("username=:username", array(':username' => $username))->id;
     $student = $_POST['user_name'];
     $receiver = User::model()->find("username=:username", array(':username' => $student));
     $link = $username;
     $model = new VideoInterview();
     $model->attributes = $_POST['VideoInterview'];
     $model->FK_employer = $sender_id;
     $model->FK_student = $receiver->id;
     $model->session_key = $key;
     $model->notification_id = $refid->id + 2;
     $model->save(false);
     $message = $username . " scheduled a video interview with you on: {$model->date} at: {$model->time} Good Luck!";
     User::sendSchedualNotificationAlart($sender_id, $receiver->id, $message, $link);
     //print "<pre>"; print_r($receiver_id);print "</pre>";return;
     //SAVE TO VIDEO INTERVIEW TABLE
     $message2 = "You scheduled an interview with " . $student . " at " . $model->time . " on " . $model->date . " Click here to go to the interview page.";
     User::sendSchedualNotificationAlart($receiver->id, $sender_id, $message2, $student);
     $message3 = "Hi {$receiver->username}, {$username} will like to interview you on:<br/>Date: {$model->date}<br/>Time: {$model->time}";
     User::sendEmail($receiver->email, "Virtual Job Fair", "Scheduled Interview", $message3);
     //User::sendEmailNotificationAlart($receiver->email, $receiver->username, $username, $message3);
     $link = CHtml::link('here', 'http://' . Yii::app()->request->getServerName() . '/JobFair/index.php/home/studenthome');
     $message4 = "{$username} scheduled an interview with you on:<br/>Date: {$model->date}<br/>Time: {$model->time}<br/>{$link}" . " Click {$link} to go to the interview page";
     //$html = User::replaceMessage($student, $message4);
     User::sendEmail($receiver->email, "Virtual Job Fair", "Scheduled Interview", $message4);
     //User::sendEmailNotificationAlart($receiver->email, $receiver->username, $username, $message4);
     $this->redirect("/JobFair/index.php/profile/student/user/" . $student);
     //print "<pre>"; print_r($key);print "</pre>";return;
 }
Example #3
0
 public function actionForgotPassword()
 {
     if (isset($_POST['User'])) {
         $email = $_POST['User']['email'];
         $model = User::model()->find("email=:email", array(':email' => $email));
         if ($model == null) {
             $error = 'Email does not exist in our records';
             $this->render('forgotPassword', array('error' => $error));
             return;
         }
         $password = $this->genRandomString(10);
         $hasher = new PasswordHash(8, false);
         $model->password = $hasher->HashPassword($password);
         $model->save(false);
         $link = CHtml::link('here', 'http://' . Yii::app()->request->getServerName() . '/JobFair/');
         $message = '<br/>Username: '******'<br/>Password: '******'<br/>Login: '******'Email has been sent';
         $this->render('forgotPassword', array('error' => $error));
         return;
     }
     $error = '';
     $this->render('forgotPassword', array('error' => $error));
 }
Example #4
0
            $my_user->setEmail($email);
        } else {
            $err .= "Email already exits";
        }
    }
    $pass = $my_user->setPassword($password);
    if ($password != "") {
        if (isset($pass) && $pass == FALSE) {
            $err .= "Password needs to be more than 6 characters";
        }
    }
    echo $err;
    if ($err == "") {
        $userid = $my_user->Insert();
        if ($userid) {
            $emailstat = $my_user->sendEmail($email, $act_code);
            if ($emailstat) {
                $msg .= "Registration Succesfully Completed";
            }
        } else {
            $msg .= "Registration Fail";
        }
        echo $msg;
    }
}
?>
</td>
  </tr>
<form name="register_frm" method="post" action="">
    
  <tr>
Example #5
0
 public function run($args)
 {
     date_default_timezone_set('America/New_York');
     $new_active_user = false;
     $nau_info = array();
     $interval = 0;
     $send_empl = false;
     $switches = array("-u", "-e", "-i", "-h", "-m", "--help");
     if (count($args) > 0) {
         for ($j = 0; $j < count($args); $j++) {
             if (in_array($args[$j], $args)) {
                 switch ($args[$j]) {
                     case "-u":
                         $new_active_user = true;
                         $nau_info['username'] = $args[$j + 1];
                         break;
                     case "-m":
                         $send_empl = true;
                         break;
                     case "-e":
                         $new_active_user = true;
                         $nau_info['email'] = $args[$j + 1];
                         break;
                     case "-i":
                         $interval = intval($args[$j + 1]);
                         if (!in_array($interval, array(1, 7, 30))) {
                             echo "[INVALID] Invalid interval value.\n";
                             $this->getHelp();
                         }
                         break;
                     case "-h":
                     case "--help":
                         $this->getHelp();
                 }
             }
         }
     } else {
         $this->getHelp();
     }
     $now = date('Y-m-d H:i:s');
     $date = date('Y-m-d');
     $time = date('H:i:s');
     $pasttime = $date . " " . date('H:i:s', strtotime("-30 min"));
     $matchnotification = MatchNotification::model()->findBySql("SELECT * FROM match_notification ORDER BY date_modified DESC limit 1");
     $notfication_status = intval($matchnotification['status']);
     if ($notfication_status) {
         if ($new_active_user) {
             if (isset($nau_info['email']) && $nau_info['email'] != '' && isset($nau_info['username']) && $nau_info['username'] != '') {
                 $jobs = Job::model()->findAll("active = 1");
                 $student = User::model()->find("username=:username", array(':username' => $nau_info['username']));
                 if ($student['username'] != null && $student['looking_for_job'] == 1 && $student['job_notification'] == 1) {
                     $message = "";
                     $results = Yii::app()->jobmatch->getStudentMatchJobs(intval($student['id']), $jobs);
                     if (count($results) > 0) {
                         $message .= $this->buildTable('student', $results, $interval);
                         User::sendEmail($student->email, "Virtual Job Fair | Job Matches", "Your Job Matches", $message);
                     }
                     return;
                 }
                 return;
             }
             return;
         }
         echo "[*] Job Matching Notification is ON\n";
         $jobs = Job::model()->findAll("post_date > '{$pasttime}' AND active = 1");
         #Add fecthing for user not active or validated
         $students = User::model()->findAll("FK_usertype = 1 AND job_notification = 1 AND looking_for_job = 1 AND activated = 1 AND disable = 0");
         echo "\n::::::::::::::::::::\n[*] Matching jobs for students.\n";
         foreach ($students as $st) {
             $message = "";
             $results = array();
             $saved_queries = SavedQuery::model()->findAll("FK_userid=:id AND active = 1", array(':id' => $st->id));
             if (count($saved_queries) > 0 && $interval == intval($st->job_int_date) && $interval > 0) {
                 $word = "query";
                 if (count($saved_queries) > 1) {
                     $word = "queries";
                 }
                 $message .= "Jobs matching your custom {$word}:<br/>";
                 foreach ($saved_queries as $query) {
                     $results = Yii::app()->jobmatch->customJobSearch(html_entity_decode($query->query), $query->location);
                     $message .= "Matches for query [{$query->query}]<br/>";
                     $message .= $this->buildTable('student_custom', $results, $interval);
                     $message .= "<br/>";
                 }
                 echo "[*] Sending custom search job results email to: {$st->email}\n";
                 User::sendEmail($st->email, "Virtual Job Fair | Job Matches", "Your Job Matches", $message);
             } else {
                 if ($interval == intval($st->job_int_date) && $interval > 0) {
                     $results = Yii::app()->jobmatch->getStudentMatchJobs($st->id, $jobs);
                     if (count($results) > 0) {
                         $message .= "The following jobs matched with your skills:<br/>";
                         $message .= $this->buildTable('student', $results, $interval);
                         echo "[*] Sending skill matches results email to: {$st->email}\n";
                         User::sendEmail($st->email, "Virtual Job Fair | Job Matches", "Your Job Matches", $message);
                     }
                 }
             }
         }
         if ($send_empl) {
             $count = 1;
             foreach ($jobs as $job) {
                 $message = "";
                 $job_poster_info = User::model()->findByPk($job->FK_poster);
                 if (!$job_poster_info->job_notification) {
                     echo "[*] Employer {$job_poster_info->username} has notifications OFF\n";
                     continue;
                 }
                 $job_poster_email = $job_poster_info->email;
                 echo "\n[*] Working on jobid {$job->id} : {$job->title}\n";
                 $results = Yii::app()->jobmatch->getJobStudentsMatch($job->id);
                 if (!isset($results['students']) || count($results) == 0 || $results['students'] == NULL) {
                     echo "[*] No student matches found for: " . $job->title . "\n";
                     continue;
                 }
                 $message .= "The following students matched this job posting:<br/>";
                 $table = $this->buildTable('', $results, $interval);
                 $message .= $table;
                 echo $this->replaceTags($message);
                 echo "[*] Sending email to {$job_poster_email}\n";
                 User::sendEmail($job_poster_email, "Virtual Job Fair | Job Matches", "Job Matches for {$job->title}", $message);
             }
         }
         return 0;
     } else {
         echo "[*] Job Matching Notification is OFF\n";
     }
 }
Example #6
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 #7
0
 public function actionEmployer()
 {
     if (isset($_GET['user'])) {
         $username = $_GET['user'];
     }
     $model = User::model()->find("username=:username", array(':username' => $username));
     if ($model->hide_email) {
         $model->email = "<i>hidden</i>";
     }
     if ($model->basicInfo->hide_phone) {
         $model->basicInfo->phone = "<i>hidden</i>";
     }
     if (!$model->activated || $model->disable) {
         if (isset($_GET["activation"])) {
             $activation_id = intval($_GET["activation"]);
             User::activeEmployer($activation_id);
             $modle = User::model()->findByPk($activation_id);
             $link = CHtml::link('here', 'http://' . Yii::app()->request->getServerName() . '/JobFair/');
             $message = "Your account has just been activated. Click {$link} to login";
             User::sendEmail($modle->email, "Virtual Job Fair", "Account Activated", $message);
             //User::sendEmployerVerificationEmail($_GET["activation"]);
         }
         $this->render('userInvalid');
     } else {
         $this->render('employer', array('user' => $model));
     }
 }
Example #8
0
 public function actionVirtualHandshake($jobid, $studentid)
 {
     $handshake = new Handshake();
     $handshake->jobid = $jobid;
     $handshake->studentid = $studentid;
     $handshake->employerid = User::getCurrentUser()->id;
     $student = User::model()->findByPk($studentid);
     if (Job::hasHandShake($jobid, User::getCurrentUser()->id, $studentid) == "" && User::getCurrentUser()->isAEmployer() && $student->isAStudent()) {
         $handshake->save(false);
         //SENDNOTIFICATION to $student, an employer is interested you, apply for this job
         $joblink = CHtml::link(CHtml::encode('View Job'), "/JobFair/index.php/job/view/jobid/" . $jobid, array('target' => '_blank', 'style' => 'float:left'));
         $link = 'http://' . Yii::app()->request->getServerName() . '/JobFair/index.php/job/view/jobid/' . $jobid;
         $job = Job::model()->findByPk($jobid);
         $message = User::getCurrentUser()->username . " is interested in you for the following job post: " . $job->title . " Click here to view the post and consider applying.";
         User::sendUserNotificationHandshakeAlart($handshake->employerid, $studentid, $link, $message);
         //SENT EMAIL NOTIFICATION
         $link1 = CHtml::link('click here to see ' . $job->title . ' page', 'http://' . Yii::app()->request->getServerName() . '/JobFair/index.php/job/view/jobid/' . $jobid);
         $message1 = User::getCurrentUser()->username . " is interested in you for the following job post:  " . $job->title . "<br/>{$link1}";
         //$html = User::replaceMessage($student->username, $message1);
         User::sendEmail($student->email, "A handshake from Virtual Job Fair", "Handshake Notification", $message1);
         //User::sendEmailStudentNotificationVirtualHandshakeAlart($student->email, $student->username, User::getCurrentUser()->username ,$message1);
     }
     return;
 }
Example #9
0
 public function actionAcceptNotificationSchedualInterview()
 {
     $id = $_GET['id'];
     //print "<pre>"; print_r($id);print "</pre>"; return;
     $modle = Notification::model()->find("id=:id", array(':id' => $id));
     $modle->been_read = 1;
     //User::sendEmployerNotificationStudentAcceptIntervie($modle->receiver_id, $modle->sender_id);
     $modle->save(false);
     //SEND EMAIL NOTIFICATION
     $username = Yii::app()->user->name;
     $user = User::model()->find("username=:username", array(':username' => $username));
     $message = "{$username} just accepted your interview invitation.";
     $recive = User::model()->findByPk($modle->sender_id);
     //$html = User::replaceMessage($recive->username, $message);
     User::sendEmail($recive->email, "Virtual Job Fair", "Interview Schedule Accepted", $message);
     //User::sendEmailEmployerAcceptingInterviewNotificationAlart($recive->email, $recive->username, $username, $message);
     if ($user->FK_usertype == 1) {
         $this->redirect("/JobFair/index.php/home/studenthome");
     } else {
         $this->redirect("/JobFair/index.php/home/employerhome");
     }
 }