1: <?php
2: /**
3: * A null driver for Horde_Lock.
4: *
5: * Copyright 2010-2012 Horde LLC (http://www.horde.org/)
6: *
7: * See the enclosed file COPYING for license information (LGPL). If you did
8: * not receive this file, see http://www.horde.org/licenses/lgpl21.
9: *
10: * @author Michael Slusarz <slusarz@horde.org>
11: * @category Horde
12: * @package Lock
13: */
14: class Horde_Lock_Null extends Horde_Lock
15: {
16: /**
17: * Return an array of information about the requested lock.
18: *
19: * @param string $lockid Lock ID to look up.
20: *
21: * @return array Lock information.
22: * @throws Horde_Lock_Exception
23: */
24: public function getLockInfo($lockid)
25: {
26: return array();
27: }
28:
29: /**
30: * Return a list of valid locks with the option to limit the results
31: * by principal, scope and/or type.
32: *
33: * @param string $scope The scope of the lock. Typically the name of
34: * the application requesting the lock or some
35: * other identifier used to group locks together.
36: * @param string $principal Principal for which to check for locks
37: * @param integer $type Only return locks of the given type.
38: * Defaults to null, or all locks
39: *
40: * @return array Array of locks with the ID as the key and the lock details
41: * as the value. If there are no current locks this will
42: * return an empty array.
43: * @throws Horde_Lock_Exception
44: */
45: public function getLocks($scope = null, $principal = null, $type = null)
46: {
47: return array();
48: }
49:
50: /**
51: * Extend the valid lifetime of a valid lock to now + $extend.
52: *
53: * @param string $lockid Lock ID to reset. Must be a valid, non-expired
54: * lock.
55: * @param integer $extend Extend lock this many seconds from now.
56: *
57: * @return boolean Returns true on success.
58: * @throws Horde_Lock_Exception
59: */
60: public function resetLock($lockid, $extend)
61: {
62: return true;
63: }
64:
65: /**
66: * Sets a lock on the requested principal and returns the generated lock
67: * ID. NOTE: No security checks are done in the Horde_Lock API. It is
68: * expected that the calling application has done all necessary security
69: * checks before requesting a lock be granted.
70: *
71: * @param string $requestor User ID of the lock requestor.
72: * @param string $scope The scope of the lock. Typically the name of
73: * the application requesting the lock or some
74: * other identifier used to group locks
75: * together.
76: * @param string $principal A principal on which a lock should be
77: * granted. The format can be any string but is
78: * suggested to be in URI form.
79: * @param integer $lifetime Time (in seconds) for which the lock will be
80: * considered valid.
81: * @param string exclusive One of Horde_Lock::TYPE_SHARED or
82: * Horde_Lock::TYPE_EXCLUSIVE.
83: * - An exclusive lock will be enforced strictly
84: * and must be interpreted to mean that the
85: * resource can not be modified. Only one
86: * exclusive lock per principal is allowed.
87: * - A shared lock is one that notifies other
88: * potential lock requestors that the resource
89: * is in use. This lock can be overridden
90: * (cleared or replaced with a subsequent
91: * call to setLock()) by other users. Multiple
92: * users may request (and will be granted) a
93: * shared lock on a given principal. All locks
94: * will be considered valid until they are
95: * cleared or expire.
96: *
97: * @return mixed A string lock ID.
98: * @throws Horde_Lock_Exception
99: */
100: public function setLock($requestor, $scope, $principal, $lifetime = 1,
101: $exclusive = Horde_Lock::TYPE_SHARED)
102: {
103: return strval(new Horde_Support_Uuid());
104: }
105:
106: /**
107: * Removes a lock given the lock ID.
108: * NOTE: No security checks are done in the Horde_Lock API. It is
109: * expected that the calling application has done all necessary security
110: * checks before requesting a lock be cleared.
111: *
112: * @param string $lockid The lock ID as generated by a previous call
113: * to setLock()
114: *
115: * @return boolean Returns true on success.
116: * @throws Horde_Lock_Exception
117: */
118: public function clearLock($lockid)
119: {
120: return true;
121: }
122:
123: }
124: