Code

Added alternative password reading
[gosa.git] / gosa-core / include / functions.inc
index 9ce2f2abf4b7c2179b6ceca7c015e4169fa65c9d..08626e248e47382e578ea438ae417740b2aceaf2 100644 (file)
@@ -22,9 +22,8 @@
 
 /* Configuration file location */
 define ("CONFIG_DIR", "/etc/gosa");
-define ("CONFIG_FILE", "gosa.conf-trunk");
+define ("CONFIG_FILE", "gosa.conf");
 define ("CONFIG_TEMPLATE_DIR", "../contrib/");
-define ("HELP_BASEDIR", "/var/www/doc/");
 
 /* Define get_list flags */
 define("GL_NONE",         0);
@@ -1094,6 +1093,10 @@ function convert_department_dn($dn)
 
   /* Build a sub-directory style list of the tree level
      specified in $dn */
+  global $config;
+  $dn = preg_replace("/".normalizePreg($config->current['BASE'])."$/i","",$dn);
+  if(empty($dn)) return("/");
+
   foreach (split(',', $dn) as $rdn){
 
     /* We're only interested in organizational units... */
@@ -1291,7 +1294,7 @@ function gen_locked_message($user, $dn)
   } else {
     $smarty->assign ("action", _("Edit anyway"));
   }
-  $smarty->assign ("message", sprintf(_("You're going to edit the LDAP entry/entries '%s'"), "<b>".$msg."</b>", ""));
+  $smarty->assign ("message", sprintf(_("You're going to edit the LDAP entry/entries %s"), "<b>".$msg."</b>", ""));
 
   return ($smarty->fetch (get_template_path('islocked.tpl')));
 }
@@ -2685,6 +2688,42 @@ function xmlentities($str)
 }
 
 
+/*! \brief  Updates all accessTo attributes from a given value to a new one.
+            For example if a host is renamed.
+    @param  String  $from The source accessTo name.
+    @param  String  $to   The destination accessTo name.
+*/
+function update_accessTo($from,$to)
+{
+  global $config;
+  $ldap = $config->get_ldap_link();
+  $ldap->cd($config->current['BASE']);
+  $ldap->search("(&(objectClass=trustAccount)(accessTo=".$from."))",array("objectClass","accessTo"));
+  while($attrs = $ldap->fetch()){
+    $new_attrs = array("accessTo" => array());
+    $dn = $attrs['dn'];
+    for($i = 0 ; $i < $attrs['objectClass']['count']; $i++){
+      $new_attrs['objectClass'][] =  $attrs['objectClass'][$i];
+    }
+    for($i = 0 ; $i < $attrs['accessTo']['count']; $i++){
+      if($attrs['accessTo'][$i] == $from){
+        if(!empty($to)){
+          $new_attrs['accessTo'][] =  $to;
+        }
+      }else{
+        $new_attrs['accessTo'][] =  $attrs['accessTo'][$i]; 
+      }
+    }
+    $ldap->cd($dn);
+    $ldap->modify($new_attrs);
+    if (!$ldap->success()){
+      msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $dn, LDAP_MOD, "update_accessTo($from,$to)"));
+    }
+    new log("modify","update_accessTo($from,$to)",$dn,array_keys($new_attrs),$ldap->get_error());
+  }
+}
+
+
 function get_random_char () {
      $randno = rand (0, 63);
      if ($randno < 12) {