Code

Enabled single cut and paste
[gosa.git] / plugins / admin / ogroups / class_ogroup.inc
index 6093ef128bfd083668dbfe237288d5758f8329d9..1a5db9bca3162789803ffcf7918338b605357f0f 100644 (file)
@@ -30,6 +30,7 @@ class ogroup extends plugin
   var $member= array();
   var $orig_dn= "";
   var $group_dialog= FALSE;
+  var $view_logged = FALSE;
 
   /* attribute list for save action */
   var $attributes= array("cn", "description", "gosaGroupObjects","member");
@@ -46,6 +47,7 @@ class ogroup extends plugin
     if (isset($this->attrs['member'])){
       foreach ($this->attrs['member'] as $key => $value){
         if ("$key" != "count"){
+          $value= @LDAP::convert($value);
           $this->member["$value"]= "$value";
         }
       }
@@ -100,12 +102,15 @@ class ogroup extends plugin
   function AddDelMembership($NewMember = false){
 
     if($NewMember){
-      $this->memberList[$NewMember]= $this->objcache[$NewMember];
+
+      /* Add member and force reload */
       $this->member[$NewMember]= $NewMember;
+      $this->reload(); 
+
+      $this->memberList[$NewMember]= $this->objcache[$NewMember];
       unset ($this->objects[$NewMember]);
       uasort ($this->memberList, 'sort_list');
       reset ($this->memberList);
-      $this->reload();
     }else{
       /* Delete objects from group */
       if (isset($_POST['delete_membership']) && isset($_POST['members'])){
@@ -135,10 +140,14 @@ class ogroup extends plugin
 
   function execute()
   {
-       /* Call parent execute */
-       plugin::execute();
+    /* Call parent execute */
+    plugin::execute();
+
+    if(!$this->view_logged){
+      $this->view_logged = TRUE;
+      new log("view","ogroups/".get_class($this),$this->dn);
+    }
 
-//    $this->reload();
 
     /* Do we represent a valid group? */
     if (!$this->is_account){
@@ -183,13 +192,6 @@ class ogroup extends plugin
       $smarty->assign($name."ACL",$this->getacl($name));
     }
 
-    /* Create base acls */
-    $baseACL = $this->getacl("base",(!is_object($this->parent) && !isset($_SESSION['edit'])));
-    if(!$this->acl_is_moveable()) {
-      $baseACL = preg_replace("/w/","",$baseACL);
-    }
-    $smarty->assign("baseACL",          $baseACL);
-
     /* Base select dialog */
     $once = true;
     foreach($_POST as $name => $value){
@@ -208,7 +210,12 @@ class ogroup extends plugin
       if($this->dialog->isClosed()){
         $this->dialog = false;
       }elseif($this->dialog->isSelected()){
-        $this->base = $this->dialog->isSelected();
+
+        /* A new base was selected, check if it is a valid one */
+        $tmp = $this->get_allowed_bases();
+        if(isset($tmp[$this->dialog->isSelected()])){
+          $this->base = $this->dialog->isSelected();
+        }
         $this->dialog= false;
       }else{
         return($this->dialog->execute());
@@ -336,8 +343,21 @@ class ogroup extends plugin
   {
     /* Save additional values for possible next step */
     if (isset($_POST['ogroupedit'])){
+
+      /* Create a base backup and reset the
+         base directly after calling plugin::save_object();
+         Base will be set seperatly a few lines below */
+      $base_tmp = $this->base;
       plugin::save_object();
-  
+      $this->base = $base_tmp;
+
+      /* Save base, since this is no LDAP attribute */
+      $tmp = $this->get_allowed_bases();
+      if(isset($_POST['base'])){
+        if(isset($tmp[$_POST['base']])){
+          $this->base= $_POST['base'];
+        }
+      }
     }
   }
 
@@ -501,7 +521,7 @@ class ogroup extends plugin
 
     foreach ($input as $key => $value){
       /* Generate output */
-      $temp.= "<option value=\"$key\" class=\"select\" style=\"background-image:url('".get_template_path("images/".$conv[$value['type']])."');\">".$value['text']."</option>\n";
+      $temp.= "<option title='".addslashes( $key)."' value=\"$key\" class=\"select\" style=\"background-image:url('".get_template_path("images/".$conv[$value['type']])."');\">".$value['text']."</option>\n";
     }
 
     return ($temp);
@@ -580,12 +600,8 @@ class ogroup extends plugin
       $this->set_acl_base($this->base);
     }
 
-    if ($this->orig_dn == "new" && !$this->acl_is_createable()){
-      $message[]= _("You have no permissions to create a group on this 'Base'.");
-    }
-
     /* must: cn */
-    if ($this->cn == "" && $this->acl_is_writeable("cn")){
+    if ($this->cn == ""){
       $message[]= "The required field 'Name' is not set.";
     }
 
@@ -625,6 +641,7 @@ class ogroup extends plugin
         $this->attrs['member']= array();
       }
       $mode= "modify";
+
     } else {
       $mode= "add";
       $ldap->cd($this->config->current['BASE']);
@@ -636,6 +653,12 @@ class ogroup extends plugin
     $this->cleanup();
     $ldap->$mode($this->attrs);
 
+    if($mode == "add"){
+      new log("create","ogroups/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
+    }else{
+      new log("modify","ogroups/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
+    }
+
     /* Trigger post signal */
     $this->handle_post_events($mode);
 
@@ -655,10 +678,42 @@ class ogroup extends plugin
     $ldap->rmdir($this->dn);
     show_ldap_error($ldap->get_error(), sprintf(_("Removing of object group/generic with dn '%s' failed."),$this->dn));
 
+    new log("remove","ogroups/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
+
     /* Trigger remove signal */
     $this->handle_post_events("remove");
   }
 
+  
+  function PrepareForCopyPaste($source)
+  {
+    /* Update available object types */
+    if(isset($source['gosaGroupObjects'][0])){
+      $this->gosaGroupObjects =  $source['gosaGroupObjects'][0];
+    }
+
+    /* Reload tabs */
+    $this->parent->reload($this->gosaGroupObjects );
+   
+    /* Reload plugins */ 
+    foreach($this->parent->by_object as $name => $class ){
+      if(get_class($this) != $name) {
+        $this->parent->by_object[$name]->PrepareForCopyPaste($source);
+      }
+    }
+
+    /* Load member objects */
+    if (isset($source['member'])){
+      foreach ($source['member'] as $key => $value){
+        if ("$key" != "count"){
+          $value= @LDAP::convert($value);
+          $this->member["$value"]= "$value";
+        }
+      }
+    }
+
+  }
+
 
   function getCopyDialog()
   {