home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 April / CMCD0404.ISO / Software / Freeware / Programare / dotproject / modules / system / roles / index.php < prev    next >
Encoding:
PHP Script  |  2003-10-02  |  3.3 KB  |  101 lines

  1. <?php /* ROLES $Id: index.php,v 1.5 2003/10/02 08:59:42 gregorerhardt Exp $ */
  2. $AppUI->savePlace();
  3.  
  4. // pull all the key types
  5. $sql = "SELECT *,mod_name FROM roles LEFT JOIN modules ON mod_id = role_module ORDER BY role_module, role_name";
  6. $roles = db_loadList( $sql );
  7.  
  8. $role_id = dPgetParam( $_GET, 'role_id', 0 );
  9.  
  10. $modules = 
  11. $sql = "SELECT mod_id, mod_name FROM modules WHERE mod_active > 0 ORDER BY mod_directory";
  12. $modules = arrayMerge( array( '0'=>'All' ), db_loadHashList( $sql ) );
  13.  
  14. // setup the title block
  15. $titleBlock = new CTitleBlock( 'Roles', 'main-settings.png', $m, "$m.$a" );
  16. $titleBlock->addCrumb( "?m=system", "System Admin" );
  17. $titleBlock->show();
  18.  
  19. $crumbs = array();
  20. $crumbs["?m=system"] = "System Admin";
  21. ?>
  22.  
  23. <script language="javascript">
  24. function delIt(id) {
  25.     if (confirm( 'Are you sure you want to delete this?' )) {
  26.         f = document.roleFrm;
  27.         f.del.value = 1;
  28.         f.role_id.value = id;
  29.         f.submit();
  30.     }
  31. }
  32. </script>
  33.  
  34. <span style="color:red"><strong>Note this function is still in development and testing phase</strong></span>
  35.  
  36. <table border="0" cellpadding="2" cellspacing="1" width="100%" class="tbl">
  37. <tr>
  38.     <th> </th>
  39.     <th><?php echo $AppUI->_('Role Name');?></th>
  40.     <th><?php echo $AppUI->_('Description');?></th>
  41.     <th><?php echo $AppUI->_('Type');?></th>
  42.     <th><?php echo $AppUI->_('Module');?></th>
  43.     <th> </th>
  44. </tr>
  45. <?php
  46.  
  47. function showRow( $role=null ) {
  48.     global $canEdit, $role_id, $AppUI, $modules;
  49.     $CR = "\n";
  50.     $id = @$role['role_id'];
  51.     $name = @$role['role_name'];
  52.     $description = @$role['role_description'];
  53.     $type = @$role['role_type'];
  54.     $module = @$role['role_module'];
  55.  
  56.     $s = '<tr>'.$CR;
  57.     if (($role_id == $id || $id == 0) && $canEdit) {
  58.     // edit form
  59.         $s .= '<form name="roleFrm" method="post" action="?m=system&u=roles">'.$CR;
  60.         $s .= '<input type="hidden" name="dosql" value="do_role_aed" />'.$CR;
  61.         $s .= '<input type="hidden" name="del" value="0" />'.$CR;
  62.         $s .= '<input type="hidden" name="role_id" value="'.$id.'" />'.$CR;
  63.  
  64.         $s .= '<td> </td>';
  65.         $s .= '<td valign="top"><input type="text" name="role_name" value="'.$name.'" class="text" /></td>';
  66.         $s .= '<td valign="top"><textarea name="role_description" class="small" rows="5" cols="40">'.$description.'</textarea></td>';
  67.         $s .= '<td valign="top">' . arraySelect( $modules, 'role_module', 'size="1" class="text"', $module ) . '</td>';
  68.         $s .= '<td><input type="submit" value="'.$AppUI->_($id ? 'edit' : 'add').'" class="button" /></td>';
  69.         $s .= '<td> </td>';
  70.     } else {
  71.         $s .= '<td width="12" valign="top">';
  72.         if ($canEdit) {
  73.             $s .= '<a href="?m=system&u=roles&role_id='.$id.'"><img src="./images/icons/pencil.gif" alt="edit" border="0" width="12" height="12"></a>';
  74.             $s .= '</td>'.$CR;
  75.         }
  76.         $s .= '<td valign="top">'.$name.'</td>'.$CR;
  77.         $s .= '<td valign="top">'.$description.'</td>'.$CR;
  78.         $s .= '<td valign="top">'.$type.'</td>'.$CR;
  79.         $s .= '<td valign="top">'.$modules[$module].'</td>'.$CR;
  80.         $s .= '<td valign="top" width="16">';
  81.         if ($canEdit) {
  82.             $s .= '<a href="javascript:delIt('.$id.')"><img align="absmiddle" src="./images/icons/trash.gif" width="16" height="16" alt="'.$AppUI->_('delete').'" border="0"></a>';
  83.         }
  84.         $s .= '</td>'.$CR;
  85.     }
  86.     $s .= '</tr>'.$CR;
  87.     return $s;
  88. }
  89.  
  90. // do the modules that are installed on the system
  91. $s = '';
  92. foreach ($roles as $row) {
  93.     echo showRow( $row );
  94. }
  95. // add in the new key row:
  96. if ($role_id == 0) {
  97.     echo showRow();
  98. }
  99. ?>
  100. </table>
  101.