[ Index ]

Source Code Reference for V1.00

title

Body

[close]

/modules/system/roles/ -> index.php (source)

   1  <?php /* $Id: index.php 40 2008-02-11 12:11:44Z pedroix $ $URL: https://web2project.svn.sourceforge.net/svnroot/web2project/trunk/modules/system/roles/index.php $ */
   2  if (!defined('W2P_BASE_DIR')) {
   3      die('You should not access this file directly.');
   4  }
   5  
   6  $AppUI->savePlace();
   7  
   8  // pull all the key types

   9  $perms = &$AppUI->acl();
  10  
  11  // Get the permissions for this module

  12  $canAccess = $perms->checkModule('roles', 'access');
  13  if (!$canAccess) {
  14      $AppUI->redirect('m=public&a=access_denied');
  15  }
  16  $canRead = $perms->checkModule('roles', 'view');
  17  $canAdd = $perms->checkModule('roles', 'add');
  18  $canEdit = $perms->checkModule('roles', 'edit');
  19  $canDelete = $perms->checkModule('roles', 'delete');
  20  
  21  $crole = &new CRole;
  22  $roles = $crole->getRoles();
  23  
  24  $role_id = w2PgetParam($_GET, 'role_id', 0);
  25  
  26  $q = new DBQuery;
  27  $q->addTable('modules');
  28  $q->addQuery('mod_id, mod_name');
  29  $q->addWhere('mod_active > 0');
  30  $q->addOrder('mod_directory');
  31  $modules = arrayMerge(array('0' => 'All'), $q->loadHashList());
  32  $q->clear();
  33  
  34  // setup the title block

  35  $titleBlock = new CTitleBlock('Roles', 'main-settings.png', $m, $m . '.' . $a);
  36  $titleBlock->addCrumb('?m=system', 'System Admin');
  37  $titleBlock->show();
  38  
  39  $crumbs = array();
  40  $crumbs['?m=system'] = 'System Admin';
  41  
  42  ?>
  43  
  44  <script language="javascript">
  45  <?php
  46  // security improvement:

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

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

  49  if ($canDelete) {
  50  ?>
  51  function delIt(id) {
  52      if (confirm( 'Are you sure you want to delete this?' )) {
  53          f = document.roleFrm;
  54          f.del.value = 1;
  55          f.role_id.value = id;
  56          f.submit();
  57      }
  58  }
  59  <?php } ?>
  60  </script>
  61  
  62  <table border="0" cellpadding="2" cellspacing="1" width="100%" class="tbl">
  63  <tr>
  64      <th>&nbsp;</th>
  65      <th><?php echo $AppUI->_('Role ID'); ?></th>
  66      <th><?php echo $AppUI->_('Description'); ?></th>
  67      <th>&nbsp;</th>
  68  </tr>
  69  <?php
  70  
  71  function showRow($role = null) {
  72      global $canEdit, $canDelete, $role_id, $AppUI, $modules;
  73      $id = $role['id'];
  74      $name = $role['value'];
  75      $description = $role['name'];
  76  
  77      $s = '';
  78      if (($role_id == $id || $id == 0) && $canEdit) {
  79          // edit form

  80          $s .= '<form name="roleFrm" method="post" action="?m=system&u=roles">';
  81          $s .= '<input type="hidden" name="dosql" value="do_role_aed" />';
  82          $s .= '<input type="hidden" name="del" value="0" />';
  83          $s .= '<input type="hidden" name="role_id" value="' . $id . '" />';
  84          $s .= '<tr><td>&nbsp;</td>';
  85          $s .= '<td valign="top"><input type="text" name="role_name" value="' . $name . '" class="text" /></td>';
  86          $s .= '<td valign="top"><input type="text" name="role_description" class="text" value="' . $description . '"></td>';
  87          $s .= '<td><input type="submit" value="' . $AppUI->_($id ? 'edit' : 'add') . '" class="button" /></td>';
  88      } else {
  89          $s .= '<tr><td width="50" valign="top">';
  90          if ($canEdit) {
  91              $s .= '<a href="?m=system&u=roles&role_id=' . $id . '">' . w2PshowImage('icons/stock_edit-16.png') . '</a><a href="?m=system&u=roles&a=viewrole&role_id=' . $id . '" title="">' . w2PshowImage('obj/lock.gif') . '</a>';
  92          }
  93          if ($canDelete) {
  94              $s .= '<a href=\'javascript:delIt(' . $id . ')\'>' . w2PshowImage('icons/stock_delete-16.png') . '</a>';
  95          }
  96          $s .= '</td><td valign="top">' . $name . '</td><td valign="top">' . $AppUI->_($description) . '</td><td valign="top" width="16">&nbsp;</td>';
  97      }
  98      $s .= '</tr>';
  99      return $s;
 100  }
 101  
 102  // do the modules that are installed on the system

 103  $s = '';
 104  foreach ($roles as $row) {
 105      echo showRow($row);
 106  }
 107  // add in the new key row:

 108  if ($role_id == 0) {
 109      echo showRow();
 110  }
 111  ?>
 112  </table>
 113  <?php
 114  // Do all the tab stuff.

 115  ?>


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