plugins/SpecialUserPrefs.php
changeset 406 7468a663315f
parent 389 da3bb3e99323
child 411 d1a95497b68f
equal deleted inserted replaced
405:adb7f8de8ce1 406:7468a663315f
   150 
   150 
   151 function page_Special_Preferences()
   151 function page_Special_Preferences()
   152 {
   152 {
   153   global $db, $session, $paths, $template, $plugins; // Common objects
   153   global $db, $session, $paths, $template, $plugins; // Common objects
   154   global $lang;
   154   global $lang;
       
   155   global $timezone;
   155   
   156   
   156   // We need a login to continue
   157   // We need a login to continue
   157   if ( !$session->user_logged_in )
   158   if ( !$session->user_logged_in )
   158     redirect(makeUrlNS('Special', 'Login/' . $paths->page), 'Login required', 'You need to be logged in to access this page. Please wait while you are redirected to the login page.');
   159     redirect(makeUrlNS('Special', 'Login/' . $paths->page), 'Login required', 'You need to be logged in to access this page. Please wait while you are redirected to the login page.');
   159   
   160   
   481       if ( isset($_POST['submit']) )
   482       if ( isset($_POST['submit']) )
   482       {
   483       {
   483         $real_name = htmlspecialchars($_POST['real_name']);
   484         $real_name = htmlspecialchars($_POST['real_name']);
   484         $real_name = $db->escape($real_name);
   485         $real_name = $db->escape($real_name);
   485         
   486         
       
   487         $timezone = intval($_POST['timezone']);
       
   488         $tz_local = $timezone + 1440;
       
   489         
   486         $imaddr_aim = htmlspecialchars($_POST['imaddr_aim']);
   490         $imaddr_aim = htmlspecialchars($_POST['imaddr_aim']);
   487         $imaddr_aim = $db->escape($imaddr_aim);
   491         $imaddr_aim = $db->escape($imaddr_aim);
   488         
   492         
   489         $imaddr_msn = htmlspecialchars($_POST['imaddr_msn']);
   493         $imaddr_msn = htmlspecialchars($_POST['imaddr_msn']);
   490         $imaddr_msn = $db->escape($imaddr_msn);
   494         $imaddr_msn = $db->escape($imaddr_msn);
   534         $session->user_extra['user_location'] = $location;
   538         $session->user_extra['user_location'] = $location;
   535         $session->user_extra['user_job'] = $occupation;
   539         $session->user_extra['user_job'] = $occupation;
   536         $session->user_extra['user_hobbies'] = $hobbies;
   540         $session->user_extra['user_hobbies'] = $hobbies;
   537         $session->user_extra['email_public'] = intval($email_public);
   541         $session->user_extra['email_public'] = intval($email_public);
   538         
   542         
   539         $q = $db->sql_query('UPDATE '.table_prefix."users SET real_name='$real_name' WHERE user_id=$session->user_id;");
   543         $q = $db->sql_query('UPDATE '.table_prefix."users SET real_name='$real_name', user_timezone = $tz_local WHERE user_id=$session->user_id;");
   540         if ( !$q )
   544         if ( !$q )
   541           $db->_die();
   545           $db->_die();
   542         
   546         
   543         $q = $db->sql_query('UPDATE '.table_prefix."users_extra SET user_aim='$imaddr_aim',user_yahoo='$imaddr_yahoo',user_msn='$imaddr_msn',
   547         $q = $db->sql_query('UPDATE '.table_prefix."users_extra SET user_aim='$imaddr_aim',user_yahoo='$imaddr_yahoo',user_msn='$imaddr_msn',
   544                                user_xmpp='$imaddr_xmpp',user_homepage='$homepage',user_location='$location',user_job='$occupation',
   548                                user_xmpp='$imaddr_xmpp',user_homepage='$homepage',user_location='$location',user_job='$occupation',
   590         $lang_box .= "<option value=\"$lang_id\"$selected>$lang_name</option>";
   594         $lang_box .= "<option value=\"$lang_id\"$selected>$lang_name</option>";
   591       }
   595       }
   592       
   596       
   593       $lang_box .= '</select>';
   597       $lang_box .= '</select>';
   594       
   598       
       
   599       $tz_select = '<select name="timezone">';
       
   600       $tz_list = $lang->get('tz_list');
       
   601       try
       
   602       {
       
   603         $tz_list = enano_json_decode($tz_list);
       
   604       }
       
   605       catch(Exception $e)
       
   606       {
       
   607         die("Caught exception decoding timezone data: <pre>$e</pre>");
       
   608       }
       
   609       foreach ( $tz_list as $key => $i )
       
   610       {
       
   611         $i = ($i * 60);
       
   612         $title = $lang->get("tz_title_{$key}");
       
   613         $hrs = $lang->get("tz_hrs_{$key}");
       
   614         $selected = ( $i == $timezone ) ? ' selected="selected"' : '';
       
   615         $tz_select .= "<option value=\"$i\"$selected>$title</option>";
       
   616       }
       
   617       $tz_select .= '</select>';
       
   618       
   595       echo '<form action="'.makeUrl($paths->fullpage).'" method="post">';
   619       echo '<form action="'.makeUrl($paths->fullpage).'" method="post">';
   596       ?>
   620       ?>
   597       <div class="tblholder">
   621       <div class="tblholder">
   598         <table border="0" cellspacing="1" cellpadding="4">
   622         <table border="0" cellspacing="1" cellpadding="4">
   599           <tr>
   623           <tr>
   611             <td class="row1"><?php echo $lang_box; ?></td>
   635             <td class="row1"><?php echo $lang_box; ?></td>
   612           </tr>
   636           </tr>
   613           <tr>
   637           <tr>
   614             <td class="row2"><?php echo $lang->get('usercp_publicinfo_field_changetheme_title'); ?></td>
   638             <td class="row2"><?php echo $lang->get('usercp_publicinfo_field_changetheme_title'); ?></td>
   615             <td class="row1"><?php echo $lang->get('usercp_publicinfo_field_changetheme_hint'); ?> <a href="<?php echo makeUrlNS('Special', 'ChangeStyle/' . $paths->page); ?>" onclick="ajaxChangeStyle(); return false;"><?php echo $lang->get('usercp_publicinfo_field_changetheme'); ?></a></td>
   639             <td class="row1"><?php echo $lang->get('usercp_publicinfo_field_changetheme_hint'); ?> <a href="<?php echo makeUrlNS('Special', 'ChangeStyle/' . $paths->page); ?>" onclick="ajaxChangeStyle(); return false;"><?php echo $lang->get('usercp_publicinfo_field_changetheme'); ?></a></td>
       
   640           </tr>
       
   641           <tr>
       
   642             <td class="row2"><?php echo $lang->get('usercp_publicinfo_field_timezone'); ?><br /><small><?php echo $lang->get('usercp_publicinfo_field_timezone_hint'); ?></small></td>
       
   643             <td class="row1"><?php echo $tz_select; ?></td>
   616           </tr>
   644           </tr>
   617           <tr>
   645           <tr>
   618             <th class="subhead" colspan="2">
   646             <th class="subhead" colspan="2">
   619               <?php echo $lang->get('usercp_publicinfo_th_im'); ?>
   647               <?php echo $lang->get('usercp_publicinfo_th_im'); ?>
   620             </th>
   648             </th>