/**
* Locks an item from this share, or the entire share if no item defined.
*
- * @param string $item_uid A uid of an item from this share.
+ * @param Horde_Lock $locks The Horde_Lock object
+ * @param string $item_uid A uid of an item from this share.
*
* @return mixed A lock ID on success, PEAR_Error on failure, false if:
* - The share is already locked
* locked in the share
* @throws Horde_Share_Exception
*/
- public function lock($item_uid = null)
+ public function lock(Horde_Lock $locks, $item_uid = null)
{
- try {
- // TODO: Pass this in as a parameter, don't use the injector directly in
- // a library
- $locks = $GLOBALS['injector']->getInstance('Horde_Lock');
- } catch (Horde_Lock_Exception $e) {
- Horde::logMessage($e, 'ERR');
- throw new Horde_Share_Exception($e);
- }
-
$shareid = $this->getId();
// Default parameters.
/**
* Removes the lock for a lock ID.
*
- * @param string $lockid The lock ID as generated by a previous call
- * to lock().
+ * @param Horde_Lock $locks The lock object
+ * @param string $lockid The lock ID as generated by a previous call
+ * to lock().
*
* @return mixed True on success, PEAR_Error on failure.
*/
- public function unlock($lockid)
+ public function unlock(Horde_Lock $locks, $lockid)
{
- try {
- // TODO: pass in method, do not use injector in library
- $locks = $GLOBALS['injector']->getInstance('Horde_Lock');
- } catch (Horde_Lock_Exception $e) {
- Horde::logMessage($e, 'ERR');
- throw new Horde_Share_Exception($e);
- }
-
return $locks->clearLock($lockid);
}
* First this checks for share locks and if none exists, checks for item
* locks (if item_uid defined). It will return the first lock found.
*
- * @param string $item_uid A uid of an item from this share.
+ * @param Horde_Lock $locks The lock object.
+ * @param string $item_uid A uid of an item from this share.
*
* @return mixed Hash with the found lock information in 'lock' and the
* lock type ('share' or 'item') in 'type', or an empty
* array if there are no locks, or a PEAR_Error on failure.
*/
- public function checkLocks($item_uid = null)
+ public function checkLocks(Horde_Lock $locks, $item_uid = null)
{
- // TODO: Inject lock object, do not use injector in library
- try {
- $locks = $GLOBALS['injector']->getInstance('Horde_Lock');
- } catch (Horde_Lock_Exception $e) {
- Horde::logMessage($e, 'ERR');
- throw new Horde_Share_Exception($e);
- }
-
$shareid = $this->getId();
$locktype = Horde_Lock::TYPE_EXCLUSIVE;
/**
* Places an exclusive lock for a calendar or an event.
*
- * @param array $calendar The calendar to lock
- * @param array $event The event to lock
+ * @param string $calendar The id of the calendar to lock
+ * @param string $event The uid for the event to lock
*
* @return mixed A lock ID on success, false if:
* - The calendar is already locked
Kronolith::listCalendars(false, Horde_Perms::EDIT))) {
throw new Horde_Exception_PermissionDenied();
}
- return $GLOBALS['kronolith_shares']->getShare($calendar)->lock($calendar, $event);
+ if (!empty($event)) {
+ $uid = $calendar . ':' . $event;
+ }
+ return $GLOBALS['kronolith_shares']->getShare($calendar)->lock($GLOBALS['injector']->getInstance('Horde_Lock'), $uid);
}
/**
Kronolith::listCalendars(false, Horde_Perms::EDIT))) {
throw new Horde_Exception_PermissionDenied();
}
- return $GLOBALS['kronolith_shares']->getShare($calendar)->unlock($lockid);
+
+ return $GLOBALS['kronolith_shares']->getShare($calendar)->unlock($GLOBALS['injector']->getInstance('Horde_Lock'), $lockid);
}
/**
Kronolith::listCalendars(false, Horde_Perms::READ))) {
throw new Horde_Exception_PermissionDenied();
}
- return $GLOBALS['kronolith_shares']->getShare($calendar)->checkLocks($event);
+ if (!empty($event)) {
+ $uid = $calendar . ':' . $event;
+ }
+ return $GLOBALS['kronolith_shares']->getShare($calendar)->checkLocks($GLOBALS['injector']->getInstance('Horde_Lock'), $uid);
}
/**