/** * Checks if an event can be proposed in the given date and time * * @param string $date * @param string $time * @return TRUE on success, a ADA error code on failure */ public static function canProposeThisDateTime(ADALoggableUser $userObj, $date, $time, $tester = NULL) { $date = DataValidator::validate_date_format($date); if ($date === FALSE) { return ADA_EVENT_PROPOSAL_ERROR_DATE_FORMAT; } else { $current_timestamp = time(); /** * @var timezone management */ $offset = 0; if ($tester === NULL) { $tester_TimeZone = SERVER_TIMEZONE; } else { $tester_TimeZone = MultiPort::getTesterTimeZone($tester); $offset = get_timezone_offset($tester_TimeZone, SERVER_TIMEZONE); } $timestamp_time_zone = sumDateTimeFN(array($date, "{$time}:00")); $timestamp = $timestamp_time_zone - $offset; if ($current_timestamp >= $timestamp) { return ADA_EVENT_PROPOSAL_ERROR_DATE_IN_THE_PAST; } if (MultiPort::hasThisUserAnAppointmentInThisDate($userObj, $timestamp)) { return ADA_EVENT_PROPOSAL_ERROR_DATE_IN_USE; } } return TRUE; }