コード例 #1
0
 public static function applyForJob($job_id)
 {
     $app = \Slim\Slim::getInstance();
     if (!\parser\controllers\ApplicationController::isLogin()) {
         $app->render(401, ['Status' => 'Unauthorised.']);
         return;
     }
     try {
         $allPostVars = $app->request->post();
         $resume_path = \parser\controllers\ApplicationController::saveResumeFromUpload();
         $telephone = @$allPostVars['telephone'] ? @trim(htmlspecialchars($allPostVars['telephone'], ENT_QUOTES, 'UTF-8')) : NULL;
         if (!InputValidator::isValidStringInput($telephone, 10, 8) || !preg_match("/^[0-9]{8,10}\$/", $telephone)) {
             $app->render(400, ['Status' => 'Invalid input.']);
             return;
         }
         $job = \parser\models\Job::where('id', '=', $job_id)->first();
         $user = \parser\models\User::where('email', '=', $_SESSION['email'])->first();
         $job_application = \parser\models\Application::where('job_id', '=', $job->id)->where('user_id', '=', $user->id)->first();
         if ($user && $job && !$job_application) {
             $job_application = new \parser\models\Application();
             $job_application->user_id = $user->id;
             $job_application->job_id = $job->id;
             $job_application->contact = $telephone;
             $job_application->resume_path = $resume_path;
             $job_application->save();
             shell_exec("/usr/bin/java -jar ../../parser.jar './resume-uploads/{$resume_path}' '{$user->id}' '{$job->id}' '{$job_application->id}' >/dev/null 2>/dev/null &");
             echo json_encode($job_application, JSON_UNESCAPED_SLASHES);
         } else {
             throw new \Exception('Error!');
         }
     } catch (\Exception $e) {
         $app->render(500, ['Status' => 'An error occurred.']);
     }
 }
コード例 #2
0
 public static function updateSettingsForJob($job_id)
 {
     $app = \Slim\Slim::getInstance();
     if (!\parser\controllers\ApplicationController::isLogin()) {
         $app->render(401, ['Status' => 'Unauthorised.']);
         return;
     }
     $allPostVars = $app->request->post();
     $minimum_score = @$allPostVars['minimum_score'] ? @intval($allPostVars['minimum_score']) : 0;
     $is_available = @$allPostVars['is_available'] ? @$allPostVars['is_available'] : 0;
     $is_available = $is_available == "on" ? 1 : 0;
     if (!preg_match('/^\\d+$/', $minimum_score)) {
         $app->render(400, ['Status' => 'Invalid input.']);
         return;
     }
     try {
         $user = \parser\models\User::where('email', '=', $_SESSION['email'])->first();
         $job = \parser\models\Job::where('id', '=', $job_id)->whereIn('id', function ($query) use($user) {
             $query->select('job_id')->from('job_recruiters')->where('user_id', '=', $user->id);
         })->first();
         if ($user && $job) {
             $job->minimum = $minimum_score;
             $job->is_available = $is_available;
             $job->save();
             echo json_encode($job, JSON_UNESCAPED_SLASHES);
         } else {
             $app->render(401, ['Status' => 'Unauthorised.']);
             return;
         }
     } catch (\Exception $e) {
         $app->render(500, ['Status' => 'An error occurred.']);
         return;
     }
 }