FusionDirectory
Static Public Member Functions
Lock Class Reference

Static Public Member Functions

static add ($object, string $user=NULL)
 Add a lock for object(s) More...
 
static deleteByObject ($object)
 Remove a lock for object(s) More...
 
static deleteByUser (string $userdn)
 Remove all locks owned by a specific userdn. More...
 
static get ($objects, bool $allow_readonly=FALSE)
 Get locks for objects. More...
 
static addOrFail ($object, string $user=NULL, int $retries=10)
 Add a lock for object(s) or fail. More...
 
static genLockedMessage (array $locks, bool $allowReadonly=FALSE, string $action=NULL)
 Generate a lock message. More...
 

Detailed Description

Definition at line 22 of file class_Lock.inc.

Member Function Documentation

◆ add()

static add (   $object,
string  $user = NULL 
)
static

Add a lock for object(s)

Adds a lock by the specified user for one or multiple objects. If a lock for that object already exists from another user, an error is triggered.

Parameters
array$objectThe object or array of objects to lock
string$userThe user who shall own the lock

Definition at line 47 of file class_Lock.inc.

References get_ou(), session\get_ref(), htmlescape(), session\is_set(), and session\set().

Referenced by addOrFail(), management\editEntry(), and config\set_current().

◆ addOrFail()

static addOrFail (   $object,
string  $user = NULL,
int  $retries = 10 
)
static

Add a lock for object(s) or fail.

Adds a lock by the specified user for one ore multiple objects. If the lock for that object already exists, waits a bit and retry. If a lock cannot be set, throws.

Parameters
array | string$objectThe object or array of objects to lock
string$userThe user who shall own the lock
int$retrieshow many times we can retry (waiting a second each time)

Definition at line 294 of file class_Lock.inc.

References add(), and get().

Referenced by templateHandling\listFields().

◆ deleteByObject()

static deleteByObject (   $object)
static

Remove a lock for object(s)

Remove a lock for object(s)

Parameters
mixed$objectobject or array of objects for which a lock shall be removed

Definition at line 135 of file class_Lock.inc.

References get_ou(), session\get_ref(), and session\is_set().

Referenced by templateHandling\listFields(), management\removeLocks(), and config\set_current().

◆ deleteByUser()

static deleteByUser ( string  $userdn)
static

Remove all locks owned by a specific userdn.

For a given userdn remove all existing locks. This is usually called on logout.

Parameters
string$userdnthe subject whose locks shall be deleted

Definition at line 185 of file class_Lock.inc.

References get_ou().

◆ genLockedMessage()

static genLockedMessage ( array  $locks,
bool  $allowReadonly = FALSE,
string  $action = NULL 
)
static

Generate a lock message.

This message shows a warning to the user, that a certain object is locked and presents some choices how the user can proceed. By default this is 'Cancel' or 'Edit anyway', but depending on the function call its possible to allow readonly access, too.

Example usage:

if ($locks = Lock::get($this->dn)) {
return Lock::genLockedMessage($locks, TRUE);
}
Parameters
string$locksthe locks as returned by Lock::get
boolean$allowReadonlyTRUE if readonly access should be permitted, FALSE if not (default).
string$actionLabel of the action button, "Edit anyway" by default. Will be escaped.

Definition at line 331 of file class_Lock.inc.

References session\get(), session\is_set(), and session\set().

Referenced by management\editEntry().

◆ get()

static get (   $objects,
bool  $allow_readonly = FALSE 
)
static

Get locks for objects.

Parameters
mixed$objectsArray of dns for which a lock will be searched or dn of a single object
boolean$allow_readonlyTRUE if readonly access should be permitted, FALSE if not (default).
Returns
A numbered array containing all found locks as an array with key 'object' and key 'user', or FALSE if an error occured.

Definition at line 211 of file class_Lock.inc.

References get_ou().

Referenced by addOrFail(), and management\editEntry().


The documentation for this class was generated from the following file: