/** * 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}"); } } } }
/** * Sets the {@link $expire_date} 'n' days in the future. * @see expire_when_session_ends() * @param integer $days */ public function expire_in_n_days($days) { $this->expire_date->set_from_php(time() + $days * 86400); }