From: hickert Date: Tue, 21 Mar 2006 07:56:44 +0000 (+0000) Subject: Added copy & paste for user X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=91d4cb30817fcb9ff01d9cf652c853fbfab3471e;p=gosa.git Added copy & paste for user git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@2874 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/include/class_CopyPasteHandler.inc b/include/class_CopyPasteHandler.inc index f83b415ba..154c940bd 100644 --- a/include/class_CopyPasteHandler.inc +++ b/include/class_CopyPasteHandler.inc @@ -10,6 +10,8 @@ class CopyPasteHandler { var $dialogOpen = false; var $objectdn = false; + var $lastdn = ""; + var $was_successfull = false; /* Create CP handler @@ -35,14 +37,12 @@ class CopyPasteHandler { /* Clears all copy & paste informations */ - function Clear($current_too = false) + function Clear() { $this->copyCurrent = false; $this->cutCurrent = false; $this->dialogOpen = false; - if($current_too){ - $this->current = NULL; - } + $this->current = NULL; } @@ -65,6 +65,11 @@ class CopyPasteHandler { foreach($obj->attributes as $attr){ $this->current->by_object[$name]->$attr = $obj->$attr; } + foreach(array("is_account") as $attr){ + if(isset($obj->$attr)){ + $this->current->by_object[$name]->$attr = $obj->$attr; + } + } } if($this->isCurrentObjectPastAble()){ return(true); @@ -133,6 +138,7 @@ class CopyPasteHandler { $this->dialogOpen =false; $smarty = get_smarty(); $smarty->assign("Complete",true); + $this->lastdn= $this->current->dn; $this->Clear(); return($smarty->fetch(get_template_path("copyPasteDialog.tpl",FALSE))); @@ -150,6 +156,7 @@ class CopyPasteHandler { $this->dialogOpen =false; $smarty = get_smarty(); $smarty->assign("Complete",true); + $this->lastdn = $this->current->dn; $this->Clear(); if($displayMessageOnSuccess){ return($smarty->fetch(get_template_path("copyPasteDialog.tpl",FALSE))); diff --git a/plugins/admin/users/class_userManagement.inc b/plugins/admin/users/class_userManagement.inc index d3b3b46e4..093e66446 100644 --- a/plugins/admin/users/class_userManagement.inc +++ b/plugins/admin/users/class_userManagement.inc @@ -34,12 +34,20 @@ class userManagement extends plugin var $got_uid= false; var $departments=array(); + var $CopyPasteHandler ; + var $enableCopyPaste = false; + function userManagement ($config, $ui) { /* Save configuration for internal use */ $this->config= $config; $this->ui= $ui; + /* Copy & Paste handler */ + 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 (!isset($_SESSION["userfilter"])){ @@ -107,6 +115,14 @@ class userManagement extends plugin }elseif(preg_match("/userfrom_tpl.*/i",$key)){ $s_action="create_user_from_tpl"; $s_entry = preg_replace("/userfrom_tpl_/i","",$key); + }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); } } @@ -152,6 +168,70 @@ class userManagement extends plugin } } + + /* 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",$userfilter['depselect']); + $ret = $this->CopyPasteHandler->execute(false); + if($ret) return($ret); + $this->reload(); + $s_action = "change_pw"; + $dn = $this->CopyPasteHandler->lastdn; + + foreach($this->list as $id => $entry){ + if($entry['dn'] == $dn){ + $s_entry = $id; + } + } + $s_action = "change_pw"; + } + + + /* Copy current object to CopyHandler + */ + if($s_action == "copy"){ + $this->CopyPasteHandler->Clear(); + + $dn = $this->list[trim($s_entry)]['dn']; + $acl = get_permissions ($dn, $this->ui->subtreeACL); + + $obj = new usertabs($this->config, $this->config->data['TABS']['USERTABS'], $dn); + $objNew = new usertabs($this->config, $this->config->data['TABS']['USERTABS'], "new"); + + $obj->set_acl($acl); + $objNew->set_acl($acl); + + foreach($obj->by_object as $name => $tab){ + foreach(array("photoData","jpegPhoto","is_account") as $attr){ + if(isset($obj->by_object[$name]->$attr)){ + $objNew->by_object[$name]->$attr = $obj->by_object[$name]->$attr; + } + } + } + $this->CopyPasteHandler->Copy($obj,$objNew); + } + + + /* Copy current object to CopyHandler + */ + if($s_action == "cut"){ + $this->CopyPasteHandler->Clear(); + $dn = $this->list[trim($s_entry)]['dn']; + $acl= get_permissions ($dn, $this->ui->subtreeACL); + + $obj = new usertabs($this->config, $this->config->data['TABS']['USERTABS'], $dn); + $obj->set_acl($acl); + + $this->CopyPasteHandler->Cut($obj); + } + } + /* End for new List Managment */ /* Save filter data if we are in the headpage */ @@ -672,6 +752,27 @@ class userManagement extends plugin } } + + /* Create paste icon + */ + if($this->enableCopyPaste){ + $Copy_Paste = "  "; + if($this->CopyPasteHandler->isCurrentObjectPastAble()){ + if($this->CopyPasteHandler->isCurrentCutted()){ + $img = "images/cutpaste.png"; + }else{ + $img = "images/copypaste.png"; + } + $Copy_Paste .= " "; + }else{ + $Copy_Paste .= ""._("Can "; + } + }else{ + $Copy_Paste =""; + } + + /* NEW LIST MANAGMENT */ $listhead = "
". "  ". @@ -680,14 +781,34 @@ class userManagement extends plugin "  ". "  ". "  ". + $Copy_Paste. "  ". _("Base")." ". "  ". "
"; - $action= ""; - $action.= ""; - $action.= ""; + + + + if($this->enableCopyPaste){ + $action = " "; + $action.= " "; + $action.= ""; + $action.= ""; + $action.= ""; + }else{ + $action= ""; + $action.= ""; + $action.= ""; + } @@ -696,7 +817,7 @@ class userManagement extends plugin array("string" => " ", "attach" => "style='text-align:center;width:20px;'"), array("string" => _("Username")." / "._("Department"), "attach" => "style=''"), array("string" => _("Properties"), "attach" => "style='width:152px;'"), - array("string" => _("Actions"), "attach" => "style='width:60px;border-right:0px;text-align:right;'"))); + array("string" => _("Actions"), "attach" => "style='width:90px;border-right:0px;text-align:right;'"))); $divlist->SetSummary(_("This table displays all users, in the selected tree.")); @@ -723,7 +844,7 @@ class userManagement extends plugin $field1 = array("string" => "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:152px;'"); - $field4 = array("string" => " ", "attach" => "style='width:60px;border-right:0px;text-align:right;'"); + $field4 = array("string" => " ", "attach" => "style='width:90px;border-right:0px;text-align:right;'"); $divlist->AddEntry(array($field1,$field2,$field3,$field4)); @@ -876,7 +997,7 @@ class userManagement extends plugin $field1 = array("string" => sprintf($tpl,$val['dn']), "attach" => "style='text-align:center;width:20px;'"); $field2 = array("string" => sprintf($editlink,$key,$display).$ip_port, "attach" => "style='' title='".$val['dn']."'"); $field3 = array("string" => $usrimg2." ".$posix." ".$enviro." ".$maila." ".$fonac." ".$faxac." ".$samba." ".$s_img_create_from_template, "attach" => "style='width:152px;'"); - $field4 = array("string" => preg_replace("/%KEY%/", "$key", $action),"attach" => "style='width:60px;border-right:0px;text-align:right;'"); + $field4 = array("string" => preg_replace("/%KEY%/", "$key", $action),"attach" => "style='width:90px;border-right:0px;text-align:right;'"); $add = array($field1,$field2,$field3,$field4); diff --git a/plugins/admin/users/tabs_user.inc b/plugins/admin/users/tabs_user.inc index 9569ed396..5ac4fb7b3 100644 --- a/plugins/admin/users/tabs_user.inc +++ b/plugins/admin/users/tabs_user.inc @@ -129,6 +129,16 @@ class usertabs extends tabs $this->by_object[$key]->is_template= TRUE; } } + + function saveCopyDialog() + { + tabs::saveCopyDialog(); + $baseobject= $this->by_object['user']; + $uid = $baseobject->uid; + foreach($this->by_object as $name => $obj){ + $this->by_object[$name]->uid = $uid; + } + } } diff --git a/plugins/personal/posix/class_posixAccount.inc b/plugins/personal/posix/class_posixAccount.inc index a5498c798..c68ed4e2f 100644 --- a/plugins/personal/posix/class_posixAccount.inc +++ b/plugins/personal/posix/class_posixAccount.inc @@ -825,7 +825,8 @@ $ldap->modify ($this->attrs); /* Save data to LDAP */ $ldap->cd($this->dn); $this->cleanup(); -$ldap->modify ($this->attrs); + unset($this->attrs['uid']); + $ldap->modify ($this->attrs); show_ldap_error($ldap->get_error()); @@ -1147,6 +1148,97 @@ $ldap->modify ($this->attrs); } reset ($this->grouplist); } + + function getCopyDialog() + { + if(!$this->is_account) return(""); + if ($this->force_ids == 1){ + $force_ids = "checked"; + if ($_SESSION['js']){ + $forceMode = ""; + } + } else { + if ($_SESSION['js']){ + if($this->acl != "#none#") + $forceMode ="disabled"; + } + $force_ids = ""; + } + + /* + if(isset($_POST['editGroupMembership'])){ + $this->group_dialog = TRUE; + } + + if(isset($_POST['add_groups_finish']) || isset($_POST['add_groups_cancel'])){ + $this->execute(); + $this->group_dialog =FALSE; + } + + if($this->group_dialog){ + return($this->execute()); + } + */ + + $str =" + + + + +
+

"._("Posix settings")."

+ + + + + + + + + + + + + + + + + + +
+ + + homeDirectory."\"> +
+ + + + + + + uidNumber."\"> +
+ + + gidNumber."\"> +
+
+ "; + return($str); + } + } // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: