Revision: 2228
          http://mrbs.svn.sourceforge.net/mrbs/?rev=2228&view=rev
Author:   cimorrison
Date:     2012-01-01 13:00:48 +0000 (Sun, 01 Jan 2012)
Log Message:
-----------
Limited the timezones presented in the timezone drop-down box on the Edit Area 
page to those that have a corresponding VTIMEZONE definition

Modified Paths:
--------------
    mrbs/trunk/web/edit_area_room.php
    mrbs/trunk/web/functions_ical.inc
    mrbs/trunk/web/internalconfig.inc.php
    mrbs/trunk/web/systemdefaults.inc.php

Modified: mrbs/trunk/web/edit_area_room.php
===================================================================
--- mrbs/trunk/web/edit_area_room.php   2011-12-31 13:41:12 UTC (rev 2227)
+++ mrbs/trunk/web/edit_area_room.php   2012-01-01 13:00:48 UTC (rev 2228)
@@ -48,14 +48,15 @@
 
 function create_field_entry_timezone()
 {
-  global $timezone;
+  global $timezone, $zoneinfo_outlook_compatible;
   
   $special_group = "Others";
   
   echo "<div>\n";
   echo "<label for=\"area_timezone\">" . get_vocab("timezone") . ":</label>\n";
 
-  // If possible we'll present a list of timezones that this server supports.
+  // If possible we'll present a list of timezones that this server supports 
and
+  // which also have a corresponding VTIMEZONE definition.
   // Otherwise we'll just have to let the user type in a timezone, which 
introduces
   // the possibility of an invalid timezone.
   if (function_exists('timezone_identifiers_list'))
@@ -80,28 +81,38 @@
         // limit the explosion to two
         list($continent, $city) = explode('/', $value, 2);
       }
-      $timezones[$continent][] = $city;
+      // Check that there's a VTIMEZONE definition
+      $tz_dir = ($zoneinfo_outlook_compatible) ? TZDIR_OUTLOOK : TZDIR;  
+      $tz_file = "$tz_dir/$value.ics";
+      // UTC is a special case because we can always produce UTC times in 
iCalendar
+      if (($city=='UTC') || file_exists($tz_file))
+      {
+        $timezones[$continent][] = $city;
+      }
     }
     
     echo "<select id=\"area_timezone\" name=\"area_timezone\">\n";
     foreach ($timezones as $continent => $cities)
     {
-      echo "<optgroup label=\"" . htmlspecialchars($continent) . "\">\n";
-      foreach ($cities as $city)
+      if (count($cities) > 0)
       {
-        if ($continent == $special_group)
+        echo "<optgroup label=\"" . htmlspecialchars($continent) . "\">\n";
+        foreach ($cities as $city)
         {
-          $timezone_identifier = $city;
+          if ($continent == $special_group)
+          {
+            $timezone_identifier = $city;
+          }
+          else
+          {
+            $timezone_identifier = "$continent/$city";
+          }
+          echo "<option value=\"" . htmlspecialchars($timezone_identifier) . 
"\"" .
+               (($timezone_identifier == $timezone) ? " selected=\"selected\"" 
: "") .
+               ">" . htmlspecialchars($city) . "</option>\n";
         }
-        else
-        {
-          $timezone_identifier = "$continent/$city";
-        }
-        echo "<option value=\"" . htmlspecialchars($timezone_identifier) . 
"\"" .
-             (($timezone_identifier == $timezone) ? " selected=\"selected\"" : 
"") .
-             ">" . htmlspecialchars($city) . "</option>\n";
+        echo "</optgroup>\n";
       }
-      echo "</optgroup>\n";
     }
     echo "</select>\n";
   }

Modified: mrbs/trunk/web/functions_ical.inc
===================================================================
--- mrbs/trunk/web/functions_ical.inc   2011-12-31 13:41:12 UTC (rev 2227)
+++ mrbs/trunk/web/functions_ical.inc   2012-01-01 13:00:48 UTC (rev 2228)
@@ -82,16 +82,15 @@
 // the filesystem.
 function get_vtimezone($tz)
 {
-  global $tbl_zoneinfo, $zoneinfo_update, $zoneinfo_expiry;
+  global $tbl_zoneinfo, $zoneinfo_update, $zoneinfo_expiry, 
$zoneinfo_outlook_compatible;
   
-  $outlook_compatible = TRUE;    // We use the Outlook compatible versions
-  $tz_dir = ($outlook_compatible) ? "tzurl/zoneinfo-outlook" : 
"tzurl/zoneinfo";  
+  $tz_dir = ($zoneinfo_outlook_compatible) ? TZDIR_OUTLOOK : TZDIR;  
   $tz_file = "$tz_dir/$tz.ics";  // A fallback for a VTIMEZONE definition
   
   $vtimezone = FALSE;  // Default value in case we don't find one
   
   // Convert booleans into 1 or 0 (necessary for the database)
-  $outlook_compatible = ($outlook_compatible) ? 1 : 0;
+  $zoneinfo_outlook_compatible = ($zoneinfo_outlook_compatible) ? 1 : 0;
   
   // Acquire a mutex to lock out others who might be accessing 
   // the table, to stop somebody inserting a record at the same
@@ -105,7 +104,7 @@
   $sql = "SELECT vtimezone, last_updated
             FROM $tbl_zoneinfo
            WHERE timezone='" . addslashes($tz) . "'
-             AND outlook_compatible=$outlook_compatible
+             AND outlook_compatible=$zoneinfo_outlook_compatible
            LIMIT 1";
   $res = sql_query($sql);
   if ($res === FALSE)
@@ -152,7 +151,7 @@
                      SET vtimezone='" . addslashes($vtimezone) . "',
                          last_updated=" . time() . "
                    WHERE timezone='" . addslashes($tz) . "'
-                     AND outlook_compatible=$outlook_compatible";
+                     AND outlook_compatible=$zoneinfo_outlook_compatible";
           if (sql_command($sql) < 0)
           {
             trigger_error(sql_error(), E_USER_WARNING);
@@ -176,7 +175,7 @@
         $sql = "INSERT INTO $tbl_zoneinfo
                 (timezone, outlook_compatible, vtimezone, last_updated)
                 VALUES ('" . addslashes($tz) . "', 
-                        $outlook_compatible,
+                        $zoneinfo_outlook_compatible,
                         '" . addslashes($vtimezone) . "', " .
                         time() . ")";
         if (sql_command($sql) < 0)

Modified: mrbs/trunk/web/internalconfig.inc.php
===================================================================
--- mrbs/trunk/web/internalconfig.inc.php       2011-12-31 13:41:12 UTC (rev 
2227)
+++ mrbs/trunk/web/internalconfig.inc.php       2012-01-01 13:00:48 UTC (rev 
2228)
@@ -139,6 +139,14 @@
 
 
 /*************************************************
+ * DIRECTORIES - internal use, do not change
+ *************************************************/
+ 
+define('TZDIR',           'tzurl/zoneinfo');          // Directory containing 
TZURL definitions
+define('TZDIR_OUTLOOK',   'tzurl/zoneinfo-outlook');  // Outlook compatible 
TZURL definitions
+
+
+/*************************************************
  * ICALENDAR CONSTANTS - internal use, do not change
  *************************************************/
  

Modified: mrbs/trunk/web/systemdefaults.inc.php
===================================================================
--- mrbs/trunk/web/systemdefaults.inc.php       2011-12-31 13:41:12 UTC (rev 
2227)
+++ mrbs/trunk/web/systemdefaults.inc.php       2012-01-01 13:00:48 UTC (rev 
2228)
@@ -43,6 +43,10 @@
 // setting $zoneinfo_update = FALSE;
 $zoneinfo_update = TRUE;
 
+// The VTIMEZONE definitions exist in two forms - normal and Outlook 
compatible.
+// $zoneinfo_outlook_compatible determines which ones to use.
+$zoneinfo_outlook_compatible = TRUE;
+
 // The VTIMEZONE definitions are cached in the database with an expiry time
 // of $zoneinfo_expiry seconds
 $zoneinfo_expiry = 60*60*24*28;    // 28 days

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
Ridiculously easy VDI. With Citrix VDI-in-a-Box, you don't need a complex
infrastructure or vast IT resources to deliver seamless, secure access to
virtual desktops. With this all-in-one solution, easily deploy virtual 
desktops for less than the cost of PCs and save 60% on VDI infrastructure 
costs. Try it free! http://p.sf.net/sfu/Citrix-VDIinabox
_______________________________________________
Mrbs-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mrbs-commits

Reply via email to