Exemplo n.º 1
0
 static function getTimeOptions($date = '0000-00-00 00:00:00')
 {
     // Get time (not including the final secons)
     $time = substr($date, 11, 5);
     $html = '';
     $config = new JXConfig();
     $tz = $config->getTimezone() != '' ? $config->getTimezone() : JText::_('JXLIB_DEFAULT_TIMEZONE');
     $tz = new DateTimeZone($tz);
     /* create a date for every hour */
     for ($i = 0; $i < 24; $i++) {
         $newDate = new JDate(mktime($i, 0, 0, 7, 1, 2000), $tz);
         $newDate->format(JText::_('H:i'), false);
         /* if the selected is in hours */
         $selected = $time == $newDate->format(JText::_('H:i'), true) ? 'selected="selected"' : '';
         /* add the options */
         $html .= '<option ' . $selected . 'value="' . $newDate->format(JText::_('H:i'), true) . '" >' . $newDate->format(JText::_('JXLIB_TIME_SHORT_FORMAT'), true) . '</option>';
         /* and modify for 30 mins between these hours */
         $newDate->modify('+30 minute');
         /* check again to see if its in 30 mins interval */
         $selected = $time == $newDate->format(JText::_('H:i'), true) ? 'selected="selected"' : '';
         /* add the options */
         $html .= '<option ' . $selected . 'value="' . $newDate->format(JText::_('H:i'), true) . '" >' . $newDate->format(JText::_('JXLIB_TIME_SHORT_FORMAT'), true) . '</option>';
     }
     return $html;
 }
Exemplo n.º 2
0
 /**
  *
  * $range array('month' => 2)	 
  */
 public static function get($actions, $user_id, $group_id, $range, $group_by)
 {
     if ($group_by == 'hour') {
         // todo: db datetime is server utc, might need to calculate for offset
         $config = new JXConfig();
         $defaultTz = $config->getTimezone() != '' ? $config->getTimezone() : JText::_('JXLIB_DEFAULT_TIMEZONE');
         $my = JXFactory::getUser($user_id);
         $myTimeZone = $my->getParam('timezone');
         // Second load user personalize timezone (if any) to override system default timezone
         $timeZoneStr = empty($myTimeZone) ? $defaultTz : $myTimeZone;
         $tz = new DateTimeZone($timeZoneStr);
         $date2 = new JDate('now', $tz);
         $offset = $date2->getOffset() / 3600;
     } else {
         $offset = 0;
     }
     $result = self::getDbRecord($actions, $user_id, $group_id, $range, $group_by, $offset);
     return self::formulateData($result, $group_by, $offset);
 }
Exemplo n.º 3
0
 function display($tpl = null)
 {
     $configHelper = new JXConfig();
     $my = JFactory::getUser();
     $defaultLang = JText::_('JXLIB_DEFAULT_LANGUAGE');
     $defaultTz = JText::_('JXLIB_DEFAULT_TIMEZONE');
     $defaultInvite = JXConfig::DISALLOW;
     $defaultAnon = JXConfig::ALLOW;
     // Additional Configuration which are not Joomla! native variables
     $siteName = $configHelper->get(JXConfig::SITENAME) == '' ? '' : $configHelper->get(JXConfig::SITENAME);
     $timeZone = $configHelper->getTimezone();
     $language = $configHelper->getLanguage();
     $allowAnon = $configHelper->get(JXConfig::ALLOW_ANON) == '' ? $defaultAnon : $configHelper->get(JXConfig::ALLOW_ANON);
     $allowInvite = $configHelper->get(JXConfig::ALLOW_INVITE) == '' ? $defaultInvite : $configHelper->get(JXConfig::ALLOW_INVITE);
     $limitEmailDomain = $configHelper->get(JXConfig::LIMIT_EMAIL_DOMAIN) == '' ? '' : $configHelper->get(JXConfig::LIMIT_EMAIL_DOMAIN);
     $domainName = $configHelper->getDomainName(true) == '' ? '' : $configHelper->getDomainName(true);
     //overwrite value with postParam when save error
     $error = array();
     if ($_POST) {
         $postParam = JRequest::getVar('params');
         $timeZone = isset($postParam['timezone']) ? $postParam['timezone'] : $timeZone;
         $language = isset($postParam['language']) ? $postParam['language'] : $language;
         $siteName = isset($postParam['sitename']) ? $postParam['sitename'] : $configHelper->get('sitename');
         $allowInvite = isset($postParam['allow_invite']) ? $postParam['allow_invite'] : $allowInvite;
         $limitEmailDomain = isset($postParam['limit_email_domain']) ? $postParam['limit_email_domain'] : $limitEmailDomain;
         $domainName = isset($postParam['domain_name']) ? $postParam['domain_name'] : $domainName;
     }
     $form = JForm::getInstance('profileForm', JPATH_ROOT . DS . 'components' . DS . 'com_profile' . DS . 'models' . DS . 'forms' . DS . 'edit.xml');
     $this->assignRef('profileForm', $form);
     $this->assignRef('my', $my);
     $this->assignRef('sitename', $siteName);
     $this->assignRef('default_timezone', $timeZone);
     $this->assignRef('default_language', $language);
     $this->assignRef('domain_name', $domainName);
     $this->assignRef('limit_email_domain', $limitEmailDomain);
     $this->assignRef('allow_invite', $allowInvite);
     $this->assignRef('allow_anon', $allowAnon);
     $this->assign('domain_editable', $configHelper->allowChangeDomain());
     $doc = JFactory::getDocument();
     $doc->setTitle(JText::_("COM_ACCOUNT_LABEL_ACCOUNT_SETTING"));
     parent::display($tpl);
 }
Exemplo n.º 4
0
 /**
  * This will return the user timezone
  * @param int $user_id id of the user
  * @param String $forDisplay get the display, if true then return value will be formatted to the proper display
  * @return String depends on the value of format
  */
 public static function getUserTime($user_id = null, $forDisplay = false)
 {
     $config = new JXConfig();
     $user = JFactory::getUser($user_id);
     // First load account setting (if any) timezone to override timezone in language file
     $defaultTz = $config->getTimezone() != '' ? $config->getTimezone() : JText::_('JXLIB_DEFAULT_TIMEZONE');
     $my = !$user instanceof JUser && !$user instanceof JXUser ? JXFactory::getUser() : $user;
     $timeZoneStr = $my->getParam('timezone');
     // Second load user personalize timezone (if any) to override system default timezone
     $timeZoneStr = empty($timeZoneStr) ? $defaultTz : $timeZoneStr;
     $tz = new DateTimeZone($timeZoneStr);
     $date2 = new JDate('now', $tz);
     $offset = $date2->getOffset() / 3600;
     $date = new JDate();
     $date->setOffset($offset);
     $xdate = new JXDate();
     /* if the value want to be used as display purposes */
     if ($forDisplay) {
         return $xdate->formatDate($date);
     } else {
         return $xdate->format($date);
     }
 }
Exemplo n.º 5
0
 /**
  * Return standardized formatted date
  * NOTE: FOR TEMPLATE DISPLAY PURPOSE ONLY!!! DO NOT USE FOR DB QUERIES
  * Also use only for server generated time, NOT	 
  */
 static function formatDate($date, $long = self::LONG_DATE_FORMAT, $user = null)
 {
     // return original input date that cannot be processed
     if (strtotime($date) === false) {
         return $date;
     }
     $config = new JXConfig();
     // First load account setting (if any) timezone to override timezone in language file
     $defaultTz = $config->getTimezone() != '' ? $config->getTimezone() : JText::_('JXLIB_DEFAULT_TIMEZONE');
     $my = !$user instanceof JUser && !$user instanceof JXUser ? JXFactory::getUser() : $user;
     $timeZoneStr = $my->getParam('timezone');
     // Second load user personalize timezone (if any) to override system default timezone
     $timeZoneStr = empty($timeZoneStr) ? $defaultTz : $timeZoneStr;
     $tz = new DateTimeZone($timeZoneStr);
     if ($date instanceof JDate) {
         $date = $date->format('Y-m-d h:i:s');
     }
     $datenow = new JDate('now', $tz);
     $offset = $datenow->getOffset() / 3600;
     $date = new JDate($date);
     $date->setOffset($offset);
     $dateStr = $long == self::LONG_DATE_FORMAT ? $date->format(JText::_('JXLIB_DATE_FORMAT'), true) : $date->format(JText::_('JXLIB_DATE_SHORT_FORMAT'), true);
     if ($long == self::LONG_DATE_FORMAT) {
         // Test for today
         $dmy = $datenow->format(JText::_('JXLIB_DATE_DMY'), true);
         $dateStr = str_replace($dmy, JText::_('JXLIB_DATE_TODAY'), $dateStr);
         // Test for yesterday
         $datenow->modify('-1 day');
         $dmy = $datenow->format(JText::_('JXLIB_DATE_DMY'), true);
         $dateStr = str_replace($dmy, JText::_('JXLIB_DATE_YESTERDAY'), $dateStr);
     }
     return $dateStr;
 }