Create a permission deleting form.
public setupDeleteForm ( Horde_Perms_Permission $permission ) | ||
$permission | Horde_Perms_Permission | A permissions object. |
$vars = $injector->getInstance('Horde_Variables'); $perms = $injector->getInstance('Horde_Perms'); $corePerms = $injector->getInstance('Horde_Core_Perms'); $perm_id = $vars->get('perm_id'); $category = $vars->get('category'); try { $permission = $perms->getPermissionById($perm_id); } catch (Exception $e) { /* If the permission fetched is an error return to permissions list. */ $notification->push(_("Attempt to delete a non-existent permission."), 'horde.error'); Horde::url('admin/perms/index.php', true)->redirect(); } /* Set up form. */ $ui = new Horde_Core_Perms_Ui($perms, $corePerms); $ui->setVars($vars); $ui->setupDeleteForm($permission); if ($confirmed = $ui->validateDeleteForm($info)) { try { $result = $perms->removePermission($permission, true); $notification->push(sprintf(_("Successfully deleted \"%s\"."), $corePerms->getTitle($permission->getName())), 'horde.success'); Horde::url('admin/perms/index.php', true)->redirect(); } catch (Exception $e) { $notification->push(sprintf(_("Unable to delete \"%s\": %s."), $corePerms->getTitle($permission->getName()), $result->getMessage()), 'horde.error'); } } elseif ($confirmed === false) { $notification->push(sprintf(_("Permission \"%s\" not deleted."), $corePerms->getTitle($permission->getName())), 'horde.success'); Horde::url('admin/perms/index.php', true)->redirect(); } $page_output->header(array('title' => _("Permissions Administration"))); require HORDE_TEMPLATES . '/admin/menu.inc'; /* Render the form and tree. */