Exemplo n.º 1
0
function prefs_server_list($partial = false)
{
    // Skipping the getTimeZoneList() from tikidate which just emulates the pear date format
    // Generating it is extremely costly in terms of memory.
    if (class_exists('DateTimeZone')) {
        $timezones = DateTimeZone::listIdentifiers();
    } elseif (class_exists('DateTime')) {
        $timezones = array_keys(DateTime::getTimeZoneList());
    } else {
        $timezones = TikiDate::getTimeZoneList();
        $timezones = array_keys($timezones);
    }
    sort($timezones);
    $tikidate = TikiLib::lib('tikidate');
    return array('server_timezone' => array('name' => tra('Time zone'), 'description' => tra('Indicates the default time zone to use for the server.'), 'type' => 'list', 'options' => array_combine($timezones, $timezones), 'default' => isset($tikidate) ? $tikidate->getTimezoneId() : 'UTC', 'tags' => array('basic')));
}
Exemplo n.º 2
0
 function onSetupPage($homepageUrl)
 {
     global $user, $prefs, $tiki_p_messages;
     $userlib = TikiLib::lib('user');
     $tikilib = TikiLib::lib('tiki');
     $smarty = TikiLib::lib('smarty');
     // Run the parent first
     parent::onSetupPage($homepageUrl);
     $showPage = false;
     // Show if option is selected
     if ($prefs['feature_userPreferences'] === 'y') {
         $showPage = true;
     }
     if (!$showPage) {
         return false;
     }
     $userwatch = $user;
     $smarty->assign('userwatch', $userwatch);
     $smarty->assign('show_mouseover_user_info', isset($prefs['show_mouseover_user_info']) ? $prefs['show_mouseover_user_info'] : $prefs['feature_community_mouseover']);
     $mailCharsets = array('utf-8', 'iso-8859-1');
     $smarty->assign_by_ref('mailCharsets', $mailCharsets);
     $mytiki_pages = $tikilib->get_user_preference($userwatch, 'mytiki_pages', 'y');
     $smarty->assign('mytiki_pages', $mytiki_pages);
     $mytiki_blogs = $tikilib->get_user_preference($userwatch, 'mytiki_blogs', 'y');
     $smarty->assign('mytiki_blogs', $mytiki_blogs);
     $mytiki_gals = $tikilib->get_user_preference($userwatch, 'mytiki_gals', 'y');
     $smarty->assign('mytiki_gals', $mytiki_gals);
     $mytiki_items = $tikilib->get_user_preference($userwatch, 'mytiki_items', 'y');
     $smarty->assign('mytiki_items', $mytiki_items);
     $mytiki_msgs = $tikilib->get_user_preference($userwatch, 'mytiki_msgs', 'y');
     $smarty->assign('mytiki_msgs', $mytiki_msgs);
     $mytiki_tasks = $tikilib->get_user_preference($userwatch, 'mytiki_tasks', 'y');
     $smarty->assign('mytiki_tasks', $mytiki_tasks);
     $mylevel = $tikilib->get_user_preference($userwatch, 'mylevel', '1');
     $smarty->assign('mylevel', $mylevel);
     $allowMsgs = $tikilib->get_user_preference($userwatch, 'allowMsgs', 'y');
     $smarty->assign('allowMsgs', $allowMsgs);
     $minPrio = $tikilib->get_user_preference($userwatch, 'minPrio', 3);
     $smarty->assign('minPrio', $minPrio);
     $theme = $tikilib->get_user_preference($userwatch, 'theme', '');
     $smarty->assign('theme', $theme);
     $language = $tikilib->get_user_preference($userwatch, 'language', $prefs['language']);
     $smarty->assign('language', $language);
     $email_isPublic = $tikilib->get_user_preference($userwatch, 'email is public', 'n');
     if (isset($user_preferences[$userwatch]['email is public'])) {
         $user_preferences[$userwatch]['email_isPublic'] = $user_preferences[$userwatch]['email is public'];
         $email_isPublic = $user_preferences[$userwatch]['email is public'];
     }
     $smarty->assign('email_isPublic', $email_isPublic);
     $mailCharset = $tikilib->get_user_preference($userwatch, 'mailCharset', $prefs['default_mail_charset']);
     $smarty->assign('mailCharset', $mailCharset);
     $user_dbl = $tikilib->get_user_preference($userwatch, 'user_dbl', 'n');
     $userbreadCrumb = $tikilib->get_user_preference($userwatch, 'userbreadCrumb', $prefs['site_userbreadCrumb']);
     $smarty->assign('userbreadCrumb', $userbreadCrumb);
     $smarty->assign('user_dbl', $user_dbl);
     $display_12hr_clock = $tikilib->get_user_preference($userwatch, 'display_12hr_clock', 'n');
     $smarty->assign('display_12hr_clock', $display_12hr_clock);
     $userinfo = $userlib->get_user_info($userwatch);
     $smarty->assign_by_ref('userinfo', $userinfo);
     $llist = array();
     $llist = $tikilib->list_styles();
     $smarty->assign_by_ref('styles', $llist);
     $languages = array();
     $languages = $tikilib->list_languages();
     $smarty->assign_by_ref('languages', $languages);
     $user_pages = $tikilib->get_user_pages($userwatch, -1);
     $smarty->assign_by_ref('user_pages', $user_pages);
     $bloglib = TikiLib::lib('blog');
     $user_blogs = $bloglib->list_user_blogs($userwatch, false);
     $smarty->assign_by_ref('user_blogs', $user_blogs);
     $user_galleries = $tikilib->get_user_galleries($userwatch, -1);
     $smarty->assign_by_ref('user_galleries', $user_galleries);
     $user_items = TikiLib::lib('trk')->get_user_items($userwatch);
     $smarty->assign_by_ref('user_items', $user_items);
     $scramblingMethods = array("n", "strtr", "unicode", "x", 'y');
     // email_isPublic utilizes 'n'
     $smarty->assign_by_ref('scramblingMethods', $scramblingMethods);
     $scramblingEmails = array(tra("no"), scrambleEmail($userinfo['email'], 'strtr'), scrambleEmail($userinfo['email'], 'unicode') . "-" . tra("unicode"), scrambleEmail($userinfo['email'], 'x'), $userinfo['email']);
     $smarty->assign_by_ref('scramblingEmails', $scramblingEmails);
     $mailCharsets = array('utf-8', 'iso-8859-1');
     $smarty->assign_by_ref('mailCharsets', $mailCharsets);
     $smarty->assign_by_ref('user_prefs', $user_preferences[$userwatch]);
     $tikilib->get_user_preference($userwatch, 'diff_versions', 'n');
     $usertrackerId = false;
     $useritemId = false;
     if ($prefs['userTracker'] == 'y') {
         $re = $userlib->get_usertracker($userinfo["userId"]);
         if (isset($re['usersTrackerId']) and $re['usersTrackerId']) {
             $trklib = TikiLib::lib('trk');
             $info = $trklib->get_item_id($re['usersTrackerId'], $trklib->get_field_id($re['usersTrackerId'], 'Login'), $userwatch);
             $usertrackerId = $re['usersTrackerId'];
             $useritemId = $info;
         }
     }
     $smarty->assign('usertrackerId', $usertrackerId);
     $smarty->assign('useritemId', $useritemId);
     //// Custom fields
     //foreach ($customfields as $custpref => $prefvalue) {
     //$customfields[$custpref]['value'] = $tikilib->get_user_preference($userwatch, $customfields[$custpref]['prefName'], $customfields[$custpref]['value']);
     //$smarty->assign($customfields[$custpref]['prefName'], $customfields[$custpref]['value']);
     //}
     if ($prefs['feature_messages'] == 'y' && $tiki_p_messages == 'y') {
         $unread = $tikilib->user_unread_messages($userwatch);
         $smarty->assign('unread', $unread);
     }
     $smarty->assign('timezones', TikiDate::getTimeZoneList());
     // Time zone data for the user
     if ($prefs['users_prefs_display_timezone'] == 'Site') {
         $smarty->assign('warning_site_timezone_set', 'y');
     }
     if (isset($prefs['display_timezone'])) {
         $smarty->assign('display_timezone', $prefs['display_timezone']);
     }
     $smarty->assign('userPageExists', 'n');
     if ($prefs['feature_wiki'] == 'y' and $prefs['feature_wiki_userpage'] == 'y') {
         if ($tikilib->page_exists($prefs['feature_wiki_userpage_prefix'] . $user)) {
             $smarty->assign('userPageExists', 'y');
         }
     }
     $smarty->assign_by_ref('tikifeedback', $tikifeedback);
     return true;
 }
Exemplo n.º 3
0
 function set_display_timezone($user)
 {
     global $prefs;
     if ($prefs['users_prefs_display_timezone'] == 'Site' || isset($user_preferences[$user]['display_timezone']) && $user_preferences[$user]['display_timezone'] == 'Site') {
         // Stay in the time zone of the server
         $prefs['display_timezone'] = $prefs['server_timezone'];
     } elseif (!isset($prefs['display_timezone']) and !isset($user_preferences[$user]['display_timezone']) || $user_preferences[$user]['display_timezone'] == '' || $user_preferences[$user]['display_timezone'] == 'Local') {
         // If the display timezone is not known ...
         if (isset($_COOKIE['local_tz'])) {
             //   ... we try to use the timezone detected by javascript and stored in cookies
             if (TikiDate::TimezoneIsValidId($_COOKIE['local_tz'])) {
                 $prefs['timezone_offset'] = isset($_COOKIE['local_tzoffset']) ? $_COOKIE['local_tzoffset'] : '';
                 if (isset($_COOKIE['local_tzoffset'])) {
                     $tzname = timezone_name_from_abbr($_COOKIE['local_tz'], $_COOKIE['local_tzoffset'] * 60 * 60);
                     $prefs['timezone_offset'] = $_COOKIE['local_tzoffset'];
                 } else {
                     $tzname = timezone_name_from_abbr($_COOKIE['local_tz']);
                     $prefs['timezone_offset'] = '';
                 }
                 if (TikiDate::TimezoneIsValidId($tzname)) {
                     $prefs['display_timezone'] = $tzname;
                 } else {
                     $prefs['display_timezone'] = $_COOKIE['local_tz'];
                 }
             } elseif ($_COOKIE['local_tz'] == 'HAEC') {
                 // HAEC, returned by Safari on Mac, is not recognized as a DST timezone (with daylightsavings)
                 //  ... So use one equivalent timezone name
                 $prefs['display_timezone'] = 'Europe/Paris';
             } else {
                 $prefs['display_timezone'] = $prefs['server_timezone'];
             }
         } else {
             // ... and we fallback to the server timezone if the cookie value is not available
             $prefs['display_timezone'] = $prefs['server_timezone'];
         }
     }
 }
Exemplo n.º 4
0
	function get_extend_until_info($user, $group, $periods = 1)
	{
		// Calculations here should always be 1 am system time otherwise prone to user manipulation or daylight savings problems
		global $prefs;

		$tz = $prefs['server_timezone'];
		if ( ! TikiDate::TimezoneIsValidId($tz) ) {
			$tz = 'UTC';
		}

		$timezone = new DateTimeZone($tz);
		$userInfo = $this->get_user_info($user);
		$info = $this->get_group_info($group);
 		$ratio_prorated_first_period = 1;

		if (empty($info['prorateInterval'])) {
			$prorateInterval = 'day';
		} else {
			$prorateInterval = $info['prorateInterval'];
		}

		$date = $this->getOne(
						'SELECT `expire` FROM `users_usergroups` where `userId` = ? AND `groupName` = ?',
						array($userInfo['userId'], $group)
		);

		if (!$date) {
			$date = $this->now;
		}

		if (!empty($info['anniversary'])) {
			$date_year = date('Y', $date);
			$date_month = date('m', $date);
			$date_day = date('d', $date);
			$effective_date = new DateTime("{$date_year}-{$date_month}-{$date_day} 01:00:00", $timezone);
			$ratio_prorated_first_period = 1;
			if (strlen($info['anniversary']) == 4) {
				// annual anniversaries
				$ann_month = substr($info['anniversary'], 0, 2);
				$ann_day = substr($info['anniversary'], 2, 2);
				// start off with this year's anniversary date
				$extend_until = new DateTime("{$date_year}-{$ann_month}-{$ann_day} 01:00:00", $timezone);
				while ($effective_date->format('U') >= $extend_until->format('U')) {
					// already passed the anniversary this month, extend to next year's anniversary
					$extend_until->modify('+1 year');
				}
				// store last past anniversary for prorating
				$prev_ann = clone $extend_until;
				$prev_ann->modify('-1 year');
				if ($prorateInterval == 'year') {
					$payable_from = clone $prev_ann;
				} elseif ($prorateInterval == 'month') {
					$payable_from = clone $extend_until;
					while ($payable_from->format('U') > $effective_date->format('U')) {
						$payable_from->modify('-1 month');
					}
				} elseif ($prorateInterval == 'day') {
					$payable_from = clone $effective_date;
				}
				$extend_until_first_period = clone $extend_until;
				// add extra full periods
				if ($periods > 1) {
					$p = $periods - 1;
					$extend_until->modify("+$p year");
				}
			} elseif (strlen($info['anniversary']) == 2) {
				// monthly anniversaries
				$ann_day = $info['anniversary'];
				// start off with this month's anniversary date
				$extend_until = new DateTime("{$date_year}-{$date_month}-{$ann_day} 01:00:00", $timezone);
				while ($effective_date->format('U') >= $extend_until->format('U')) {
					// already passed the anniversary this month, extend to next month's anniversary
					$extend_until->modify('+1 month');
				}
				// store last past anniversary for prorating
				$prev_ann = clone $extend_until;
				$prev_ann->modify('-1 month');
				if ($prorateInterval == 'month' || $prorateInterval == 'year') {
					$payable_from = clone $prev_ann;
				} elseif ($prorateInterval == 'day') {
					$payable_from = clone $effective_date;
				}
				$extend_until_first_period = clone $extend_until;
				// add extra full periods
				if ($periods > 1) {
					$p = $periods - 1;
					$extend_until->modify("+$p month");
				}
			} elseif (strlen($info['anniversary']) == 3) {
				// Case not handled, and variables used below is not set
				// Not sure what to do here?
			}
			$timestamp = null;
			if ($extend_until != null && $payable_from != null && $prev_ann != null) {
				$ratio_prorated_first_period = ($extend_until_first_period->format('U') - $payable_from->format('U')) / ($extend_until_first_period->format('U') - $prev_ann->format('U'));
				$timestamp = $extend_until->format('U');
			}
		} else {
			$timestamp = $date + $periods * $info['expireAfter'] * 24 * 3600;
		}

		return array('timestamp' => $timestamp, 'ratio_prorated_first_period' => $ratio_prorated_first_period);
	}
Exemplo n.º 5
0
		for ($i = count($listevents) - 1; $i >= 0; --$i) {
			$listevents[$i]['modifiable'] = in_array($listevents[$i]['calendarId'], $modifiable)? "y": "n";
		}
	} else {
		$listevents = $calendarlib->list_items($_SESSION['CalendarViewGroups'], $user, $viewstart, $viewend, 0, -1);
	}
	$smarty->assign_by_ref('listevents', $listevents);
} else {
	$listevents = array();
}

$mloop = TikiLib::date_format("%m", $viewstart);
$dloop = TikiLib::date_format("%d", $viewstart);
$yloop = TikiLib::date_format("%Y", $viewstart);

$curtikidate = new TikiDate();
$display_tz = $tikilib->get_display_timezone();
if ( $display_tz == '' ) $display_tz = 'UTC';
$curtikidate->setTZbyID($display_tz);
$curtikidate->setLocalTime($dloop, $mloop, $yloop, 0, 0, 0, 0);

$smarty->assign('display_tz', $display_tz);

$smarty->assign('day', $daystart);

$firstDay = false;

for ($i = 0; $i <= $numberofweeks; $i++) {
	$weeks[] = $weekNumbers[] = $curtikidate->getWeekOfYear();
	require_once('lib/smarty_tiki/modifier.userlink.php');
Exemplo n.º 6
0
 /**
  * Get calendar and its events
  *
  * @param $calIds
  * @param $viewstart
  * @param $viewend
  * @param $group_by
  * @param $item_name
  * @param bool $listmode if set to true populate listevents key of the returned array
  * @return array
  */
 function getCalendar($calIds, &$viewstart, &$viewend, $group_by = '', $item_name = 'events', $listmode = false)
 {
     global $user, $prefs;
     // Global vars used by tiki-calendar_setup.php (this has to be changed)
     global $calendarViewMode, $request_day, $request_month;
     global $request_year, $dayend, $myurl;
     global $weekdays, $daysnames, $daysnames_abr;
     include 'tiki-calendar_setup.php';
     $smarty = TikiLib::lib('smarty');
     $tikilib = TikiLib::lib('tiki');
     //FIXME : maxrecords = 50
     $listtikievents = $this->list_items_by_day($calIds, $user, $viewstart, $viewend, 0, 50);
     $mloop = TikiLib::date_format('%m', $viewstart);
     $dloop = TikiLib::date_format('%d', $viewstart);
     $yloop = TikiLib::date_format('%Y', $viewstart);
     $curtikidate = new TikiDate();
     $display_tz = $tikilib->get_display_timezone();
     if ($display_tz == '') {
         $display_tz = 'UTC';
     }
     $curtikidate->setTZbyID($display_tz);
     $curtikidate->setLocalTime($dloop, $mloop, $yloop, 0, 0, 0, 0);
     $listevents = array();
     // note that number of weeks starts at ZERO (i.e., zero = 1 week to display).
     for ($i = 0; $i <= $numberofweeks; $i++) {
         $weeks[] = $curtikidate->getWeekOfYear();
         foreach ($weekdays as $w) {
             $leday = array();
             if ($group_by == 'day') {
                 $key = 0;
             }
             if ($calendarViewMode['casedefault'] == 'day') {
                 $dday = $daystart;
             } else {
                 $dday = $curtikidate->getTime();
                 $curtikidate->addDays(1);
             }
             $cell[$i][$w]['day'] = $dday;
             if ($calendarViewMode['casedefault'] == 'day' or $dday >= $daystart && $dday <= $dayend) {
                 $cell[$i][$w]['focus'] = true;
             } else {
                 $cell[$i][$w]['focus'] = false;
             }
             if (isset($listtikievents["{$dday}"])) {
                 $e = -1;
                 foreach ($listtikievents["{$dday}"] as $lte) {
                     $lte['desc_name'] = $lte['name'];
                     if ($group_by_item != 'n') {
                         if ($group_by != 'day') {
                             $key = $lte['id'] . '|' . $lte['type'];
                         }
                         if (!isset($leday[$key])) {
                             $leday[$key] = $lte;
                             if ($group_by == 'day') {
                                 $leday[$key]['description'] = array($lte['where'] => array($lte['group_description']));
                                 $leday[$key]['head'] = TikiLib::date_format($prefs['short_date_format'], $cell[$i][$w]['day']);
                             } else {
                                 $leday[$key]['description'] = ' - <b>' . $lte['when'] . '</b> : ' . tra($lte['action']) . ' ' . $lte['description'];
                                 $leday[$key]['head'] = $lte['name'] . ', <i>' . tra('in') . ' ' . $lte['where'] . '</i>';
                             }
                             $leday[$key]['desc_name'] = '';
                         } else {
                             $leday_item =& $leday[$key];
                             $leday_item['user'] .= ', ' . $lte['user'];
                             if (!isset($leday_item['action']) || !is_integer($leday_item['action'])) {
                                 $leday_item['action'] = 1;
                             }
                             $leday_item['action']++;
                             if ($group_by == 'day') {
                                 $leday_item['name'] .= '<br />' . $lte['name'];
                                 $leday_item['desc_name'] = $leday_item['action'] . ' ' . tra($item_name) . ': ';
                                 $leday_item['description'][$lte['where']][] = $lte['group_description'];
                             } else {
                                 $leday_item['name'] = $lte['name'] . ' (x<b>' . $leday_item['action'] . '</b>)';
                                 $leday_item['desc_name'] = $leday_item['action'] . ' ' . tra($item_name);
                                 if ($lte['show_description'] == 'y' && !empty($lte['description'])) {
                                     $leday_item['description'] .= ",\n<br /> - <b>" . $lte['when'] . '</b> : ' . tra($lte['action']) . ' ' . $lte['description'];
                                     $leday_item['show_description'] = 'y';
                                 }
                             }
                         }
                     } else {
                         $e++;
                         $key = "{$lte['time']}{$e}";
                         $leday[$key] = $lte;
                         $lte['desc_name'] .= tra($lte['action']);
                     }
                 }
                 foreach ($leday as $key => $lte) {
                     if ($group_by == 'day') {
                         $desc = '';
                         foreach ($lte['description'] as $desc_where => $desc_items) {
                             $desc_items = array_unique($desc_items);
                             foreach ($desc_items as $desc_item) {
                                 if ($desc != '') {
                                     $desc .= '<br />';
                                 }
                                 $desc .= '- ' . $desc_item;
                                 if (!empty($lte['show_location']) && $lte['show_location'] == 'y' && $desc_where != '') {
                                     $desc .= ' <i>[' . $desc_where . ']</i>';
                                 }
                             }
                         }
                         $lte['description'] = $desc;
                     }
                     $smarty->assign('calendar_type', $myurl == 'tiki-action_calendar.php' ? 'tiki_actions' : 'calendar');
                     $smarty->assign_by_ref('item_url', $lte["url"]);
                     $smarty->assign_by_ref('cellhead', $lte["head"]);
                     $smarty->assign_by_ref('cellprio', $lte["prio"]);
                     $smarty->assign_by_ref('cellcalname', $lte["calname"]);
                     $smarty->assign('celllocation', "");
                     $smarty->assign('cellcategory', "");
                     $smarty->assign_by_ref('cellname', $lte["desc_name"]);
                     $smarty->assign('cellid', "");
                     $smarty->assign_by_ref('celldescription', $lte["description"]);
                     $smarty->assign('show_description', $lte["show_description"]);
                     if (!isset($leday[$key]["over"])) {
                         $leday[$key]["over"] = '';
                     } else {
                         $leday[$key]["over"] .= "<br />\n";
                     }
                     $leday[$key]["over"] .= $smarty->fetch("tiki-calendar_box.tpl");
                 }
             }
             if (is_array($leday)) {
                 ksort($leday);
                 $cell[$i][$w]['items'] = array_values($leday);
             }
         }
     }
     if (isset($_SESSION['CalendarViewList']) && $_SESSION['CalendarViewList'] == 'list' || $listmode) {
         if (is_array($listtikievents)) {
             foreach ($listtikievents as $le) {
                 if (is_array($le)) {
                     foreach ($le as $e) {
                         $listevents[] = $e;
                     }
                 }
             }
         }
     }
     return array('cell' => $cell, 'listevents' => $listevents, 'weeks' => $weeks, 'weekdays' => $weekdays, 'daysnames' => $daysnames, 'daysnames_abr' => $daysnames_abr, 'trunc' => $trunc);
 }
Exemplo n.º 7
0
        if (!empty($custom_js)) {
            $headerlib->add_jsfile($custom_js, 50);
        }
    }
    /** Use custom.js in lang dir if there **/
    $language = $prefs['language'];
    if (is_file("lang/{$language}/custom.js")) {
        TikiLib::lib('header')->add_jsfile("lang/{$language}/custom.js", 40);
        // before styles custom.js
    }
    if (!empty($tikidomain) && is_file("lang/{$language}/{$tikidomain}/custom.js")) {
        // Note: lang tikidomain dirs not created automatically
        TikiLib::lib('header')->add_jsfile("lang/{$language}/{$tikidomain}/custom.js", 40);
    }
    // setup timezone array
    $tz = TikiDate::getTimezoneAbbreviations();
    $headerlib->add_js('
function inArray(item, array) {
    for (var i in array) {
        if (array[i] === item) {
            return i;
        }
    }
    return false;
}
var allTimeZoneCodes = ' . json_encode(array_map("strtoupper", $tz)) . ';
var now = new Date();
var now_string = now.toString();
var offsethours = - now.getTimezoneOffset() / 60;
setCookie("local_tzoffset", offsethours);
var m = now_string.match(/[ \\(]([A-Z]{3,6})[ \\)]?[ \\d]*$/);	// try three or more char tz first at the end or just before the year
Exemplo n.º 8
0
 /**
  * @param bool $_user
  * @return null|string
  */
 function get_display_timezone($_user = false)
 {
     global $prefs, $user;
     if ($_user === false || $_user == $user) {
         // If the requested timezone is the current user timezone
         $tz = $prefs['display_timezone'];
     } elseif ($_user) {
         // ... else, get the user timezone preferences from DB
         $tz = $this->get_user_preference($_user, 'display_timezone');
     }
     if (!TikiDate::TimezoneIsValidId($tz)) {
         $tz = $prefs['server_timezone'];
     }
     if (!TikiDate::TimezoneIsValidId($tz)) {
         $tz = 'UTC';
     }
     return $tz;
 }
Exemplo n.º 9
0
 function make_time($hour, $minute, $second, $month, $day, $year)
 {
     global $tikidate, $tikilib, $prefs;
     if (!is_object($tikidate)) {
         require_once 'lib/tikidate.php';
         $tikidate = new TikiDate();
         $display_tz = $tikilib->get_display_timezone();
         if ($display_tz == '') {
             $display_tz = 'UTC';
         }
     }
     $tikidate->setTZbyID('PST');
     /// DEBUG HACK!!
     $tikidate->setLocalTime($day, $month, $year, $hour, $minute, $second, 0);
     return $tikidate->getTime();
 }
Exemplo n.º 10
0
        $usertrackerId = $re['usersTrackerId'];
        $useritemId = $info;
    }
}
$smarty->assign('usertrackerId', $usertrackerId);
$smarty->assign('useritemId', $useritemId);
// Custom fields
foreach ($customfields as $custpref => $prefvalue) {
    $customfields[$custpref]['value'] = $tikilib->get_user_preference($userwatch, $customfields[$custpref]['prefName'], $customfields[$custpref]['value']);
    $smarty->assign($customfields[$custpref]['prefName'], $customfields[$custpref]['value']);
}
if ($prefs['feature_messages'] == 'y' && $tiki_p_messages == 'y') {
    $unread = $tikilib->user_unread_messages($userwatch);
    $smarty->assign('unread', $unread);
}
$smarty->assign('timezones', TikiDate::getTimeZoneList());
$tikilib->set_display_timezone($user);
if (isset($prefs['display_timezone'])) {
    $smarty->assign('display_timezone', $prefs['display_timezone']);
}
if ($prefs['users_prefs_display_timezone'] == 'Site') {
    $smarty->assign('warning_site_timezone_set', 'y');
} else {
    $smarty->assign('warning_site_timezone_set', 'n');
}
$smarty->assign('userPageExists', 'n');
if ($prefs['feature_wiki'] == 'y' and $prefs['feature_wiki_userpage'] == 'y') {
    if ($tikilib->page_exists($prefs['feature_wiki_userpage_prefix'] . $user)) {
        $smarty->assign('userPageExists', 'y');
    }
}
Exemplo n.º 11
0
 function get_extend_until_info($user, $group, $periods = 1)
 {
     //use these functions to get current expiry dates for existing members - they are calculated in some cases
     //so just grabbing the "expire" field from the users_usergroups table doesn't always work
     $userInfo = $this->get_user_info($user);
     $usergroupdates = $this->get_user_groups_date($userInfo['userId']);
     $info = $this->get_group_info($group);
     //set the start date as now for new memberships and as expiry of current membership for existing members
     if (array_key_exists($group, $usergroupdates)) {
         if (!empty($usergroupdates[$group]['expire'])) {
             $date = $usergroupdates[$group]['expire'];
         } elseif ($info['expireAfter'] > 0) {
             $date = $usergroupdates[$group]['created'];
         }
     }
     if (!isset($date) || !$date) {
         $date = $this->now;
         //this is a new membership
         $new = true;
     }
     //convert start date to object
     $rawstartutc = new DateTimeImmutable('@' . $date);
     global $prefs;
     $tz = TikiDate::TimezoneIsValidId($prefs['server_timezone']) ? $prefs['server_timezone'] : 'UTC';
     $timezone = new DateTimeZone($tz);
     $startlocal = $rawstartutc->setTimezone($timezone);
     //anniversary memberships
     if (!empty($info['anniversary'])) {
         //set time to 1 second after midnight so that all times are set to same times for interval calculations
         $startlocal = $startlocal->setTime(0, 0, 1);
         // annual anniversaries
         if (strlen($info['anniversary']) == 4) {
             $ann_month = substr($info['anniversary'], 0, 2);
             $ann_day = substr($info['anniversary'], 2, 2);
             $startyear = $startlocal->format('Y');
             //increment the year if past the annual anniversary
             if ($startlocal->format('m') > $ann_month || $startlocal->format('m') == $ann_month && $startlocal->format('d') >= $ann_day) {
                 $startyear++;
             }
             //first extension is always to next anniversary
             $next_ann = $startlocal->setDate($startyear, $ann_month, $ann_day);
             //extend past next anniversary if more than one period
             $extendto = $next_ann->modify('+' . $periods - 1 . ' years');
             //previous anniversary for proration
             $prev_ann = $next_ann->modify('-1 years');
             // monthly anniversaries
             //using modify('+1 month') can result in "skipping" months so fix the day of the previous/next month
         } elseif (strlen($info['anniversary']) == 2) {
             $ann_day = $info['anniversary'];
             $lastday = date('d', strtotime('last day of ' . $startlocal->format('Y') . '-' . $startlocal->format('m')));
             $mod_ann_day = $ann_day > $lastday ? $lastday : $ann_day;
             if ($startlocal->format('d') < $mod_ann_day) {
                 $mod = $mod_ann_day - $startlocal->format('d');
                 $next_ann = $startlocal->modify('+' . $mod . ' days');
                 $prev_mo_lastday = $startlocal->modify('last day of last month');
                 if ($ann_day >= $prev_mo_lastday->format('d')) {
                     $prev_ann = $prev_mo_lastday;
                 } else {
                     $prev_ann = $startlocal->setDate($prev_mo_lastday->format('Y'), $prev_mo_lastday->format('m'), $mod_ann_day);
                 }
             } else {
                 //check if last day of month
                 $next_mo_lastday = $startlocal->modify('last day of next month');
                 if ($mod_ann_day >= $next_mo_lastday->format('d')) {
                     $next_ann = $next_mo_lastday;
                 } else {
                     $next_ann = $startlocal->setDate($next_mo_lastday->format('Y'), $next_mo_lastday->format('m'), $mod_ann_day);
                 }
                 $mod = $startlocal->format('d') - $mod_ann_day;
                 $prev_ann = $startlocal->modify('-' . $mod . ' days');
             }
             if ($periods - 1 > 0) {
                 $yrsplus = floor(($periods - 1) / 12);
                 $yr = $next_ann->format('Y') + $yrsplus;
                 $moplus = $periods - 1 - $yrsplus * 12;
                 if ($moplus + $next_ann->format('m') < 12) {
                     $mo = $moplus + $next_ann->format('m');
                 } else {
                     $yr++;
                     $mo = $moplus + $next_ann->format('m') - 12;
                 }
                 if ($ann_day >= date('d', strtotime('last day of ' . $yr . '-' . $mo))) {
                     $d = date('d', strtotime('last day of ' . $yr . '-' . $mo));
                 } else {
                     $d = $ann_day;
                 }
                 $extendto = $next_ann->setDate($yr, $mo, $d);
             } else {
                 $extendto = $next_ann;
             }
         }
         //calculate interval of membership term
         $interval = $startlocal->diff($extendto);
         //set prorate interval
         $prorateInterval = in_array($info['prorateInterval'], ['year', 'month', 'day']) ? $info['prorateInterval'] : 'day';
         //prorate
         if ($prorateInterval == 'year' && strlen($info['anniversary']) == 4) {
             $ratio = $interval->y;
             $ratio += $interval->m > 0 || $interval->d > 0 ? 1 : 0;
         } elseif ($prorateInterval == 'month' || $prorateInterval == 'year' && strlen($info['anniversary']) == 2) {
             $round = $interval->d > 0 ? 1 : 0;
             $ratio = $interval->y * 12 + $interval->m + $round;
             if (strlen($info['anniversary']) == 4) {
                 $ratio = $ratio / 12;
             }
         } elseif ($prorateInterval == 'day') {
             $ann_interval = $prev_ann->diff($next_ann);
             $stub_interval = $startlocal->diff($next_ann);
             $ratio = $stub_interval->days / $ann_interval->days + ($periods - 1);
         }
         $remainder = $ratio > 1 ? $ratio - floor($ratio) : $ratio;
         //memberships based on number of days
     } else {
         $remainder = 1;
         $ratio = 1;
         $extendto = $startlocal->modify('+' . $info['expireAfter'] * $periods . ' days');
         $interval = $startlocal->diff($extendto);
     }
     $timestamp = $extendto != null ? $extendto->format('U') : null;
     return array('timestamp' => $timestamp, 'ratio_prorated_first_period' => $remainder, 'ratio' => $ratio, 'interval' => $interval, 'new' => $new);
 }
Exemplo n.º 12
0
    $smarty->assign('userPage', $userPage);
    $smarty->assign('userPage_exists', $exist);
} else {
    if (isset($_SESSION['preferences'])) {
        $prefs = array_merge($prefs, $_SESSION['preferences']);
    }
    $allowMsgs = 'n';
}
$smarty->assign('IP', $tikilib->get_ip_address());
if ($prefs['users_prefs_display_timezone'] == 'Site' || isset($user_preferences[$user]['display_timezone']) && $user_preferences[$user]['display_timezone'] == 'Site') {
    // Stay in the time zone of the server
    $prefs['display_timezone'] = $prefs['server_timezone'];
} elseif (!isset($user_preferences[$user]['display_timezone']) || $user_preferences[$user]['display_timezone'] == '' || $user_preferences[$user]['display_timezone'] == 'Local') {
    // If the display timezone is not known ...
    if (isset($_COOKIE['local_tz'])) {
        //   ... we try to use the timezone detected by javascript and stored in cookies
        if (TikiDate::TimezoneIsValidId($_COOKIE['local_tz'])) {
            $prefs['display_timezone'] = $_COOKIE['local_tz'];
        } elseif ($_COOKIE['local_tz'] == 'HAEC') {
            // HAEC, returned by Safari on Mac, is not recognized as a DST timezone (with daylightsavings)
            //  ... So use one equivalent timezone name
            $prefs['display_timezone'] = 'Europe/Paris';
        } else {
            $prefs['display_timezone'] = $prefs['server_timezone'];
        }
    } else {
        // ... and we fallback to the server timezone if the cookie value is not available
        $prefs['display_timezone'] = $prefs['server_timezone'];
    }
}
$smarty->refreshLanguage();
Exemplo n.º 13
0
    $maxRecords = $_REQUEST['maxRecords'];
}
if (isset($_SESSION['CalendarFocusDate'])) {
    $startTime = $_SESSION['CalendarFocusDate'];
} else {
    // by default, export will start from yesterday's events.
    $startDate = new TikiDate();
    $startDate->addDays(-1);
    $startTime = $startDate->getTime();
}
if (isset($_REQUEST['start_date_Month'])) {
    $startTime = TikiLib::make_time(0, 0, 0, $_REQUEST['start_date_Month'], $_REQUEST['start_date_Day'], $_REQUEST['start_date_Year']);
} elseif (isset($_REQUEST["tstart"])) {
    $startTime = $_REQUEST["tstart"];
}
$endDate = new TikiDate();
$endDate->setDate($startTime);
if ($calendarViewMode['casedefault'] == 'month') {
    $stopTime = $endDate->addMonths(1);
} elseif ($calendarViewMode['casedefault'] == 'quarter') {
    $stopTime = $endDate->addMonths(3);
} elseif ($calendarViewMode['casedefault'] == 'semester') {
    $stopTime = $endDate->addMonths(6);
} elseif ($calendarViewMode['casedefault'] == 'year') {
    $stopTime = $endDate->addMonths(12);
} else {
    $stopTime = $endDate->addMonths(1);
}
$stopTime = $endDate->getTime();
if (isset($_REQUEST['stop_date_Month'])) {
    $stopTime = TikiLib::make_time(0, 0, 0, $_REQUEST['stop_date_Month'], $_REQUEST['stop_date_Day'], $_REQUEST['stop_date_Year']);
Exemplo n.º 14
0
    // Stay in the time zone of the server
    $prefs['display_timezone'] = $prefs['server_timezone'];
} elseif (!isset($user_preferences[$user]['display_timezone']) || $user_preferences[$user]['display_timezone'] == '' || $user_preferences[$user]['display_timezone'] == 'Local') {
    // If the display timezone is not known ...
    if (isset($_COOKIE['local_tz'])) {
        //   ... we try to use the timezone detected by javascript and stored in cookies
        if (TikiDate::TimezoneIsValidId($_COOKIE['local_tz'])) {
            $prefs['timezone_offset'] = isset($_COOKIE['local_tzoffset']) ? $_COOKIE['local_tzoffset'] : '';
            if (isset($_COOKIE['local_tzoffset'])) {
                $tzname = timezone_name_from_abbr($_COOKIE['local_tz'], $_COOKIE['local_tzoffset'] * 60 * 60);
                $prefs['timezone_offset'] = $_COOKIE['local_tzoffset'];
            } else {
                $tzname = timezone_name_from_abbr($_COOKIE['local_tz']);
                $prefs['timezone_offset'] = '';
            }
            if (TikiDate::TimezoneIsValidId($tzname)) {
                $prefs['display_timezone'] = $tzname;
            } else {
                $prefs['display_timezone'] = $_COOKIE['local_tz'];
            }
        } elseif ($_COOKIE['local_tz'] == 'HAEC') {
            // HAEC, returned by Safari on Mac, is not recognized as a DST timezone (with daylightsavings)
            //  ... So use one equivalent timezone name
            $prefs['display_timezone'] = 'Europe/Paris';
        } else {
            $prefs['display_timezone'] = $prefs['server_timezone'];
        }
    } else {
        // ... and we fallback to the server timezone if the cookie value is not available
        $prefs['display_timezone'] = $prefs['server_timezone'];
    }