home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 April / CMCD0404.ISO / Software / Freeware / Programare / dotproject / modules / system / addeditpref.php next >
Encoding:
PHP Script  |  2004-01-12  |  4.6 KB  |  155 lines

  1. <?php /* SYSTEM $Id: addeditpref.php,v 1.26 2004/01/12 01:12:51 ajdonnison Exp $ */
  2. ##
  3. ## add or edit a user preferences
  4. ##
  5. $user_id = isset($HTTP_GET_VARS['user_id']) ? $HTTP_GET_VARS['user_id'] : 0;
  6. // Why does this need to be different to $user_id?
  7. $transmit_user_id = $_GET['user_id'];
  8. // Check permissions
  9. if (!$canEdit && $transmit_user_id != $AppUI->user_id) {
  10.   $AppUI->redirect("m=public&a=access_denied" );
  11. }
  12.  
  13. // load the preferences
  14. $sql = "
  15. SELECT pref_name, pref_value
  16. FROM user_preferences
  17. WHERE pref_user = $user_id
  18. ";
  19. $prefs = db_loadHashList( $sql );
  20.  
  21. // get the user name
  22. $sql = "
  23. SELECT user_first_name, user_last_name
  24. FROM users
  25. WHERE user_id = $user_id
  26. ";
  27. $res  = db_exec( $sql );
  28. echo db_error();
  29. $user = db_fetch_row( $res );
  30.  
  31. $titleBlock = new CTitleBlock( 'Edit User Preferences', 'myevo-weather.png', $m, "$m.$a" );
  32. $titleBlock->addCrumb( "?m=system", "system admin" );
  33. $titleBlock->show();
  34. ?>
  35. <script language="javascript">
  36. function submitIt(){
  37.     var form = document.changeuser;
  38.     //if (form.user_username.value.length < 3) {
  39.     //    alert("Please enter a valid user name");
  40.     //    form.user_username.focus();
  41.     //} else {
  42.         form.submit();
  43.     //}
  44. }
  45. </script>
  46.  
  47. <table width="100%" border="0" cellpadding="1" cellspacing="1" class="std">
  48.  
  49. <form name="changeuser" action="./index.php?m=system" method="post">
  50.     <input type="hidden" name="dosql" value="do_preference_aed" />
  51.     <input type="hidden" name="pref_user" value="<?php echo $user_id;?>" />
  52.     <input type="hidden" name="del" value="0" />
  53.  
  54. <tr height="20">
  55.     <th colspan="2"><?php echo $AppUI->_('User Preferences');?>:
  56.     <?php
  57.         echo $user_id ? "$user[0] $user[1]" : $AppUI->_("Default");
  58.     ?></th>
  59. </tr>
  60.  
  61. <tr>
  62.     <td align="right"><?php echo $AppUI->_('Locale');?>:</td>
  63.     <td>
  64. <?php
  65.     // read the installed languages
  66.     $locales = $AppUI->readDirs( 'locales' );
  67.     $temp = $AppUI->setWarning( false );
  68.     echo arraySelect( $locales, 'pref_name[LOCALE]', 'class=text size=1', @$prefs['LOCALE'], true );
  69.     $AppUI->setWarning( $temp );
  70. ?>
  71.     </td>
  72. </tr>
  73.  
  74. <tr>
  75.     <td align="right"><?php echo $AppUI->_('Tabbed Box View');?>:</td>
  76.     <td>
  77. <?php
  78.     $tabview = array( 'either', 'tabbed', 'flat' );
  79.     echo arraySelect( $tabview, 'pref_name[TABVIEW]', 'class=text size=1', @$prefs['TABVIEW'], true );
  80. ?>
  81.     </td>
  82. </tr>
  83.  
  84. <tr>
  85.     <td align="right"><?php echo $AppUI->_('Short Date Format');?>:</td>
  86.     <td>
  87. <?php
  88.     // exmample date
  89.     $ex = new CDate();
  90.  
  91.     $dates = array();
  92.     $f = "%d/%m/%Y"; $dates[$f]    = $ex->format( $f );
  93.     $f = "%d/%b/%Y"; $dates[$f]    = $ex->format( $f );
  94.     $f = "%m/%d/%Y"; $dates[$f]    = $ex->format( $f );
  95.     $f = "%b/%d/%Y"; $dates[$f]    = $ex->format( $f );
  96.     $f = "%d.%m.%Y"; $dates[$f]    = $ex->format( $f );
  97.     echo arraySelect( $dates, 'pref_name[SHDATEFORMAT]', 'class=text size=1', @$prefs['SHDATEFORMAT'], false );
  98. ?>
  99.     </td>
  100. </tr>
  101.  
  102. <tr>
  103.     <td align="right"><?php echo $AppUI->_('Time Format');?>:</td>
  104.     <td>
  105. <?php
  106.     // exmample date
  107.     $times = array();
  108.     $f = "%I:%M %p"; $times[$f]    = $ex->format( $f );
  109.     $f = "%H:%M"; $times[$f]    = $ex->format( $f ).' (24)';
  110.     $f = "%H:%M:%S"; $times[$f]    = $ex->format( $f ).' (24)';
  111.     echo arraySelect( $times, 'pref_name[TIMEFORMAT]', 'class=text size=1', @$prefs['TIMEFORMAT'], false );
  112. ?>
  113.     </td>
  114. </tr>
  115.  
  116. <tr>
  117.     <td align="right"><?php echo $AppUI->_('Currency Format');?>:</td>
  118.     <td>
  119. <?php
  120.     $currencies = array();
  121.     $currEx = 1234567.89;
  122.  
  123.         // This is a server not using Windows
  124.         $f = "es_ES"; $currencies[$f]    = formatCurrency( $currEx, $f );
  125.         $f = "es_MX"; $currencies[$f]    = formatCurrency( $currEx, $f );
  126.     $f = "en_US"; $currencies[$f]    = formatCurrency( $currEx, $f );
  127.     $f = "en_GB"; $currencies[$f]    = formatCurrency( $currEx, $f );
  128.     $f = "en_AU"; $currencies[$f]    = formatCurrency( $currEx, $f );
  129.     $f = "en_CA"; $currencies[$f]    = formatCurrency( $currEx, $f );
  130.     $f = "en_NZ"; $currencies[$f]    = formatCurrency( $currEx, $f );
  131.     $f = "pt_PT"; $currencies[$f]    = formatCurrency( $currEx, $f );
  132.     $f = "pt_BR"; $currencies[$f]    = formatCurrency( $currEx, $f );
  133.     echo arraySelect( $currencies, 'pref_name[CURRENCYFORMAT]', 'class=text size=1', @$prefs['CURRENCYFORMAT'], false );
  134. ?>
  135.     </td>
  136. </tr>
  137.  
  138. <tr>
  139.     <td align="right"><?php echo $AppUI->_('User Interface Style');?>:</td>
  140.     <td>
  141. <?php
  142.     $styles = $AppUI->readDirs( 'style' );
  143.     $temp = $AppUI->setWarning( false );
  144.     echo arraySelect( $styles, 'pref_name[UISTYLE]', 'class=text size=1', @$prefs['UISTYLE'], true );
  145.     $AppUI->setWarning( $temp );
  146. ?>
  147.     </td>
  148. </tr>
  149.  
  150. <tr>
  151.     <td align="left"><input class="button"  type="button" value="<?php echo $AppUI->_('back');?>" onClick="javascript:history.back(-1);" /></td>
  152.     <td align="right"><input class="button" type="button" value="<?php echo $AppUI->_('submit');?>" onClick="submitIt()" /></td>
  153. </tr>
  154. </table>
  155.