Пример #1
0
 /**
  * Resets application settings.
  *
  * @return void
  * @since 0.1.0
  */
 public function resetApplicationSettings()
 {
     $appModel = new \ApplicationModel();
     $appModel->language = Fixtures::get('defaults:app:language');
     $appModel->name = Fixtures::get('defaults:app:name');
     $appModel->theme = Fixtures::get('defaults:app:theme');
     $appModel->save();
 }
Пример #2
0
 /**
  * Renders options page and saves passed options.
  *
  * @return void
  * @since 0.1.0
  */
 public function actionOptions()
 {
     $model = new \ApplicationModel();
     if ($data = \Yii::app()->request->getPost('ApplicationModel', false)) {
         $model->save($data);
         // setAndSave analog, errors fetched in view
         // resetting page title after language switch
         $this->page->resetI18n();
     }
     $this->render('options', array('appModel' => $model));
 }
Пример #3
0
 public static function run()
 {
     $class = get_called_class();
     TEST($class, "{$class}.student.saveEditSubmitAndDelete", function ($class) {
         // Create job
         global $MJob;
         $jobId = new MongoId($MJob->save([], false));
         $studentId = new MongoId();
         // make sure saving an application for a job with no application
         // fails
         EQ(null, ApplicationStudent::save($jobId, $studentId, []));
         // create application for job
         $questionId = new MongoId();
         $questions = [$questionId];
         ApplicationJob::createOrUpdate($jobId, $questions);
         $answers = [['_id' => $questionId, 'answer' => 'swag']];
         $firstApplication = ApplicationStudent::save($jobId, $studentId, $answers);
         NEQ(null, $firstApplication);
         $applicationId = $firstApplication->getId();
         NEQ(null, $firstApplication->getQuestions());
         EQ('swag', $firstApplication->getQuestions()[0]['answer']);
         // edit application
         ApplicationStudent::edit($applicationId, [['_id' => $questionId, 'answer' => 'qswag']]);
         $editedApplication = ApplicationModel::getSavedForJob($jobId)[0];
         EQ('qswag', $editedApplication['questions'][0]['answer']);
         // submit application
         TRUE(ApplicationStudent::submitSaved($applicationId));
         TRUE(ApplicationModel::checkSubmitted($applicationId));
         // submit new application
         $secondStudent = new MongoId();
         $secondApplication = ApplicationStudent::submitNew($jobId, $secondStudent, $answers);
         TRUE(ApplicationModel::checkSubmitted($secondApplication->getId()));
         // create, save, and delete application
         $thirdStudent = new MongoId();
         $applicationToDelete = ApplicationStudent::save($jobId, $thirdStudent, $answers)->getId();
         TRUE(ApplicationModel::applicationExists($jobId, $thirdStudent));
         TRUE(ApplicationStudent::deleteSaved($applicationToDelete));
     });
     TEST($class, "{$class}.student.getUnclaimedAndClaimed", function ($class) {
         TRUE(false, 'TODO: Write test');
     });
     TEST($class, "{$class}.job.createOrUpdate", function ($class) {
         // Try to create/update application for nonexistent job
         FALSE(ApplicationJob::createOrUpdate(new MongoId(), []));
         // Create job
         global $MJob;
         $jobId = new MongoId($MJob->save([], false));
         // Try to create application for job
         $oldQuestionId = new MongoId();
         $oldQuestions = [$oldQuestionId];
         TRUE(ApplicationJob::createOrUpdate($jobId, $oldQuestions));
         EQ($MJob::getApplicationQuestionIds($jobId), $oldQuestions);
         // Try to change one question in application for job
         $newQuestionId = new MongoId();
         $newQuestions = [$newQuestionId];
         TRUE(ApplicationJob::createOrUpdate($jobId, $newQuestions));
         EQ($MJob::getApplicationQuestionIds($jobId), $newQuestions);
         TRUE(false, 'TODO: Check to make sure student applications are updated right.');
     });
 }
Пример #4
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');
 }
Пример #5
0
 static function load_controller()
 {
     if (false === (include CTRLSPATH . Request::$controller . '/_controller.php')) {
         self::exit_with_status(500, 'Could not load controller file for ' . Request::$controller . '.');
     }
     $modelname = strtolower(ApplicationModel::filename_to_modelname(Request::$controller));
     if (Application::$models->exists($modelname)) {
         Application::$models->{$modelname}->load();
     }
 }
Пример #6
0
/**
 * $models - comma-separated string of model names (their file name, not class name).
 * When including a model, do so in the first line of the model file.
 */
function include_model($models)
{
    $models = explode(',', str_replace(' ', '', $models));
    foreach ($models as $model) {
        $model_name = strtolower(ApplicationModel::filename_to_modelname($model));
        if (empty(Application::$models->{$model_name})) {
            echo "Warning: include_model: Model {$model_name} not found";
            continue;
        }
        Application::$models->{$model_name}->load();
    }
}
Пример #7
0
 /**
  * Updates saved student applications to be the new set of $questionsIds.
  */
 private static function updateSavedApplications(MongoId $jobId, array $questionIds)
 {
     // Get the saved applications corresponding to $jobId.
     $saved = ApplicationModel::getSavedForJob($jobId);
     // Prune the questions field to be just those in $questionIds.
     foreach ($saved as $application) {
         $questions = $application['questions'];
         $newQuestions = self::pruneQuestionsByIdSet($questions, $questionIds);
         // Update the entry with $newQuestions.
         ApplicationModel::replaceQuestionsField($application['_id'], $newQuestions);
     }
 }
 public static function apply(array $restOfRoute)
 {
     global $params;
     StudentController::requireLogin();
     $jobId = self::getIdFromRoute($restOfRoute);
     if (is_null($jobId)) {
         return;
     }
     $studentId = $_SESSION['_id'];
     $application = ApplicationJob::get($jobId);
     // Make sure job exists.
     if (!self::checkJobExists($jobId)) {
         return;
     }
     // Saving of application.
     if (isset($params['questions'])) {
         ApplicationStudent::save($jobId, $studentId, $params['questions']);
         return;
     }
     $submitted = false;
     // Submitting of application.
     if ($params) {
         self::submit($jobId, $studentId, $params);
     }
     $entry = JobModel::getById($jobId);
     $companyId = $entry['company'];
     $company = CompanyModel::getById($companyId);
     $questions = array();
     if (ApplicationModel::applicationExists($jobId, $studentId)) {
         $applicationData = ApplicationModel::getApplication($jobId, $studentId);
         $application = new ApplicationStudent($applicationData);
         $applicationId = $application->getId();
         $submitted = ApplicationModel::checkSubmitted($application->getId());
         if ($submitted) {
             //student succesfully submitted application
             self::redirect("../application/{$applicationId}");
         }
         foreach ($application->getQuestions() as $question) {
             $_id = $question['_id'];
             $questions[] = ['_id' => $_id, 'text' => Question::getTextById($_id), 'answer' => $question['answer']];
         }
     } else {
         JobModel::incrementApply($jobId);
         foreach ($application->getQuestions() as $questionId) {
             $answer = '';
             $answers = StudentModel::getAnswers($studentId);
             $answers = arrayToHashByKey($answers, '_id');
             if (isset($answers[$questionId . ''])) {
                 $answer = $answers[$questionId . '']['answer'];
             } else {
                 $answer = '';
             }
             $questions[] = ['_id' => $questionId, 'text' => Question::getTextById($questionId), 'answer' => $answer];
         }
     }
     self::render('jobs/applications/apply', ['questions' => $questions, 'jobtitle' => $entry['title'], 'companytitle' => $company['name'], 'jobId' => $jobId, 'submitted' => $submitted]);
 }
Пример #9
0
<?php

$model =& ApplicationModel::getInstance();
header('Content-type: text/html;charset=UTF-8');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xml:lang="cs" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<title>Cestovní železniční zápisník</title>
<link href="raillog.css" type="text/css" rel="stylesheet" />
</head>
<body>

<table>
<?php 
$cars = $model->getStatisticsCars();
usort($cars, array('StatCountTuple', 'compare'));
foreach ($cars as $car) {
    ?>
<tr>
<td><?php 
    echo $car->getObject();
    ?>
</td>
<td><?php 
    echo $car->getCount();
    ?>
</td>
</tr>
<?php 
 public static function report()
 {
     RecruiterController::requireLogin();
     global $params;
     $applicationId = new MongoId($params['_id']);
     $recruiterId = $_SESSION['_id'];
     if (!ApplicationModel::isOwned($recruiterId, $applicationId)) {
         return self::ajaxError();
     }
     ApplicationModel::changeStatus($applicationId, ApplicationStudent::STATUS_REPORTED);
     $message = "\n        <h1>Application Reported</h1><br />\n        <b>Application ID:</b> {$applicationId}\n      ";
     sendgmail(['*****@*****.**', '*****@*****.**'], "*****@*****.**", 'Application Reported', $message);
     return self::ajaxSuccess();
 }
Пример #11
0
 public function delete($id)
 {
     $this->db->trans_start();
     # remove bookmark related employee
     $this->load->model("BookmarkModel");
     $bookmark = new BookmarkModel();
     $bookmark->delete_by_employee($id);
     # remove follower related employee
     $this->load->model("FollowerModel");
     $follower = new FollowerModel();
     $follower->delete_by_employee($id);
     # remove activity related employee
     $this->load->model("EmployeeActivityModel");
     $activity = new EmployeeActivityModel();
     $activity->delete_by_employee($id);
     # remove cv list of experience related employee
     $this->load->model("ExperienceModel");
     $experience = new ExperienceModel();
     $experience->delete_by_employee($id);
     # remove cv list of education related employee
     $this->load->model("PortfolioModel");
     $education = new PortfolioModel();
     $education->delete_by_employee($id);
     # remove thread list related employee
     $this->load->model("ThreadModel");
     $thread = new ThreadModel();
     $thread->delete_by_employee($id);
     # remove application ever sent
     $this->load->model("ApplicationModel");
     $application = new ApplicationModel();
     $application->delete_by_employee($id);
     # remove employee itself
     $condition = array(EmployeeModel::$primary_key => $id);
     $this->db->delete(EmployeeModel::$table_name, $condition);
     $this->db->trans_complete();
     return $this->db->trans_status();
 }
Пример #12
0
 function recruiters()
 {
     global $MRecruiter, $MJob, $MCompany, $MApp;
     $recruiterArray = [];
     $recruiterColumns = ["email", "firstname", "lastname", "company", "datejoined", "postedjob", "madecompany", "approved"];
     $jobColumns = ["jobname", "jobviews", "jobclicks", "applicants"];
     $recruiterArray[] = implode(',', $recruiterColumns) . ',' . implode(',', $jobColumns);
     $r = $MRecruiter->find();
     $j = $MJob->find();
     $rids = array();
     // an array of recruiters ids that have posted jobs
     foreach ($j as $job) {
         $rids[] = $job['recruiter']->{'$id'};
     }
     foreach ($r as $recruiter) {
         $info = [];
         $id = $recruiter['_id'];
         $rdoc = $MRecruiter->getById($id);
         if (isset($recruiter['email'])) {
             $info['email'] = $recruiter['email'];
         } else {
             $info['email'] = 'no email';
         }
         if (isset($recruiter['firstname'])) {
             $info['firstname'] = $recruiter['firstname'];
         } else {
             $info['firstname'] = 'no firstname';
         }
         if (isset($recruiter['lastname'])) {
             $info['lastname'] = $recruiter['lastname'];
         } else {
             $info['lastname'] = 'no lastname';
         }
         if (isset($recruiter['company'])) {
             if (MongoID::isValid($recruiter['company'])) {
                 // if the company is a MongoID
                 $info['company'] = $MCompany->getName($recruiter['company']);
             } else {
                 $info['company'] = $recruiter['company'];
             }
         } else {
             $info['company'] = 'no company';
         }
         $info['dateJoined'] = fdate($recruiter['_id']->getTimestamp());
         if (in_array($id, $rids)) {
             // recruiters who have posted at least one job and have a company profile
             $info['postedJob'] = 'YES';
             $info['madeCompany'] = 'YES';
             $info['approved'] = 'YES';
         } else {
             // recruiters who have not posted a job
             $info['postedJob'] = 'NO';
             if (MongoID::isValid($recruiter['company'])) {
                 // recruiters who have a company profile
                 $info['madeCompany'] = 'YES';
                 $info['approved'] = 'YES';
             } else {
                 // recruiters who don't have a company profile
                 $info['madeCompany'] = 'NO';
                 if ($recruiter['approved'] == 'approved') {
                     // recruiters who are approved
                     $info['approved'] = 'YES';
                 } else {
                     // recruiters who are not approved
                     $info['approved'] = 'NO';
                 }
             }
         }
         $recruiterArray[] = implode(',', self::quoteStringsInArray($info));
         $jobs = $MJob->getByRecruiter($id);
         // get jobs for recruiter
         foreach ($jobs as $job) {
             //make rows under each recruiter for their listed jobs
             $jobInfo = [];
             if (isset($job['title'])) {
                 $jobInfo['title'] = $job['title'];
             } else {
                 'No Job Title';
             }
             $jobInfo['views'] = $job['stats']['views'];
             $jobInfo['clicks'] = $job['stats']['clicks'];
             $jobInfo['applicants'] = ApplicationModel::countByJob($job['_id']);
             $recruiterArray[] = str_repeat(',', count($recruiterColumns)) . implode(',', self::quoteStringsInArray($jobInfo));
         }
     }
     return ["recruiterArray" => $recruiterArray];
 }
Пример #13
0
<?php

header('Content-type: text/plain;charset=UTF-8');
print_r(ApplicationModel::getInstance());
Пример #14
0
 /**
  *  @return object ApplicationModel Shared instance
  */
 public static function &getInstance()
 {
     if (is_null(self::$instance)) {
         self::$instance = new ApplicationModel();
     }
     return self::$instance;
 }
Пример #15
0
 /**
  * Creates a student application to be inserted into the 'applications'
  * collection.
  * Need to make sure student has not already saved an application for the
  * job.
  */
 private static function create(MongoId $jobId, MongoId $studentId, array $questions, $submitted)
 {
     // Retrieve application list from $jobId.
     $applicationQuestions = JobModel::getApplicationQuestionIds($jobId);
     // Build question-answer pairs.
     $savedQuestions = self::pruneQuestionsByIdSet($questions, $applicationQuestions);
     // Save the application.
     $application = new ApplicationStudent(['jobid' => $jobId, 'studentid' => $studentId, 'questions' => $savedQuestions, 'submitted' => $submitted]);
     $id = ApplicationModel::insert($application->getData());
     $application->setId($id);
     // Return created application.
     return $application;
 }
Пример #16
0
 private function register_assocs()
 {
     if (!System::$assocs_temp) {
         return;
     }
     foreach (System::$assocs_temp as $assoc_type => $assocs) {
         foreach ($assocs as $assoc) {
             $prop_name = array_shift($assoc);
             if ($assoc) {
                 $params = array_shift($assoc);
             } else {
                 $params = array();
             }
             if (!isset($params['model_name'])) {
                 if ($assoc_type == 'has_many') {
                     $model_name = ApplicationModel::filename_to_modelname(substr($prop_name, 0, -1));
                 } else {
                     $model_name = ApplicationModel::filename_to_modelname($prop_name);
                 }
             } else {
                 $model_name = $params['model_name'];
                 unset($params['model_name']);
             }
             $this->assocs->{$prop_name} = array2obj(array('model_name' => $model_name, 'type' => $assoc_type, 'params' => $params));
         }
     }
     System::$assocs_temp = array();
 }
Пример #17
0
 public function delete($id, $company = null)
 {
     $this->db->trans_start();
     $this->load->model("BookmarkModel");
     $this->load->model("ApplicationModel");
     # delete bookmark related by job
     $bookmark = new BookmarkModel();
     $bookmark->delete_by_job($id);
     # delete application related by job
     $application = new ApplicationModel();
     $application->delete_by_job($id);
     # remove the job itself
     $condition = array(JobModel::$primary_key => $id);
     if ($company != null) {
         $condition["job_company"] = $company;
     }
     $this->db->delete(JobModel::$table_name, $condition);
     $this->db->trans_complete();
     return $this->db->trans_status();
 }