public function __construct($id = 0) { if (empty($id)) { $this->start_time = PHPWS_Time::getUserTime(); $this->end_time = PHPWS_Time::getUserTime(); return; } else { $this->id = (int) $id; $result = $this->init(); if (PHPWS_Error::isError($result)) { PHPWS_Error::log($result); $this->id = 0; } elseif (!$result) { $this->id = 0; } } }
/** * Loads todays unix time and date info */ public function loadToday() { $atime = PHPWS_Time::getTimeArray(); $this->today =& $atime['u']; $this->current_date = $this->today; $this->int_month =& $atime['m']; $this->int_day =& $atime['d']; $this->int_year =& $atime['y']; }
public static function userForm(PHPWS_User $user, $message = NULL) { require_once PHPWS_SOURCE_DIR . 'core/class/Time.php'; javascript('jquery'); $form = new PHPWS_Form(); $form->addHidden('module', 'users'); $form->addHidden('action', 'user'); $form->addHidden('command', 'my_page'); $form->addHidden('subcommand', 'postUser'); if (Current_User::allow('users') || $user->display_name == $user->username) { $form->addText('display_name', $user->display_name); $form->setClass('display_name', 'form-control'); $form->setLabel('display_name', dgettext('users', 'Display Name')); } else { $form->addTplTag('DISPLAY_NAME_LABEL', dgettext('users', 'Display Name')); $tpl['DISPLAY_NAME'] = javascript('slider', array('link' => $user->display_name, 'id' => 'name-info', 'message' => dgettext('users', 'Once you change your display name, you may not change it again until reset by the site administrator.'))); } if ($user->canChangePassword()) { $form->addPassword('password1'); $form->setAutoComplete('password1'); $form->setClass('password1', 'form-control'); $form->addPassword('password2'); $form->setAutoComplete('password2'); $form->setClass('password2', 'form-control'); $form->setTitle('password2', dgettext('users', 'Password confirm')); $form->setLabel('password1', dgettext('users', 'Password')); } else { $tpl['PASSWORD1_LABEL'] = dgettext('users', 'Password'); $tpl['PASSWORD1'] = javascript('slider', array('link' => dgettext('users', 'Why can\'t I change my password?'), 'id' => 'pw-info', 'message' => dgettext('users', 'Your account is authorized external to this site. You will need to update it at the source.'))); } $form->addText('email', $user->getEmail()); $form->setSize('email', 40); $form->setLabel('email', dgettext('users', 'Email Address')); $form->setClass('email', 'form-control'); if (isset($tpl)) { $form->mergeTemplate($tpl); } $tz_list = PHPWS_Time::getTZList(); $timezones['server'] = dgettext('users', '-- Use server\'s time zone --'); foreach ($tz_list as $tz) { if (!empty($tz['codes'])) { $timezones[$tz['id']] = sprintf('%s : %s', $tz['id'], $tz['codes'][0]); } elseif (!empty($tz['city'])) { $timezones[$tz['id']] = sprintf('%s : %s', $tz['id'], $tz['city'][0]); } else { $timezones[$tz['id']] = $tz['id']; } } if (isset($_REQUEST['timezone'])) { $user_tz = $_REQUEST['timezone']; } else { $user_tz = PHPWS_Cookie::read('user_tz'); } $form->addSelect('timezone', $timezones); $form->setLabel('timezone', dgettext('users', 'Time Zone')); $form->setMatch('timezone', $user_tz); $form->setClass('timezone', 'form-control'); if (isset($_REQUEST['dst']) && $_REQUEST['timezone'] != 'server') { $dst = $_REQUEST['dst']; } else { $dst = PHPWS_Cookie::read('user_dst'); } $form->addCheckbox('dst', 1); $form->setMatch('dst', $dst); $form->setLabel('dst', dgettext('users', 'Use Daylight Savings Time')); if (isset($_POST['cp'])) { $cp = (int) $_POST['cp']; } else { $cp = (int) PHPWS_Cookie::read('user_cp'); } if (Current_User::allowRememberMe()) { // User must authorize locally if ($_SESSION['User']->authorize == 1) { $form->addCheckbox('remember_me', 1); if (PHPWS_Cookie::read('remember_me')) { $form->setMatch('remember_me', 1); } $form->setLabel('remember_me', dgettext('users', 'Remember me')); } } $form->addHidden('userId', $user->getId()); $form->addSubmit('submit', dgettext('users', 'Update my information')); $form->setClass('submit', 'btn btn-primary'); if (!DISABLE_TRANSLATION && !FORCE_DEFAULT_LANGUAGE) { $language_file = PHPWS_Core::getConfigFile('users', 'languages.php'); if ($language_file) { include $language_file; $form->addSelect('language', $languages); $form->setClass('language', 'form-control'); $form->setLabel('language', dgettext('users', 'Language preference')); if (isset($_COOKIE['phpws_default_language'])) { $language = preg_replace('/\\W/', '', $_COOKIE['phpws_default_language']); $form->setMatch('language', $language); } } } $template = $form->getTemplate(); if (isset($message)) { foreach ($message as $tag => $error) { $template[$tag] = $error; } } $template['ACCT_INFO'] = dgettext('users', 'Account Information'); $template['LOCAL_INFO'] = dgettext('users', 'Localization'); $template['PREF'] = dgettext('users', 'Preferences'); return PHPWS_Template::process($template, 'users', 'my_page/user_setting.tpl'); }
public function getUpdateDate($format = '%c') { return strftime($format, PHPWS_Time::getServerTime($this->update_date)); }
function getUpdated($format = WIKI_DATE_FORMAT) { return strftime($format, PHPWS_Time::getUserTime($this->updated)); }
public function addSuggestLink($default_date = NULL) { if (!isset($default_date)) { $default_date = PHPWS_Time::getUserTime(); } $suggest_label = dgettext('calendar', 'Suggest event'); if (javascriptEnabled()) { $vars['address'] = sprintf('index.php?module=calendar&uop=suggest_event&js=1&sch_id=%s&date=%s', $this->id, $default_date); $vars['link_title'] = $vars['label'] = $suggest_label; $vars['width'] = CALENDAR_SUGGEST_WIDTH; $vars['height'] = CALENDAR_SUGGEST_HEIGHT; return javascript('open_window', $vars); } else { return PHPWS_Text::moduleLink($suggest_label, 'calendar', array('uop' => 'suggest_event', 'sch_id' => $this->id, 'date' => $default_date)); } }
public static function getTimeArray($time = 0) { if (!$time) { $time = PHPWS_Time::getServerTime(); } $aTime['m'] = (int) strftime('%m', $time); $aTime['d'] = (int) strftime('%e', $time); $aTime['y'] = (int) strftime('%Y', $time); $aTime['h'] = (int) strftime('%k', $time); $aTime['i'] = (int) strftime('%M', $time); $aTime['u'] = $time; return $aTime; }
public function icalTags() { static $today = 0; static $contact = null; if (empty($today)) { $today = time(); $contact = PHPWS_Settings::get('users', 'site_contact'); } $tpl['BEGINEVENT'] = "\n"; $tpl['ENDEVENT'] = "\n"; $tpl['TODAY'] = PHPWS_Time::getDTTime($today); $tpl['EMAIL'] = $contact; $tpl['UID'] = sprintf('%s-%s.%s', $this->_schedule->title, $this->_schedule->id, $this->id); $tpl['SUMMARY'] = $this->summary; if (!empty($this->location)) { if (!empty($this->loc_link)) { $tpl['LOCATION'] = $this->loc_link . " " . $this->location; } else { $tpl['LOCATION'] = $this->location; } } $description = strip_tags(str_ireplace('', '', $this->getDescription())); $description = preg_replace(array('/^\\s\\s+/', '/\\s\\s+$/', '/\\s\\s+/u'), array('', '', ' '), $description); if (!empty($description)) { $tpl['DESCRIPTION'] =& $description; } if ($this->all_day) { $tpl['DTSTART_AD'] = PHPWS_Time::getDTTime($this->start_time, 'all_day'); $tpl['DTEND_AD'] = PHPWS_Time::getDTTime($this->end_time, 'all_day'); } else { $tpl['DTSTART'] = PHPWS_Time::getDTTime($this->start_time); $tpl['DTEND'] = PHPWS_Time::getDTTime($this->end_time); } return $tpl; }
public function brief_view() { $template['TITLE'] = $this->title; $template['LOCAL_DATE'] = $this->getPublishDate(); $template['PUBLISHED_DATE'] = PHPWS_Time::getDTTime($this->publish_date); $template['SUMMARY'] = PHPWS_Text::parseTag($this->getSummary(true)); $template['ENTRY'] = PHPWS_Text::parseTag($this->getEntry(true)); $template['IMAGE'] = $this->getFile($this->thumbnail); $template['POSTED_BY'] = dgettext('blog', 'Posted by'); $template['POSTED_ON'] = dgettext('blog', 'Posted at'); $template['PUBLISHED'] = dgettext('blog', 'Published'); if ($this->author_id) { $template['AUTHOR'] = $this->author; } else { $template['AUTHOR'] = dgettext('blog', 'Anonymous'); } return PHPWS_Template::process($template, 'blog', 'view_full.tpl'); }