1<?php 2/** 3 * Copyright 1999-2017 Horde LLC (http://www.horde.org/) 4 * 5 * See the enclosed file COPYING for license information (LGPL-2). If you 6 * did not receive this file, see http://www.horde.org/licenses/lgpl. 7 * 8 * @author Chuck Hagenbuch <chuck@horde.org> 9 * @author Jan Schneider <jan@horde.org> 10 * @category Horde 11 * @license http://www.horde.org/licenses/lgpl LGPL-2 12 * @package Horde 13 */ 14 15require_once __DIR__ . '/../../lib/Application.php'; 16Horde_Registry::appInit('horde', array( 17 'permission' => array('horde:administration:perms') 18)); 19 20/* Set up the form variables. */ 21$vars = $injector->getInstance('Horde_Variables'); 22$perms = $injector->getInstance('Horde_Perms'); 23$corePerms = $injector->getInstance('Horde_Core_Perms'); 24$perm_id = $vars->get('perm_id'); 25$category = $vars->get('category'); 26try { 27 $permission = $perms->getPermissionById($perm_id); 28} catch (Exception $e) { 29 /* If the permission fetched is an error return to permissions list. */ 30 $notification->push(_("Attempt to delete a non-existent permission."), 'horde.error'); 31 Horde::url('admin/perms/index.php', true)->redirect(); 32} 33 34/* Set up form. */ 35$ui = new Horde_Core_Perms_Ui($perms, $corePerms); 36$ui->setVars($vars); 37$ui->setupDeleteForm($permission); 38 39if ($confirmed = $ui->validateDeleteForm($info)) { 40 try { 41 $result = $perms->removePermission($permission, true); 42 $notification->push(sprintf(_("Successfully deleted \"%s\"."), $corePerms->getTitle($permission->getName())), 'horde.success'); 43 Horde::url('admin/perms/index.php', true)->redirect(); 44 } catch (Exception $e) { 45 $notification->push(sprintf(_("Unable to delete \"%s\": %s."), $corePerms->getTitle($permission->getName()), $result->getMessage()), 'horde.error'); 46 } 47} elseif ($confirmed === false) { 48 $notification->push(sprintf(_("Permission \"%s\" not deleted."), $corePerms->getTitle($permission->getName())), 'horde.success'); 49 Horde::url('admin/perms/index.php', true)->redirect(); 50} 51 52$page_output->header(array( 53 'title' => _("Permissions Administration") 54)); 55require HORDE_TEMPLATES . '/admin/menu.inc'; 56 57/* Render the form and tree. */ 58$ui->renderForm('delete.php'); 59echo '<br />'; 60$ui->renderTree($perm_id); 61 62$page_output->footer(); 63