Code

Don not't reset server settings, if gosa.conf was modified
[gosa.git] / gosa-core / include / class_plugin.inc
index 7d3a6dd4e8d0de40cc6ee65193835bc383619c5d..1c57be2cc96bd77e92e8edd950d568e6db171e58 100644 (file)
@@ -150,8 +150,14 @@ class plugin
       return;
     }
 
+    /* Check if this entry was opened in read only mode */
     if(isset($_POST['open_readonly'])){
-      $this->read_only = TRUE;
+      if(session::global_is_set("LOCK_CACHE")){
+        $cache = &session::get("LOCK_CACHE");
+        if(isset($cache['READ_ONLY'][$this->dn])){
+          $this->read_only = TRUE;
+        }
+      }
     }
 
     /* Save current dn as acl_base */
@@ -253,7 +259,7 @@ class plugin
   function execute()
   {
     /* This one is empty currently. Fabian - please fill in the docu code */
-    session::set('current_class_for_help',get_class($this));
+    session::global_set('current_class_for_help',get_class($this));
 
     /* Reset Lock message POST/GET check array, to prevent perg_match errors*/
     session::set('LOCK_VARS_TO_USE',array());
@@ -919,7 +925,10 @@ class plugin
     $ldap->cd($this->config->current['BASE']);
     $ldap->create_missing_trees(preg_replace("/^[^,]+,/","",$dst_dn));
     if (!$ldap->rename_dn($src_dn,$dst_dn)){
-      msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $src_dn, "", get_class()));
+#      msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $src_dn, "", get_class()));
+      new log("debug","Ldap Protocol v3 implementation error, ldap_rename failed, falling back to manual copy.","FROM: $src_dn  -- TO: $dst_dn",array(),$ldap->get_error());
+      @DEBUG(DEBUG_LDAP,__LINE__,__FUNCTION__,__FILE__,"Rename failed FROM: $src_dn  -- TO:  $dst_dn", 
+          "Ldap Protocol v3 implementation error, falling back to maunal method.");
       return(FALSE);
     }
 
@@ -984,7 +993,7 @@ class plugin
     if(count($leaf_deps)){
       $this->config->get_departments();
       $this->config->make_idepartments();
-      session::set("config",$this->config);
+      session::global_set("config",$this->config);
       $ui =get_userinfo();
       $ui->reset_acl_cache();
     }
@@ -1297,7 +1306,10 @@ class plugin
     $this->dn = $dn;
     $ldap = $this->config->get_ldap_link();
     $ldap->cd($this->config->current['BASE']);
-    $ldap->rmdir_recursive($dn);
+    $ldap->rmdir_recursive($this->dn);
+    if(!$ldap->success()){
+      msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn));
+    }
     $this->dn = $old_dn;
   }
 
@@ -1507,10 +1519,11 @@ class plugin
     $this->parent = $parent;
 
     foreach($_POST as $name => $value){
-                       $entry = base64_decode(preg_replace("/_[xy]$/","",$name));
 
       /* Create a new snapshot, display a dialog */
-      if(preg_match("/^CreateSnapShotDialog_/",$name) && $once){
+      if(preg_match("/^CreateSnapShotDialog_[^_]*_[xy]$/",$name) && $once){
+
+                         $entry = base64_decode(preg_replace("/^CreateSnapShotDialog_([^_]*)_[xy]$/","\\1",$name));
         $once = false;
         $entry = preg_replace("/^CreateSnapShotDialog_/","",$entry);
 
@@ -1524,8 +1537,8 @@ class plugin
       /* Restore a snapshot, display a dialog with all snapshots of the current object */
       if(preg_match("/^RestoreSnapShotDialog_/",$name) && $once){
         $once = false;
-        $entry = preg_replace("/^RestoreSnapShotDialog_/","",$entry);
-        if(!empty($entry) && $ui->allow_snapshot_restore($entry,$this->parent->acl_module)){
+        $entry = base64_decode(preg_replace("/^RestoreSnapShotDialog_([^_]*)_[xy]$/i","\\1",$name));
+        if(!empty($entry) && $ui->allow_snapshot_restore($this->dn,$this->parent->acl_module)){
           $this->snapDialog = new SnapShotDialog($this->config,$entry,$this);
           $this->snapDialog->display_restore_dialog = true;
         }else{
@@ -1538,7 +1551,7 @@ class plugin
           || preg_match("/^RestoreDeletedSnapShot_/",$name)) && $once){
         $once = false;
 
-        if($ui->allow_snapshot_restore($base,$this->parent->acl_module)){
+        if($ui->allow_snapshot_restore($this->dn,$this->parent->acl_module)){
           $this->snapDialog = new SnapShotDialog($this->config,"",$this);
           $this->snapDialog->set_snapshot_bases($baseSuffixe);
           $this->snapDialog->display_restore_dialog      = true;
@@ -1551,8 +1564,9 @@ class plugin
       /* Restore selected snapshot */
       if(preg_match("/^RestoreSnapShot_/",$name) && $once){
         $once = false;
-        $entry = preg_replace("/^RestoreSnapShot_/","",$entry);
-        if(!empty($entry) && $ui->allow_snapshot_restore($entry,$this->parent->acl_module)){
+        $entry = base64_decode(preg_replace("/^RestoreSnapShot_([^_]*)_[xy]$/i","\\1",$name));
+
+        if(!empty($entry) && $ui->allow_snapshot_restore($this->dn,$this->parent->acl_module)){
           $this->restore_snapshot($entry);
           $this->snapDialog = NULL;
         }else{
@@ -1716,10 +1730,10 @@ class plugin
     }
 
     /* Update userinfo if necessary */
-    $ui = session::get('ui');
+    $ui = session::global_get('ui');
     if($ui->dn == $old_dn){
       $ui->dn = $new_dn;
-      session::set('ui',$ui);
+      session::global_set('ui',$ui);
       new log("view","acl/".get_class($this),$this->dn,array(),"Updated current object dn from '".$old_dn."' to '".$new_dn."'");
     }
 
@@ -1864,7 +1878,7 @@ class plugin
   function multiple_execute()
   {
     /* This one is empty currently. Fabian - please fill in the docu code */
-    session::set('current_class_for_help',get_class($this));
+    session::global_set('current_class_for_help',get_class($this));
 
     /* Reset Lock message POST/GET check array, to prevent perg_match errors*/
     session::set('LOCK_VARS_TO_USE',array());