summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: cb9af9b)
raw | patch | inline | side by side (parent: cb9af9b)
author | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Tue, 8 Apr 2008 10:49:55 +0000 (10:49 +0000) | ||
committer | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Tue, 8 Apr 2008 10:49:55 +0000 (10:49 +0000) |
-Added copy & paste.
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@10279 594d385d-05f5-0310-b6e9-bd551577e9d8
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@10279 594d385d-05f5-0310-b6e9-bd551577e9d8
diff --git a/gosa-plugins/sudo/admin/sudo/class_divListSudo.inc b/gosa-plugins/sudo/admin/sudo/class_divListSudo.inc
index de03718668d44ad923186b0dbfee5554e2933ef8..404a5a0e26313d5764b6068edaa43ab971464521 100644 (file)
$this->EnableSaveButton (false);
/* Dynamic action col, depending on snapshot icons */
- $action_col_size = 50;
+ $action_col_size = 54;
if($this->parent->snapshotEnabled()){
- $action_col_size += 38;
+ $action_col_size += 32;
+ }
+ if($this->parent->CopyPasteHandler){
+ $action_col_size += 20;
}
/* Toggle all selected / deselected */
" "._("Remove")."|"."del_role|\n";
}
+ /* Add multiple copy & cut icons */
+ if(is_object($this->parent->CopyPasteHandler) && preg_match("/(c.*w|w.*c)/",$acl)){
+ $s.= "..|---|\n";
+ $s.= "..|<img src='images/editcopy.png' alt='' border='0' class='center'>".
+ " "._("Copy")."|"."multiple_copy_systems|\n";
+# $s.= "..|<img src='images/editcut.png' alt='' border='0' class='center'>".
+# " "._("Cut")."|"."multiple_cut_systems|\n";
+
+ if($this->parent->CopyPasteHandler->entries_queued()){
+ $img = "<img border='0' class='center' src='images/editpaste.png' alt=''>";
+ $s.="..|".$img." "._("Paste")."|editPaste|\n";
+ }else{
+ $img = "<img border='0' class='center' src='images/cant_editpaste.png' alt=''>";
+ $s.="..|".$img." "._("Paste")."\n";
+ }
+ }
+
+
/* Add snapshot icons */
if(preg_match("/(c.*w|w.*c)/",$acl)){
$s .= "..|---|\n";
$userimg = "<img class='center' src='images/select_sudo.png' alt='Sudo' title='%s'>";
$ui = get_userinfo();
- $action_col_size = 50;
+ $action_col_size = 54;
if($this->parent->snapshotEnabled()){
- $action_col_size += 38;
+ $action_col_size += 32;
+ }
+ if($this->parent->CopyPasteHandler){
+ $action_col_size += 20;
}
// Test Every Entry and generate divlist Array
/* Add edit icon */
$actions = "";
+
+ $actions= "";
+ if(($this->parent->CopyPasteHandler) && preg_match("/(c.*w|w.*c)/",$acl)){
+# $actions.= "<input class='center' type='image'
+# src='images/editcut.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='".msgPool::editButton()."' name='sudo_edit_%KEY%' title='"._("Edit this entry")."'>";
$display = "<b>$display</b>";
}
+ /* Cutted objects should be displayed in light grey */
+ if($this->parent->CopyPasteHandler){
+ foreach($this->parent->CopyPasteHandler->queue as $queue_key => $queue_data){
+ if($queue_data['dn'] == $val['dn']) {
+ $display = "<font color='#999999'>".$display."</font>";
+ break;
+ }
+ }
+ }
+
$field1 = array("string" => "<input type='checkbox' id='item_selected_".$key."' name='item_selected_".$key."'>" ,
"attach" => "style='width:20px;'");
$field2 = array("string" => sprintf($userimg,$val['dn']),
diff --git a/gosa-plugins/sudo/admin/sudo/class_sudoGeneric.inc b/gosa-plugins/sudo/admin/sudo/class_sudoGeneric.inc
index 16545939182c0d996d11786660d01184a9dd967f..6f33477d1f31e3f136358050d813a24e74998f02 100644 (file)
"trustModel" => _("Access control list"))
));
}
+
+
+ /*! \brief This function will be called if an object gets copied.
+ This function adapts attributes from the source object.
+ @param Array The source object.
+ */
+ function PrepareForCopyPaste($source)
+ {
+ plugin::PrepareForCopyPaste($source);
+ foreach(array("sudoUser","sudoCommand","sudoHost","sudoRunAs") as $attr){
+ $this->$attr = array();
+ if(isset($source[$attr])){
+ $tmp = array();
+ for($i = 0 ; $i < $source[$attr]['count']; $i++){
+ $tmp[] = $source[$attr][$i];
+ }
+ $this->$attr = $tmp;
+ }
+ }
+
+ /* Is this account a trustAccount? */
+ if (isset($source['trustModel'])){
+ $this->trustModel= $source['trustModel'][0];
+ $this->was_trust_account= TRUE;
+ } else {
+ $this->was_trust_account= FALSE;
+ $this->trustModel= "";
+ }
+
+ $this->accessTo = array();
+ if (isset($source['accessTo'])){
+ for ($i= 0; $i<$source['accessTo']['count']; $i++){
+ $tmp= $source['accessTo'][$i];
+ $this->accessTo[$tmp]= $tmp;
+ }
+ }
+ }
+
+
+ /*! \brief Used for copy & paste.
+ Returns a HTML input mask, which allows to change the cn of this entry.
+ @param Array Array containing current status && a HTML template.
+ */
+ function getCopyDialog()
+ {
+ $vars = array("cn");
+ $smarty = get_smarty();
+ $smarty->assign("cn" ,$this->cn);
+ $str = $smarty->fetch(get_template_path("paste_generic.tpl",TRUE));
+ $ret = array();
+ $ret['string'] = $str;
+ $ret['status'] = "";
+ return($ret);
+ }
+
+
+ /*! \brief Used for copy & paste.
+ Some entries must be renamed to avaoid duplicate entries.
+ */
+ function saveCopyDialog()
+ {
+ if(isset($_POST['cn'])){
+ $this->cn = get_post('cn');
+ }
+ }
}
// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
?>
diff --git a/gosa-plugins/sudo/admin/sudo/class_sudoManagement.inc b/gosa-plugins/sudo/admin/sudo/class_sudoManagement.inc
index 835e3a2240680cfe03a9b9e05d54cd250d0a1be9..9f13e3ab8a1ca587c013515b0ca7c0ba268243c0 100644 (file)
private $DivListSudo = NULL;
private $sudotabs = NULL;
private $base = "";
+
+ private $start_pasting_copied_objects = FALSE;
/*! \brief */
public function __construct(&$config, &$ui)
$this->ui = &$ui;
$this->base = sudo::get_sudoers_ou($this->config);
+ /* 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);
+ }
+
/* Create dialog object */
$this->DivListSudo = new divListSudo($this->config,$this);
}
/* Store these posts if the current object is locked (used by somebody else)*/
session::set('LOCK_VARS_TO_USE',array(
- "/^act$/","/^id$/","/^sudo_edit_/",
+ "/^act$/","/^id$/","/^sudo_edit_/","/^cut_/","/^copy_/",
"/^sudo_del_/","/^item_selected/","/menu_action/"));
if(preg_match("/^sudo_del_/",$name)){
$s_action = "del_role";
$s_entry = preg_replace("/^sudo_del_([0-9]*).*$/","\\1",$name);
+ }elseif(preg_match("/^editPaste.*/i",$name)){
+ $s_action="editPaste";
+ }elseif(preg_match("/^copy_.*/",$name)){
+ $s_action="copy";
+ $s_entry = preg_replace("/^copy_([0-9]*).*$/i","\\1",$name);
+# }elseif(preg_match("/^cut_.*/",$name)){
+# $s_action="cut";
+# $s_entry = preg_replace("/^cut_([0-9]*).*$/i","\\1",$name);
}
}
}
}
- if(isset($_POST['menu_action']) && in_array($_POST['menu_action'],array("new_role","del_role","new_default"))){
+ if(isset($_POST['menu_action']) && in_array($_POST['menu_action'],array("new_role","del_role","new_default","editPaste"))){
$s_action = $_POST['menu_action'];
}
+
+
$smarty= get_smarty();
+ /********************
+ 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);
+ }
+
+
/********************
Create a new sudo ...
********************/
public function save_object()
{
$this->DivListSudo->save_object();
+ if(is_object($this->CopyPasteHandler)){
+ $this->CopyPasteHandler->save_object();
+ }
}
}
}
- function get_used_snapshot_bases(){
+ function get_used_snapshot_bases()
+ {
return(array(sudo::get_sudoers_ou($this->config)));
}
+
+
+ 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->list[$s_entry]['dn'];
+ $this->CopyPasteHandler->add_to_queue($dn,$s_action,"sudotabs","SUDOTABS","sudo");
+ }
+
+ /* 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->list[$id]['dn'];
+
+ if($s_action == "copy_multiple"){
+ $this->CopyPasteHandler->add_to_queue($dn,"copy","sudotabs","SUDOTABS","sudo");
+ }
+ if($s_action == "cut_multiple"){
+ $this->CopyPasteHandler->add_to_queue($dn,"cut","sudotabs","SUDOTABS","sudo");
+ }
+ }
+ }
+
+ /* 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()){
+
+ /* Get dialog */
+ $data = $this->CopyPasteHandler->execute();
+ $this->CopyPasteHandler->SetVar("base",$this->DivListSudo->selectedBase);
+
+ /* 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("");
+ }
}
// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
?>
diff --git a/gosa-plugins/sudo/admin/sudo/class_sudoOption.inc b/gosa-plugins/sudo/admin/sudo/class_sudoOption.inc
index 48d862f6a5ac7e8051c9db48a36748d49d3a2553..e73ec41ffd258c15f047e982b30aa139e8b22977 100644 (file)
ksort($option);
$this->options = $option;
+ $this->load_options();
+ }
+
+
+ private function load_options()
+ {
+
/****
Parse given sudoOption attributes
****/
}
+
/*! \brief Create HTML output for this plugin
@return String HTML output for this plugin.
*/
$ldap->modify($this->attrs);;
}
-
+
/*! \brief Checks input validity
*/
function check()
$message[] = msgPool::invalid($name,$option['VALUE'],"/[0-9]/");
}
} break;
-
}
}
}
-
return ($message);
}
+
+
+ /*! \brief This function will be called if an object gets copied.
+ This function adapts attributes from the source object.
+ @param Array The source object.
+ */
+ function PrepareForCopyPaste($source)
+ {
+ plugin::PrepareForCopyPaste($source);
+ $this->attrs['sudoOption'] = $source['sudoOption'];
+ $this->load_options();
+ }
}
// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
?>