-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathpermissions.php
51 lines (45 loc) · 1.88 KB
/
permissions.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php
/**
* Gollem permissions administration page.
*
* Copyright 2005-2007 Vijay Mahrra <[email protected]>
*
* See the enclosed file LICENSE for license information (GPL). If you
* did not receive this file, see http://www.horde.org/licenses/gpl.
*
* @author Vijay Mahrra <[email protected]>
* @category Horde
* @license http://www.horde.org/licenses/gpl GPL
* @package Gollem
*/
require_once __DIR__ . '/lib/Application.php';
Horde_Registry::appInit('gollem', array('admin' => true));
if (!Gollem_Auth::getBackend()) {
$notification->push(_("You need at least one backend defined to set permissions."), 'horde.error');
Horde::url('index.php', true)->redirect();
}
/* Edit permissions for the preferred backend if none is selected. */
$key = Horde_Util::getFormData('backend', Gollem_Auth::getPreferredBackend());
$app = $registry->getApp();
$backendTag = $app . ':backends:' . $key;
$perms = $injector->getInstance('Horde_Perms');
if ($perms->exists($backendTag)) {
$permission = $perms->getPermission($backendTag);
$perm_id = $perms->getPermissionId($permission);
} else {
$permission = $injector
->getInstance('Horde_Perms')
->newPermission($backendTag);
try {
$perms->addPermission($permission, $app);
} catch (Horde_Perms_Exception $e) {
$notification->push(sprintf(_("Unable to create backend permission: %s"), $e->getMessage()), 'horde.error');
Horde::url('index.php', true)->redirect();
}
$perm_id = $perms->getPermissionId($permission);
$notification->push(sprintf(_("Created empty permissions for \"%s\". You must explicitly grant access to this backend now."), $key), 'horde.warning');
}
/* Redirect to horde permissions administration interface. */
Horde::url($registry->get('webroot', 'horde') . '/admin/perms/edit.php', true)
->add('perm_id', $permission->getId())
->redirect();