[ Index ]

PHP Cross Reference of Moodle 1.9.3 [Build 15-Oct-2008]

title

Body

[close]

/admin/roles/ -> manage.html (source)

   1  <?php  //$Id: manage.html,v 1.38.2.2 2008/03/02 15:02:25 moodler Exp $
   2  
   3      switch ($action) {
   4          case 'add':
   5              $submitlabel = get_string('addrole', 'role');
   6              break;
   7          case 'edit':
   8          default:
   9              $submitlabel = get_string('savechanges');
  10      }
  11  
  12      if ($action == 'view') {
  13  ?>
  14  <?php
  15      }
  16  ?>
  17  <form id="rolesform" action="manage.php" method="post">
  18  <fieldset class="invisiblefieldset">
  19  <input type="hidden" name="roleid" value="<?php p($roleid) ?>" />
  20  <input type="hidden" name="sesskey" value="<?php p(sesskey()) ?>" />
  21  <input type="hidden" name="action" value="<?php if ($action != 'view') { echo p($action); } ?>" />
  22  </fieldset>
  23  <table class="roledesc" cellpadding="9" cellspacing="0">
  24  <?php if ($action == 'view') { ?>
  25      <tr valign="top">
  26          <td align="right"><?php print_string('name') ?>:</td>
  27          <td><?php p($role->name); ?></td>
  28      </tr>
  29      <tr valign="top">
  30          <td align="right"><?php print_string('shortname') ?>:</td>
  31          <td><?php p($role->shortname); ?></td>
  32      </tr>
  33      <tr valign="top">
  34          <td align="right"><?php print_string('description') ?>:</td>
  35          <td><?php p($role->description); $usehtmleditor = false; ?></td>
  36      </tr>
  37      <tr valign="top">
  38          <td align="right"><?php print_string('legacytype', 'role') ?>:</td>
  39          <td><?php 
  40                  $usehtmleditor = false;
  41                  if (empty($role->legacytype)) {
  42                      print_string('none');
  43                  } else {
  44                      print_string('legacy:'.$role->legacytype, 'role');
  45                  }
  46              ?>
  47          </td>
  48      </tr>
  49  <?php } else { ?>
  50      <tr valign="top">
  51          <td align="right"><label for="name"><?php print_string('name') ?></label></td>
  52          <td><?php
  53              echo '<input type="text" id="name" name="name" maxlength="254" size="50" value="'.s($role->name).'" />';
  54              if (isset($errors["name"])) formerr($errors["name"]);
  55              ?>
  56          </td>
  57      </tr>
  58      <tr valign="top">
  59          <td align="right"><label for="shortname"><?php print_string('shortname') ?></label></td>
  60          <td><?php
  61              echo '<input type="text" id="shortname" name="shortname" maxlength="100" size="15" value="'.s($role->shortname).'" />';
  62              if (isset($errors["shortname"])) formerr($errors["shortname"]);
  63              ?>
  64          </td>
  65      </tr>
  66      <tr valign="top">
  67          <td align="right"><label for="edit-description"><?php print_string('description') ?></label></td>
  68          <td><?php
  69              print_textarea($usehtmleditor, 10, 50, 50, 10, 'description', $role->description);
  70              ?>
  71          </td>
  72      </tr>
  73      <tr valign="top">
  74          <td align="right"><label for="menulegacytype"><?php print_string('legacytype', 'role') ?></label></td>
  75          <td><?php
  76              $options = array();
  77              $options[''] = get_string('none');
  78              $legacyroles = get_legacy_roles();
  79              foreach($legacyroles as $ltype=>$lcap) {
  80                  $options[$ltype] = get_string('legacy:'.$ltype, 'role');
  81              }
  82              choose_from_menu($options, 'legacytype', $role->legacytype, '');
  83              ?>
  84          </td>
  85      </tr>
  86  <?php } ?>
  87  </table>
  88  
  89  <?php
  90      print_heading_with_help(get_string('permissions','role'), 'permissions');
  91  
  92      $strinherit = get_string('notset','role');
  93      $strallow = get_string('allow','role');
  94      $strprevent = get_string('prevent','role');
  95      $strprohibit = get_string('prohibit','role');
  96  ?>
  97  
  98  <table class="rolecap">
  99  
 100  <tr>
 101  <th class="name" align="left" scope="col"><?php print_string('capability','role') ?></th>
 102  <th class="inherit" scope="col"><?php p($strinherit); ?></th>
 103  <th class="allow" scope="col"><?php p($strallow); ?></th>
 104  <th class="prevent" scope="col"><?php p($strprevent); ?></th>
 105  <th class="prohibit" scope="col"><?php p($strprohibit); ?></th>
 106  <th class="risk" colspan="5" scope="col"><?php print_string('risks','role') ?></th>
 107  </tr>
 108  
 109  <?php
 110  
 111  // init these 2
 112  $contextlevel = 0;
 113  $component = '';
 114  
 115  $strrisks = s(get_string('risks', 'role'));
 116  // MDL-11687
 117  $strcapabilities = 'Capabilities';//s(get_string('capabilities', 'role'));
 118  
 119  // prepare legacy defaults
 120  if (!empty($role->legacytype)) {
 121      $defaultcaps = get_default_capabilities($role->legacytype);
 122  } else {
 123      $defaultcaps = false;
 124  }
 125  
 126  foreach ($capabilities as $capability) {
 127  
 128      //legacy caps have their own selector
 129      if (islegacy($capability->name)) {
 130          continue;
 131      }
 132  
 133      // prints a breaker if component or name or context level
 134      if (component_level_changed($capability, $component, $contextlevel)) {
 135      //if ($capability->component != $component or $capability->contextlevel != $contextlevel) {
 136          echo ('<tr class="rolecapheading header"><td colspan="10" class="header"><strong>'.
 137                 get_component_string($capability->component, $capability->contextlevel).'</strong></td></tr>');
 138      }
 139  
 140      // these 2 are used to see to group same mod/core capabilities together
 141      $contextlevel = $capability->contextlevel;
 142      $component = $capability->component;
 143  
 144      if (empty($errors)) {
 145         // check the capability override for this cap, this role in this context
 146          $localoverride = get_local_override($roleid, $sitecontext->id, $capability->name);
 147      } else {
 148          $localoverride = new object();
 149          $localoverride->permission = $role->{$capability->name};
 150      }
 151  
 152      $disabled = ($action != 'edit' and $action != 'add') ? ' disabled="disabled" ' : '';
 153  
 154      $riskinfo = '<td class="risk managetrust">';
 155      $rowclasses = '';
 156      if (RISK_MANAGETRUST & (int)$capability->riskbitmask) {
 157          $riskinfo .= '<a onclick="this.target=\'docspopup\'" title="'.get_string('riskmanagetrust', 'admin').'" href="'.$CFG->docroot.'/'.$lang.'/'.$strrisks.'">';
 158          $riskinfo .= '<img src="'.$CFG->pixpath.'/i/risk_managetrust.gif" alt="'.get_string('riskmanagetrustshort', 'admin').'" /></a>';
 159          $rowclasses .= ' riskmanagetrust';
 160      }
 161      $riskinfo .= '</td><td class="risk config">';
 162      if (RISK_CONFIG & (int)$capability->riskbitmask) {
 163          $riskinfo .= '<a onclick="this.target=\'docspopup\'" title="'.get_string('riskconfig', 'admin').'" href="'.$CFG->docroot.'/'.$lang.'/'.$strrisks.'">';
 164          $riskinfo .= '<img src="'.$CFG->pixpath.'/i/risk_config.gif" alt="'.get_string('riskconfigshort', 'admin').'" /></a>';
 165          $rowclasses .= ' riskconfig';
 166      }
 167      $riskinfo .= '</td><td class="risk xss">';
 168      if (RISK_XSS & (int)$capability->riskbitmask) {
 169          $riskinfo .= '<a onclick="this.target=\'docspopup\'" title="'.get_string('riskxss', 'admin').'" href="'.$CFG->docroot.'/'.$lang.'/'.$strrisks.'">';
 170          $riskinfo .= '<img src="'.$CFG->pixpath.'/i/risk_xss.gif" alt="'.get_string('riskxssshort', 'admin').'" /></a>';
 171          $rowclasses .= ' riskxss';
 172      }
 173      $riskinfo .= '</td><td class="risk personal">';
 174      if (RISK_PERSONAL & (int)$capability->riskbitmask) {
 175          $riskinfo .= '<a onclick="this.target=\'docspopup\'" title="'.get_string('riskpersonal', 'admin').'" href="'.$CFG->docroot.'/'.$lang.'/'.$strrisks.'">';
 176          $riskinfo .= '<img src="'.$CFG->pixpath.'/i/risk_personal.gif" alt="'.get_string('riskpersonalshort', 'admin').'" /></a>';
 177          $rowclasses .= ' riskpersonal';
 178      }
 179      $riskinfo .= '</td><td class="risk spam">';
 180      if (RISK_SPAM & (int)$capability->riskbitmask) {
 181          $riskinfo .= '<a onclick="this.target=\'docspopup\'" title="'.get_string('riskspam', 'admin').'" href="'.$CFG->docroot.'/'.$lang.'/'.$strrisks.'">';
 182          $riskinfo .= '<img src="'.$CFG->pixpath.'/i/risk_spam.gif" alt="'.get_string('riskspamshort', 'admin').'" /></a>';
 183          $rowclasses .= ' riskspam';
 184      }
 185      $riskinfo .= '</td>';
 186  
 187      $isinherit  = (!isset($defaultcaps[$capability->name]) or $defaultcaps[$capability->name] == CAP_INHERIT) ? 'capdefault' : '';
 188      $isallow    = (isset($defaultcaps[$capability->name]) and $defaultcaps[$capability->name] == CAP_ALLOW) ? 'capdefault' : '';
 189      $isprevent  = (isset($defaultcaps[$capability->name]) and $defaultcaps[$capability->name] == CAP_PREVENT) ? 'capdefault' : '';
 190      $isprohibit = (isset($defaultcaps[$capability->name]) and $defaultcaps[$capability->name] == CAP_PROHIBIT) ? 'capdefault' : '';
 191  
 192      ?>
 193  
 194          <tr class="rolecap <?php echo $rowclasses; ?>">
 195          <td class="name"><span class="cap-desc"><a onclick="this.target='docspopup'" href="<?php echo $CFG->docroot.'/'.$lang.'/'.$strcapabilities.'/'.$capability->name ?>"><?php echo get_capability_string($capability->name); ?></a><span class="cap-name"><?php echo $capability->name ?></span></span></td>
 196          <td class="inherit <?php echo $isinherit ?>">
 197            <input type="radio" title="<?php p($strinherit); ?>" name="<?php echo $capability->name; ?>" value="<?php echo CAP_INHERIT ?>" <?php if (!isset($localoverride->permission) || $localoverride->permission==CAP_INHERIT){ echo 'checked="checked"'; }?> <?php echo $disabled; ?>/></td>
 198          <td class="allow <?php echo $isallow ?>">
 199            <input type="radio" title="<?php p($strallow); ?>" name="<?php echo $capability->name; ?>" value="<?php echo CAP_ALLOW ?>" <?php if (isset($localoverride->permission) && $localoverride->permission==CAP_ALLOW){ echo 'checked="checked"'; }?> <?php echo $disabled; ?>/></td>
 200          <td class="prevent <?php echo $isprevent ?>" >
 201            <input type="radio" title="<?php p($strprevent); ?>" name="<?php echo $capability->name; ?>" value="<?php echo CAP_PREVENT ?>" <?php if (isset($localoverride->permission) && $localoverride->permission==CAP_PREVENT){ echo 'checked="checked"'; }?> <?php echo $disabled; ?>/></td>
 202          <td class="prohibit <?php echo $isprohibit ?>" >
 203            <input type="radio" title="<?php p($strprohibit); ?>" name="<?php echo $capability->name; ?>" value="<?php echo CAP_PROHIBIT ?>" <?php if (isset($localoverride->permission) && $localoverride->permission==CAP_PROHIBIT){ echo 'checked="checked"'; }?> <?php echo $disabled; ?>/></td>
 204  
 205          <?php echo $riskinfo; ?>
 206  
 207          </tr>
 208  
 209  <?php } ?>
 210  </table>
 211  
 212  <?php if ($action != 'view') { ?>
 213  <div class="submit buttons">
 214  <input type="submit" value="<?php p($submitlabel) ?>" />
 215  <input type="submit" name="cancel" value="<?php print_string('cancel') ?>" />
 216  </div>
 217  <?php } ?>
 218  
 219  </form>


Generated: Wed Jan 14 11:33:29 2009 Cross-referenced by PHPXref 0.7