Code

Added copy & paste for conferences
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 13 Jun 2007 12:46:11 +0000 (12:46 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 13 Jun 2007 12:46:11 +0000 (12:46 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@6577 594d385d-05f5-0310-b6e9-bd551577e9d8

plugins/gofon/conference/class_divListConferences.inc
plugins/gofon/conference/class_phoneConferenceGeneric.inc
plugins/gofon/conference/class_phoneConferenceManagment.inc

index 7819f676115cc17f9e43919bba74eb599258f67c..feafc1a3f8d7eb27a14adcc2c8a1dc615e75ddb3 100755 (executable)
@@ -42,7 +42,7 @@ class divListConference extends MultiSelectWindow
     $this->EnableSaveButton (false);
 
     /* Dynamic action col, depending on snapshot icons */
-    $action_col_size = 60;
+    $action_col_size = 100;
     if($this->parent->snapshotEnabled()){
       $action_col_size += 20;
     }
@@ -128,6 +128,20 @@ class divListConference extends MultiSelectWindow
     /* Add default header */
     $listhead = MultiSelectWindow::get_default_header();
 
+    /* Get copy & paste icon */
+    $Copy_Paste ="";
+    if(preg_match("/(c.*w|w.*c)/",$acls) &&  $this->parent->CopyPasteHandler){
+      $Copy_Paste = $this->parent->CopyPasteHandler->generatePasteIcon();
+      $addsep = true;
+    }
+
+
+    /* Only display snapshot settings if we are able to write && create new entries */
+    if(preg_match("/(c.*w|w.*c)/",$acl_all)){
+      $listhead .= $this->get_snapshot_header($this->selectedBase);
+    }
+    $listhead .= $Copy_Paste;
+
     /* Only display create new conference if we are allowed to create new confe... */
     if(preg_match("/c/",$acls)){
       $listhead .=" <img class='center' src='images/list_seperator.png' align='middle' alt='' height='16' width='1'>&nbsp;".
@@ -135,11 +149,6 @@ class divListConference extends MultiSelectWindow
         title='"._("Create new conference")."' alt='"._("New conference")."' name='conference_new'>&nbsp;".
         " <img class='center' src='images/list_seperator.png' align='middle' alt='' height='16' width='1'>&nbsp;";
     }
-
-    /* Only display snapshot settings if we are able to write && create new entries */
-    if(preg_match("/(c.*w|w.*c)/",$acl_all)){
-      $listhead .= $this->get_snapshot_header($this->selectedBase);
-    }
   
     /* Add the rest (base select ....)*/
     $listhead .= _("Base")."&nbsp;<select name='CurrentMainBase' onChange='mainform.submit()' class='center'>$options</select>".
@@ -150,6 +159,15 @@ class divListConference extends MultiSelectWindow
     $listhead .= "&nbsp;<input class='center' type='image' align='middle' src='images/edittrash.png'
       title='"._("Remove selected conferences")."' alt='"._("Remove conferences")."' name='remove_multiple_conferences'>&nbsp;";
 
+    /* Add multiple copy & cut icons */
+    if(is_object($this->parent->CopyPasteHandler)){
+      $listhead .= "&nbsp;<input class='center' type='image' align='middle' src='images/editcopy.png'
+        title='"._("Copy selected objects")."' alt='"._("Copy objects")."' name='multiple_copy_objects'>&nbsp;";
+      $listhead .= "&nbsp;<input class='center' type='image' align='middle' src='images/editcut.png'
+        title='"._("cut selected objects")."' alt='"._("Cut objects")."' name='multiple_cut_objects'>&nbsp;";
+      $listhead .= "</div>";
+    }
+
     $listhead .="</div>";
 
     $this->SetListHeader($listhead);
@@ -169,7 +187,7 @@ class divListConference extends MultiSelectWindow
     $editlink = "<a href='?plug=".$_GET['plug']."&amp;id=%s&amp;act=edit_entry'>%s</a>";
 
     /* Dynamic action col, depending on snapshot icons */
-    $action_col_size = 60;
+    $action_col_size = 100;
     if($this->parent->snapshotEnabled()){
       $action_col_size += 20;
     }
@@ -186,8 +204,16 @@ class divListConference extends MultiSelectWindow
         continue;
       }
 
+      $actions ="";
+      if(($this->parent->CopyPasteHandler) && preg_match("/(c.*w|w.*c)/",$acl_all)){
+        $actions.= "<input class='center' type='image'
+          src='images/editcut.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;";
+      }
+
       /* Add edit icon - This is allowed when we have at least read access. */
-      $actions= "<input class='center' type='image' src='images/edit.png'     
+      $actions.= "<input class='center' type='image' src='images/edit.png'     
                     alt='"._("edit")."'    name='conference_edit_%KEY%' title='"._("Edit this entry")."'>";
 
       /* Add snapshot icon - This is allowed when we have create and write access for the current entry */
index 4eba32b4658dd4a6a4ce26052c41dc9639c95040..1714edca398964a2f7f8c818bbabdb2d73026997 100644 (file)
@@ -387,6 +387,12 @@ class conference extends plugin
       $message[] = $str;
     }
 
+    $ldap = $this->config->get_ldap_link();
+    $ldap->cd("ou=conferences,ou=asterisk,ou=configs,ou=systems,".$this->base);
+    $ldap->search("(&(objectClass=goFonConference)(cn=".$this->cn."))",array("cn"));
+    if($ldap->count()){
+      $message[] =_("There is already a conference with this name in the current tree.");
+    }
     return $message;
   }
 
@@ -684,6 +690,31 @@ class conference extends plugin
     $this->postcreate();
   }
 
+
+  function getCopyDialog()
+  {
+    $smarty = get_smarty();
+    $smarty->assign("cn" ,$this->cn);
+    $smarty->assign("telephoneNumber" ,$this->telephoneNumber);
+    $str = $smarty->fetch(get_template_path("paste_generic.tpl",TRUE));
+    $ret = array();
+    $ret['string'] = $str;
+    $ret['status'] = "";
+    return($ret);
+  }
+
+
+  function saveCopyDialog()
+  {
+    if(isset($_POST['cn'])){
+      $this->cn = $_POST['cn'];
+    }
+    if(isset($_POST['telephoneNumber'])){
+      $this->telephoneNumber = $_POST['telephoneNumber'];
+    }
+  }
+
+
   /* Return plugin informations for acl handling */
   function plInfo()
   {
index 715e5fe4a0d2d0f54b0eb4d775c74f88a9fec343..c79968277e6e42e03531311c15ad037d963743f4 100644 (file)
@@ -39,6 +39,9 @@ class phoneConferenceManagment extends plugin
   var $ui                 = NULL;
   var $DivListConference  = NULL;
 
+  var $CopyPasteHandler = NULL;
+  var $start_pasting_copied_objects = FALSE;
+
   /* Initialise Class */
   function phoneConferenceManagment ($config, $ui)
   {
@@ -46,6 +49,11 @@ class phoneConferenceManagment extends plugin
     $this->dn                    = "";
     $this->config              = $config;
     $this->DivListConference = new divListConference($this->config,$this);
+
+    /* Copy & Paste enabled ?*/
+    if((isset($this->config->data['MAIN']['ENABLECOPYPASTE']))&&(preg_match("/true/i",$this->config->data['MAIN']['ENABLECOPYPASTE']))){
+      $this->CopyPasteHandler = new CopyPasteHandler($this->config);
+    }
   }
 
 
@@ -87,6 +95,20 @@ class phoneConferenceManagment extends plugin
         $s_entry  = preg_replace("/_.*$/","",$s_entry);
       }elseif(preg_match("/^remove_multiple_conferences/",$key)){
         $s_action="del_multiple";
+      }elseif(preg_match("/^editPaste.*/i",$key)){
+        $s_action="editPaste";
+      }elseif(preg_match("/^copy_.*/",$key)){
+        $s_action="copy";
+        $s_entry  = preg_replace("/^copy_/i","",$key);
+        $s_entry  = preg_replace("/_.$/","",$s_entry);
+      }elseif(preg_match("/^cut_.*/",$key)){
+        $s_action="cut";
+        $s_entry  = preg_replace("/^cut_/i","",$key);
+        $s_entry  = preg_replace("/_.$/","",$s_entry);
+      }elseif(preg_match("/^multiple_copy_objects/",$key)){
+        $s_action = "copy_multiple";
+      }elseif(preg_match("/^multiple_cut_objects/",$key)){
+        $s_action = "cut_multiple";
       } 
     }
 
@@ -114,6 +136,16 @@ class phoneConferenceManagment extends plugin
     }
 
 
+    /********************
+      Copy & Paste Handling  ...
+     ********************/
+
+    /* Display the copy & paste dialog, if it is currently open */
+    $ret = $this->copyPasteHandling_from_queue($s_action,$s_entry);
+    if($ret){
+      return($ret);
+    }
+
 
     /********************
       Delete MULTIPLE entries requested, display confirm dialog
@@ -407,6 +439,70 @@ class phoneConferenceManagment extends plugin
 
   }
 
+
+  function copyPasteHandling_from_queue($s_action,$s_entry)
+  {
+    /* Check if Copy & Paste is disabled */
+    if(!is_object($this->CopyPasteHandler)){
+      return("");
+    }
+
+    /* Add a single entry to queue */
+    if($s_action == "cut" || $s_action == "copy"){
+
+      /* Cleanup object queue */
+      $this->CopyPasteHandler->cleanup_queue();
+      $dn = $this->conferences[$s_entry]['dn'];
+      $this->CopyPasteHandler->add_to_queue($dn,$s_action,"conferencetabs","CONFERENCETABS","gofonconference");
+    }
+
+    /* Add entries to queue */
+    if($s_action == "copy_multiple" || $s_action == "cut_multiple"){
+
+      /* Cleanup object queue */
+      $this->CopyPasteHandler->cleanup_queue();
+
+      /* Add new entries to CP queue */
+      foreach($this->list_get_selected_items() as $id){
+        $dn = $this->conferences[$id]['dn'];
+
+        if($s_action == "copy_multiple"){
+          $this->CopyPasteHandler->add_to_queue($dn,"copy","conferencetabs","CONFERENCETABS","gofonconference");
+        }
+        if($s_action == "cut_multiple"){
+          $this->CopyPasteHandler->add_to_queue($dn,"cut","conferencetabs","CONFERENCETABS","gofonconference");
+        }
+      }
+    }
+
+    /* Start pasting entries */
+    if($s_action == "editPaste"){
+      $this->start_pasting_copied_objects = TRUE;
+    }
+    /* Return C&P dialog */
+    if($this->start_pasting_copied_objects && $this->CopyPasteHandler->entries_queued()){
+
+      /* Load entry from queue and set base */
+      $this->CopyPasteHandler->load_entry_from_queue();
+      $this->CopyPasteHandler->SetVar("base",$this->DivListConference->selectedBase);
+
+      /* Get dialog */
+      $data = $this->CopyPasteHandler->execute();
+
+      /* Return dialog data */
+      if(!empty($data)){
+        return($data);
+      }
+    }
+
+    /* Automatically disable status for pasting */
+    if(!$this->CopyPasteHandler->entries_queued()){
+      $this->start_pasting_copied_objects = FALSE;
+    }
+    return("");
+  }
+
+
   function save_object()
   {
     $this->DivListConference->save_object();