private static function getSchoolsForUnclaimed(MongoId $jobId)
 {
     global $S;
     $schools = [];
     $unclaimed = ApplicationStudent::getUnclaimedByJob($jobId);
     foreach ($unclaimed as $application) {
         $studentId = $application->getStudentId();
         $student = StudentModel::getById($studentId, ['email' => 1]);
         $email = $student['email'];
         $school = $S->nameOf($email);
         $schools[] = $school;
     }
     return $schools;
 }
 public static function view(array $restOfRoute)
 {
     JobController::requireLogin();
     $applicationId = self::getIdFromRoute($restOfRoute);
     if (is_null($applicationId)) {
         return;
     }
     $application = ApplicationStudent::getById($applicationId);
     if (is_null($application)) {
         self::error("nonexistent application");
         self::render('notice');
         return;
     }
     // Only the student who submitted the application and the recruiter
     // associated with the job can view the application.
     $myId = $_SESSION['_id'];
     $jobId = $application->getJobId();
     $studentId = $application->getStudentId();
     $recruiterId = JobModel::getRecruiterId($jobId);
     $isRecruiter = $recruiterId == $myId;
     $isStudent = $studentId == $myId;
     if (!$isStudent && !$isRecruiter) {
         self::error("permission denied");
         self::render('notice');
         return;
     }
     // Retrieve data for student.
     $student = StudentModel::getById($studentId, ['name' => 1]);
     $studentName = $student['name'];
     // Retrieve data on the job.
     $job = JobModel::getById($jobId);
     $title = $job['title'];
     $companyId = $job['company'];
     $company = CompanyModel::getById($companyId);
     // Set data from application.
     $profile = $application->getProfile();
     $questions = $application->getQuestions();
     // Add 'text' to questions to show.
     $responses = [];
     foreach ($questions as $question) {
         $_id = $question['_id'];
         $responses[] = ['_id' => $_id, 'text' => Question::getTextById($_id), 'answer' => $question['answer']];
     }
     self::render('jobs/applications/view', ['responses' => toJSON($responses), 'studentname' => $studentName, 'jobtitle' => $title, 'companytitle' => $company['name'], 'isStudent' => $isStudent, 'isRecruiter' => $isRecruiter, 'studentId' => $studentId, 'recruiterId' => $recruiterId]);
     self::render('jobs/student/studentprofile', ['profile' => toJSON($profile)]);
     self::render('jobs/applications/report', ['applicationId' => $applicationId, 'isStudent' => $isStudent, 'isRecruiter' => $isRecruiter]);
 }
예제 #3
0
 function view()
 {
     global $MSublet;
     global $MStudent;
     // Validations
     $this->startValidations();
     $this->validate(isset($_GET['id']) and ($entry = $MSublet->get($id = $_GET['id'])) != NULL, $err, 'unknown sublet');
     if ($this->isValid()) {
         $this->validate($entry['publish'] or isset($_SESSION['_id']) and $entry['student'] == $_SESSION['_id'], $err, 'access denied');
     }
     // Code
     if ($this->isValid()) {
         $data = array('commented' => false);
         if (isset($_POST['addcomment'])) {
             function dataComment($data)
             {
                 $comment = clean($data['comment']);
                 return array('comment' => $comment);
             }
             global $params;
             extract($data = dataComment($params));
             array_unshift($entry['comments'], array('time' => time(), 'commenter' => $_SESSION['_id'], 'comment' => $comment));
             $data['commented'] = true;
             // Notify us of the comment
             $commenter = $_SESSION['email'];
             $message = "\n            <b>{$commenter}</b> has commented on <a href=\"http://sublite.net/housing/sublet.php?id={$id}\">{$id}</a>:\n            <br /><br />\n            {$comment}\n          ";
             sendgmail(array('*****@*****.**', '*****@*****.**'), "*****@*****.**", 'Comment posted on SubLite!', $message);
             // Notify the subletter of the comment
             $subletterEmail = StudentModel::getById($entry['student'])['email'];
             $subletterName = $_SESSION['name'];
             $message = "\n            Hey there!\n            <br /><br />\n            {$subletterName} has commented on your sublet!\n            Check it out <a href=\"http://sublite.net/housing/sublet.php?id={$id}\">here</a>.\n            <br /><br />\n            View your sublet:\n            <a href=\"http://sublite.net/housing/sublet.php?id={$id}\">\n              http://sublite.net/housing/sublet.php?id={$id}\n            </a>\n            <br /><br />\n            Happy subletting,<br />\n            SubLite Team\n          ";
             sendgmail(array($subletterEmail), "*****@*****.**", 'You have a new comment on your sublet! | SubLite', $message);
         }
         $entry['stats']['views']++;
         $MSublet->save($entry);
         $data = array_merge($entry, $data);
         $data['_id'] = $entry['_id'];
         $data['mine'] = (isset($_SESSION['_id']) and $entry['student'] == $_SESSION['_id']);
         // ANY MODiFICATIONS ON DATA GOES HERE
         $s = $MStudent->getById($entry['student']);
         if ($s == NULL) {
             $entry['publish'] = false;
             $MSublet->save($entry);
             self::error('this listing is no longer available');
             self::render('notice');
             return;
         }
         $data['studentname'] = $s['name'];
         $data['studentid'] = $s['_id']->{'$id'};
         $data['studentclass'] = $s['class'] > 0 ? " '" . substr($s['class'], -2) : '';
         $data['studentschool'] = strlen($s['school']) > 0 ? $s['school'] : 'Undergraduate';
         $data['studentpic'] = isset($s['photo']) ? $s['photo'] : $GLOBALS['dirpreFromRoute'] . 'assets/gfx/defaultpic.png';
         global $S;
         $data['studentcollege'] = $S->nameOf($s['email']);
         $data['studentbio'] = isset($s['bio']) ? $s['bio'] : 'Welcome to my profile!';
         if (isset($_SESSION['loggedinstudent'])) {
             $me = $MStudent->me();
             $data['studentmsg'] = "Hi " . $data['studentname'] . ",%0A%0A" . "I am writing to inquire about your listing '" . $data['title'] . "' (http://sublite.net/housing/sublet.php?id=" . $entry['_id'] . ").%0A%0A" . "Best,%0A" . $me['name'];
         }
         $data['latitude'] = $data['geocode']['latitude'];
         $data['longitude'] = $data['geocode']['longitude'];
         $data['address'] = $data['address'] . ', ' . $data['city'] . ', ' . $data['state'];
         if (count($data['photos']) == 0) {
             $data['photos'][] = $GLOBALS['dirpreFromRoute'] . 'assets/gfx/subletnophoto.png';
         }
         $data['startdate'] = fdate($data['startdate']);
         $data['enddate'] = fdate($data['enddate']);
         switch ($data['gender']) {
             case 'male':
                 $data['gender'] = 'Male only';
                 break;
             case 'female':
                 $data['gender'] = 'Female only';
                 break;
         }
         for ($i = 0; $i < count($data['comments']); $i++) {
             $comment = $data['comments'][$i];
             $commenter = $MStudent->getById($comment['commenter']);
             $data['comments'][$i] = array('name' => $commenter['name'], 'photo' => $commenter['photo'], 'time' => timeAgo($comment['time']), 'text' => $comment['comment']);
         }
         self::displayMetatags('sublet');
         self::render('student/sublets/viewsublet', $data);
         return;
     }
     self::error($err);
     self::render('notice');
 }