From: hickert Date: Fri, 12 May 2006 05:31:10 +0000 (+0000) Subject: Initial commit for department tagging & recursive move X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=be474dde1784149bed77c2d102b01ade01751c45;p=gosa.git Initial commit for department tagging & recursive move git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@3302 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/plugins/admin/departments/class_departmentGeneric.inc b/plugins/admin/departments/class_departmentGeneric.inc index 61160d2f6..53afc78d7 100644 --- a/plugins/admin/departments/class_departmentGeneric.inc +++ b/plugins/admin/departments/class_departmentGeneric.inc @@ -161,7 +161,6 @@ class department extends plugin } } - function remove_from_parent() { $ldap= $this->config->get_ldap_link(); @@ -172,6 +171,16 @@ class department extends plugin $this->handle_post_events('remove'); } + function must_be_tagged() + { + return $this->must_be_tagged; + } + + function am_i_moved() + { + return $this->rec_cpy; + } + /* Save data to object */ function save_object() @@ -258,7 +267,9 @@ class department extends plugin /* Add tag objects if needed */ if ($this->is_administrational_unit){ - $this->objectclasses[]= "gosaAdministrativeUnit"; + if(!in_array_ics("gosaAdministrativeUnit",$this->objectclasses)){ + $this->objectclasses[]= "gosaAdministrativeUnit"; + } if ($this->gosaUnitTag == ""){ /* It's unlikely, but check if already used... */ @@ -320,14 +331,24 @@ class department extends plugin } show_ldap_error($ldap->get_error()); - + /* The parameter forces only to set must_be_tagged, and don't touch any objects + This will be done later */ + $this->tag_objects(true); + /* Optionally execute a command after we're done */ - $this->must_be_tagged =true; $this->postcreate(); return(true); } + function ShowMoveFrame() + { + $smarty = get_smarty(); + $smarty->assign("src","?plug=".$_GET['plug']."&PerformRecMove"); + $display= $smarty->fetch(get_template_path("recursive_move.tpl",TRUE)); + return($display); + } + function ShowTagFrame() { $smarty = get_smarty(); @@ -337,7 +358,7 @@ class department extends plugin } /* Tag objects to have the gosaAdministrativeUnitTag */ - function tag_objects() + function tag_objects($OnlySetTagFlag = false) { $add= $this->is_administrational_unit; $len= strlen($this->dn); @@ -371,38 +392,36 @@ class department extends plugin } } - /* Fix entry if needed */ - if ($fix){ - echo "asdfasdfasdfasdf"; - $this->handle_object_tagging($attrs['dn'], $this->gosaUnitTag, true); + /* Fix entry if needed */ + if ($fix){ + if($OnlySetTagFlag){ + $this->must_be_tagged =true; + return; + } + $this->handle_object_tagging($attrs['dn'], $this->gosaUnitTag, TRUE ); } } - echo '

 

'; - - echo "
-
-
"; - + if(!$OnlySetTagFlag){ + echo '

 

'; + echo "
+
+
"; + } } /* Move/Rename complete trees */ function recursive_move($src_dn, $dst_dn,$force = false) { + /* If force == false prepare to recursive move this object from src to dst + on the next call. */ if(!$force){ - $this->rec_cpy = true; $this->rec_src = $src_dn; $this->rec_dst = $dst_dn; - - $smarty = get_smarty(); - - $smarty->assign("src","?plug=".$_GET['plug']."&PerformRecMove"); - - $display= $smarty->fetch(get_template_path("recursive_move.tpl",TRUE)); - return($display); - }else{ + + /* If this is called, but not wanted, abort */ if(!$this->rec_cpy){ return; } @@ -426,7 +445,7 @@ class department extends plugin if ($ldap->fetch()){ trigger_error("Recursive_move $dst_dn already exists.", E_USER_WARNING); - echo sprintf_("Recursive_move: '%s' already exists", $dst_dn)."
"; + echo sprintf("Recursive_move: '%s' already exists", $dst_dn)."
"; return (FALSE); } @@ -478,17 +497,6 @@ class department extends plugin return (TRUE); } } - - function must_be_tagged() - { - return $this->must_be_tagged; - } - - function am_i_moved() - { - return $this->rec_cpy; - } - } // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: ?> diff --git a/plugins/admin/departments/class_departmentManagement.inc b/plugins/admin/departments/class_departmentManagement.inc index 1d231605b..2fcbe8fde 100644 --- a/plugins/admin/departments/class_departmentManagement.inc +++ b/plugins/admin/departments/class_departmentManagement.inc @@ -39,6 +39,10 @@ class departmentManagement extends plugin var $attributes= array(); var $objectclasses= array(); + var $ObjectInSaveMode = false; + var $RecursiveRemoveRequested = false; + var $ObjectTaggingRequested = false; + function departmentManagement ($config, $ui) { $this->ui= $ui; @@ -208,40 +212,6 @@ class departmentManagement extends plugin } } - - /* If this var ist true, the object will be unset after the next two operations */ - $UnsetAfterTaggingMoving = false; - - /* This department must be tagged - */ - if((isset($_GET['TagDepartment'])) && ($this->deptabs->by_object['department']->must_be_tagged())){ - $this->deptabs->by_object['department']->tag_objects(); - $UnsetAfterTaggingMoving = true; - - } - - /* Edit Complete ... - * Finish request - */ - if((isset($_GET['PerformRecMove'])) &&( $this->deptabs->by_object['department']->am_i_moved())){ - $this->deptabs->save(true); - $this->deptabs->by_object['department']->recursive_move("","",true); - $UnsetAfterTaggingMoving = true; - } - - /* Unset current object / all operations are done */ - if($UnsetAfterTaggingMoving){ - /* There's no page reload so we have to read new users at - this point. */ - del_lock ($this->dn); - $this->reload (); - unset ($this->deptabs); - $this->deptabs= NULL; - unset ($_SESSION['objectinfo']); - exit(); - } - - if ((isset($_POST['edit_finish'])) && (isset($this->deptabs->config) ) ){ /* Check tabs, will feed message array */ @@ -250,38 +220,19 @@ class departmentManagement extends plugin /* Save, or display error message? */ if (count($message) == 0){ - $res = $this->deptabs->save(true); - $display = ""; - + $this->deptabs->save(true); + $this->deptabs->by_object['department']->save(); + /* Get tagging frame */ if($this->deptabs->by_object['department']->must_be_tagged()){ - $display .= $this->deptabs->by_object['department']->ShowTagFrame(); - } + $this->ObjectTaggingRequested = true; + } /* Get recursive move frame */ if($this->deptabs->by_object['department']->am_i_moved()){ - $display .= $res; + $this->RecursiveRemoveRequested = true; } - - /* If no frame is returned, unset this obejct, else display those frames */ - if(empty($display)){ - gosa_log ("Department object'".$this->dn."' has been saved"); - - /* Group has been saved successfully, remove lock from - LDAP. */ - if ($this->dn != "new"){ - del_lock ($this->dn); - } - - /* There's no page reload so we have to read new users at - this point. */ - $this->reload (); - unset ($this->deptabs); - $this->deptabs= NULL; - unset ($_SESSION['objectinfo']); - }else{ - return($display); - } + $this->ObjectInSaveMode = true; } else { /* Ok. There seem to be errors regarding to the tab data, show message and continue as usual. */ @@ -289,6 +240,39 @@ class departmentManagement extends plugin } } + /* This department must be tagged */ + if((isset($_GET['TagDepartment'])) && ($this->ObjectTaggingRequested)){ + $this->deptabs->by_object['department']->tag_objects(); + $this->ObjectTaggingRequested = false; + exit(); + } + /* initiate recursive remove*/ + if((isset($_GET['PerformRecMove'])) &&($this->RecursiveRemoveRequested)){ + $this->deptabs->by_object['department']->recursive_move("","",true); + $this->RecursiveRemoveRequested = false; + exit(); + } + + if($this->ObjectTaggingRequested){ + return($this->deptabs->by_object['department']->ShowTagFrame()); + } + if($this->RecursiveRemoveRequested){ + return($this->deptabs->by_object['department']->ShowMoveFrame()); + } + + /* Unset current object / all operations are done */ + if($this->ObjectInSaveMode && (!$this->RecursiveRemoveRequested) && (!$this->ObjectTaggingRequested)){ + $this->deptabs->save(); + $this->ObjectInSaveMode = false; + if ($this->dn != "new"){ + del_lock ($this->dn); + } + gosa_log ("Department object'".$this->dn."' has been saved"); + $this->reload (); + unset ($this->deptabs); + $this->deptabs= NULL; + unset ($_SESSION['objectinfo']); + } /* User cancelt edit oder delete * Cancel dialog diff --git a/plugins/admin/departments/tabs_department.inc b/plugins/admin/departments/tabs_department.inc index 77834bb27..f5d771bde 100644 --- a/plugins/admin/departments/tabs_department.inc +++ b/plugins/admin/departments/tabs_department.inc @@ -6,40 +6,40 @@ class deptabs extends tabs function deptabs($config, $data, $dn) { - tabs::tabs($config, $data, $dn); - $this->base= $this->by_object['department']->base; + tabs::tabs($config, $data, $dn); + $this->base= $this->by_object['department']->base; } function check() { - return (tabs::check(TRUE)); + return (tabs::check(TRUE)); } - + function save($justsave = false) { - if(!$justsave){ - $baseobject= $this->by_object['department']; - $ou= preg_replace('/,/', '\,', $baseobject->ou); - $new_dn= @LDAP::convert('ou='.$ou.','.$baseobject->base); - $disp =""; - if ($this->dn != $new_dn && $this->dn != "new"){ - - /* if( new_dn is subtree of this->dn ) */ - $cnt1 = count(split(",",$this->dn)); - $cnt2 = count(split(",",$new_dn)); - if((strstr($new_dn,$this->dn))&&($cnt1<$cnt2)){ - print_red(_("Try to move tree failed. Destination tree is subtree of source tree.")); - }else{ - $disp = ($baseobject->recursive_move($this->dn, $new_dn)); - return($disp); - } - } - $this->dn= $new_dn; - } - return(tabs::save(TRUE)); + $baseobject= $this->by_object['department']; + $ou= preg_replace('/,/', '\,', $baseobject->ou); + $new_dn= @LDAP::convert('ou='.$ou.','.$baseobject->base); + + if($justsave){ + if ($this->dn != $new_dn && $this->dn != "new"){ + /* if( new_dn is subtree of this->dn ) */ + $cnt1 = count(split(",",$this->dn)); + $cnt2 = count(split(",",$new_dn)); + if((strstr($new_dn,$this->dn))&&($cnt1<$cnt2)){ + print_red(_("Try to move tree failed. Destination tree is subtree of source tree.")); + }else{ + /* Prepare to be moved */ + $baseobject->recursive_move($this->dn, $new_dn); + return; + } + } + } + $this->dn= $new_dn; + return(tabs::save(TRUE)); } } - +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: ?>