Пример #1
0
 public static function delete(array $restOfRoute)
 {
     RecruiterController::requireLogin();
     $jobId = self::getIdFromRoute($restOfRoute);
     if (is_null($jobId)) {
         return;
     }
     // Make sure job exists.
     // Make sure recruiter has permission to edit the job.
     if (!self::checkJobExists($jobId)) {
         return;
     }
     if (!self::ownsJob($jobId)) {
         return;
     }
     // Delete all applications with jobid.
     ApplicationModel::deleteByJob($jobId);
     // Delete from questions' uses this jobid.
     $application = ApplicationJob::get($jobId);
     $questions = [];
     if (!is_null($application)) {
         $questions = $application->getQuestions();
     }
     foreach ($questions as $questionId) {
         QuestionModel::removeFromUses($questionId, $jobId);
     }
     // Delete this job.
     JobModel::deleteById($jobId);
     // Redirect back to home.
     self::redirect('../home');
 }
 public static function edit(array $restOfRoute)
 {
     RecruiterController::requireLogin();
     global $params;
     $jobId = self::getIdFromRoute($restOfRoute);
     if (is_null($jobId)) {
         return;
     }
     // Make sure job exists.
     // Make sure recruiter has permission to edit the job.
     if (!self::checkJobExists($jobId)) {
         return;
     }
     if (!self::ownsJob($jobId)) {
         return;
     }
     // Process saving of questions.
     if (self::save($jobId)) {
         return;
     }
     $vanillaQuestions = Question::getAllVanilla();
     $vanillaQuestionsData = [];
     $chosenData = [];
     // Get existing questions.
     $chosenIds = ApplicationModel::getJobApplication($jobId);
     // Remove any existing from $vanillaQuestions.
     if ($chosenIds !== null) {
         $chosenIdHash = arrayToSet($chosenIds);
     }
     foreach ($vanillaQuestions as $question) {
         $id = (string) $question->getId();
         $data = $question->getData();
         $data['hide'] = $chosenIds !== null && isset($chosenIdHash[$id]);
         $vanillaQuestionsData[] = $data;
     }
     // If no application, we show form to create application.
     // Else, we show form to edit existing application.
     if ($chosenIds === null) {
         $createEdit = 'create';
     } else {
         $createEdit = 'edit';
         // Get the text for each $chosenIds.
         foreach ($chosenIds as $_id) {
             $data = QuestionModel::getById($_id, ['text' => 1, 'vanilla' => 1]);
             if ($data === null) {
                 continue;
             }
             $text = $data['text'];
             $vanilla = $data['vanilla'];
             $chosenData[] = ['_id' => $_id, 'text' => $text, 'vanilla' => $vanilla];
         }
     }
     $job = JobModel::getByIdMinimal($jobId);
     self::render('jobs/applications/edit', ['createEdit' => $createEdit, 'vanillaQuestions' => $vanillaQuestionsData, 'chosen' => $chosenData, 'jobId' => $jobId, 'jobTitle' => $job['title'], 'jobLocation' => $job['location']]);
 }
 public static function getCards()
 {
     RecruiterController::requireLogin();
     $recruiterId = $_SESSION['_id'];
     $cards = StripeBilling::getCardsByRecruiter($recruiterId);
     echo toJSON($cards);
 }
 public static function searchCustom()
 {
     RecruiterController::requireLogin();
     global $params;
     $search = $params['search'];
     $questions = Question::searchCustom($search);
     $questionData = self::questionArrayToJson($questions);
     return $questionData;
 }
Пример #5
0
});
Router::register('employers/addjob', function () {
    Controller::displayMetatags('/employers');
    GLOBALvarGet('CJob')->add();
});
Router::register('employers/approve', function () {
    Controller::displayMetatags('/employers');
    GLOBALvarGet('CRecruiter')->approve();
});
Router::register('employers/buycredits', function () {
    Controller::displayMetatags('/employers');
    PaymentControllerAJAX::buyCredits();
});
Router::register('employers/buyplan', function () {
    Controller::displayMetatags('/employers');
    RecruiterController::buyPlan();
});
Router::register('employers/buyplanfinish', function () {
    PaymentControllerAJAX::buyPlan();
});
Router::register('employers/addcard', function () {
    PaymentControllerAJAX::addPaymentInfo();
});
Router::register('employers/removecard', function () {
    PaymentControllerAJAX::removePaymentInfo();
});
Router::register('employers/getcards', function () {
    PaymentControllerAJAX::getCards();
});
Router::register('employers/changepass', function () {
    Controller::displayMetatags('/employers');