[ Index ] |
|
Code source de IMP H3 (4.1.5) |
1 <?php 2 /** 3 * $Horde: imp/acl.php,v 1.23.10.9 2007/01/02 13:54:53 jan Exp $ 4 * 5 * Copyright 2000-2007 Chris Hastie <imp@oak-wood.co.uk> 6 * 7 * See the enclosed file COPYING for license information (GPL). If you 8 * did not receive this file, see http://www.fsf.org/copyleft/gpl.html. 9 */ 10 11 @define('IMP_BASE', dirname(__FILE__)); 12 $authentication = OP_HALFOPEN; 13 require_once IMP_BASE . '/lib/base.php'; 14 require_once IMP_BASE . '/lib/Folder.php'; 15 require_once 'Horde/IMAP/ACL.php'; 16 17 $prefs_url = IMP::prefsURL(true); 18 19 /* Redirect back to the options screen if ACL is not enabled. */ 20 if ($prefs->isLocked('acl') || 21 !(isset($_SESSION['imp']['acl']) && 22 is_array($_SESSION['imp']['acl']))) { 23 $notification->push(_("Folder sharing is not enabled."), 'horde.error'); 24 header('Location: ' . $prefs_url); 25 exit; 26 } 27 28 $params = array( 29 'hostspec' => $_SESSION['imp']['server'], 30 'port' => $_SESSION['imp']['port'], 31 'protocol' => $_SESSION['imp']['protocol'], 32 'username' => $_SESSION['imp']['user'], 33 'password' => Secret::read(Secret::getKey('imp'), $_SESSION['imp']['pass']) 34 ); 35 36 if (isset($_SESSION['imp']['acl']['params'])) { 37 $params = array_merge($params, $_SESSION['imp']['acl']['params']); 38 } 39 $ACLDriver = IMAP_ACL::singleton($_SESSION['imp']['acl']['driver'], $params); 40 41 /* Check selected driver is supported. Redirect to options screen with 42 * error message if not */ 43 $error = null; 44 if (!$ACLDriver->isSupported()) { 45 $error = _("This server does not support sharing folders."); 46 } else { 47 $error = $ACLDriver->getError(); 48 } 49 50 if ($error) { 51 $notification->push($error, 'horde.error'); 52 header('Location: ' . $prefs_url); 53 exit; 54 } 55 56 $acl = Util::getFormData('acl'); 57 $folder = Util::getFormData('folder'); 58 $protected = $ACLDriver->getProtected(); 59 $share_user = Util::getFormData('share_user'); 60 $ok_form = true; 61 62 /* Run through the action handlers. */ 63 $actionID = Util::getFormData('actionID'); 64 switch ($actionID) { 65 case 'imp_acl_set': 66 if (!$share_user) { 67 $notification->push(_("No user specified."), 'horde.error'); 68 $ok_form = false; 69 } 70 if (!$folder) { 71 $notification->push(_("No folder selected."), 'horde.error'); 72 $ok_form = false; 73 } 74 if (in_array($share_user, $protected)) { 75 $notification->push(_("Permissions for this user cannot be changed."), 'horde.error'); 76 $ok_form = false; 77 } 78 79 if ($ok_form) { 80 $result = $ACLDriver->createACL($folder, $share_user, $acl); 81 if (is_a($result, 'PEAR_Error')) { 82 $notification->push($result); 83 } elseif (!count($acl)) { 84 $notification->push(sprintf(_("All rights on folder \"%s\" successfully removed for user \"%s\"."), $folder, $share_user), 'horde.success'); 85 } else { 86 $notification->push(sprintf(_("User \"%s\" successfully given the specified rights for the folder \"%s\"."), $share_user, $folder), 'horde.success'); 87 } 88 } 89 break; 90 91 case 'imp_acl_edit': 92 if (!$share_user) { 93 $notification->push(_("No user specified."), 'horde.error'); 94 $ok_form = false; 95 } 96 if (!$folder) { 97 $notification->push(_("No folder selected."), 'horde.error'); 98 $ok_form = false; 99 } 100 if (in_array($share_user, $protected)) { 101 $notification->push(_("Permissions for this user cannot be changed."), 'horde.error'); 102 $ok_form = false; 103 } 104 105 if ($ok_form) { 106 $result = $ACLDriver->editACL($folder, $share_user, $acl); 107 if (is_a($result, 'PEAR_Error')) { 108 $notification->push($result); 109 } else { 110 if ($acl) { 111 $notification->push(sprintf(_("User \"%s\" successfully given the specified rights for the folder \"%s\"."), $share_user, $folder), 'horde.success'); 112 } else { 113 $notification->push(sprintf(_("User \"%s\" successfully revoked the specified rights for the folder \"%s\"."), $share_user, $folder), 'horde.success'); 114 } 115 } 116 } 117 break; 118 } 119 120 $imp_folder = &IMP_Folder::singleton(); 121 $rights = $ACLDriver->getRights(); 122 123 if (empty($folder)) { 124 $folder = 'INBOX'; 125 } 126 127 if (count($imp_folder->flist_IMP())) { 128 $options = IMP::flistSelect('', true, array(), $folder); 129 } 130 131 $curr_acl = $ACLDriver->getACL($folder); 132 $canEdit = $ACLDriver->canEdit($folder, $_SESSION['imp']['user']); 133 134 if (is_a($curr_acl, 'PEAR_Error')) { 135 $notification->push($curr_acl, 'horde_error'); 136 $curr_acl = array(); 137 } else { 138 /* Set up javascript arrays. */ 139 if (count($curr_acl)) { 140 $js_user = ''; 141 foreach (array_keys($rights) as $right) { 142 $js_right[$right] = ''; 143 } 144 145 foreach ($curr_acl as $curr_user => $granted) { 146 if (strlen($js_user) > 0) { 147 $js_user .= ', '; 148 foreach (array_keys($rights) as $right) { 149 $js_right[$right] .= ', '; 150 } 151 } 152 153 $js_user .= '"' . $curr_user . '"'; 154 155 foreach (array_keys($rights) as $right) { 156 $js_right[$right] .= (empty($granted[$right])) ? '"0"' : '"1"'; 157 } 158 } 159 } 160 } 161 162 require_once 'Horde/Prefs/UI.php'; 163 require IMP_BASE . '/config/prefs.php'; 164 $app = 'imp'; 165 166 Prefs_UI::generateHeader(); 167 require IMP_TEMPLATES . '/acl/acl.inc'; 168 require $registry->get('templates', 'horde') . '/common-footer.inc';
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Thu Nov 29 12:30:07 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |