2 /*********************************************************************************
3 * SugarCRM is a customer relationship management program developed by
4 * SugarCRM, Inc. Copyright (C) 2004-2011 SugarCRM Inc.
6 * This program is free software; you can redistribute it and/or modify it under
7 * the terms of the GNU Affero General Public License version 3 as published by the
8 * Free Software Foundation with the addition of the following permission added
9 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
10 * IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
11 * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
13 * This program is distributed in the hope that it will be useful, but WITHOUT
14 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
18 * You should have received a copy of the GNU Affero General Public License along with
19 * this program; if not, see http://www.gnu.org/licenses or write to the Free
20 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
23 * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
24 * SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
26 * The interactive user interfaces in modified source and object code versions
27 * of this program must display Appropriate Legal Notices, as required under
28 * Section 5 of the GNU Affero General Public License version 3.
30 * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
31 * these Appropriate Legal Notices must retain the display of the "Powered by
32 * SugarCRM" logo. If the display of the logo is not reasonably feasible for
33 * technical reasons, the Appropriate Legal Notices must display the words
34 * "Powered by SugarCRM".
35 ********************************************************************************/
38 <form action='index.php' method="POST">
39 <input type='hidden' name='action' value='updateTimezonePrefs'>
40 <input type='hidden' name='module' value='Administration'>
44 if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
45 $prompt_users = 'checked';
46 if(isset($_POST['preview']) && !isset($_POST['prompt_users'])){
51 $result = $db->query("SELECT id, user_preferences, user_name FROM users");
53 // loop through user preferences and check for "bad" elements; rebuild preferences array and update database
54 if(isset($_POST['execute'])){
57 $serverTimeZone = lookupTimezone(0);
58 while ($row = $db->fetchByAssoc($result)) {
61 if(isset($_POST[$row['id'].'adjust'])){
62 $adjustment = $_POST[$row['id'].'adjust'];
66 if($execute)$string = "Updating";
67 echo "<tr><td> $string timezone preferences for user <b>{$row['user_name']}</b>...</td><td>";
73 $prefs = unserialize(base64_decode($row['user_preferences']));
78 foreach ($prefs as $key => $val) {
79 if ($key == 'timez') {
80 if(empty($prefs['timezone']) && $val != ''){
81 $hourAdjust = $adjustment;
82 if($hourAdjust == 'none'){
85 $selectedZone = lookupTimezone($prefs['timez'] + $hourAdjust);
87 if(!empty($selectedZone)){
88 $newprefs['timezone'] = $selectedZone;
89 $newprefs['timez'] = $val;
90 $setTo = $selectedZone;
91 if(empty($prompt_users)){
97 $newprefs['timezone'] = $serverTimeZone;
98 $newprefs['timez'] = $val;
99 $setTo = $serverTimeZone;
100 if(empty($prompt_users)){
107 $newprefs[$key] = $val;
108 if(!empty($prefs['timezone'])){
109 $alreadySet = 'Previously Set - '. $prefs['timezone'];
115 $newprefs[$key] = $val;
119 $newstr = mysql_real_escape_string(base64_encode(serialize($newprefs)));
120 $db->query("UPDATE users SET user_preferences = '{$newstr}' WHERE id = '{$row['id']}'");
126 if(!empty($alreadySet)){
129 echo $serverTimeZone;
130 $prefs['timezone'] = $serverTimeZone;
137 if(isset($_POST[$row['id'].'adjust'])){
141 echo "<select name='{$row['id']}adjust'>";
143 echo get_select_options_with_id(array('-1'=>'-1', 'none'=>'0', '1'=>'+1'), $adjustment.'');
152 $the_old_prefs[] = $prefs;
153 $the_new_prefs[] = $newprefs;
163 echo "<br>All timezone preferences updated!<br><br>";
166 echo "Prompt users on login to confirm:<input type='checkbox' name='prompt_users' value='1' $prompt_users><br>";
167 echo "<input class='button' type='submit' name='execute' value='Execute'> <input class='button' type='submit' name='preview' value='Preview'>";
170 echo " <input class='button' type='button' name='Done' value='Done' onclick='document.location.href=\"index.php?action=DstFix&module=Administration\"'>";