Exemple #1
0
 public static function deleteRoom($roomId)
 {
     if (!Current_User::allow('hms', 'room_structure')) {
         PHPWS_Core::initModClass('hms', 'exception/PermissionException.php');
         throw new PermissionException('You do not have permission to delete a room.');
     }
     // check that we're not about to do something stupid
     if (!isset($roomId)) {
         throw new InvalidArgumentException('Invalid room id.');
     }
     $room = new HMS_Room($roomId);
     // make sure there isn't an assignment
     if ($room->get_number_of_assignees() != 0) {
         PHPWS_Core::initModClass('hms', 'exception/HallStructureException.php');
         throw new HallStructureException('One or more students are currently assigned to that room and therefore it cannot deleted.');
     }
     // delete any beds
     try {
         if ($room->loadBeds()) {
             if (!empty($room->_beds)) {
                 foreach ($room->_beds as $bed) {
                     HMS_Bed::deleteBed($bed->id);
                 }
             }
         }
         $room->delete();
     } catch (Exception $e) {
         throw $e;
     }
     return true;
 }