summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 7ba6a2e)
raw | patch | inline | side by side (parent: 7ba6a2e)
author | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Tue, 25 Apr 2006 11:46:42 +0000 (11:46 +0000) | ||
committer | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Tue, 25 Apr 2006 11:46:42 +0000 (11:46 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@3108 594d385d-05f5-0310-b6e9-bd551577e9d8
index 996407c3076ae1dacc55f3c458c61ea069dff41b..4ec220be551b28193731719c6d999a5d3af27071 100644 (file)
<?php
-//FIXME: Comments are somewhat off the normal comment usage
class CopyPasteHandler {
var $was_successfull = false;
- /* Create CP handler
- */
+ /* Create CP handler */
function CopyPasteHandler($config){
$this->config = $config;
$this->current= NULL;
}
- /* Returns wether the current object can be pasted
- */
+ /* Returns wether the current object can be pasted */
function isCurrentObjectPastAble(){
- /* Check if we got a valid object
- */
+ /* Check if we got a valid object */
if($this->current == NULL){
return(false);
}
}
- /* Clears all copy & paste informations
- */
+ /* Clears all copy & paste informations */
function Clear()
{
$this->copyCurrent = false;
}
- /* return current obejct dn
- */
+ /* return current obejct dn */
function GetCurrentDn()
{
return($this->objectdn);
}
- /* Add Object which should be copied
- */
+ /* 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){
-
+
+ /* Prepare every single class, to be copied */
$this->current->by_object[$name]->PrepareForCopyPaste($obj);
-
+
+ /* handle some special vars */
foreach(array("is_account") as $attr){
if(isset($obj->$attr)){
$this->current->by_object[$name]->$attr = $obj->$attr;
}
- /* Add Object which should be cutted
- */
+ /* Add Object which should be cutted */
function Cut($obj){
$this->cutCurrent = true;
$this->current = $obj;
/* Returns true if current object
- * is cutted. And awaits to be pasted anywhere
- */
+ * 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
- */
+ * was copied, and awaits to be pasted again */
function isCurrentCopied(){
return($this->copyCurrent);
}
- /* stillOpen
- */
+ /* Returns true if the copy$paste dialog is still open */
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($displayMessageOnSuccess = true)
+ Create unique names, ids, or what ever */
+ function execute()
{
$this->dialogOpen = true;
if($this->cutCurrent){
$this->current->save();
$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)));
/* Copy & paste
*/
}else{
$this->current->save();
$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)));
- }else{
- //FIXME: Types!!! Either use strings, or use bool. But don't mix it!
- return( false);
- }
}
}
- $smarty = get_smarty();
- $smarty->assign("Complete",false);
- $smarty->assign("AttributesToFix",$this->generateAttributesToFix());
- $smarty->assign("SubDialog",$this->current->SubDialog);
-
- $smarty->assign("objectDN" ,$this->objectdn);
- $smarty->assign("message", sprintf(_("You are going to copy the entry '%s'."), $this->objectdn));
- return($smarty->fetch(get_template_path("copyPasteDialog.tpl",FALSE)));
+ if($this->current){
+ $smarty = get_smarty();
+ $smarty->assign("Complete",false);
+ $smarty->assign("AttributesToFix",$this->generateAttributesToFix());
+ $smarty->assign("SubDialog",$this->current->SubDialog);
+ $smarty->assign("objectDN" ,$this->objectdn);
+ $smarty->assign("message", sprintf(_("You are going to copy the entry '%s'."), $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()
- */
+ /* Create dialog which asks unique attributes/values ...
+ * call tabs -> getCopyDialog()
+ * which calls tab -> getCopyDialog() */
function generateAttributesToFix()
{
- return($this->current->getCopyDialog());
+ if($this->current){
+ return($this->current->getCopyDialog());
+ }
}
/* Set a single attribute to specified value
- * example : ("base", $newBase );
- */
+ * example : ("base", $newBase ); */
function SetVar($name,$value)
{
foreach($this-> current->by_object as $key => $obj){
}
- /* Save new values posted by copy & paste dialog
- */
+ /* Save new values posted by copy & paste dialog */
function save_object()
{
/* Assign posted var to all tabs
*/
- $this->current->saveCopyDialog();
+ if($this->current){
+ $this->current->saveCopyDialog();
+ }
}
- /* Returns possible errors returned from all including tabs ..
- */
+ /* Returns errors from including tabs. */
function check()
{
$ret = array();
$ret = array_merge($ret , $obj->check());
}
}
-
return($ret);
}
+ /* returns the paste icon for headpages */
function generatePasteIcon()
{
$Copy_Paste= " <img class='center' src='images/list_seperator.png' align='middle' alt='' height='16' width='1'> ";
diff --git a/include/functions.inc b/include/functions.inc
index dcd4ccaaf19915d297795cecf95c2de43bb66404..98b739af9940b05ede72ae7e6e47d84e7464ae10 100644 (file)
--- a/include/functions.inc
+++ b/include/functions.inc
}
+/* Resturns the difference between to microtime() results in float */
+function get_MicroTimeDiff($start , $stop)
+{
+ $a = split("\ ",$start);
+ $b = split("\ ",$stop);
+
+ $secs = $b[1] - $a[1];
+ $msecs= $b[0] - $a[0];
+
+ $ret = (float) ($secs+ $msecs);
+ return($ret);
+}
+
+
// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
?>
diff --git a/plugins/admin/users/class_userManagement.inc b/plugins/admin/users/class_userManagement.inc
index a23d11d2a9e2db392db2922d20309cee7f7a4ab3..f3e3596cdc740adb8fc77aeaaafab17b407238e1 100644 (file)
var $templates= array();
var $got_uid= false;
var $departments= array();
- var $CopyPasteHandler= NULL;
-
+ var $CopyPasteHandler = NULL;
+ var $CPPasswordChange = ""; // Contains the entry id which should get a new password
function userManagement($config, $ui)
{
"back" => "dep_back", "new" => "user_new",
"home" => "dep_home", "new_tpl" => "user_tplnew",
"change_pw" => "user_chgpw", "root" => "dep_root",
- "editpaste" => "editpaste", "copy" => "copy",
+ "editPaste" => "editPaste", "copy" => "copy",
"cut" => "cut") as $act => $name){
if (preg_match("/".$name.".*/", $key)){
}
}
-# |||| ----------------------- copy and paste - move it into a seperate function
-//FIXME: I've mostly skipped reviewing this. Just a few comments have been
-// added. Fact is, that we've an execute() function with more than 800
-// lines. I personally tend to make this shorter. Even the complete new
-// list management is a huge copy'n paste factor which can be sourced out
-// to another function.
-
- /* Only perform copy/paste if it is enabled */
- if($this->CopyPasteHandler){
-
- /* Paste copied/cutted object in here */
- //FIXME: Sure? Does this comment describe what happens below?
- if( $s_action == "editPaste" || $this->CopyPasteHandler->stillOpen()){
- $this->CopyPasteHandler->save_object();
- $this->CopyPasteHandler->SetVar("base", $_SESSION['CurrentMainBase']);
-
- /* Execute copy and paste without showing message on success. */
- //FIXME: It is not clear what really happens, or why we're stopping
- // to process data here. See the FIXME in class_CopyAndPasteHandler.
- // Normally we don't have something in $ret, because we've fired
- // up with (false) <=> which seems to mean "no messages".
- if( ($ret= $this->CopyPasteHandler->execute(false))){
- return ($ret);
- }
-
- /* Reload to have freshly copied entries in the list */
- $this->reload();
-
- /* Use the last dn to search for it's ID in the newly generated list. */
- $dn= $this->CopyPasteHandler->lastdn;
- foreach($this->list as $id => $entry){
- if($entry['dn'] == $dn){
- $s_entry= $id;
- break;
- }
- }
-
- /* Change action to "change_pw" if user has requested to do so. */
- if($_POST['passwordTodo'] == "new"){
- $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 */
- //FIXME: Again? This is cut. Hopefully it works without touching the special
- // attributes from above.
- 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);
- }
+ $ret = $this->copyPasteHandling($s_action,$s_entry);
+ if($ret){
+ return($ret);
}
-# ^^^^^ ----------------------- copy and paste - move it into a seperate function
/* Save filter data if we are in the headpage */
if(!isset($this->usertab)){
}
/* Password change requested */
- if ($s_action == "change_pw"){
+ if (($s_action == "change_pw") || (!empty($this->CPPasswordChange))){
+
+ if(!empty($this->CPPasswordChange)){
+ $s_entry = $this->CPPasswordChange;
+ $this->CPPasswordChange = "";
+ }
/* Get 'dn' from posted 'uid' */
$this->dn= $this->list[trim($s_entry)]['dn'];
}
}
+
+ /* Perform copy & paste requests
+ If copy&paste is in progress this returns a dialog to fix required attributes
+ */
+ function copyPasteHandling($s_action,$s_entry)
+ {
+ /* Only perform copy/paste if it is enabled */
+ if($this->CopyPasteHandler){
+
+ /* Prepare current object to be pasted */
+ if( $s_action == "editPaste" || $this->CopyPasteHandler->stillOpen()){
+
+ $this->CopyPasteHandler->save_object();
+ $this->CopyPasteHandler->SetVar("base", $_SESSION['CurrentMainBase']);
+
+ /* Execute copy & paste dialog and display returned data, normaly a dialog which allows
+ us to solve all attribute mismatches for this object.
+ If nothing is returned, copy & paste was succesfully or aborted */
+ if(($ret= $this->CopyPasteHandler->execute())){
+ return ($ret);
+ }
+
+ /* Reload to have freshly copied entries in the list */
+ $this->reload();
+
+ /* Use the last dn to search for it's ID in the newly generated list. */
+ $dn= $this->CopyPasteHandler->lastdn;
+ foreach($this->list as $id => $entry){
+ if($entry['dn'] == $dn){
+ $s_entry= $id;
+ break;
+ }
+ }
+
+ /* Set CPPasswordChange to s_entry which indicates that this entry requires a new password. */
+ if(isset($_POST['passwordTodo']) && ($_POST['passwordTodo'] == "new")){
+ $this->CPPasswordChange = $s_entry;
+ }
+ }
+
+ /* Copy selected object
+ Create a new empty object and the current selected object.
+ Send both to copy&paste class*/
+ 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);
+ $this->CopyPasteHandler->Copy($obj,$objNew);
+ }
+
+ /* Cut selected object.
+ Open user object and send it to the copy & paste handler */
+ 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);
+ }
+ }
+ }
+
/* A set of disabled and therefore overloaded functions. They are
not needed in this class. */
diff --git a/plugins/gofon/phoneaccount/class_phoneAccount.inc b/plugins/gofon/phoneaccount/class_phoneAccount.inc
index 80660f27e9d03b329bd41f6924a296a779f32886..0c4363cde71a74283cca57043a16e1ce085dd439 100644 (file)
}
}
+
+ /* Create phoneAccount part of copy & paste dialog */
function getCopyDialog()
{
if(!$this->is_account) return("");
return($ret);
}
+ /* Save posts from copy & paste dialog dialog */
function saveCopyDialog()
{
if(!$this->is_account) return;
diff --git a/plugins/personal/mail/class_mailAccount.inc b/plugins/personal/mail/class_mailAccount.inc
index 94bd81e8af98c194572408ced563d60120a70222..65686eeb4a572d5493951afe2d6316f603ea8412 100644 (file)
return ($name);
}
+
+ /* Create the mail part for the copy & paste dialog */
function getCopyDialog()
{
if(!$this->is_account) return("");
diff --git a/plugins/personal/posix/class_posixAccount.inc b/plugins/personal/posix/class_posixAccount.inc
index 18724b25f635fef32e56e9452fb7869192559bcc..86e8a892f841db7d114f76f010b8edf89b395836 100644 (file)
reset ($this->grouplist);
}
+
+ /* Create the posix dialog part for copy & paste */
function getCopyDialog()
{
+ /* Skip dialog creation if this is not a valid account*/
if(!$this->is_account) return("");
if ($this->force_ids == 1){
$force_ids = "checked";
$sta = "";
+ /* Open group add dialog */
if(isset($_POST['edit_groupmembership'])){
$this->group_dialog = TRUE;
$sta = "SubDialog";
}
+ /* If the group-add dialog is closed, call execute
+ to ensure that the membership is updatd */
if(isset($_POST['add_groups_finish']) || isset($_POST['add_groups_cancel'])){
$this->execute();
$this->group_dialog =FALSE;
return($ret);
}
+ /* If a group member should be deleted, simply call execute */
if(isset($_POST['delete_groupmembership'])){
$this->execute();
}
+ /* Assigned informations to smarty */
$smarty = get_smarty();
$smarty->assign("homeDirectory",$this->homeDirectory);
$smarty->assign("uidNumber",$this->uidNumber);
$smarty->assign("gidNumber",$this->gidNumber);
$smarty->assign("forceMode",$forceMode);
$smarty->assign("force_ids",$force_ids);
- if (!count($this->groupMembership)){
+ if (!count($this->groupMembership)){
$smarty->assign("groupMembership", array(" "));
} else {
$smarty->assign("groupMembership", $this->groupMembership);
}
+
+ /* Display wars message if there are more than 16 group members */
if (count($this->groupMembership) > 16){
$smarty->assign("groups", "too_many_for_nfs");
} else {