summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: fb77ba7)
raw | patch | inline | side by side (parent: fb77ba7)
author | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Thu, 16 Mar 2006 10:23:32 +0000 (10:23 +0000) | ||
committer | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Thu, 16 Mar 2006 10:23:32 +0000 (10:23 +0000) |
Only for apllications right now.
To enable and 'Test' this feature, enable it your gosa.conf.
(enableCopyPaste="false")
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@2848 594d385d-05f5-0310-b6e9-bd551577e9d8
To enable and 'Test' this feature, enable it your gosa.conf.
(enableCopyPaste="false")
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@2848 594d385d-05f5-0310-b6e9-bd551577e9d8
contrib/gosa.conf | patch | blob | history | |
html/images/cant_editpaste.png | [new file with mode: 0644] | patch | blob |
ihtml/themes/default/copyPasteDialog.tpl | [new file with mode: 0644] | patch | blob |
include/class_CopyPasteHandler.inc | [new file with mode: 0644] | patch | blob |
include/class_plugin.inc | patch | blob | history | |
include/class_tabs.inc | patch | blob | history | |
plugins/admin/applications/class_applicationGeneric.inc | patch | blob | history | |
plugins/admin/applications/class_applicationManagement.inc | patch | blob | history |
diff --git a/contrib/gosa.conf b/contrib/gosa.conf
index 009a199b5b35b30eb72f1419dc3345cdd2d29be9..5ad665ee56c4affdc76245f7f36202c79a0a723d 100644 (file)
--- a/contrib/gosa.conf
+++ b/contrib/gosa.conf
</faipackagetabs>
<main default="{LOCATIONNAME}"
+ enableCopyPaste="false"
ppd_path="/var/spool/ppd/"
kde_applications_menu=""
compile="/var/spool/gosa"
diff --git a/html/images/cant_editpaste.png b/html/images/cant_editpaste.png
new file mode 100644 (file)
index 0000000..fdcc88d
Binary files /dev/null and b/html/images/cant_editpaste.png differ
index 0000000..fdcc88d
Binary files /dev/null and b/html/images/cant_editpaste.png differ
diff --git a/ihtml/themes/default/copyPasteDialog.tpl b/ihtml/themes/default/copyPasteDialog.tpl
--- /dev/null
@@ -0,0 +1,25 @@
+<h2>{t}Copy & paste wizzard{/t}</h2>
+
+{t}This dialog assists you with GOsas copy and paste functionality.{/t}<br>
+{t}Some objects require unique attributes, as example the often used cn should be unique within the complete ldap database in order to exclude a confounding.{/t}
+<br><br>
+{t}If a paste requires such unique attributes, the wizard will display them below.{/t}
+<br><br>
+<p class='seperator'> </p>
+<br>
+{if $Complete == false}
+ {$objectDN}
+ <br><br>
+ {$AttributesToFix}
+ <p class='seperator'> </p>
+ <br>
+ <div style='text-align:right;width:100%;'>
+ <input type='submit' name='PerformCopyPaste' value='{t}Save{/t}'>
+ <input type='submit' name='AbortCopyPaste' value='{t}Cancel{/t}'>
+ </div>
+{else}
+ <h2>{t}Operation complete{/t}</h2>
+ <div style='text-align:right;width:100%;'>
+ <input type='submit' name='Back' value='{t}Finish{/t}'>
+ </div>
+{/if}
diff --git a/include/class_CopyPasteHandler.inc b/include/class_CopyPasteHandler.inc
--- /dev/null
@@ -0,0 +1,198 @@
+<?php
+
+class CopyPasteHandler {
+
+ var $config;
+ var $current;
+
+ var $copyCurrent = false;
+ var $cutCurrent = false;
+ var $dialogOpen = false;
+ var $objectdn = false;
+
+ /* Create CP handler
+ */
+ function CopyPasteHandler($config){
+ $this->config = $config;
+ $this->current= NULL;
+ }
+
+
+ /* Returns wether the current object can be pasted
+ */
+ function isCurrentObjectPastAble(){
+
+ /* Check if we got a valid object
+ */
+ if($this->current == NULL){
+ return(false);
+ }
+ return(true);
+ }
+
+
+ /* Clears all copy & paste informations
+ */
+ function Clear()
+ {
+ $this->copyCurrent = false;
+ $this->cutCurrent = false;
+ $this->dialogOpen = false;
+ $this->current = NULL;
+ }
+
+
+ /* Add Object which should be copied
+ */
+ function Copy($obj,$emptyObj)
+ {
+ $this->copyCurrent = true;
+ $this->objectdn = $obj->dn;
+ $this->current = $emptyObj;
+ foreach($obj->by_object as $name => $obj){
+ foreach($obj->attributes as $attr){
+ $this->current->by_object[$name]->$attr = $obj->$attr;
+ }
+ }
+ if($this->isCurrentObjectPastAble()){
+ return(true);
+ }else{
+ $this->cutCurrent = $this->copyCurrent = false;
+ $this->obj = NULL;
+ }
+ return(false);
+ }
+
+
+ /* Add Object which should be cutted
+ */
+ function Cut($obj){
+ $this->cutCurrent = true;
+ $this->current = $obj;
+ if($this->isCurrentObjectPastAble()){
+ return(true);
+ }else{
+ $this->cutCurrent = $this->copyCurrent = false;
+ $this->obj = NULL;
+ }
+ return(false);
+ }
+
+
+ /* Returns true if current object
+ * is cutted. And awaits to be pasted anywhere
+ */
+ function isCurrentCutted(){
+ return($this->cutCurrent);
+ }
+
+
+ /* Returns true if current object
+ * was copied, and awaits to be pasted again
+ */
+ function isCurrentCopied(){
+ return($this->copyCurrent);
+ }
+
+
+ /* stillOpen
+ */
+ function stillOpen(){
+ if(isset($_POST['AbortCopyPaste'])){
+ $this->dialogOpen = false;
+ }
+
+ return($this->dialogOpen);
+ }
+
+
+ /* Displays a dialog which allows the user to fix all dependencies of this object.
+ Create unique names, ids, or what ever
+ */
+ function execute()
+ {
+ $this->dialogOpen = true;
+
+ /* Cut & paste
+ */
+ if($this->cutCurrent){
+ $this->current->save();
+ $this->dialogOpen =false;
+ $smarty = get_smarty();
+ $smarty->assign("Complete",true);
+ $this->Clear();
+ return($smarty->fetch(get_template_path("copyPasteDialog.tpl",FALSE)));
+
+ /* Copy & paste
+ */
+ }else{
+ if(isset($_POST['PerformCopyPaste'])){
+ $msgs = $this->check();
+ if(count ($msgs) ){
+ foreach( $msgs as $msg){
+ print_red($msg);
+ }
+ }else{
+ $this->current->save();
+ $this->dialogOpen =false;
+ $smarty = get_smarty();
+ $smarty->assign("Complete",true);
+ $this->Clear();
+ return($smarty->fetch(get_template_path("copyPasteDialog.tpl",FALSE)));
+ }
+ }
+ $smarty = get_smarty();
+ $smarty->assign("Complete",false);
+ $smarty->assign("AttributesToFix",$this->generateAttributesToFix());
+ $smarty->assign("objectDN" ,$this->objectdn);
+ return($smarty->fetch(get_template_path("copyPasteDialog.tpl",FALSE)));
+ }
+ }
+
+ /* Create dialog which asks unique attributes values ...
+ * calls tabs -> getCopyDialog()
+ * which calls tab -> getCopyDialog()
+ */
+ function generateAttributesToFix()
+ {
+ return($this->current->getCopyDialog());
+ }
+
+
+ /* Set a single attribute to specified value
+ * example : ("base", $newBase );
+ */
+ function SetVar($name,$value)
+ {
+ foreach($this-> current->by_object as $key => $obj){
+ if(isset($this->current->by_object[$key]->$name)){
+ $this->current->by_object[$key]->$name = $value;
+ }
+ }
+ }
+
+
+ /* Save new values posted by copy & paste dialog
+ */
+ function save_object()
+ {
+ /* Assign posted var to all tabs
+ */
+ $this->current->saveCopyDialog();
+ }
+
+
+ /* Returns possible errors returned from all including tabs ..
+ */
+ function check()
+ {
+ $ret = array();
+ foreach($this-> current->by_object as $obj){
+ $ret = array_merge($ret , $obj->check());
+ }
+ return($ret);
+ }
+
+}
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
index b34fc5ed0993957d3fbee336e4631902c9f1ede0..4f927edf0ff8ebd873a8bfe01c6f4d8cb834f8bb 100644 (file)
--- a/include/class_plugin.inc
+++ b/include/class_plugin.inc
}
}
-}
+ function saveCopyDialog(){
+ }
+ function getCopyDialog(){
+ return("");
+ }
+
+}
// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
?>
diff --git a/include/class_tabs.inc b/include/class_tabs.inc
index 2fc2fdf0f8d17967ee25f816fe791482b73d3437..9c0ebfd560b258cee81aa4adebb47a101a4b341f 100644 (file)
--- a/include/class_tabs.inc
+++ b/include/class_tabs.inc
}
}
+
+ /* Save attributes posted by copy & paste dialog
+ */
+ function saveCopyDialog()
+ {
+ foreach ($this->by_object as $key => $obj){
+ $this->by_object[$key]->saveCopyDialog();
+ }
+ }
+
+
+ /* return copy & paste dialog
+ */
+ function getCopyDialog()
+ {
+ $ret = "";
+ foreach ($this->by_object as $key => $obj){
+ $ret .= $this->by_object[$key]->getCopyDialog();
+ }
+ return($ret);
+ }
+
}
?>
diff --git a/plugins/admin/applications/class_applicationGeneric.inc b/plugins/admin/applications/class_applicationGeneric.inc
index cedecff9c023e458c0d690029e50ea1136e2d5ed..f85385ab9d1dc4a5395e27986aa6de63bee5a8ea 100644 (file)
function save_object()
{
if (isset($_POST['cn'])){
-
- plugin::save_object();
/* Save application flags */
$flag= "";
}
}
+ function getCopyDialog()
+ {
+ $vars = array("cn");
+
+ $str =" <table>
+ <tr>
+ <td>".
+ _("Application name").
+ "</td>
+ <td>
+ <input id='gosaApplicationName' name='cn' size='35' maxlength='60'
+ value='".$this->cn."'
+ title='"._("Application name to be displayed (i.e. below icons)")."'>
+ </td>
+ </tr>
+ </table>";
+
+ return($str);
+ }
+ function saveCopyDialog()
+ {
+ if(isset($_POST['cn'])){
+ $this->cn = $_POST['cn'];
+ }
+ }
}
-
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
?>
diff --git a/plugins/admin/applications/class_applicationManagement.inc b/plugins/admin/applications/class_applicationManagement.inc
index 874e803f249d69b6184a90d128d931969376d3eb..60a83685fa76f31fc1f9ef8c20d367785e7f8e43 100644 (file)
var $ui= NULL;
var $acl= "";
+ var $CopyPasteHandler ;
+
+ var $enableCopyPaste = false;
+
function applicationManagement ($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("appfilter")){
$base= get_base_from_people($ui->dn);
$s_action="edit";
$s_entry = preg_replace("/appl_".$s_action."_/i","",$key);
// Post for new
- }elseif(preg_match("/dep_back.*/i",$key)){
+ }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);
+ // Post for new
+ }elseif(preg_match("/^dep_back.*/i",$key)){
$s_action="back";
- }elseif(preg_match("/appl_new.*/",$key)){
+ }elseif(preg_match("/^appl_new.*/",$key)){
$s_action="new";
- }elseif(preg_match("/dep_home.*/i",$key)){
+ }elseif(preg_match("/^dep_home.*/i",$key)){
$s_action="home";
- }elseif(preg_match("/dep_root.*/i",$key)){
+ }elseif(preg_match("/^dep_root.*/i",$key)){
$s_action="root";
+ }elseif(preg_match("/^editPaste.*/i",$key)){
+ $s_action="editPaste";
}
}
}
+ /* 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",$appfilter['depselect']);
+ return($this->CopyPasteHandler->execute());
+ }
+
+
+ /* Copy current object to CopyHandler
+ */
+ if($s_action == "copy"){
+ $this->CopyPasteHandler->Clear();
+ $dn = $this->applications[$s_entry]['dn'];
+ $obj = new apptabs($this->config, $this->config->data['TABS']['APPSTABS'], $dn);
+ $objNew = new apptabs($this->config, $this->config->data['TABS']['APPSTABS'], "new");
+ $this->CopyPasteHandler->Copy($obj,$objNew);
+ }
+
+
+ /* Copy current object to CopyHandler
+ */
+ if($s_action == "cut"){
+ $this->CopyPasteHandler->Clear();
+ $dn = $this->applications[$s_entry]['dn'];
+ $obj = new apptabs($this->config, $this->config->data['TABS']['APPSTABS'], $dn);
+ $this->CopyPasteHandler->Cut($obj);
+ }
+ }
+
/* New application? */
if ($s_action=="new"){
$options.= "<option value='$key'>$value</option>";
}
}
+
+ if($this->enableCopyPaste){
+ $Copy_Paste = " <img class='center' src='images/list_seperator.png' align='middle' alt='' height='16' width='1'> ";
+ if($this->CopyPasteHandler->isCurrentObjectPastAble()){
+ $Copy_Paste .= "<input type='image' name='editPaste' class='center' src='images/editpaste.png' alt='"._("Paste")."'> ";
+ }else{
+ $Copy_Paste .= "<img class='center' src='images/cant_editpaste.png' alt='"._("Can't paste")."'> ";
+ }
+ }else{
+ $Copy_Paste ="";
+ }
// Managment
$listhead = "<div style='background:#F0F0F9;padding:5px;'>".
" <input class='center' type='image' align='middle' src='images/list_home.png' title='"._("Go to users department")."' alt='"._("Home")."' name='dep_home'> ".
" <img class='center' src='images/list_seperator.png' align='middle' alt='' height='16' width='1'> ".
" <input class='center' type='image' align='middle' src='images/list_new_app.png' alt='"._("new")."' title='"._("Create new application")."' name='appl_new'> ".
+ $Copy_Paste.
" <img class='center' src='images/list_seperator.png' align='middle' alt='' height='16' width='1'> ".
_("Base")." <select name='depselect' onChange='mainform.submit()' class='center'>$options</select>".
" <input class='center' type='image' src='images/list_submit.png' align='middle' title='"._("Submit department")."' name='submit_department' alt='"._("Submit")."'> ".
"</div>";
- $actions = "<input class='center' type='image' src='images/edit.png' alt='"._("edit")."' name='appl_edit_%KEY%' title='"._("Edit this entry")."'>";
- $actions.= "<input class='center' type='image' src='images/edittrash.png' alt='"._("delete")."' name='appl_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")."'> ";
+ $actions.= "<input class='center' type='image'
+ src='images/editcopy.png' alt='"._("copy")."' name='copy_%KEY%' title='"._("Copy this entry")."'> ";
+ $actions.= "<input class='center' type='image'
+ src='images/edit.png' alt='"._("edit")."' name='appl_edit_%KEY%' title='"._("Edit this entry")."'>";
+ $actions.= "<input class='center' type='image'
+ src='images/edittrash.png' alt='"._("delete")."' name='appl_del_%KEY%' title='"._("Delete this entry")."'>";
+ }else{
+
+ $actions = "<input class='center' type='image'
+ src='images/edit.png' alt='"._("edit")."' name='appl_edit_%KEY%' title='"._("Edit this entry")."'>";
+ $actions.= "<input class='center' type='image'
+ src='images/edittrash.png' alt='"._("delete")."' name='appl_del_%KEY%' title='"._("Delete this entry")."'>";
+ }
+
// Defining Links
$linkopen = "<a href='?plug=".$_GET['plug']."&act=dep_open&dep_id=%s'>%s</a>";
$divlist->SetHeader(array(
array("string" => " ", "attach" => "style='text-align:center;width:20px;'"),
array("string" => _("Application name")." / "._("Department"), "attach" => "style=''"),
- 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;'")
));
$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" => " ", "attach" => "style='width:60px;border-right:0px;text-align:right;'");
+ $field3 = array("string" => " ", "attach" => "style='width:80px;border-right:0px;text-align:right;'");
$divlist->AddEntry(array($field1,$field2,$field3));
}
}
$field1 = array("string" => sprintf($applimg,$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, $actions), "attach" => "style='width:60px;border-right:0px;text-align:right;'");
+ $field3 = array("string" => preg_replace("/%KEY%/", $key, $actions), "attach" => "style='width:80px;border-right:0px;text-align:right;'");
$divlist->AddEntry(array($field1,$field2,$field3));
}
function remove_lock()
{
- if (isset($this->apptabs->dn)){
- del_lock ($this->apptabs->dn);
- }
+ if (isset($this->apptabs->dn)){
+ del_lock ($this->apptabs->dn);
+ }
}
}