コード例 #1
0
 public function actionDeleteInterest()
 {
     $model = SavedQuery::model()->findByPk($_GET['id']);
     //var_dump($model);die;
     $model->delete();
     $this->redirect('/JobFair/index.php/profile/view');
 }
コード例 #2
0
ファイル: JobMatchCommand.php プロジェクト: erick305/testing
 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";
     }
 }
コード例 #3
0
ファイル: JobController.php プロジェクト: erick305/testing
 public function actionSaveQuery($allWords = null, $phrase = null, $anyWord = null, $minus = null, $city = null, $tagName = null)
 {
     $saveQuery = "";
     $loc = "";
     $tag = "";
     $suc = false;
     if (isset($city) && $city != "") {
         $loc = $city;
     } else {
         $loc = "";
     }
     if (isset($tagName) && $tagName != "" && strlen($tagName) < 25) {
         $tag = $tagName;
     }
     if (isset($phrase) && $phrase != "") {
         if (strpos($phrase, '"') !== false) {
             $saveQuery = $phrase . " ";
         } else {
             $saveQuery = "\"{$phrase}\"" . " ";
         }
         // add  ""
     }
     if (isset($allWords) && $allWords != "") {
         if (strpos($allWords, '+') !== false) {
             $saveQuery .= $allWords . " ";
         } else {
             $saveQuery .= "+" . str_replace(" ", ' +', $allWords) . " ";
         }
         // add +
     }
     if (isset($anyWord) && $anyWord != "") {
         if (strpos($anyWord, 'OR') !== false) {
             $saveQuery .= $anyWord . " ";
         } else {
             $saveQuery .= str_replace(" ", ' OR ', $anyWord) . " ";
         }
         // add OR
     }
     if (isset($minus) && $minus != "") {
         if (strpos($minus, '-') !== false) {
             $saveQuery .= $minus . " ";
         } else {
             $saveQuery .= "-" . str_replace(" ", ' -', $minus) . " ";
         }
         // add +
     }
     if ($saveQuery != "") {
         $username = Yii::app()->user->name;
         $model = User::model()->find("username=:username", array(':username' => $username));
         $saved_queries = new SavedQuery();
         $saved_queries->query = htmlentities($saveQuery);
         $saved_queries->query_tag = $tag;
         $saved_queries->FK_userid = $model->id;
         $saved_queries->location = $loc;
         try {
             $saved_queries->save(false);
             $suc = 1;
         } catch (Exception $e) {
             $suc = 0;
             //alert("Oops, something went wrong. Please try again.");
         }
     }
     $this->render('savedQuerySuc', array('mesg' => $suc));
     //$this->actionsavedQuerySuc($suc);
 }