Commit 5f1d344b authored by Côme Chilliet's avatar Côme Chilliet
Browse files

Fixes #5410 Fixed read only feature which was broken by #5154 fixes

parent 9cb049fb
......@@ -792,10 +792,13 @@ function get_lock($object)
*
* \param mixed $objects Array of dns for which a lock will be searched or dn of a single object
*
* \param boolean $allow_readonly TRUE if readonly access should be permitted,
* FALSE if not (default).
*
* \return A numbered array containing all found locks as an array with key 'object'
* and key 'user', or FALSE if an error occured.
*/
function get_locks($objects)
function get_locks($objects, $allow_readonly = FALSE)
{
global $config;
......@@ -803,12 +806,19 @@ function get_locks($objects)
$objects = reset($objects);
}
if (is_array($objects)) {
if ($allow_readonly) {
trigger_error('Read only is not possible for several objects');
}
$filter = '(&(objectClass=fdLockEntry)(|';
foreach ($objects as $obj) {
$filter .= '(fdObjectDn='.base64_encode($obj).')';
}
$filter .= '))';
} else {
if ($allow_readonly && isset($_POST['open_readonly'])) {
/* If readonly is allowed and asked and there is only one object, bypass lock detection */
return array();
}
$filter = '(&(objectClass=fdLockEntry)(fdObjectDn='.base64_encode($objects).'))';
}
......
......@@ -862,7 +862,7 @@ class simpleManagement
// Get the dn of the object and creates lock
$this->dn = array_pop($target);
set_object_info($this->dn);
if ($locks = get_locks($this->dn)) {
if ($locks = get_locks($this->dn, TRUE)) {
return gen_locked_message($locks, $this->dn, TRUE);
}
add_lock ($this->dn, $ui->dn);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment