function get_checkbox_style() { if (get_web_browser() == "moz") { return "padding: 4px; margin: 4px;"; }elseif (get_web_browser() == "ie") { return "padding: 0px; margin: 0px;"; }elseif (get_web_browser() == "other") { return "padding: 4px; margin: 4px;"; } }
function load_user_preferences() { global $login, $browser, $views, $prefarray, $is_assistant, $has_boss, $user; $lang_found = false; $browser = get_web_browser(); $browser_lang = get_browser_language(); $prefarray = array(); // Note: default values are set in config.php $res = dbi_query("SELECT cal_setting, cal_value FROM webcal_user_pref " . "WHERE cal_login = '******'"); if ($res) { while ($row = dbi_fetch_row($res)) { $setting = $row[0]; $value = $row[1]; $sys_setting = "sys_" . $setting; // save system defaults if (!empty($GLOBALS[$setting])) { $GLOBALS["sys_" . $setting] = $GLOBALS[$setting]; } $GLOBALS[$setting] = $value; $prefarray[$setting] = $value; if ($setting == "LANGUAGE") { $lang_found = true; } } dbi_free_result($res); } // get views for this user $res = dbi_query("SELECT cal_view_id, cal_name, cal_view_type FROM webcal_view " . "WHERE cal_owner = '{$login}'"); if ($res) { $views = array(); while ($row = dbi_fetch_row($res)) { $v = array("cal_view_id" => $row[0], "cal_name" => $row[1], "cal_view_type" => $row[2]); $views[] = $v; } dbi_free_result($res); } // If user has not set a language preference, then use their browser // settings to figure it out, and save it in the database for future // use (email reminders). if (!$lang_found && strlen($login) && $login != "__public__") { $LANGUAGE = $browser_lang; dbi_query("INSERT INTO webcal_user_pref " . "( cal_login, cal_setting, cal_value ) VALUES " . "( '{$login}', 'LANGUAGE', '{$LANGUAGE}' )"); } if (empty($GLOBALS["DATE_FORMAT_MY"])) { $GLOBALS["DATE_FORMAT_MY"] = "__month__ __yyyy__"; } if (empty($GLOBALS["DATE_FORMAT_MD"])) { $GLOBALS["DATE_FORMAT_MD"] = "__month__ __dd__"; } $is_assistant = user_is_assistant($login, $user); $has_boss = user_has_boss($login); }
/** * Loads the current user's preferences as global variables from the webcal_user_pref table. * * Also loads the list of views for this user (not really a preference, but * this is a convenient place to put this...) * * <b>Notes:</b> * - If <var>$allow_color_customization</var> is set to 'N', then we ignore any * color preferences. * - Other default values will also be set if the user has not saved a * preference and no global value has been set by the administrator in the * system settings. */ function load_user_preferences() { global $login, $browser, $views, $prefarray, $is_assistant, $has_boss, $user, $is_nonuser_admin, $allow_color_customization; $lang_found = false; $colors = array("BGCOLOR" => 1, "H2COLOR" => 1, "THBG" => 1, "THFG" => 1, "CELLBG" => 1, "TODAYCELLBG" => 1, "WEEKENDBG" => 1, "POPUP_BG" => 1, "POPUP_FG" => 1); $browser = get_web_browser(); $browser_lang = get_browser_language(); $prefarray = array(); // Note: default values are set in config.php $res = dbi_query("SELECT cal_setting, cal_value FROM webcal_user_pref " . "WHERE cal_login = '******'"); if ($res) { while ($row = dbi_fetch_row($res)) { $setting = $row[0]; $value = $row[1]; if ($allow_color_customization == 'N') { if (isset($colors[$setting])) { continue; } } $sys_setting = "sys_" . $setting; // save system defaults if (!empty($GLOBALS[$setting])) { $GLOBALS["sys_" . $setting] = $GLOBALS[$setting]; } $GLOBALS[$setting] = $value; $prefarray[$setting] = $value; if ($setting == "LANGUAGE") { $lang_found = true; } } dbi_free_result($res); } // get views for this user and global views $res = dbi_query("SELECT cal_view_id, cal_name, cal_view_type, cal_is_global " . "FROM webcal_view " . "WHERE cal_owner = '{$login}' OR cal_is_global = 'Y' " . "ORDER BY cal_name"); if ($res) { $views = array(); while ($row = dbi_fetch_row($res)) { if ($row[2] == 'S') { $url = "view_t.php?timeb=1&id={$row['0']}"; } else { if ($row[2] == 'T') { $url = "view_t.php?timeb=0&id={$row['0']}"; } else { $url = "view_" . strtolower($row[2]) . ".php?id={$row['0']}"; } } $v = array("cal_view_id" => $row[0], "cal_name" => $row[1], "cal_view_type" => $row[2], "cal_is_global" => $row[3], "url" => $url); $views[] = $v; } dbi_free_result($res); } // If user has not set a language preference, then use their browser // settings to figure it out, and save it in the database for future // use (email reminders). if (!$lang_found && strlen($login) && $login != "__public__") { $LANGUAGE = $browser_lang; dbi_query("INSERT INTO webcal_user_pref " . "( cal_login, cal_setting, cal_value ) VALUES " . "( '{$login}', 'LANGUAGE', '{$LANGUAGE}' )"); } if (empty($GLOBALS["DATE_FORMAT_MY"])) { $GLOBALS["DATE_FORMAT_MY"] = "__month__ __yyyy__"; } if (empty($GLOBALS["DATE_FORMAT_MD"])) { $GLOBALS["DATE_FORMAT_MD"] = "__month__ __dd__"; } $is_assistant = empty($user) ? false : user_is_assistant($login, $user); $has_boss = user_has_boss($login); $is_nonuser_admin = $user ? user_is_nonuser_admin($login, $user) : false; if ($is_nonuser_admin) { load_nonuser_preferences($user); } }
function load_user_preferences($guest = '') { global $ALLOW_COLOR_CUSTOMIZATION, $browser, $DATE_FORMAT, $DATE_FORMAT_MD, $DATE_FORMAT_MY, $DATE_FORMAT_TASK, $has_boss, $is_assistant, $is_nonuser, $is_nonuser_admin, $lang_file, $LANGUAGE, $login, $prefarray, $user, $views; $browser = get_web_browser(); $browser_lang = get_browser_language(); $colors = array('BGCOLOR' => 1, 'CELLBG' => 1, 'H2COLOR' => 1, 'HASEVENTSBG' => 1, 'MYEVENTS' => 1, 'OTHERMONTHBG' => 1, 'POPUP_BG' => 1, 'POPUP_FG' => 1, 'TABLEBG' => 1, 'TEXTCOLOR' => 1, 'THBG' => 1, 'THFG' => 1, 'TODAYCELLBG' => 1, 'WEEKENDBG' => 1, 'WEEKNUMBER' => 1); $lang_found = false; $prefarray = array(); // Allow __public__ pref to be used if logging in or user not validated. $tmp_login = empty($guest) ? $login : ($guest == 'guest' ? '__public__' : $guest); $rows = dbi_get_cached_rows('SELECT cal_setting, cal_value FROM webcal_user_pref WHERE cal_login = ?', array($tmp_login)); if ($rows) { for ($i = 0, $cnt = count($rows); $i < $cnt; $i++) { $row = $rows[$i]; $setting = $row[0]; $value = $row[1]; if ($setting == 'LANGUAGE') { $lang_found = true; } if ($ALLOW_COLOR_CUSTOMIZATION == 'N' && isset($colors[$setting])) { continue; } // $sys_setting = 'sys_' . $setting; // Save system defaults. if (!empty($GLOBALS[$setting])) { $GLOBALS['sys_' . $setting] = $GLOBALS[$setting]; } $GLOBALS[$setting] = $prefarray[$setting] = $value; } } // Set users timezone. if (isset($GLOBALS['TIMEZONE'])) { set_env('TZ', $GLOBALS['TIMEZONE']); } // Get views for this user and global views. // If NUC and not authorized by UAC, disallow global views. $rows = dbi_get_cached_rows('SELECT cal_view_id, cal_name, cal_view_type, cal_is_global, cal_owner FROM webcal_view WHERE cal_owner = ? ' . ($is_nonuser && (!access_is_enabled() || access_is_enabled() && !access_can_access_function(ACCESS_VIEW, $guest)) ? '' : ' OR cal_is_global = \'Y\' ') . 'ORDER BY cal_name', array($tmp_login)); if ($rows) { $views = array(); for ($i = 0, $cnt = count($rows); $i < $cnt; $i++) { $row = $rows[$i]; $url = 'view_'; if ($row[2] == 'E') { $url .= 'r.php?'; } elseif ($row[2] == 'S') { $url .= 't.php?'; } elseif ($row[2] == 'T') { $url .= 't.php?'; } else { $url .= strtolower($row[2]) . '.php?'; } $v = array('cal_view_id' => $row[0], 'cal_name' => $row[1], 'cal_view_type' => $row[2], 'cal_is_global' => $row[3], 'cal_owner' => $row[4], 'url' => $url . 'id=' . $row[0]); $views[] = $v; } } // If user has not set a language preference and admin has not specified a // language, then use their browser settings to figure it out // and save it in the database for future use (email reminders). $lang = 'none'; if (!$lang_found && strlen($tmp_login) && $tmp_login != '__public__') { if ($LANGUAGE == 'none') { $lang = $browser_lang; } dbi_execute('INSERT INTO webcal_user_pref ( cal_login, cal_setting, cal_value ) VALUES ( ?, ?, ? )', array($tmp_login, 'LANGUAGE', $lang)); } reset_language(!empty($LANGUAGE) && $LANGUAGE != 'none' ? $LANGUAGE : $browser_lang); if (empty($DATE_FORMAT) || $DATE_FORMAT == 'LANGUAGE_DEFINED') { $DATE_FORMAT = translate('__month__ __dd__, __yyyy__'); } if (empty($DATE_FORMAT_MY) || $DATE_FORMAT_MY == 'LANGUAGE_DEFINED') { $DATE_FORMAT_MY = translate('__month__ __yyyy__'); } if (empty($DATE_FORMAT_MD) || $DATE_FORMAT_MD == 'LANGUAGE_DEFINED') { $DATE_FORMAT_MD = translate('__month__ __dd__'); } if (empty($DATE_FORMAT_TASK) || $DATE_FORMAT_TASK == 'LANGUAGE_DEFINED') { $DATE_FORMAT_TASK = translate('__mm__/__dd__/__yyyy__'); } $has_boss = user_has_boss($tmp_login); $is_assistant = empty($user) ? false : user_is_assistant($tmp_login, $user); $is_nonuser_admin = $user ? user_is_nonuser_admin($tmp_login, $user) : false; // if ( $is_nonuser_admin ) load_nonuser_preferences ($user); }
function get_checkbox_style() { require_once(CACTI_BASE_PATH . "/lib/sys/http.php"); if (get_web_browser() == "moz") { return "padding: 4px; margin: 4px;"; }elseif (get_web_browser() == "ie") { return "padding: 0px; margin: 0px;"; }elseif (get_web_browser() == "other") { return "padding: 4px; margin: 4px;"; } }