/** * Return the time to issue "warning" for the given date. * The {@link RELEASE_DATE_STATUS} uses this time to determine whether to format * a warning into the status or not. Based on values taken from {@link PROJECT_OPTIONS}. * @param DATE_TIME $date * @return DATE_TIME */ public function warning_time($date) { $fldr = $this->parent_folder(); $options = $fldr->options(); switch ($options->seconds_until_deadline) { case 0: return new DATE_TIME(); default: return new DATE_TIME($date->as_php() - $options->seconds_until_deadline); } }
/** * @param DATE_TIME $t1 * @param DATE_TIME $t2 */ public function __construct($t1, $t2) { $php_t1 = $t1->as_php(); $php_t2 = $t2->as_php(); $this->_total_seconds = $php_t1 - $php_t2; }
/** * Set the first and last days to render. * Must be called before calling {@link display()}. * @param DATE_TIME $first_day * @param DATE_TIME $last_day */ public function set_ranges($first_day, $last_day) { $first_day->set_time_from_iso('00:00:00'); $last_day->set_time_from_iso('23:59:59'); $this->first_day = $first_day; $this->last_day = $last_day; $php_first_day = $first_day->as_php(); $php_last_day = $last_day->as_php(); $first_month = date("n", $php_first_day); $first_year = date("Y", $php_first_day); $last_month = date("n", $php_last_day); $last_year = date("Y", $php_last_day); $diff_months = $last_year * Months_in_year + $last_month - ($first_year * Months_in_year + $first_month); if ($diff_months > Months_in_year) { $this->num_years = $last_year - $first_year + 1; } else { $this->num_years = 1; } $this->pager->set_ranges($this->num_years, 1); $this->pager->page_offset = date("Y", $php_first_day) - 1; $curr_month = $first_month; $curr_year = $first_year; $diff_months = $last_year * 12 + $last_month - ($curr_year * 12 + $curr_month); if ($diff_months > 12) { // the span is more than 12 months, so split into pages if ($this->pager->page_number == 1) { $last_month = 12; $last_year = $curr_year; } else { $curr_month = 1; $curr_year = $curr_year + $this->pager->page_number - 1; if ($curr_year != $last_year) { $last_month = 12; $last_year = $curr_year; } } } $this->_curr_month = $curr_month; $this->_curr_year = $curr_year; $this->_last_month = $last_month; $this->_last_year = $last_year; $this->_page_changed(); }
/** * Adjust first and last days to include the given entry. * Only has an effect when the album has a {@link $first_day_mode} or {@link * $last_day_mode} of {@link Day_mode_adjust}. Use {@link refresh_dates()} to * set the days from already contained content. * @param ALBUM_ENTRY $entry * @param boolean $update_now Updates the database immediately when * <code>True</code>. */ public function include_entry($entry, $update_now = true) { $first_day = $this->first_day->as_php(); $last_day = $this->last_day->as_php(); $day = $entry->date->as_php(); if ($this->first_day_mode == Day_mode_adjust) { if ($day < $first_day) { $this->first_day->set_from_php($day); if ($update_now) { $this->db->logged_query("UPDATE {$this->app->table_names->folders} SET first_day = '" . $this->first_day->as_iso() . "' WHERE id = {$this->id}"); } } } if ($this->last_day_mode == Day_mode_adjust) { $need_update = $day > $last_day; if (!$need_update) { $entry_query = $this->entry_query(); $need_update = $entry_query->size() == 0; } if ($need_update) { $this->last_day->set_from_php($day); if ($update_now) { $this->db->logged_query("UPDATE {$this->app->table_names->folders} SET last_day = '" . $this->last_day->as_iso() . "' WHERE id = {$this->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; }