/** * Returns this rlc application (and assignment) as array of fields for CSV export * * @return Array */ public function viewByRLCExportFields() { PHPWS_Core::initModClass('hms', 'HMS_Assignment.php'); PHPWS_Core::initModClass('hms', 'StudentFactory.php'); $row = array(); // Get the Student object try { $student = StudentFactory::getStudentByUsername($this->username, Term::getSelectedTerm()); } catch (StudentNotFoundException $e) { // Catch the StudentNotFound exception in the odd case that someone doesn't exist. // Show a warning message and skip the rest of the method NQ::simple('hms', hms\NotificationView::WARNING, "No student found with username: {$this->username}."); $row['username'] = $this->username; $row['name'] = 'UNKNOWN - INVALID'; return $tags; } $row['name'] = $student->getFullName(); $row['gender'] = $student->getPrintableGender(); $row['student_type'] = $student->getPrintableType(); $row['username'] = $student->getUsername(); $row['banner_id'] = $student->getBannerId(); /*** Assignment Status/State ***/ // Lookup the assignmnet (used later as well) $assign = HMS_RLC_Assignment::getAssignmentByUsername($this->username, $this->term); $state = $assign->getStateName(); if ($state == 'confirmed') { $row['state'] = 'confirmed'; } else { if ($state == 'declined') { $row['state'] = 'declined'; } else { if ($state == 'new') { $row['state'] = 'not invited'; } else { if ($state == 'invited') { $row['state'] = 'pending'; } else { $row['state'] = ''; } } } } // Check for/display room assignment $roomAssign = HMS_Assignment::getAssignmentByBannerId($student->getBannerId(), Term::getSelectedTerm()); if (isset($roomAssign)) { $row['room_assignment'] = $roomAssign->where_am_i(); } else { $row['room_assignment'] = 'n/a'; } /*** Roommates ***/ // Show all possible roommates for this application PHPWS_Core::initModClass('hms', 'HMS_Roommate.php'); $allRoommates = HMS_Roommate::get_all_roommates($this->username, $this->term); $row['roommates'] = 'N/A'; // Default text if (sizeof($allRoommates) > 1) { // Don't show all the roommates $row['roommates'] = "Multiple Requests"; } elseif (sizeof($allRoommates) == 1) { // Get other roommate $otherGuy = StudentFactory::getStudentByUsername($allRoommates[0]->get_other_guy($this->username), $this->term); $row['roommates'] = $otherGuy->getFullName(); // If roommate is pending then show little status message if (!$allRoommates[0]->confirmed) { $row['roommates'] .= " (Pending)"; } } return $row; }
/** * Handles removing roommate requests * @param Student $student */ private function handleRoommate(Student $student) { # check for and delete any roommate requests, perhaps let the other roommate know? $roommates = HMS_Roommate::get_all_roommates($student->getUsername(), $this->term); if (sizeof($roommates) > 0) { # Delete each roommate request foreach ($roommates as $rm) { try { $rm->delete(); } catch (Exception $e) { //TODO } $this->actions[$student->getUsername()][] = "Roommate request removed. {$rm->requestor} -> {$rm->requestee}"; HMS_Activity_Log::log_activity($rm->requestor, ACTIVITY_WITHDRAWN_ROOMMATE_DELETED, UserStatus::getUsername(), "Withdarwn search; {$rm->requestor}->{$rm->requestee}"); HMS_Activity_Log::log_activity($rm->requestee, ACTIVITY_WITHDRAWN_ROOMMATE_DELETED, UserStatus::getUsername(), "withdrawn search; {$rm->requestor}->{$rm->requestee}"); # TODO: notify the other roommate, perhaps? } } }