From: hickert Date: Wed, 17 Oct 2007 11:37:59 +0000 (+0000) Subject: Allow lock messages for multiple entries at once. X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=7c4b2a414b0cb8f1cfd04713969d7e9b8c78d2f0;p=gosa.git Allow lock messages for multiple entries at once. git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@7582 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/include/functions.inc b/include/functions.inc index 7b36499ab..54179252d 100644 --- a/include/functions.inc +++ b/include/functions.inc @@ -449,6 +449,13 @@ function add_lock ($object, $user) { global $config; + if(is_array($object)){ + foreach($object as $obj){ + add_lock($obj,$user); + } + return; + } + /* Just a sanity check... */ if ($object == "" || $user == ""){ print_red(_("Error while adding a lock. Parameters are not set correctly, please check the source!")); @@ -488,6 +495,13 @@ function del_lock ($object) { global $config; + if(is_array($object)){ + foreach($object as $obj){ + del_lock($obj); + } + return; + } + /* Sanity check */ if ($object == ""){ return; @@ -563,11 +577,43 @@ function get_lock ($object) $attrs = $ldap->fetch(); $user= $attrs['gosaUser'][0]; } - return ($user); } +function get_multiple_locks($objects) +{ + global $config; + + if(is_array($objects)){ + $filter = "(&(objectClass=gosaLockEntry)(|"; + foreach($objects as $obj){ + $filter.="(gosaObject=".base64_encode($obj).")"; + } + $filter.= "))"; + }else{ + $filter = "(&(objectClass=gosaLockEntry)(gosaObject=".base64_encode($objects)."))"; + } + + /* Get LDAP link, check for presence of the lock entry */ + $user= ""; + $ldap= $config->get_ldap_link(); + $ldap->cd ($config->current['CONFIG']); + $ldap->search($filter, array("gosaUser","gosaObject")); + if (!preg_match("/Success/i", $ldap->error)){ + print_red (_("Can't get locking information in LDAP database. Please check the 'config' entry in gosa.conf!")); + return(""); + } + + while($attrs = $ldap->fetch()){ + $dn = base64_decode($attrs['gosaObject'][0]); + $user = $attrs['gosaUser'][0]; + $users[] = array("dn"=> $dn,"user"=>$user); + } + return ($users); +} + + function get_list($filter, $category, $base= "", $attributes= array(), $flags= GL_SUBSEARCH) { global $config, $ui; @@ -1041,19 +1087,6 @@ function gen_locked_message($user, $dn) global $plug, $config; $_SESSION['dn']= $dn; - $ldap= $config->get_ldap_link(); - $ldap->cat ($user, array('uid', 'cn')); - $attrs= $ldap->fetch(); - - /* Stop if we have no user here... */ - if (count($attrs)){ - $uid= $attrs["uid"][0]; - $cn= $attrs["cn"][0]; - } else { - $uid= $attrs["uid"][0]; - $cn= $attrs["cn"][0]; - } - $remove= false; /* Save variables from LOCK_VARS_TO_USE in session - for further editing */ @@ -1079,13 +1112,24 @@ function gen_locked_message($user, $dn) /* Prepare and show template */ $smarty= get_smarty(); - $smarty->assign ("dn", $dn); + + if(is_array($dn)){ + $msg = "
";
+    foreach($dn as $sub_dn){
+      $msg .= "\n".$sub_dn.", ";
+    }
+    $msg = preg_replace("/, $/","
",$msg); + }else{ + $msg = $dn; + } + + $smarty->assign ("dn", $msg); if ($remove){ $smarty->assign ("action", _("Continue anyway")); } else { $smarty->assign ("action", _("Edit anyway")); } - $smarty->assign ("message", sprintf(_("You're going to edit the LDAP entry '%s' which appears to be used by '%s'. Please contact the person in order to clarify proceedings."), "".$dn."", "$cn")); + $smarty->assign ("message", sprintf(_("You're going to edit the LDAP entry/entries '%s'"), "".$msg."", "")); return ($smarty->fetch (get_template_path('islocked.tpl'))); }