public static function deleteBed($bedId) { if (!UserStatus::isAdmin() || !Current_User::allow('hms', 'bed_structure')) { PHPWS_Core::initModClass('hms', 'exception/PermissionException.php'); throw new PermissionException('You do not have permission to delete a bed.'); } if (!isset($bedId)) { throw new InvalidArgumentException('Invalid bed id.'); } // Create the bed object $bed = new HMS_Bed($bedId); // Make sure the bed isn't assigned to anyone $bed->loadAssignment(); if ($bed->_curr_assignment != NULL) { PHPWS_Core::initModClass('hms', 'exception/HallStructureException.php'); throw new HallStructureException('A student is currently assigned to that bed and therefore it cannot deleted.'); } try { $bed->delete(); } catch (DatabaseException $e) { throw $e; } return true; }