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 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214
|
<?php
/**
* Contains functions related to managing
* Access Control Lists.
*
* $Horde: framework/IMAP/IMAP/ACL.php,v 1.2.12.10 2006/02/03 03:07:57 selsky Exp $
*
* Copyright 2003-2006 Chris Hastie <imp@oak-wood.co.uk>
*
* See the enclosed file COPYING for license information (LGPL). If you
* did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
*
* @author Chris Hastie <imp@oak-wood.co.uk>
* @since Horde 3.0
* @package Horde_IMAP
*/
class IMAP_ACL {
/**
* Hash containing connection parameters.
*
* @var array
*/
var $_params = array();
/**
* Boolean indicating if the driver is supported by the server
*
* @var boolean
*/
var $_supported = false;
/**
* Any PEAR_Error that occured but couldn't be returned directly.
*
* @var PEAR_Error
*/
var $_error = null;
/**
* Hash containing the list of possible rights and a human
* readable description of each
*
* Array (
* right-id => right-description
* )
*
* @var array
*/
var $_rightsList = array();
/**
* Array containing user names that cannot have their access
* rights changed.
*
* @var boolean
*/
var $_protected;
/**
* Constructor.
*
* @param array $params Hash containing connection parameters.
*/
function IMAP_ACL($params = array())
{
$this->_params = $params;
}
/**
* Attempts to retrieve the existing ACL for a folder from
* the current IMAP server.
*
* @param string folder The folder to get the ACL for
*
* @return array A hash containing information on the ACL
* Array (
* user => Array (
* right => 1
* )
* )
*/
function getACL($folder)
{
return false;
}
/**
* Sets the ACL on an IMAP server
*
* @param string $folder The folder on which to edit the ACL
*
* @param string $share_user The user to grant rights to
*
* @param array $acl An array, the keys of which are the
* rights to be granted (see RFC 2086)
*
* @return mixed True on success, false on failure unless
* server doesn't support ACLs, returns 'no_support'
*/
function createACL($folder, $share_user, $acl)
{
return false;
}
/**
* Edits an ACL on an IMAP server
*
* @param string $folder The folder on which to edit the ACL
*
* @param string $share_user The user to grant rights to
*
* @param array $acl An array, the keys of which are the
* rights to be granted (see RFC 2086)
*
* @return mixed True on success, false on failure unless
* server doesn't support ACLs, returns 'no_support'
*/
function editACL($folder, $share_user, $acl)
{
return false;
}
/**
* Can a user edit the ACL for this folder? Returns true if $user
* permission to edit the ACL on $folder
*
* @param string $folder The folder name
*
* @param string $user A user name
*
* @return boolean True if $user has 'a' right
*/
function canEdit($folder, $user)
{
return true;
}
function getRights()
{
return $this->_rightsList;
}
function getProtected()
{
return $this->_protected;
}
function isSupported()
{
return $this->_supported;
}
function getError()
{
$error = $this->_error;
$this->_error = null;
return $error;
}
/**
* Attempts to return an ACL instance based on $driver.
*
* @param string $driver The type of concrete ACL subclass to return.
* @param array $params A hash containing any additional configuration or
* connection parameters a subclass might need.
*
* @return mixed The newly created concrete ACL instance, or false
* on error.
*/
function &factory($driver, $params = array())
{
$driver = basename($driver);
require_once dirname(__FILE__) . '/ACL/' . $driver . '.php';
$class = 'IMAP_ACL_' . $driver;
if (class_exists($class)) {
$acl = &new $class($params);
} else {
$acl = false;
}
return $acl;
}
/**
* Attempts to return a reference to a concrete ACL instance
* based on $driver. It will only create a new instance if no
* ACL instance with the same parameters currently exists.
*
* This method must be invoked as: $var = &IMAP_ACL::singleton()
*
* @param string $driver The type of concrete ACL subclass to return.
* @param array $params A hash containing any additional configuration or
* connection parameters a subclass might need.
*
* @return mixed The created concrete ACL instance, or false on error.
*/
function &singleton($driver, $params = array())
{
static $instances;
if (!isset($instances)) {
$instances = array();
}
$signature = serialize(array($driver, $params));
if (!isset($instances[$signature])) {
$instances[$signature] = &IMAP_ACL::factory($driver, $params);
}
return $instances[$signature];
}
}
|