[ Index ]
 

Code source de Serendipity 1.2

Accédez au Source d'autres logiciels libres

title

Body

[fermer]

/include/admin/ -> groups.inc.php (source)

   1  <?php # $Id: users.inc.php 114 2005-05-22 15:37:11Z garvinhicking $
   2  # Copyright (c) 2003-2005, Jannis Hermanns (on behalf the Serendipity Developer Team)
   3  # All rights reserved.  See LICENSE file for licensing details
   4  
   5  if (IN_serendipity !== true) {
   6      die ('Don\'t hack!');
   7  }
   8  
   9  if (!serendipity_checkPermission('adminUsersGroups')) {
  10      return;
  11  }
  12  
  13  /* Delete a group */
  14  if (isset($_POST['DELETE_YES']) && serendipity_checkFormToken()) {
  15      $group = serendipity_fetchGroup($serendipity['POST']['group']);
  16      serendipity_deleteGroup($serendipity['POST']['group']);
  17      printf('<div class="serendipityAdminMsgSuccess"><img style="height: 22px; width: 22px; border: 0px; padding-right: 4px; vertical-align: middle" src="' . serendipity_getTemplateFile('admin/img/admin_msg_success.png') . '" alt="" />' . DELETED_GROUP . '</div>', $serendipity['POST']['group'], $group['name']);
  18  }
  19  
  20  /* Save new group */
  21  if (isset($_POST['SAVE_NEW']) && serendipity_checkFormToken()) {
  22      $serendipity['POST']['group'] = serendipity_addGroup($serendipity['POST']['name']);
  23      $perms = serendipity_getAllPermissionNames();
  24      serendipity_updateGroupConfig($serendipity['POST']['group'], $perms, $serendipity['POST'], false, $serendipity['POST']['forbidden_plugins'], $serendipity['POST']['forbidden_hooks']);
  25      printf('<div class="serendipityAdminMsgSuccess"><img style="height: 22px; width: 22px; border: 0px; padding-right: 4px; vertical-align: middle" src="' . serendipity_getTemplateFile('admin/img/admin_msg_success.png') . '" alt="" />' . CREATED_GROUP . '</div>', '#' . $serendipity['POST']['group'] . ', ' . $serendipity['POST']['name']);
  26  }
  27  
  28  
  29  /* Edit a group */
  30  if (isset($_POST['SAVE_EDIT']) && serendipity_checkFormToken()) {
  31      $perms = serendipity_getAllPermissionNames();
  32      serendipity_updateGroupConfig($serendipity['POST']['group'], $perms, $serendipity['POST'], false, $serendipity['POST']['forbidden_plugins'], $serendipity['POST']['forbidden_hooks']);
  33      printf('<div class="serendipityAdminMsgSuccess"><img style="height: 22px; width: 22px; border: 0px; padding-right: 4px; vertical-align: middle" src="' . serendipity_getTemplateFile('admin/img/admin_msg_success.png') . '" alt="" />' . MODIFIED_GROUP . '</div>', $serendipity['POST']['name']);
  34  }
  35  
  36  if ( $serendipity['GET']['adminAction'] != 'delete' ) {
  37  ?>
  38      <table width="100%">
  39          <tr>
  40              <td><strong><?php echo GROUP; ?></strong></td>
  41              <td width="200">&nbsp;</td>
  42          </tr>
  43          <tr>
  44              <td colspan="3">
  45  <?php
  46  if (serendipity_checkPermission('adminUsersMaintainOthers')) {
  47      $groups = serendipity_getAllGroups();
  48  } elseif (serendipity_checkPermission('adminUsersMaintainSame')) {
  49      $groups = serendipity_getAllGroups($serendipity['authorid']);
  50  } else {
  51      $groups = array();
  52  }
  53  $i = 0;
  54  foreach($groups as $group) {
  55  ?>
  56  <div class="serendipity_admin_list_item serendipity_admin_list_item_<?php echo ($i++ % 2) ? 'even' : 'uneven' ?>">
  57  <table width="100%">
  58      <tr>
  59          <td><?php echo htmlspecialchars($group['name']); ?></td>
  60          <td width="200" align="right"> <a href="?serendipity[adminModule]=groups&amp;serendipity[adminAction]=edit&amp;serendipity[group]=<?php echo $group['id'] ?>" title="<?php echo EDIT . " " . $group['name']; ?>" class="serendipityIconLink"><img src="<?php echo serendipity_getTemplateFile('admin/img/edit.png'); ?>" alt="<?php echo EDIT . " " . $group['name']; ?>" /><?php echo EDIT ?></a>
  61                                         <a href="?<?php echo serendipity_setFormToken('url'); ?>&amp;serendipity[adminModule]=groups&amp;serendipity[adminAction]=delete&amp;serendipity[group]=<?php echo $group['id'] ?>" title="<?php echo DELETE . " " . $group['name']; ?>" class="serendipityIconLink"><img src="<?php echo serendipity_getTemplateFile('admin/img/delete.png'); ?>" alt="<?php echo DELETE . " " . $group['name']; ?>" /><?php echo DELETE ?></a></td>
  62      </tr>
  63  </table>
  64  </div>
  65  <?php
  66      }
  67  ?>
  68              </tr>
  69          </tr>
  70  <?php if ( !isset($_POST['NEW']) ) { ?>
  71          <tr>
  72              <td colspan="3" align="right">
  73                  <form action="?serendipity[adminModule]=groups" method="post">
  74                      <input type="submit" name="NEW"   value="<?php echo CREATE_NEW_GROUP; ?>" class="serendipityPrettyButton input_button" />
  75                  </form>
  76              </td>
  77          </tr>
  78  <?php } ?>
  79      </table>
  80  
  81  <?php
  82  }
  83  
  84  
  85  if ($serendipity['GET']['adminAction'] == 'edit' || isset($_POST['NEW'])) {
  86  ?>
  87  <br />
  88  <br />
  89  <hr noshade="noshade">
  90  <form action="?serendipity[adminModule]=groups" method="post">
  91  <?php echo serendipity_setFormToken(); ?>
  92      <div>
  93      <h3>
  94  <?php
  95  if ($serendipity['GET']['adminAction'] == 'edit') {
  96      $group = serendipity_fetchGroup($serendipity['GET']['group']);
  97      echo EDIT;
  98      $from = &$group;
  99      echo '<input type="hidden" name="serendipity[group]" value="' . $from['id'] . '" />';
 100  } else {
 101      echo CREATE;
 102      $from = array();
 103  }
 104  ?>
 105      </h3>
 106  <table>
 107      <tr>
 108          <td><?php echo NAME; ?></td>
 109          <td><input class="input_textbox" type="text" name="serendipity[name]" value="<?php echo htmlspecialchars($from['name']); ?>" /></td>
 110      </tr>
 111      <tr>
 112          <td valign="top"><?php echo USERCONF_GROUPS; ?></td>
 113          <td><select name="serendipity[members][]" multiple="multiple" size="5">
 114  <?php
 115  $allusers = serendipity_fetchUsers();
 116  $users    = serendipity_getGroupUsers($from['id']);
 117  
 118  $selected = array();
 119  foreach((array)$users AS $user) {
 120      $selected[$user['id']] = true;
 121  }
 122  
 123  foreach($allusers AS $user) {
 124      echo '<option value="' . (int)$user['authorid'] . '" ' . (isset($selected[$user['authorid']]) ? 'selected="selected"' : '') . '>' . htmlspecialchars($user['realname']) . '</option>' . "\n";
 125  }
 126  ?>
 127              </select>
 128          </td>
 129      </tr>
 130      <tr>
 131          <td colspan="2">&nbsp;</td>
 132      </tr>
 133  <?php
 134      $perms = serendipity_getAllPermissionNames();
 135      ksort($perms);
 136      foreach($perms AS $perm => $userlevels) {
 137          if (substr($perm, 0, 2) == 'f_') {
 138              continue;
 139          }
 140  
 141          if (isset($from[$perm]) && $from[$perm] === 'true') {
 142              $selected = 'checked="checked"';
 143          } else {
 144              $selected = '';
 145          }
 146  
 147          if (!isset($section)) {
 148              $section = $perm;
 149          }
 150  
 151          if ($section != $perm && substr($perm, 0, strlen($section)) == $section) {
 152              $indent  = '&nbsp;&nbsp;';
 153              $indentB = '';
 154          } elseif ($section != $perm) {
 155              $indent  = '<br />';
 156              $indentB = '<br />';
 157              $section = $perm;
 158          }
 159  
 160          if (defined('PERMISSION_' . strtoupper($perm))) {
 161              $permname = constant('PERMISSION_' . strtoupper($perm));
 162          } else {
 163              $permname = $perm;
 164          }
 165  
 166          if (!serendipity_checkPermission($perm)) {
 167              echo "<tr>\n";
 168              echo "<td>$indent" . htmlspecialchars($permname) . "</td>\n";
 169              echo '<td>' . $indentB . ' ' . (!empty($selected) ? YES : NO) . '</td>' . "\n";
 170              echo "</tr>\n";
 171          } else {
 172              echo "<tr>\n";
 173              echo "<td>$indent<label for=\"" . htmlspecialchars($perm) . "\">" . htmlspecialchars($permname) . "</label></td>\n";
 174              echo '<td>' . $indentB . '<input class="input_checkbox" id="' . htmlspecialchars($perm) . '" type="checkbox" name="serendipity[' . htmlspecialchars($perm) . ']" value="true" ' . $selected . ' /></td>' . "\n";
 175              echo "</tr>\n";
 176          }
 177      }
 178  
 179      if ($serendipity['enablePluginACL']) {
 180          $allplugins =& serendipity_plugin_api::get_event_plugins();
 181          $allhooks   = array();
 182  ?>
 183      <tr>
 184          <td colspan="2">&nbsp;</td>
 185      </tr>
 186      <tr>
 187          <td valign="top"><?php echo PERMISSION_FORBIDDEN_PLUGINS; ?></td>
 188          <td>
 189              <select name="serendipity[forbidden_plugins][]" multiple="multiple" size="5">
 190              <?php
 191                  foreach($allplugins AS $plugid => $currentplugin) {
 192                      foreach($currentplugin['b']->properties['event_hooks'] AS $hook => $set) {
 193                          $allhooks[$hook] = true;
 194                      }
 195                      echo '<option value="' . urlencode($plugid) . '" ' . (serendipity_hasPluginPermissions($plugid, $from['id']) ? '' : 'selected="selected"') . '>' . htmlspecialchars($currentplugin['b']->properties['name']) . '</option>' . "\n";
 196                  }
 197                  ksort($allhooks);
 198              ?>
 199              </select>
 200          </td>
 201      </tr>
 202  
 203      <tr>
 204          <td colspan="2">&nbsp;</td>
 205      </tr>
 206      <tr>
 207          <td valign="top"><?php echo PERMISSION_FORBIDDEN_HOOKS; ?></td>
 208          <td>
 209              <select name="serendipity[forbidden_hooks][]" multiple="multiple" size="5">
 210              <?php
 211                  foreach($allhooks AS $hook => $set) {
 212                      echo '<option value="' . urlencode($hook) . '" ' . (serendipity_hasPluginPermissions($hook, $from['id']) ? '' : 'selected="selected"') . '>' . htmlspecialchars($hook) . '</option>' . "\n";
 213                  }
 214              ?>
 215              </select>
 216          </td>
 217      </tr>
 218  <?php
 219      } else {
 220  ?>
 221      <tr>
 222          <td colspan="2">&nbsp;</td>
 223      </tr>
 224  
 225      <tr>
 226          <td colspan="2"><?php echo PERMISSION_FORBIDDEN_ENABLE_DESC; ?></td>
 227      </tr>
 228  <?php
 229      }
 230  ?>
 231  </table>
 232  
 233  <?php
 234  if ($serendipity['GET']['adminAction'] == 'edit') { ?>
 235          <input type="submit" name="SAVE_EDIT"   value="<?php echo SAVE; ?>" class="serendipityPrettyButton input_button" />
 236          <?php echo ' - ' . WORD_OR . ' - ' ?>
 237          <input type="submit" name="SAVE_NEW"   value="<?php echo CREATE_NEW_GROUP; ?>" class="serendipityPrettyButton input_button" />
 238  <?php } else { ?>
 239          <input type="submit" name="SAVE_NEW" value="<?php echo CREATE_NEW_GROUP; ?>" class="serendipityPrettyButton input_button" />
 240  <?php } ?>
 241  
 242      </div>
 243  </form>
 244  <?php
 245  } elseif ($serendipity['GET']['adminAction'] == 'delete') {
 246      $group = serendipity_fetchGroup($serendipity['GET']['group']);
 247  ?>
 248  <form action="?serendipity[adminModule]=groups" method="post">
 249      <div>
 250      <?php printf(DELETE_GROUP, $serendipity['GET']['group'], $group['name']); ?>
 251          <br /><br />
 252          <?php echo serendipity_setFormToken(); ?>
 253          <input type="hidden" name="serendipity[group]" value="<?php echo $serendipity['GET']['group']; ?>" />
 254          <input type="submit" name="DELETE_YES" value="<?php echo DUMP_IT; ?>" class="serendipityPrettyButton input_button" />
 255          <input type="submit" name="NO" value="<?php echo NOT_REALLY; ?>" class="serendipityPrettyButton input_button" />
 256      </div>
 257  </form>
 258  <?php
 259  }
 260  
 261  /* vim: set sts=4 ts=4 expandtab : */
 262  ?>


Généré le : Sat Nov 24 09:00:37 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics