[ Index ]

Source Code Reference for V1.00

title

Body

[close]

/modules/system/ -> addeditpref.php (source)

   1  <?php /* $Id: addeditpref.php 137 2008-04-04 16:12:02Z pedroix $ $URL: https://web2project.svn.sourceforge.net/svnroot/web2project/trunk/modules/system/addeditpref.php $ */
   2  if (!defined('W2P_BASE_DIR')) {
   3      die('You should not access this file directly.');
   4  }
   5  
   6  ##
   7  ## add or edit a user preferences
   8  ##
   9  
  10  $user_id = w2PgetParam($_GET, 'user_id', '0');
  11  $perms = &$AppUI->acl();
  12  // check permissions for this record
  13  $canEdit = $perms->checkModule('system', 'edit');
  14  // Check permissions
  15  if (!$canEdit && $user_id != $AppUI->user_id) {
  16      $AppUI->redirect('m=public&a=access_denied');
  17  }
  18  
  19  // load the preferences
  20  $q = new DBQuery;
  21  $q->addTable('user_preferences');
  22  $q->addQuery('pref_name, pref_value');
  23  $q->addWhere('pref_user = ' . (int)$user_id);
  24  $prefs = $q->loadHashList();
  25  $q->clear();
  26  
  27  // get the user name
  28  if ($user_id) {
  29      $user = w2PgetUsernameFromID($user_id);
  30  } else {
  31      $user = 'Default';
  32  }
  33  
  34  $titleBlock = new CTitleBlock('Edit User Preferences', 'myevo-weather.png', $m, $m . '.' . $a);
  35  $perms = &$AppUI->acl();
  36  if ($perms->checkModule('system', 'edit')) {
  37      $titleBlock->addCrumb('?m=system', 'system admin');
  38      $titleBlock->addCrumb('?m=system&a=systemconfig', 'system configuration');
  39  }
  40  $titleBlock->show();
  41  ?>
  42  <script language="javascript">
  43  function submitIt() {
  44      var form = document.changeuser;
  45      // Collate the checked states of the task log stuff
  46      var defs = document.getElementById('task_log_email_defaults');
  47      var mask = 0;
  48      if (form.tl_assign.checked) {
  49          mask += 1;
  50      }
  51      if (form.tl_task.checked) {
  52          mask += 2;
  53      }
  54      if (form.tl_proj.checked) {
  55          mask += 4;
  56      }
  57      defs.value = mask;
  58      var expanded = document.getElementById('tasks_expanded');
  59      var mask = 0;
  60      if (form.expanded.checked) {
  61          mask += 1;
  62      }
  63      expanded.value = mask;
  64      form.submit();
  65  }
  66  </script>
  67  
  68  <form name="changeuser" action="./index.php?m=system" method="post">
  69      <input type="hidden" name="dosql" value="do_preference_aed" />
  70      <input type="hidden" name="pref_user" value="<?php echo $user_id; ?>" />
  71      <input type="hidden" name="del" value="0" />
  72  <table width="100%" border="0" cellpadding="1" cellspacing="1" class="std">
  73  <tr>
  74      <th colspan="2"><?php echo $AppUI->_('User Preferences'); ?>:
  75      <?php
  76  echo $user_id ? $user : $AppUI->_('Default');
  77  ?></th>
  78  </tr>
  79  
  80  <tr>
  81      <td align="right"><?php echo $AppUI->_('Locale'); ?>:</td>
  82      <td>
  83  <?php
  84  // read the installed languages
  85  $LANGUAGES = $AppUI->loadLanguages();
  86  $temp = $AppUI->setWarning(false);
  87  $langlist = array();
  88  foreach ($LANGUAGES as $lang => $langinfo)
  89      $langlist[$lang] = $langinfo[1];
  90  echo arraySelect($langlist, 'pref_name[LOCALE]', 'class=text size=1', $prefs['LOCALE'], true);
  91  $AppUI->setWarning($temp);
  92  ?>
  93      </td>
  94  </tr>
  95  
  96  <tr>
  97      <td align="right"><?php echo $AppUI->_('Tabbed Box View'); ?>:</td>
  98      <td>
  99  <?php
 100  $tabview = array('either', 'tabbed', 'flat');
 101  echo arraySelect($tabview, 'pref_name[TABVIEW]', 'class=text size=1', $prefs['TABVIEW'], true);
 102  ?>
 103      </td>
 104  </tr>
 105  
 106  <tr>
 107      <td align="right"><?php echo $AppUI->_('Short Date Format'); ?>:</td>
 108      <td>
 109  <?php
 110  // exmample date
 111  $ex = new CDate();
 112  
 113  $dates = array();
 114  $f = '%d/%m/%Y';
 115  $dates[$f] = $ex->format($f);
 116  $f = '%d/%b/%Y';
 117  $dates[$f] = $ex->format($f);
 118  $f = '%m/%d/%Y';
 119  $dates[$f] = $ex->format($f);
 120  $f = '%b/%d/%Y';
 121  $dates[$f] = $ex->format($f);
 122  $f = '%d.%m.%Y';
 123  $dates[$f] = $ex->format($f);
 124  $f = '%Y/%b/%d';
 125  $dates[$f] = $ex->format($f);
 126  $f = '%Y/%m/%d';
 127  $dates[$f] = $ex->format($f);
 128  echo arraySelect($dates, 'pref_name[SHDATEFORMAT]', 'class=text size=1', $prefs['SHDATEFORMAT'], false);
 129  ?>
 130      </td>
 131  </tr>
 132  
 133  <tr>
 134      <td align="right"><?php echo $AppUI->_('Time Format'); ?>:</td>
 135      <td>
 136  <?php
 137  // exmample date
 138  $times = array();
 139  $f = '%I:%M %p';
 140  $times[$f] = $ex->format($f);
 141  $f = '%H:%M';
 142  $times[$f] = $ex->format($f) . ' (24)';
 143  $f = '%H:%M:%S';
 144  $times[$f] = $ex->format($f) . ' (24)';
 145  echo arraySelect($times, 'pref_name[TIMEFORMAT]', 'class=text size=1', $prefs['TIMEFORMAT'], false);
 146  ?>
 147      </td>
 148  </tr>
 149  
 150  <tr>
 151      <td align="right"><?php echo $AppUI->_('Currency Format'); ?>:</td>
 152      <td>
 153  <?php
 154  $currencies = array();
 155  $currEx = 1234567.89;
 156  
 157  if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN')
 158      $is_win = true;
 159  else
 160      $is_win = false;
 161  foreach (array_keys($LANGUAGES) as $lang) {
 162      $currencies[$lang] = formatCurrency($currEx, $AppUI->setUserLocale($lang, false));
 163  }
 164  echo arraySelect($currencies, 'pref_name[CURRENCYFORM]', 'class=text size=1', $prefs['CURRENCYFORM'], false);
 165  ?>
 166      </td>
 167  </tr>
 168  
 169  <tr>
 170      <td align="right"><?php echo $AppUI->_('User Interface Style'); ?>:</td>
 171      <td>
 172  <?php
 173  $uis = $prefs['UISTYLE'] ? $prefs['UISTYLE'] : 'default';
 174  $styles = $AppUI->readDirs('style');
 175  $temp = $AppUI->setWarning(false);
 176  echo arraySelect($styles, 'pref_name[UISTYLE]', 'class=text size=1', $uis, true, true);
 177  $AppUI->setWarning($temp);
 178  ?>
 179      </td>
 180  </tr>
 181  <tr>
 182      <td align="right"><?php echo $AppUI->_('User Task Assignment Maximum'); ?>:</td>
 183      <td>
 184  <?php
 185  $tam = ($prefs['TASKASSIGNMAX'] > 0) ? $prefs['TASKASSIGNMAX'] : 100;
 186  $taskAssMax = array();
 187  for ($i = 5; $i <= 200; $i += 5) {
 188      $taskAssMax[$i] = $i . '%';
 189  }
 190  echo arraySelect($taskAssMax, 'pref_name[TASKASSIGNMAX]', 'class=text size=1', $tam, false);
 191  
 192  ?>
 193      </td>
 194  </tr>
 195  <tr>
 196      <td align="right"><?php echo $AppUI->_('Default Event Filter'); ?>:</td>
 197      <td>
 198  <?php
 199  require_once $AppUI->getModuleClass('calendar');
 200  echo arraySelect($event_filter_list, 'pref_name[EVENTFILTER]', 'class=text size=1', $prefs['EVENTFILTER'], true);
 201  ?>
 202      </td>
 203  </tr>
 204  <tr>
 205      <td align="right"><?php echo $AppUI->_('Task Notification Method'); ?>:</td>
 206      <td>
 207  <?php
 208  $notify_filter = array(0 => 'Do not include task/event owner', 1 => 'Include task/event owner');
 209  
 210  echo arraySelect($notify_filter, 'pref_name[MAILALL]', 'class=text size=1', $prefs['MAILALL'], true);
 211  
 212  ?>
 213      </td>
 214  </tr>
 215  <tr>
 216      <td align="right"><?php echo $AppUI->_('Task Log Email Defaults'); ?>:</td>
 217      <td>
 218          <input type="hidden" name="pref_name[TASKLOGEMAIL]" id="task_log_email_defaults" value="<?php echo $prefs['TASKLOGEMAIL']; ?>" />
 219  <?php
 220  if (!isset($prefs['TASKLOGEMAIL'])) {
 221      $prefs['TASKLOGEMAIL'] = 0;
 222  }
 223  $tl_assign = $prefs['TASKLOGEMAIL'] & 1;
 224  $tl_task = $prefs['TASKLOGEMAIL'] & 2;
 225  $tl_proj = $prefs['TASKLOGEMAIL'] & 4;
 226  echo '<label for="tl_assign">' . $AppUI->_('Email Assignees') . '</label>&nbsp;<input type="checkbox" name="tl_assign" id="tl_assign"';
 227  if ($tl_assign) {
 228      echo ' checked="checked"';
 229  }
 230  echo ' /><br />';
 231  echo '<label for="tl_task">' . $AppUI->_('Email Task Contacts') . '</label>&nbsp;<input type="checkbox" name="tl_task" id="tl_task"';
 232  if ($tl_task) {
 233      echo 'checked="checked"';
 234  }
 235  echo ' /><br />';
 236  echo '<label for="tl_proj">' . $AppUI->_('Email Project Contacts') . '</label>&nbsp;<input type="checkbox" name="tl_proj" id="tl_proj"';
 237  if ($tl_proj) {
 238      echo ' checked="checked"';
 239  }
 240  echo ' />';
 241  ?>
 242      </td>
 243  </tr>
 244  <tr>
 245      <td align="right"><?php echo $AppUI->_('Task Log Email Subject'); ?>:</td>
 246      <td>
 247          <input type="text" class="text" name="pref_name[TASKLOGSUBJ]" value="<?php echo $prefs['TASKLOGSUBJ']; ?>" />
 248      </td>
 249  </tr>
 250  <tr>
 251      <td align="right"><?php echo $AppUI->_('Task Log Email Recording Method'); ?>:</td>
 252      <td>
 253      <?php
 254  $record_method['0'] = $AppUI->_('None');
 255  $record_method['1'] = $AppUI->_('Append to Log');
 256  echo arraySelect($record_method, 'pref_name[TASKLOGNOTE]', 'class="text" size="1"', $prefs['TASKLOGNOTE'], false);
 257  ?>
 258      </td>
 259  </tr>
 260  <tr>
 261      <td align="right"><?php echo $AppUI->_('Show Parent Tasks Expanded by Default'); ?>:</td>
 262      <td>
 263          <input type="hidden" name="pref_name[TASKSEXPANDED]" id="tasks_expanded" value="<?php echo $prefs['TASKSEXPANDED']; ?>" />
 264  <?php
 265          echo '<input type="checkbox" name="expanded"';
 266          if ($prefs['TASKSEXPANDED']) {
 267              echo ' checked="checked"';
 268          }
 269          echo ' />';
 270  ?>
 271      </td>
 272  </tr>
 273  <tr>
 274      <td align="left"><input class="button"  type="button" value="<?php echo $AppUI->_('back'); ?>" onclick="javascript:history.back(-1);" /></td>
 275      <td align="right"><input class="button" type="button" value="<?php echo $AppUI->_('submit'); ?>" onclick="submitIt()" /></td>
 276  </tr>
 277  </table>
 278  </form>


Generated: Thu Jan 8 03:00:03 2009 Cross-referenced by PHPXref 0.7