home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 April / CMCD0404.ISO / Software / Freeware / Programare / groupoffice-com-2.01 / configuration / preferences / index.php
Encoding:
PHP Script  |  2004-03-08  |  8.4 KB  |  310 lines

  1. <?php
  2. /*
  3. Author: Merijn Schering <mschering@intermesh.nl>
  4. Version: 1.0 Release date: 14 March 2003
  5. */
  6.  
  7. require("../../Group-Office.php");
  8. $GO_SECURITY->authenticate();
  9. require($GO_LANGUAGE->get_language_file('preferences'));
  10. require($GO_CONFIG->class_path."users.class.inc");
  11. $users = new users();
  12. $user = $users->get_user($users->user_id);
  13.  
  14. $return_to = $GO_CONFIG->host.'configuration/';
  15. $save_action = isset($_POST['save_action']) ? $_POST['save_action'] : false;
  16.  
  17.  
  18. require($GO_THEME->theme_path."header.inc");
  19.  
  20. if ($_SERVER['REQUEST_METHOD'] == "POST")
  21. {
  22.     if($save_action)
  23.     {
  24.         $mail_client = isset($_POST['mail_client']) ? $_POST['mail_client'] : "0";
  25.  
  26.         //if date formats are not present in the settings then use this default
  27.         $date_format = (isset($_POST['date_format']) && $_POST['date_format'] != '') ? $_POST['date_format'] : 'd-m-Y H:i';
  28.         $users->set_preferences($users->user_id, $_POST['date_format'], $_POST['time_format'], $_POST['thousands_seperator'], $_POST['decimal_seperator'], $_POST['currency'], $mail_client, $_POST['max_rows_list'], $_POST['timezone'], $_POST['start_module'], $_POST['language'], $_POST['theme'], $_POST['first_weekday']);
  29.         $save_action = false;
  30.  
  31.         echo '<script type="text/javascript">';
  32.  
  33.         if ($_POST['close'] == 'true')
  34.         {
  35.             echo 'parent.location="'.$GO_CONFIG->host.'index.php?return_to='.urlencode($return_to).'";';
  36.         }else
  37.         {
  38.             echo 'parent.location="'.$GO_CONFIG->host.'index.php?return_to='.urlencode($_SERVER['PHP_SELF']).'";';
  39.         }
  40.         echo '</script>';
  41.     }
  42. }
  43.  
  44. $tabtable = new tabtable('preferences', $menu_preferences, '600', '300');
  45. ?>
  46. <form name="preferences" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
  47. <input type="hidden" name="save_action" />
  48. <input type="hidden" name="close" value="false" />
  49.  
  50. <?php $tabtable->print_head(); ?>
  51. <table border="0" cellpadding="0" cellspacing="3">
  52. <tr>
  53.     <td> </td>
  54. </tr>
  55. <tr>
  56.     <td ><h2><?php echo $pref_look; ?></h2></td>
  57. </tr>
  58. <tr>
  59.     <td>
  60.     <table border="0">
  61.     <tr>
  62.         <td nowrap>
  63.             <?php echo $pref_language; ?>:
  64.         </td>
  65.         <td>
  66.             <?php
  67.             $languages = $GO_LANGUAGE->get_languages();
  68.             $dropbox = new dropbox();
  69.             $dropbox->add_arrays($languages, $languages);
  70.             $dropbox->print_dropbox("language", $_SESSION['GO_SESSION']['language']);
  71.             ?>
  72.         </td>
  73.     </tr>
  74.  
  75.     <tr>
  76.         <td nowrap>
  77.             <?php echo $pref_timezone; ?>:
  78.         </td>
  79.         <td>
  80.             <?php
  81.             $dropbox = new dropbox();
  82.             $dropbox->add_value('12','+12 GMT');
  83.             $dropbox->add_value('11','+11 GMT');
  84.             $dropbox->add_value('10','+10 GMT');
  85.             $dropbox->add_value('9','+1 GMT');
  86.             $dropbox->add_value('8','+8 GMT');
  87.             $dropbox->add_value('7','+7 GMT');
  88.             $dropbox->add_value('6','+6 GMT');
  89.             $dropbox->add_value('5','+5 GMT');
  90.             $dropbox->add_value('4','+4 GMT');
  91.             $dropbox->add_value('3','+3 GMT');
  92.             $dropbox->add_value('2','+2 GMT');
  93.             $dropbox->add_value('1','+1 GMT');
  94.             $dropbox->add_value('0','GMT');
  95.             $dropbox->add_value('-1','-1 GMT');
  96.             $dropbox->add_value('-2','-2 GMT');
  97.             $dropbox->add_value('-3','-3 GMT');
  98.             $dropbox->add_value('-4','-4 GMT');
  99.             $dropbox->add_value('-5','-5 GMT');
  100.             $dropbox->add_value('-6','-6 GMT');
  101.             $dropbox->add_value('-7','-7 GMT');
  102.             $dropbox->add_value('-8','-8 GMT');
  103.             $dropbox->add_value('-9','-9 GMT');
  104.             $dropbox->add_value('-10','-10 GMT');
  105.             $dropbox->add_value('-11','-11 GMT');
  106.             $dropbox->add_value('-12','-12 GMT');
  107.             $dropbox->print_dropbox("timezone", $_SESSION['GO_SESSION']['timezone']);
  108.             ?>
  109.         </td>
  110.     </tr>
  111.     <?php
  112.     if ($GO_CONFIG->allow_themes == true)
  113.     {
  114.     ?>
  115.     <tr>
  116.         <td > </td>
  117.     </tr>
  118.     <tr>
  119.         <td nowrap>
  120.             <?php echo $pref_theme; ?>:
  121.         </td>
  122.         <td>
  123.             <?php
  124.             $themes = $GO_THEME->get_themes();
  125.             $dropbox = new dropbox();
  126.             $dropbox->add_arrays($themes, $themes);
  127.             $dropbox->print_dropbox("theme", $_SESSION['GO_SESSION']['theme']);
  128.             ?>
  129.         </td>
  130.     </tr>
  131.     <?php
  132.     }
  133.     ?>
  134.     <tr>
  135.         <td>
  136.         <?php echo $pref_startmodule; ?>:
  137.         </td>
  138.         <td>
  139.         <?php
  140.         $dropbox = new dropbox();
  141.         $GO_MODULES->get_modules();
  142.         while ($GO_MODULES->next_record())
  143.         {
  144.             if ($GO_SECURITY->has_permission($GO_SECURITY->user_id, $GO_MODULES->f('acl_read')))
  145.             {
  146.                 $lang_var = isset($lang_modules[$GO_MODULES->f('id')]) ? $lang_modules[$GO_MODULES->f('id')] : $GO_MODULES->f('id');
  147.                 $dropbox->add_value($GO_MODULES->f('id'), $lang_var);
  148.             }
  149.         }
  150.         $dropbox->print_dropbox('start_module', $_SESSION['GO_SESSION']['start_module']);
  151.         ?>
  152.         </td>
  153.     </tr>
  154.     </table>
  155.     </td>
  156. </tr>
  157.  
  158. <tr>
  159.     <td>
  160.         <?php
  161.         $module = $GO_MODULES->get_module('email');
  162.  
  163.         if ($GO_SECURITY->has_permission($GO_SECURITY->user_id, $module['acl_read']) || $GO_SECURITY->has_permission($GO_SECURITY->user_id, $module['acl_write']))
  164.         {
  165.             $checked = ($_SESSION['GO_SESSION']['mail_client'] == 1) ? true : false;
  166.             $checkbox = new checkbox('mail_client', '1', $pref_mail_client, $checked);
  167.         }
  168.         ?>
  169.     </td>
  170. </tr>
  171. <tr>
  172.     <td>
  173.     <table border="0">
  174.     <tr>
  175.         <td><?php echo $pref_max_rows_list; ?>:</td>
  176.         <td>
  177.         <?php
  178.         $dropbox = new dropbox();
  179.         $dropbox->add_value('0',$pref_unlimited);
  180.         $dropbox->add_value('10','10');
  181.         $dropbox->add_value('15','15');
  182.         $dropbox->add_value('20','20');
  183.         $dropbox->add_value('25','25');
  184.         $dropbox->add_value('30','30');
  185.         $dropbox->add_value('50','50');
  186.         $dropbox->add_value('75','75');
  187.         $dropbox->add_value('100','100');
  188.         $dropbox->print_dropbox('max_rows_list', $_SESSION['GO_SESSION']['max_rows_list']);
  189.         ?>
  190.         </td>
  191.     </tr>
  192.     </table>
  193.     </td>
  194. </tr>
  195. <tr>
  196.     <td > </td>
  197. </tr>
  198. <tr>
  199.     <td><h2><?php echo $pref_notations; ?></h2></td>
  200. </tr>
  201. <tr>
  202.     <td>
  203.     <table border="0">
  204.     <tr>
  205.         <td nowrap>
  206.             <?php echo $pref_date_format; ?>:
  207.         </td>
  208.         <td>
  209.             <?php
  210.             //create an xml object because the date formats are stored as a setting in xml format
  211.                 //add them to a dropbox
  212.             $dropbox = new dropbox();
  213.             for ($i=0;$i<count($GO_CONFIG->date_formats);$i++)
  214.             {
  215.                 $dropbox->add_value($GO_CONFIG->date_formats[$i], date($GO_CONFIG->date_formats[$i], get_time()));
  216.             }
  217.             $dropbox->print_dropbox("date_format", $_SESSION['GO_SESSION']['date_format']);
  218.             ?>
  219.         </td>
  220.     </tr>
  221.     <tr>
  222.         <td nowrap>
  223.             <?php echo $pref_time_format; ?>:
  224.         </td>
  225.         <td>
  226.             <?php
  227.             //create an xml object because the date formats are stored as a setting in xml format
  228.                 //add them to a dropbox
  229.             $dropbox = new dropbox();
  230.             for($i=0;$i<count($GO_CONFIG->time_formats);$i++)
  231.             {
  232.                 $dropbox->add_value($GO_CONFIG->time_formats[$i], date($GO_CONFIG->time_formats[$i], get_time()));
  233.             }
  234.             $dropbox->print_dropbox("time_format", $_SESSION['GO_SESSION']['time_format']);
  235.             ?>
  236.         </td>
  237.     </tr>
  238.     <tr>
  239.         <td nowrap>
  240.             <?php echo $pref_first_weekday; ?>:
  241.         </td>
  242.         <td>
  243.             <?php
  244.             //create an xml object because the date formats are stored as a setting in xml format
  245.                 //add them to a dropbox
  246.             $dropbox = new dropbox();
  247.             for($i=0;$i<count($full_days);$i++)
  248.             {
  249.                 $dropbox->add_value($i, $full_days[$i]);
  250.             }
  251.             $dropbox->print_dropbox("first_weekday", $_SESSION['GO_SESSION']['first_weekday']);
  252.             ?>
  253.         </td>
  254.     </tr>
  255.     <tr>
  256.         <td > </td>
  257.     </tr>
  258.     <tr>
  259.         <td>
  260.             <?php echo $pref_thousands_seperator; ?>:
  261.         </td>
  262.         <td>
  263.             <input type="text" class="textbox" size="3" name="thousands_seperator" value="<?php echo $_SESSION['GO_SESSION']['thousands_seperator']; ?>" maxlength="1" />
  264.         </td>
  265.     </tr>
  266.     <tr>
  267.         <td>
  268.             <?php echo $pref_decimal_seperator; ?>:
  269.         </td>
  270.         <td>
  271.             <input type="text" class="textbox" size="3" name="decimal_seperator" value="<?php echo $_SESSION['GO_SESSION']['decimal_seperator']; ?>" maxlength="1" />
  272.         </td>
  273.     </tr>
  274.     <tr>
  275.         <td>
  276.             <?php echo $pref_currency; ?>:
  277.         </td>
  278.         <td>
  279.             <input type="text" class="textbox" size="3" max_length="3" name="currency" value="<?php echo $_SESSION['GO_SESSION']['currency']; ?>" />
  280.         </td>
  281.     </tr>
  282.     </table>
  283.     </td>
  284. </tr>
  285. <tr>
  286.     <td colspan="2" height="40">
  287.     <?php
  288.     $button = new button($cmdOk, "javascript:save_preferences('true')");
  289.     echo '  ';
  290.     $button = new button($cmdApply, "javascript:save_preferences('false')");
  291.     echo '  ';
  292.     $button = new button($cmdClose, "javascript:document.location='".$return_to ."'");
  293.     ?>
  294.     </td>
  295. </tr>
  296. </table>
  297. <?php $tabtable->print_foot(); ?>
  298.  
  299. <script type="text/javascript">
  300. function save_preferences(close)
  301. {
  302.     document.forms[0].save_action.value=true;
  303.     document.forms[0].close.value=close;
  304.     document.forms[0].submit();
  305. }
  306. </script>
  307. </form>
  308. <?php
  309. require($GO_THEME->theme_path."footer.inc");
  310. ?>
  311.