protected function _update_next_deadline() { $rel_valid = $this->time_scheduled->is_valid(); $test_valid = $this->time_testing_scheduled->is_valid(); if ($rel_valid) { if ($test_valid) { if ($this->time_scheduled->less_than($this->time_testing_scheduled)) { $this->time_next_deadline = $this->time_scheduled; } else { $this->time_next_deadline = $this->time_testing_scheduled; } } else { $this->time_next_deadline = $this->time_scheduled; } } else { if ($test_valid) { $this->time_next_deadline = $this->time_testing_scheduled; } else { $this->time_next_deadline->clear(); } } }
/** * Record difference in times, if any * @param string $name * @param DATE_TIME $orig_date * @param DATE_TIME $new_date * @param string $type Type of date-time formatting to use. * @access private */ protected function _record_time_difference($name, $orig_date, $new_date, $type = Date_time_format_short_date_and_time) { if (!$orig_date->equals($new_date)) { $f = $orig_date->formatter(); $f->set_type_and_clear_flags($type); if ($orig_date->is_valid()) { $orig_text = $orig_date->format($f); } else { $orig_text = '[not set]'; } if ($new_date->is_valid()) { $new_text = $new_date->format($f); } else { $new_text = '[not set]'; } $this->_record_string_difference($name, $orig_text, $new_text); } }
/** * Format a date for display. * @param DATE_TIME $date * @param boolean $text_only Do not use tags when formatting. * @return string * @access private */ protected function _date($date, $text_only) { $Result = ''; if (isset($date) && $date->is_valid()) { $f = $date->formatter(); $f->type = Date_time_format_short_date; $f->show_local_time = !$text_only && $this->context->local_times_allowed(); $f->show_CSS = !$text_only; $Result = $date->format($f); if (!$text_only) { $Result = '<span class="visible">' . $Result . '</span>'; } } return $Result; }
/** * Restrict on a date field. * 'from' or 'to' may be empty. * @param string $field * @param DATE_TIME $from * @param DATE_TIME $to */ public function restrict_date($field, $from, $to) { if ($from && $from->is_valid()) { $this->restrict("{$field} >= '" . $from->as_ISO() . "'"); } if ($to && $to->is_valid()) { $this->restrict("{$field} <= '" . $to->as_ISO() . "'"); } }
protected function _pre_store() { parent::_pre_store(); if ($this->unpublished()) { $this->time_published->clear(); $this->publisher_id = 0; if ($this->_state_when_loaded != $this->state) { // State changed; check history items and revoke notification for published items $history_item_query = $this->history_item_query(); /** @var HISTORY_ITEM[] $history_items */ $history_items = $history_item_query->objects(); foreach ($history_items as $history_item) { if ($history_item->kind == History_item_published && $history_item->publication_state == History_item_needs_send) { $history_item->publication_state = History_item_silent; $history_item->store(); } } } } elseif (!$this->time_published->is_valid()) { $this->time_published->set_now(); if ($this->update_modifier_on_change) { $this->publisher_id = $this->login->id; } else { $this->publisher_id = $this->modifier_id; } } }
/** * Can messages be sent to this subscriber? * This function returns false if {@link $min_hours_to_wait} have not elapsed since messages were last * sent to this user. * @return boolean */ public function ready_for_messages() { if ($this->time_messages_sent->is_valid()) { $php_time_sent = $this->time_messages_sent->as_php(); return $php_time_sent + $this->min_hours_to_wait * 3600 < time(); } return $this->min_hours_to_wait != Subscriptions_disabled; }