[ Index ]

Source Code Reference for V1.00

title

Body

[close]

/modules/admin/ -> viewuser.php (source)

   1  <?php /* $Id: viewuser.php 102 2008-03-18 19:52:59Z pedroix $ $URL: https://web2project.svn.sourceforge.net/svnroot/web2project/trunk/modules/admin/viewuser.php $ */
   2  if (!defined('W2P_BASE_DIR')) {
   3      die('You should not access this file directly.');
   4  }
   5  
   6  global $addPwT, $company_id, $dept_ids, $department, $min_view, $m, $a;
   7  $user_id = isset($_GET['user_id']) ? w2PgetParam($_GET, 'user_id', 0) : 0;
   8  
   9  if ($user_id != $AppUI->user_id && (!$perms->checkModuleItem('admin', 'view', $user_id) || !$perms->checkModuleItem('users', 'view', $user_id))) {
  10      $AppUI->redirect('m=public&a=access_denied');
  11  }
  12  
  13  $AppUI->savePlace();
  14  
  15  if (isset($_POST['show_form'])) {
  16      $add_pwt = w2PgetParam($_POST, 'add_pwt', 0);
  17      $AppUI->setState('addProjWithTasks', $add_pwt);
  18  } else {
  19      $AppUI->setState('addProjWithTasks', false);
  20  }
  21  
  22  $addPwT = $AppUI->getState('addProjWithTasks') ? $AppUI->getState('addProjWithTasks') : 0;
  23  
  24  $company_id = $AppUI->getState('UsrProjIdxCompany') !== null ? $AppUI->getState('UsrProjIdxCompany') : $AppUI->user_company;
  25  
  26  $company_prefix = 'company_';
  27  
  28  if (isset($_POST['department'])) {
  29      $AppUI->setState('UsrProjIdxDepartment', $_POST['department']);
  30  
  31      //if department is set, ignore the company_id field

  32      unset($company_id);
  33  }
  34  $department = $AppUI->getState('UsrProjIdxDepartment') !== null ? $AppUI->getState('UsrProjIdxDepartment') : $company_prefix . $AppUI->user_company;
  35  
  36  //if $department contains the $company_prefix string that it's requesting a company and not a department.  So, clear the

  37  // $department variable, and populate the $company_id variable.

  38  if (!(strpos($department, $company_prefix) === false)) {
  39      $company_id = substr($department, strlen($company_prefix));
  40      $AppUI->setState('UsrProjIdxCompany', $company_id);
  41      unset($department);
  42  }
  43  
  44  if (isset($_GET['tab'])) {
  45      $AppUI->setState('UserVwTab', w2PgetParam($_GET, 'tab', null));
  46  }
  47  $tab = $AppUI->getState('UserVwTab') !== null ? $AppUI->getState('UserVwTab') : 0;
  48  
  49  // pull data

  50  $q = new DBQuery;
  51  $q->addTable('users', 'u');
  52  $q->addQuery('u.*');
  53  $q->addQuery('con.*, company_id, company_name, dept_name, dept_id');
  54  $q->addJoin('contacts', 'con', 'user_contact = contact_id', 'inner');
  55  $q->addJoin('companies', 'com', 'contact_company = company_id');
  56  $q->addJoin('departments', 'dep', 'dept_id = contact_department');
  57  $q->addWhere('u.user_id = ' . (int)$user_id);
  58  $user = $q->loadHash();
  59  $q->clear();
  60  
  61  if (!$user) {
  62      $titleBlock = new CTitleBlock('Invalid User ID', 'helix-setup-user.png', $m, "$m.$a");
  63      $titleBlock->addCrumb('?m=admin', 'users list');
  64      $titleBlock->show();
  65  } else {
  66      $countries = w2PgetSysVal('GlobalCountries');
  67      // setup the title block

  68      $titleBlock = new CTitleBlock('View User', 'helix-setup-user.png', $m, "$m.$a");
  69      if ($canRead) {
  70          $titleBlock->addCrumb('?m=admin', 'users list');
  71      }
  72      if ($canEdit || $user_id == $AppUI->user_id) {
  73          $titleBlock->addCrumb('?m=admin&a=addedituser&user_id='.$user_id, 'edit this user');
  74          $titleBlock->addCrumb('?m=system&a=addeditpref&user_id='.$user_id, 'edit preferences');
  75          $titleBlock->addCrumbRight('<div class="crumb"><ul><li style="float:right;"><a href="javascript: void(0);" onclick="popChgPwd();return false"><span>' . $AppUI->_('change password') . '</span></a></li></ul></div>');
  76          $titleBlock->addCell('<td align="right" width="100%"><input type="button" class=button value="' . $AppUI->_('add user') . '" onclick="javascript:window.location=\'./index.php?m=admin&a=addedituser\';" /></td>');
  77      }
  78      $titleBlock->show();
  79  ?>
  80  <script language="javascript">
  81  <?php
  82      // security improvement:

  83      // some javascript functions may not appear on client side in case of user not having write permissions

  84      // else users would be able to arbitrarily run 'bad' functions

  85      if ($canEdit || $user_id == $AppUI->user_id) {
  86  ?>
  87  function popChgPwd() {
  88      window.open( './index.php?m=public&a=chpwd&dialog=1&user_id=<?php echo $user['user_id']; ?>', 'chpwd', 'top=250,left=250,width=350, height=220, scrollbars=no' );
  89  }
  90  <?php } ?>
  91  </script>
  92  
  93  <table border="0" cellpadding="4" cellspacing="0" width="100%" class="std">
  94  <tr valign="top">
  95      <td width="50%">
  96          <table cellspacing="1" cellpadding="2" border="0" width="100%">
  97          <tr>
  98              <td align="right" nowrap="nowrap"><?php echo $AppUI->_('Login Name'); ?>:</td>
  99              <td class="hilite" width="100%"><?php echo $user['user_username']; ?></td>
 100          </tr>
 101          <tr>
 102              <td align="right" nowrap="nowrap"><?php echo $AppUI->_('User Type'); ?>:</td>
 103              <td class="hilite" width="100%"><?php echo $AppUI->_($utypes[$user['user_type']]); ?></td>
 104          </tr>
 105          <tr>
 106              <td align="right" nowrap="nowrap"><?php echo $AppUI->_('Real Name'); ?>:</td>
 107              <td class="hilite" width="100%"><?php echo $user['contact_first_name'] . ' ' . $user['contact_last_name']; ?></td>
 108          </tr>
 109          <tr>
 110              <td align="right" nowrap="nowrap"><?php echo $AppUI->_('Company'); ?>:</td>
 111              <td class="hilite" width="100%">
 112                  <a href="?m=companies&a=view&company_id=<?php echo $user['contact_company']; ?>"><?php echo $user['company_name']; ?></a>
 113              </td>
 114          </tr>
 115          <tr>
 116              <td align="right" nowrap="nowrap"><?php echo $AppUI->_('Department'); ?>:</td>
 117              <td class="hilite" width="100%">
 118                  <a href="?m=departments&a=view&dept_id=<?php echo $user['contact_department']; ?>"><?php echo $user['dept_name']; ?></a>
 119              </td>
 120          </tr>
 121          <tr>
 122              <td align="right" nowrap="nowrap"><?php echo $AppUI->_('Phone'); ?>:</td>
 123              <td class="hilite" width="100%"><?php echo $user['contact_phone']; ?></td>
 124          </tr>
 125          <tr>
 126              <td align="right" nowrap="nowrap"><?php echo $AppUI->_('Home Phone'); ?>:</td>
 127              <td class="hilite" width="100%"><?php echo $user['contact_phone2']; ?></td>
 128          </tr>
 129          <tr>
 130              <td align="right" nowrap="nowrap"><?php echo $AppUI->_('Mobile'); ?>:</td>
 131              <td class="hilite" width="100%"><?php echo $user['contact_mobile']; ?></td>
 132          </tr>
 133          <tr valign="top">
 134              <td align="right" nowrap="nowrap"><?php echo $AppUI->_('Address'); ?>:</td>
 135              <td class="hilite" width="100%"><?php
 136      echo $user['contact_address1'] . (($user['contact_address2']) ? '<br />' . $user['contact_address2'] : '') . '<br />' . $user['contact_city'] . '&nbsp;&nbsp;' . $user['contact_state'] . '&nbsp;&nbsp;' . $user['contact_zip'] . '<br />' . ($countries[$user['contact_country']] ? $countries[$user['contact_country']] : $user['contact_country']);
 137  ?></td>
 138          </tr>
 139          </table>
 140  
 141      </td>
 142      <td width="50%">
 143          <table width="100%">
 144          <tr>
 145              <td align="right" nowrap="nowrap"><?php echo $AppUI->_('Birthday'); ?>:</td>
 146              <td class="hilite" width="100%"><?php echo $user['contact_birthday']; ?></td>
 147          </tr>
 148          <tr>
 149              <td align="right" nowrap="nowrap">Jabber:</td>
 150              <td class="hilite" width="100%"><?php echo $user['contact_jabber']; ?></td>
 151          </tr>
 152          <tr>
 153              <td align="right" nowrap="nowrap">ICQ:</td>
 154              <td class="hilite" width="100%"><?php echo $user['contact_icq']; ?></td>
 155          </tr>
 156          <tr>
 157              <td align="right" nowrap="nowrap">AOL Nick:</td>
 158              <td class="hilite" width="100%"><a href="aim:<?php echo $user['contact_aol']; ?>"><?php echo $user['contact_aol']; ?></a></td>
 159          </tr>
 160          <tr>
 161              <td align="right" nowrap="nowrap">MSN:</td>
 162              <td class="hilite" width="100%"><?php echo $user['contact_msn']; ?></td>
 163          </tr>
 164          <tr>
 165              <td align="right" nowrap="nowrap">Yahoo:</td>
 166              <td class="hilite" width="100%"><a href="ymsgr:sendIM?<?php echo $user['contact_yahoo']; ?>"><?php echo $user['contact_yahoo']; ?></a></td>
 167          </tr>
 168          <tr>
 169              <td align="right" nowrap="nowrap">Skype:</td>
 170              <td class="hilite" width="100%"><a href="skype:<?php echo $user['contact_skype']; ?>"><?php echo $user['contact_skype']; ?></a></td>
 171          </tr>
 172          <tr>
 173              <td align="right" nowrap="nowrap">Google:</td>
 174              <td class="hilite" width="100%"><a href="google:<?php echo $user['contact_google']; ?>"><?php echo $user['contact_google']; ?></a></td>
 175          </tr>
 176          <tr>
 177              <td align="right" nowrap="nowrap"><?php echo $AppUI->_('Email'); ?>:</td>
 178              <td class="hilite" width="100%"><?php echo '<a href="mailto:' . $user['contact_email'] . '">' . $user['contact_email'] . '</a>'; ?></td>
 179          </tr>
 180          <tr>
 181              <td colspan="2"><strong><?php echo $AppUI->_('Signature'); ?>:</strong></td>
 182          </tr>
 183          <tr>
 184              <td class="hilite" width="100%" colspan="2">
 185                  <?php echo str_replace(chr(10), '<br />', $user['user_signature']); ?>&nbsp;
 186              </td>
 187          </tr>
 188          </table>
 189      </td>
 190  </tr>
 191  </table>
 192  
 193  <?php
 194      // tabbed information boxes

 195      $min_view = true;
 196      $tabBox = new CTabBox('?m=admin&a=viewuser&user_id='.$user_id, '', $tab);
 197      $tabBox->add(W2P_BASE_DIR . '/modules/admin/vw_usr_log', 'User Log');
 198      $tabBox->add(W2P_BASE_DIR . '/modules/admin/vw_usr_perms', 'Permissions');
 199      $tabBox->add(W2P_BASE_DIR . '/modules/admin/vw_usr_roles', 'Roles');
 200      $tabBox->show();
 201  }
 202  ?>


Generated: Wed Jan 7 03:00:01 2009 Cross-referenced by PHPXref 0.7