/** * Load default view * * @return bool: always returns true on successful construction of view * */ public function loadDefault() { $this->user = $this->logged_user; //Handle save if (isset($_POST['user-id'])) { $this->user->init($_POST['user-id']); //Make sure the submitted user matches the one logged in if ($_POST['user-id'] == DinklyUser::getLoggedId()) { $this->validateUserPost($_POST); if ($_POST['date-format'] == 'MM/DD/YY') { $this->user->setDateFormat('m/d/y'); } else { if ($_POST['date-format'] == 'DD/MM/YY') { $this->user->setDateFormat('d/m/y'); } } if ($_POST['time-format'] == '12') { $this->user->setTimeFormat('g:i a'); } else { if ($_POST['time-format'] == '24') { $this->user->setTimeFormat('H:i'); } } //If we have no errors, save the user if ($this->errors == array()) { $this->user->save(); $this->logged_user = $this->user; DinklyFlash::set('good_user_message', 'Profile Updated'); } } } //Timezone dropdown (http://stackoverflow.com/a/7022536/53079) $utc = new DateTimeZone('UTC'); $dt = new DateTime('now', $utc); $this->select_options = null; $timezone_identifiers = DateTimeZone::listIdentifiers(DateTimeZone::PER_COUNTRY, 'US'); foreach ($timezone_identifiers as $tz) { $current_tz = new DateTimeZone($tz); $offset = $current_tz->getOffset($dt); $transition = $current_tz->getTransitions($dt->getTimestamp(), $dt->getTimestamp()); $abbr = $transition[0]['abbr']; $selected = null; if ($this->user->getTimeZone() == $tz) { $selected = 'selected="selected"'; } $this->select_options .= '<option ' . $selected . ' value="' . $tz . '">' . str_replace('_', ' ', $tz) . ' [' . $abbr . ' ' . DinklyUser::formatOffset($offset) . ']</option>'; } return true; }