Code

Added copy & paste for groups
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 17 Mar 2006 07:19:37 +0000 (07:19 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 17 Mar 2006 07:19:37 +0000 (07:19 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@2855 594d385d-05f5-0310-b6e9-bd551577e9d8

plugins/admin/applications/class_applicationManagement.inc
plugins/admin/groups/class_groupGeneric.inc
plugins/admin/groups/class_groupMail.inc
plugins/admin/groups/class_groupManagement.inc

index ef27ae0538b5059a7ad6a9e622e531e29f1f625a..9ccd6cba0099a74a87bcd825fb4f33295ff8c83f 100644 (file)
@@ -41,15 +41,12 @@ class applicationManagement extends plugin
        $this->config= $config;
        $this->ui= $ui;
 
-
   if( (isset($this->config->data['MAIN']['ENABLECOPYPASTE'])) 
      && 
       (preg_match("/true/i",$this->config->data['MAIN']['ENABLECOPYPASTE'] ))){
     $this->enableCopyPaste = true;
   }
 
-
-
   $this->CopyPasteHandler = new CopyPasteHandler($this->config);
 
        /* Get global filter config */
index 9d2145c63a80d66ed9b2ea0619631cfbe558a2bb..d009a6f1e49e965a11491ddb5c3b0821c9013e6b 100644 (file)
@@ -809,6 +809,59 @@ class group extends plugin
     }
   }
 
+  function getCopyDialog()
+  {
+    $vars = array("cn");
+  
+    if($this ->force_gid){
+      $used = " checked ";
+      $dis  = "";
+    }else{
+      $used = "";
+      $dis  = " disabled ";
+    }
+
+    $str =" <table>
+              <tr>
+                <td>".
+                  _("Group name").
+                "</td>
+                <td>
+                   <input id='cn' name='cn' size='35' maxlength='60'
+                    value='".$this->cn."'
+                    title='"._("Posix name of the group")."'>
+                </td>
+              </tr>
+              <tr>
+                <td colspan=2>
+                  <input type=checkbox name='force_gid' value='1' ".$used."   
+                      title='"._("Normally IDs are autogenerated, select to specify manually")."' 
+                        onclick='changeState(\"gidNumber\")'
+                  <LABEL for='gidNumber'>"._("Force GID")."</LABEL>
+                &nbsp;
+                <input name='gidNumber' size=5 maxlength=5 id='gidNumber' ".$dis."  
+                    value='".$this->gidNumber."' title='"._("Forced ID number")."'>
+               </td>
+              </tr>
+
+          </table>";
+
+    return($str);
+  }
+
+  function saveCopyDialog()
+  {
+    if(isset($_POST['cn'])){
+      $this->cn = $_POST['cn'];
+    }
+    if(isset($_POST['force_gid'])){
+      $this->force_gid  = true;
+      $this->gidNumber= $_POST['gidNumber'];
+    }else{
+      $this->force_gid  = false;
+      $this->gidNumber  = false;
+    }
+  }
 }
 
 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
index a3a3cc957122d4bdb203189d83a3c3fd660c6cdc..64bf1be725f9d49135174cb0d1053a0a720f93e1 100644 (file)
@@ -942,6 +942,35 @@ I: Only insider delivery */
     return ($name);
   }
 
+  function getCopyDialog()
+  {
+    if(!$this->is_account) return("");
+
+    $str =" <table>
+              <tr>
+                <td>".
+                  _("Primary mail address").
+                "</td>
+                <td>
+                   <input id='mail' name='mail' size='16' maxlength='160'
+                    value='".$this->mail."'
+                    title='"._("Primary mail address for this shared folder")."'>
+                </td>
+              </tr>
+            </table>";
+
+    return($str);
+  }
+
+  function saveCopyDialog()
+  {
+    if(!$this->is_account) return;
+    if(isset($_POST['mail'])){
+      $this->mail = $_POST['mail'];
+    }
+  }
+
+
 }
 
 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
index 6bf78f1545b001fa94d68605f8923a3467ff036a..0636d6c4460fff0caad0c82bb1b6409caae6506c 100644 (file)
@@ -32,12 +32,20 @@ class groupManagement extends plugin
   var $ui= NULL;
   var $acl= "";
 
+  var $CopyPasteHandler ;
+  var $enableCopyPaste = false;
+
   function groupManagement ($config, $ui)
   {
     /* Save configuration for internal use */
     $this->config= $config;
     $this->ui= $ui;
 
+    if((isset($this->config->data['MAIN']['ENABLECOPYPASTE']))&&(preg_match("/true/i",$this->config->data['MAIN']['ENABLECOPYPASTE']))){
+      $this->enableCopyPaste = true;
+    }
+    $this->CopyPasteHandler = new CopyPasteHandler($this->config);
+
     /* Get global filter config */
     if (!is_global("groupfilter")){
       $base= get_base_from_people($ui->dn);
@@ -66,7 +74,6 @@ class groupManagement extends plugin
     $s_action   = "";
     $s_entry    = "";
 
-
     if (!isset($this->grouptab)){
       foreach( array("depselect", "guser", "regex") as $type){
         if (isset($_POST[$type])){
@@ -124,6 +131,14 @@ class groupManagement extends plugin
         $s_action="edit";
         $s_entry  = preg_replace("/".$type."_group_edit_/i","",$key); 
         $_POST['arg'] = $type;
+      }elseif(preg_match("/^editPaste.*/i",$key)){
+        $s_action="editPaste";
+      }elseif(preg_match("/^copy_.*/",$key)){
+        $s_action="copy";
+        $s_entry  = preg_replace("/^copy_/i","",$key);
+      }elseif(preg_match("/^cut_.*/",$key)){
+        $s_action="cut";
+        $s_entry  = preg_replace("/^cut_/i","",$key);
       }
     }
     $s_entry  = preg_replace("/_.$/","",$s_entry); 
@@ -179,6 +194,51 @@ class groupManagement extends plugin
       return($message);
     }
 
+    /* Only perform copy / paste if it is enabled
+     */
+    if($this->enableCopyPaste){
+
+      /* Paste copied/cutted object in here
+       */
+      if(($s_action == "editPaste") || ($this->CopyPasteHandler->stillOpen())){
+        $this->CopyPasteHandler->save_object();
+        $this->CopyPasteHandler->SetVar("base",$groupfilter['depselect']);
+        return($this->CopyPasteHandler->execute());
+      }
+
+
+      /* Copy current object to CopyHandler
+       */
+      if($s_action == "copy"){
+        $this->CopyPasteHandler->Clear();
+        
+        $dn     = $this->grouplist[trim($s_entry)]['dn'];
+        $acl    = get_permissions ($dn, $this->ui->subtreeACL);
+
+        $obj    = new grouptabs($this->config,$this->config->data['TABS']['GROUPTABS'], $dn);
+        $objNew = new grouptabs($this->config,$this->config->data['TABS']['GROUPTABS'], "new");
+        $obj->set_acl($acl);
+        $objNew->set_acl($acl);
+        
+        $this->CopyPasteHandler->Copy($obj,$objNew);
+      }
+
+
+      /* Copy current object to CopyHandler
+       */
+      if($s_action == "cut"){
+        $this->CopyPasteHandler->Clear();
+        $dn = $this->grouplist[trim($s_entry)]['dn'];
+        $acl= get_permissions ($dn, $this->ui->subtreeACL);
+
+        $obj= new grouptabs($this->config,$this->config->data['TABS']['GROUPTABS'], $dn);
+        $obj->set_acl($acl);
+
+        $this->CopyPasteHandler->Cut($obj);
+      }
+    }
+
+
     /* New group? */
     if ($s_action=="new"){
 
@@ -358,6 +418,25 @@ class groupManagement extends plugin
             }
     }
 
+    /* Create paste icon 
+     */
+    if($this->enableCopyPaste){
+      $Copy_Paste = " <img class='center' src='images/list_seperator.png' align='middle' alt='' height='16' width='1'>&nbsp;";
+      if($this->CopyPasteHandler->isCurrentObjectPastAble()){
+        if($this->CopyPasteHandler->isCurrentCutted()){
+          $img = "images/cutpaste.png";
+        }else{
+          $img = "images/copypaste.png";
+        }
+        $Copy_Paste .= "<input type='image' name='editPaste' class='center'
+          src='".$img."' alt='"._("Paste")."' title='".$this->CopyPasteHandler->GetCurrentDn()."'>&nbsp;";
+      }else{
+        $Copy_Paste .= "<img class='center' src='images/cant_editpaste.png' alt='"._("Can't paste")."'>&nbsp;";
+      }
+    }else{
+      $Copy_Paste ="";
+    }
+
     // Managment
     $listhead = "<div style='background:#F0F0F9;padding:5px;'>".
       " <input type='image' class='center' src='images/list_back.png' title='"._("Go up one department")."' alt='"._("Up")."' name='dep_back'>&nbsp;".
@@ -365,14 +444,29 @@ class groupManagement extends plugin
       " <input type='image' class='center' src='images/list_home.png' title='"._("Go to users department")."' alt='"._("Home")."' name='dep_home'>&nbsp;".
       " <img class='center' src='images/list_seperator.png' alt='' height='16' width='1'>&nbsp;".
       " <input type='image' class='center' src='images/list_new_group.png' title='"._("Create new group")."' alt='"._("New")."' name='group_new'>&nbsp;".
+      $Copy_Paste.
       " <img class='center' src='images/list_seperator.png' alt='' height='16' width='1'>&nbsp;".
       _("Base")."&nbsp;<select name='depselect' onChange='mainform.submit()' class='center'>$options</select>".
        " <input type='image' class='center' src='images/list_submit.png' title='"._("Submit department")."' name='submit_department' alt='"._("Submit")."'>&nbsp;".
       "</div>";
 
     
-    $actions = "<input class='center' type='image' src='images/edit.png' alt='"._("edit")."' name='group_edit_%KEY%' title='"._("Edit this entry")."'>";
-    $actions.= "<input class='center' type='image' src='images/edittrash.png' alt='"._("delete")."' name='group_del_%KEY%' title='"._("Delete this entry")."'>";
+    if($this->enableCopyPaste){
+      $actions = "<input class='center' type='image'
+        src='images/editdelete.png' alt='"._("cut")."' name='cut_%KEY%' title='"._("Cut this entry")."'>&nbsp;";
+      $actions.= "<input class='center' type='image'
+        src='images/editcopy.png' alt='"._("copy")."' name='copy_%KEY%' title='"._("Copy this entry")."'>&nbsp;";
+      $actions.= "<input class='center' type='image' 
+        src='images/edit.png' alt='"._("edit")."' name='group_edit_%KEY%' title='"._("Edit this entry")."'>";
+      $actions.= "<input class='center' type='image' 
+        src='images/edittrash.png' alt='"._("delete")."' name='group_del_%KEY%' title='"._("Delete this entry")."'>";
+    }else{
+      $actions = "<input class='center' type='image' 
+        src='images/edit.png' alt='"._("edit")."' name='group_edit_%KEY%' title='"._("Edit this entry")."'>";
+      $actions.= "<input class='center' type='image' 
+        src='images/edittrash.png' alt='"._("delete")."' name='group_del_%KEY%' title='"._("Delete this entry")."'>";
+    }
+
 
     // Defining Links
     $linkopen = "<a href='?plug=".$_GET['plug']."&amp;act=dep_open&amp;dep_id=%s'>%s</a>";
@@ -419,7 +513,7 @@ class groupManagement extends plugin
           array("string" => "&nbsp;", "attach" => "style='text-align:center;width:20px;'"),
           array("string" => _("Groupname")." / "._("Department"), "attach" => "style=''"),
           array("string" => _("Properties"), "attach" => "style='width:136px;'"),
-          array("string" => _("Actions"), "attach" => "style='width:60px;border-right:0px;text-align:right;'")
+          array("string" => _("Actions"), "attach" => "style='width:80px;border-right:0px;text-align:right;'")
           ));
 
     $divlist->SetSummary(_("This table displays all groups, in the selected tree."));
@@ -443,7 +537,7 @@ class groupManagement extends plugin
       $field1 = array("string" => "<img src='images/".$non_empty."folder.png' alt='department'>", "attach" => "style='text-align:center;width:20px;'");
       $field2 = array("string" => sprintf($linkopen,base64_encode($key),$val), "attach" => "style=''");
       $field3 = array("string" => "&nbsp;", "attach" => "style='width:136px;'");
-      $field4 = array("string" => "&nbsp;", "attach" => "style='width:60px;border-right:0px;text-align:right;'");
+      $field4 = array("string" => "&nbsp;", "attach" => "style='width:80px;border-right:0px;text-align:right;'");
 
       $divlist->AddEntry(array($field1,$field2,$field3,$field4));
     }
@@ -471,7 +565,7 @@ class groupManagement extends plugin
       $field1 = array("string" => sprintf($userimg,$val['dn']), "attach" => "style='text-align:center;width:20px;'");
       $field2 = array("string" => sprintf($editlink,$key,($val['cn']['0'].$desc)), "attach" => "style='' ".$title);
       $field3 = array("string" => preg_replace("/%KEY%/", $key, $posix."&nbsp;".$enviro."&nbsp;".$mail."&nbsp;".$samba."&nbsp;".$appl."&nbsp;".$phone), "attach" => "style='width:136px;'");  
-      $field4 = array("string" => preg_replace("/%KEY%/", $key, $actions), "attach" => "style='width:60px;border-right:0px;text-align:right;'");
+      $field4 = array("string" => preg_replace("/%KEY%/", $key, $actions), "attach" => "style='width:80px;border-right:0px;text-align:right;'");
       
       $divlist->AddEntry(array($field1,$field2,$field3,$field4));    
     }