فهرست منبع

Added userspace configurable timezone

Pontus Ullgren 23 سال پیش
والد
کامیت
986235ea11
3فایلهای تغییر یافته به همراه30 افزوده شده و 1 حذف شده
  1. 3 0
      src/load_prefs.php
  2. 22 0
      src/options_personal.php
  3. 5 1
      src/validate.php

+ 3 - 0
src/load_prefs.php

@@ -132,6 +132,9 @@ $editor_size = getPref($data_dir, $username, 'editor_size', 76 );
 $use_signature = getPref($data_dir, $username, 'use_signature', SMPREF_OFF );
 $prefix_sig = getPref($data_dir, $username, 'prefix_sig');
 
+/* Load timezone preferences */
+$timezone = getPref($data_dir, $username, 'timezone', SMPREF_NONE );
+
 /* Load preferences for reply citation style. */
 
 $reply_citation_style =

+ 22 - 0
src/options_personal.php

@@ -112,6 +112,28 @@ function load_optpage_data_personal() {
         );
     }
 
+    $TZ_ARRAY[SMPREF_NONE] = _("Same as server");
+    $fd = fopen('../locale/timezones.cfg','r');
+    while (!feof ($fd)) {
+        $zone = fgets($fd, 1024);
+        if( $zone ) {
+	    $zone = trim($zone);
+            $TZ_ARRAY["$zone"] = "$zone";
+        }
+    }
+    fclose ($fd);
+    
+    $optgrps[SMOPT_GRP_TZ] = _("Timezone Options");
+    $optvals[SMOPT_GRP_TZ] = array();
+
+    $optvals[SMOPT_GRP_TZ][] = array(
+        'name'    => 'timezone',
+	'caption' => _("Your current timezone"),
+	'type'    => SMOPT_TYPE_STRLIST,
+	'refresh' => SMOPT_REFRESH_NONE,
+	'posvals' => $TZ_ARRAY
+    );
+											     
     /*** Load the Reply Citation Options into the array ***/
     $optgrps[SMOPT_GRP_REPLY] = _("Reply Citation Options");
     $optvals[SMOPT_GRP_REPLY] = array();

+ 5 - 1
src/validate.php

@@ -70,4 +70,8 @@ require_once('../functions/prefs.php');
 global $username, $data_dir;
 set_up_language(getPref($data_dir, $username, 'language'));
 
-?>
+$timeZone = getPref($data_dir, $username, 'timezone');
+if ( $timeZone ) {
+    putenv("TZ=".$timeZone);
+}
+?>