Ejemplo n.º 1
0
 /**
  * Checks to see if two people hypothetically could live together based on
  * our rules.
  *
  * @returns true if so, false if not
  *
  * @param requestor The person requesting a roommate
  * @param requestee The person requested as a roommate
  */
 public function is_request_valid()
 {
     $requestor = strToLower($this->requestor);
     $requestee = strToLower($this->requestee);
     $term = $this->term;
     // Sanity Checking
     if (is_null($requestor)) {
         return E_ROOMMATE_MALFORMED_USERNAME;
     }
     if (is_null($requestee)) {
         return E_ROOMMATE_MALFORMED_USERNAME;
     }
     // Make sure requestor didn't request self
     if ($requestor == $requestee) {
         return E_ROOMMATE_REQUESTED_SELF;
     }
     // Make sure requestor and requestee are not requesting each other
     if (HMS_Roommate::have_requested_each_other($requestor, $requestee, $term)) {
         return E_ROOMMATE_ALREADY_REQUESTED;
     }
     // Make sure requestor does not have a pending roommate request
     if (HMS_Roommate::has_roommate_request($requestor, $term)) {
         return E_ROOMMATE_PENDING_REQUEST;
     }
     return $this->can_live_together();
 }