[ Index ]
 

Code source de Horde 3.1.3

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/admin/perms/ -> edit.php (source)

   1  <?php
   2  /**
   3   * $Horde: horde/admin/perms/edit.php,v 1.38.2.5 2006/01/01 21:28:05 jan Exp $
   4   *
   5   * Copyright 1999-2006 Chuck Hagenbuch <chuck@horde.org>
   6   * Copyright 2005-2006 Jan Schneider <jan@horde.org>
   7   *
   8   * See the enclosed file COPYING for license information (LGPL). If you did
   9   * not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
  10   */
  11  
  12  @define('HORDE_BASE', dirname(__FILE__) . '/../..');
  13  require_once  HORDE_BASE . '/lib/base.php';
  14  require_once  'Horde/Menu.php';
  15  
  16  if (!Auth::isAdmin()) {
  17      Horde::authenticationFailureRedirect();
  18  }
  19  
  20  /* Set up the form variables. */
  21  require_once 'Horde/Variables.php';
  22  $vars = &Variables::getDefaultVariables();
  23  $perm_id = $vars->get('perm_id');
  24  $category = $vars->get('category');
  25  
  26  /* See if we need to (and are supposed to) autocreate the permission. */
  27  if ($category !== null) {
  28      $permission = &$perms->getPermission($category);
  29      if (is_a($permission, 'PEAR_Error') && Util::getFormData('autocreate')) {
  30  
  31          /* Check to see if the permission we are copying from exists before we
  32           * autocreate. */
  33          $copyFrom = Util::getFormData('autocreate_copy');
  34          if ($copyFrom && !$perms->exists($copyFrom)) {
  35              $copyFrom = null;
  36          }
  37  
  38          $parent = $vars->get('parent');
  39          $permission = &$perms->newPermission($category);
  40          $result = $perms->addPermission($permission, $parent);
  41          if (!is_a($result, 'PEAR_Error')) {
  42              $form = 'edit.inc';
  43              $perm_id = $perms->getPermissionId($permission);
  44          }
  45  
  46          if ($copyFrom) {
  47              /* We have autocreated the permission and we have been told to
  48               * copy an existing permission for the defaults. */
  49              $copyFromObj = &$perms->getPermission($copyFrom);
  50              $permission->addGuestPermission($copyFromObj->getGuestPermissions(), false);
  51              $permission->addDefaultPermission($copyFromObj->getDefaultPermissions(), false);
  52              $permission->addCreatorPermission($copyFromObj->getCreatorPermissions(), false);
  53              foreach ($copyFromObj->getUserPermissions() as $user => $uperm) {
  54                  $permission->addUserPermission($user, $uperm, false);
  55              }
  56              foreach ($copyFromObj->getGroupPermissions() as $group => $gperm) {
  57                  $permission->addGroupPermission($group, $gperm, false);
  58              }
  59          } else {
  60              /* We have autocreated the permission and we don't have an
  61               * existing permission to copy.  See if some defaults were
  62               * supplied. */
  63              $addPerms = Util::getFormData('autocreate_guest');
  64              if ($addPerms) {
  65                  $permission->addGuestPermission($addPerms, false);
  66              }
  67              $addPerms = Util::getFormData('autocreate_default');
  68              if ($addPerms) {
  69                  $permission->addDefaultPermission($addPerms, false);
  70              }
  71              $addPerms = Util::getFormData('autocreate_creator');
  72              if ($addPerms) {
  73                  $permission->addCreatorPermission($addPerms, false);
  74              }
  75          }
  76          $permission->save();
  77      } else {
  78          $perm_id = $perms->getPermissionId($permission);
  79      }
  80      $vars->set('perm_id', $perm_id);
  81  } else {
  82      $permission = &$perms->getPermissionById($perm_id);
  83  }
  84  
  85  /* If the permission fetched is an error return to the permissions list. */
  86  if (is_a($permission, 'PEAR_Error')) {
  87      $notification->push(_("Attempt to edit a non-existent permission."), 'horde.error');
  88      $url = Horde::applicationUrl('admin/perms/index.php', true);
  89      header('Location: ' . $url);
  90      exit;
  91  }
  92  
  93  require_once 'Horde/Perms/UI.php';
  94  $ui = &new Perms_UI($perms);
  95  $ui->setVars($vars);
  96  $ui->setupEditForm($permission);
  97  
  98  if ($ui->validateEditForm($info)) {
  99      /* Update and save the permissions. */
 100      $permission->updatePermissions($info);
 101      $permission->save();
 102      $notification->push(sprintf(_("Updated \"%s\"."), $perms->getTitle($permission->getName())), 'horde.success');
 103      $url = Util::addParameter('admin/perms/edit.php', 'perm_id', $permission->getId());
 104      $url = Horde::applicationUrl($url, true);
 105      header('Location: ' . $url);
 106      exit;
 107  }
 108  
 109  $title = _("Permissions Administration");
 110  require  HORDE_TEMPLATES . '/common-header.inc';
 111  require  HORDE_TEMPLATES . '/admin/common-header.inc';
 112  $notification->notify(array('listeners' => 'status'));
 113  
 114  /* Render the form and tree. */
 115  $ui->renderForm('edit.php');
 116  echo '<br />';
 117  $ui->renderTree($perm_id);
 118  
 119  require  HORDE_TEMPLATES . '/common-footer.inc';


Généré le : Sun Feb 25 18:01:28 2007 par Balluche grâce à PHPXref 0.7