summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: db73aad)
raw | patch | inline | side by side (parent: db73aad)
author | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Fri, 23 Jun 2006 11:08:16 +0000 (11:08 +0000) | ||
committer | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Fri, 23 Jun 2006 11:08:16 +0000 (11:08 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@3871 594d385d-05f5-0310-b6e9-bd551577e9d8
diff --git a/plugins/admin/departments/class_departmentGeneric.inc b/plugins/admin/departments/class_departmentGeneric.inc
index ed1216cdf019388fbdbee7ffea12a2793fa8a2f5..c508b614e36e58bf38aaf886ef284381c48e5d72 100644 (file)
class department extends plugin
{
/* department attributes */
- var $ou= "";
- var $description= "";
- var $base= "";
- var $st= "";
- var $l= "";
- var $postalAddress= "";
- var $businessCategory= "";
- var $telephoneNumber= "";
- var $facsimileTelephoneNumber= "";
- var $orig_dn= "";
- var $is_administrational_unit= false;
- var $gosaUnitTag= "";
-
- var $rec_dst=false; // Destination for recursive move
- var $rec_src=false; // Source for recursive move
- var $rec_cpy=false; // Is recursive move requested ?
+ var $ou = "";
+ var $description = "";
+ var $base = "";
+ var $st = "";
+ var $l = "";
+ var $postalAddress = "";
+ var $businessCategory = "";
+ var $telephoneNumber = "";
+ var $facsimileTelephoneNumber = "";
+ var $orig_dn = "";
+ var $is_administrational_unit = false;
+ var $gosaUnitTag = "";
/* Headpage attributes */
- var $last_dep_sorting= "invalid";
- var $departments= array();
+ var $last_dep_sorting = "invalid";
+ var $departments = array();
- var $must_be_tagged = false;
+ /* Used to indicate that a new tagging is required */
+ var $must_be_tagged = false;
+ var $MustBeMoved = "";
+ var $MoveDestination = "";
+ var $MoveSource = "";
+ var $MoveOu = "";
/* attribute list for save action */
- var $attributes= array("ou", "description", "businessCategory", "st", "l", "postalAddress",
- "telephoneNumber", "facsimileTelephoneNumber", "gosaUnitTag");
- var $objectclasses= array("top", "gosaDepartment", "organizationalUnit");
+ var $attributes = array("ou", "description", "businessCategory", "st",
+ "l", "postalAddress", "telephoneNumber",
+ "facsimileTelephoneNumber", "gosaUnitTag");
+ var $objectclasses = array("top", "gosaDepartment", "organizationalUnit");
+
function department ($config, $dn)
{
-
plugin::plugin($config, $dn);
- $this->is_account= TRUE;
- $this->ui= get_userinfo();
- $this->dn= $dn;
- $this->orig_dn= $dn;
- $this->config= $config;
+ $this->is_account = TRUE;
+ $this->ui = get_userinfo();
+ $this->dn = $dn;
+ $this->orig_dn = $dn;
+ $this->config = $config;
/* Set base */
if ($this->dn == "new"){
}
/* set permissions */
- $ui= get_userinfo();
- $acl= get_permissions ($ui->dn, $ui->subtreeACL);
- $this->acl= get_module_permission($acl, "department", $ui->dn);
+ $acl = get_permissions ($this->ui->dn, $this->ui->subtreeACL);
+ $this->acl= get_module_permission($acl, "department", $this->ui->dn);
/* Is administrational Unit? */
if ($dn != "new" && in_array_ics('gosaAdministrativeUnit', $this->attrs['objectClass'])){
}
}
+
function execute()
{
/* Call parent execute */
}
}
- /* Dialog handling */
+ /* BASE select dialog handling */
if(is_object($this->dialog)){
- /* Must be called before save_object */
+
+ /* save sub dialog vars */
$this->dialog->save_object();
+ /* Check if dialog was closed */
if($this->dialog->isClosed()){
$this->dialog = false;
}elseif($this->dialog->isSelected()){
$tmp = array();
foreach($bases as $dn=>$base){
$fixed = str_replace("/","\\",$this->dn);
+
/* Only attach departments which are not a subtree of this one */
if(!preg_match("/".$fixed."/",$dn)){
$tmp[$dn]=$base;
}
$smarty->assign("bases", $tmp);
+ /* Report class vars to smarty */
foreach ($this->attributes as $val){
$smarty->assign("$val", $this->$val);
$smarty->assign("$val"."ACL", chkacl($this->acl, "$val"));
$smarty->assign("unitTag", "");
}
$smarty->assign("unitTag"."ACL", chkacl($this->acl, "unitTag"));
-
return($smarty->fetch (get_template_path('generic.tpl', TRUE)));
}
- function clear_fields()
- {
- $this->dn= "";
- $this->base= "";
- $this->acl= "#none#";
-
- foreach ($this->attributes as $val){
- $this->$val= "";
- }
- }
+ /* Remove department && all sub objects from ldap */
function remove_from_parent()
{
+ /* Remove the current department from ldap */
$ldap= $this->config->get_ldap_link();
$ldap->cd ($this->dn);
$ldap->recursive_remove();
$this->handle_post_events('remove');
}
- function must_be_tagged()
- {
- if((isset($this->attrs['gosaUnitTag'][0])) && ($this->is_administrational_unit)){
- $this->must_be_tagged = false;
- }elseif((!isset($this->attrs['gosaUnitTag'][0])) && (!$this->is_administrational_unit)){
- $this->must_be_tagged = false;
- }else{
- $this->must_be_tagged = true;
- }
- return $this->must_be_tagged;
- }
-
- function am_i_moved()
- {
- return $this->rec_cpy;
- }
-
/* Save data to object */
function save_object()
/* Add tag objects if needed */
if ($this->is_administrational_unit){
+
+ /* Add tagging objectClass if it is not available */
if(!in_array_ics("gosaAdministrativeUnit",$this->objectclasses)){
$this->objectclasses[]= "gosaAdministrativeUnit";
}
+
+
+ /* If tag wasn't set right now */
if ($this->gosaUnitTag == ""){
/* It's unlikely, but check if already used... */
$ldap->cd($this->config->current['BASE']);
while ($try--){
- /* Generate microtime stamp as tag */
+ /* Generate microtime stamp as tag, and check if this tag was already used somewhere */
list($usec, $sec)= explode(" ", microtime());
$time_stamp= preg_replace("/\./", "", $sec.$usec);
-
$ldap->search("(&(objectClass=gosaAdministrativeUnit)(gosaUnitTag=$time_stamp))",array("gosaUnitTag"));
if ($ldap->count() == 0){
break;
}
- }
+ }
+
+ /* Last try, and all generated tag are already in use */
if($try == 0) {
print_red(_("Fatal error: Can't find an unused tag to mark the administrative unit!"));
return;
$this->gosaUnitTag= preg_replace("/\./", "", $sec.$usec);
}
} else {
+
+ /* Set tag to "" if department isn't tagged */
$this->gosaUnitTag= "";
}
$ldap->add($this->attrs);
$this->handle_post_events('add');
}
- show_ldap_error($ldap->get_error(), _("Saving department failed"));
+
+ show_ldap_error($ldap->get_error(), _("Saving department failed"));
+
+ /* 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->postcreate();
}
- function ShowMoveFrame()
- {
- $smarty = get_smarty();
- $smarty->assign("src","?plug=".$_GET['plug']."&PerformRecMove");
- $smarty->assign("message","As soon as the move operation has finished, you can scroll down to end of the page and press the 'Continue' button to continue with the department management dialog.");
- $display= $smarty->fetch(get_template_path("dep_iframe.tpl",TRUE));
- return($display);
- }
-
- function ShowTagFrame()
- {
- $smarty = get_smarty();
- $smarty->assign("src","?plug=".$_GET['plug']."&TagDepartment");
- $smarty->assign("message","As soon as the tag operation has finished, you can scroll down to end of the page and press the 'Continue' button to continue with the department management dialog.");
- $display= $smarty->fetch(get_template_path("dep_iframe.tpl",TRUE));
- return($display);
- }
-
/* Tag objects to have the gosaAdministrativeUnitTag */
function tag_objects($OnlySetTagFlag = false)
{
+ /* Skip output */
if(!$OnlySetTagFlag){
$smarty= get_smarty();
echo "<!-- headers.tpl-->".$smarty->fetch(get_template_path('headers.tpl'));
echo "<h3>".sprintf(_("Tagging '%s'."),"<i>".@LDAP::fix($this->dn)."</i>")."</h3>";
}
- $add= $this->is_administrational_unit;
- $len= strlen($this->dn);
+ /* Get all object that must be tagged, or the tag removed */
$ldap= $this->config->get_ldap_link();
$ldap->cd($this->dn);
- if ($add){
- $ldap->search('(!(&(objectClass=gosaAdministrativeUnitTag)(gosaUnitTag='.
- $this->gosaUnitTag.')))', array('dn'));
+ if ($this->is_administrational_unit){
+ $ldap->search('(!(&(objectClass=gosaAdministrativeUnitTag)(gosaUnitTag='.$this->gosaUnitTag.')))', array('dn'));
} else {
$ldap->search('objectClass=gosaAdministrativeUnitTag', array('dn'));
}
+
+ /* Get dn length, it is used to validate the fetched dns */
+ $len= strlen($this->dn);
+
+ /* Walk through all objects && verify if fetch object musst be touched */
while ($attrs= $ldap->fetch()){
/* Skip self */
/* Check for confilicting administrative units */
$fix= true;
foreach ($this->config->adepartments as $key => $tag){
+
/* This one is shorter than our dn, its not relevant... */
if ($len >= strlen($key)){
continue;
/* Fix entry if needed */
if ($fix){
+
+ /* If OnlySetTagFlag is true, then only set must_be_tagged to true, and skip tagging. */
if($OnlySetTagFlag){
$this->must_be_tagged =true;
return;
+ }else{
+ $this->handle_object_tagging($attrs['dn'], $this->gosaUnitTag, TRUE );
}
- $this->handle_object_tagging($attrs['dn'], $this->gosaUnitTag, TRUE );
}
}
+
+ /* Hide all output, if we only want to if we must tag */
if(!$OnlySetTagFlag){
echo '<p class="seperator"> </p>';
echo "<div style='width:100%;text-align:right;'><form name='form' method='post' action='?plug=".$_GET['plug']."' target='_parent'>
/* Move/Rename complete trees */
- function recursive_move($src_dn, $dst_dn,$force = false)
+ function recursive_move()
{
- /* 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;
- }else{
-
- /* If this is called, but not wanted, abort */
- if(!$this->rec_cpy){
- return;
- }
+ /* Check if the destination entry exists */
+ $ldap= $this->config->get_ldap_link();
- $src_dn = $this->rec_src;
- $dst_dn = $this->rec_dst;
+ /* Get destination && source dn */
+ $src_dn = $this->MoveSource;
+ $dst_dn = $this->MoveDestination;
/* Print header to have styles included */
$smarty= get_smarty();
echo "<!-- headers.tpl-->".$smarty->fetch(get_template_path('headers.tpl'));
echo "<body style='background-image:none;margin:3px;color:black'>";
-
echo "<h3>".sprintf(_("Moving '%s' to '%s'"),"<i>".$src_dn."</i>","<i>".$dst_dn."</i>")."</h3>";
-
- /* Check if the destination entry exists */
- $ldap= $this->config->get_ldap_link();
-
/* Check if destination exists - abort */
$ldap->cat($dst_dn, array('dn'));
if ($ldap->fetch()){
- trigger_error("Recursive_move $dst_dn already exists.",
- E_USER_WARNING);
+ trigger_error("Recursive_move $dst_dn already exists.", E_USER_WARNING);
echo sprintf("Recursive_move: '%s' already exists", $dst_dn)."<br>";
return (FALSE);
}
/* Copy objects from small to big indent levels by replacing src_dn by dst_dn */
foreach ($objects as $object => $len){
-
$src= str_replace("\\","\\\\",$object);
$dst= preg_replace("/".str_replace("\\","\\\\",$src_dn)."$/", "$dst_dn", $object);
$dst= str_replace($src_dn,$dst_dn,$object);
$this->rec_cpy =false;
echo '<p class="seperator"> </p>';
-
echo "<div style='width:100%;text-align:right;'><form name='form' method='post' action='?plug=".$_GET['plug']."' target='_parent'>
<br><input type='submit' name='back' value='"._("Continue")."'>
</form></div>";
echo "</body></html>";
-
return (TRUE);
- }
}
+
+
+ /* Return an iframe, that calls the recursive move function of departmentManagement */
+ function ShowMoveFrame()
+ {
+ $smarty = get_smarty();
+ $smarty->assign("src","?plug=".$_GET['plug']."&PerformRecMove");
+ $smarty->assign("message","As soon as the move operation has finished, you can scroll down to end of the page and press the 'Continue' button to continue with the department management dialog.");
+ $display= $smarty->fetch(get_template_path("dep_iframe.tpl",TRUE));
+ return($display);
+ }
+
+
+ /* return an iframe, that will initiate the tagging process */
+ function ShowTagFrame()
+ {
+ $smarty = get_smarty();
+ $smarty->assign("src","?plug=".$_GET['plug']."&TagDepartment");
+ $smarty->assign("message","As soon as the tag operation has finished, you can scroll down to end of the page and press the 'Continue' button to continue with the department management dialog.");
+ $display= $smarty->fetch(get_template_path("dep_iframe.tpl",TRUE));
+ return($display);
+ }
+
+
}
// 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 128639d12540887409452ccb6a489149994e03ae..dbfcab0b4ad7a6797c2b7799ede3d4ab4b4a02e4 100644 (file)
var $attributes= array();
var $objectclasses= array();
- /* Vars to handle operations after saving the department
- Recursive move && tagging */
- var $ObjectInSaveMode = false; // Is true, if current object wasn't saved right now
- var $ObjectTaggingRequested = false; // Object must be tagged, an iframe will be shown.
- var $RecursiveRemoveRequested = false; // Is true, if this object must be moved, an iframe will be displayed in this case
+ /* Tagging || Moving in progress */
+ var $AfterSaveProcedure = false;
function departmentManagement ($config, $ui)
{
}
}
-
- /***************
- Edit department finished
- ***************/
-
- if ((isset($_POST['edit_finish'])) && (isset($this->deptabs->config))){
-
- /* Check tabs, will feed message array */
- $message= $this->deptabs->check();
-
- /* Save, or display error message? */
- if (count($message) == 0){
-
- $this->deptabs->save(true);
-
- if(!$this->deptabs->by_object['department']->am_i_moved()){
- $this->deptabs->save(true);
- }
-
- /* This object must be tagged, so set ObjectTaggingRequested to true */
- if($this->deptabs->by_object['department']->must_be_tagged()){
- $this->ObjectTaggingRequested = true;
- }
-
- /* Get recursive move is required, set RecursiveRemoveRequested to true */
- if($this->deptabs->by_object['department']->am_i_moved()){
- $this->RecursiveRemoveRequested = true;
- }
-
- /* This var indicated that there is an object which isn't saved right now. */
- $this->ObjectInSaveMode = true;
-
- } else {
- /* Ok. There seem to be errors regarding to the tab data,
- show message and continue as usual. */
- show_errors($message);
- }
- }
-
-
/***************
Handle Tagging (Return output for an iframe)
***************/
- /* This department must be tagged (Is called from iframe, generates output)*/
+ /* This department must be tagged (Is called from iframe, generates output) */
if(isset($_GET['TagDepartment'])){
$this->deptabs->by_object['department']->tag_objects();
+ $this->deptabs->by_object['department']->must_be_tagged = false;
exit();
}
/* initiate recursive remove (Is called from iframe, generates output)*/
if(isset($_GET['PerformRecMove'])){
- $this->deptabs->by_object['department']->recursive_move("","",true);
+ $this->deptabs->by_object['department']->recursive_move();
+ $this->deptabs->by_object['department']->MustBeMoved = false;
exit();
}
+
/***************
- Return iframes, which call tagging / recusrsive move
+ Edit department finished
***************/
- /* While one of these vars below isset, we must return an iframe,
- to perform requested operation */
- if($this->ObjectTaggingRequested){
- $this->ObjectTaggingRequested = false;
- return($this->deptabs->by_object['department']->ShowTagFrame());
- }
- if($this->RecursiveRemoveRequested){
- $this->RecursiveRemoveRequested = false;
- return($this->deptabs->by_object['department']->ShowMoveFrame());
- }
+ if (($this->AfterSaveProcedure || isset($_POST['edit_finish'])) && (isset($this->deptabs->config))){
+ /* Check tabs, will feed message array */
+ $message= $this->deptabs->check();
- /***************
- In case of tagging/moving the object wasn't deleted, do it know
- ***************/
+ /* Save, or display error message? */
+ if (count($message) == 0){
- /* If there is an unsaved object and all operations are done
- remove locks & save object tab & unset current object */
- if($this->ObjectInSaveMode && (!$this->RecursiveRemoveRequested) && (!$this->ObjectTaggingRequested)){
- $this->deptabs->save();
- $this->ObjectInSaveMode = false;
- if ($this->dn != "new"){
- del_lock ($this->dn);
+ /* Save current changes */
+ if(!$this->AfterSaveProcedure){
+ $this->deptabs->save(true);
+ }
+
+ /* Check if we have to tag this department */
+ if($this->deptabs->by_object['department']->must_be_tagged){
+ $this->AfterSaveProcedure = true;
+ $this->deptabs->by_object['department']->must_be_tagged = false;
+ return($this->deptabs->by_object['department']->ShowTagFrame());
+ }
+
+ /* Saving and tagging, is done now, lets move the dep if required */
+ if($this->deptabs->by_object['department']->MustBeMoved){
+ $this->AfterSaveProcedure = true;
+ $this->deptabs->by_object['department']->MustBeMoved = false;
+ return($this->deptabs->by_object['department']->ShowMoveFrame());
+ }
+
+ if ($this->dn != "new"){
+ del_lock ($this->dn);
+ }
+ gosa_log ("Department object'".$this->dn."' has been saved");
+ unset ($this->deptabs);
+ $this->deptabs= NULL;
+ $this->AfterSaveProcedure = false;
+ unset ($_SESSION['objectinfo']);
+ } else {
+ /* Ok. There seem to be errors regarding to the tab data,
+ show message and continue as usual. */
+ show_errors($message);
}
- gosa_log ("Department object'".$this->dn."' has been saved");
- unset ($this->deptabs);
- $this->deptabs= NULL;
- unset ($_SESSION['objectinfo']);
}
diff --git a/plugins/admin/departments/tabs_department.inc b/plugins/admin/departments/tabs_department.inc
index e1b7b98d0684c1eac510e48a6fac2e5d665f954f..deccb02c48f732e3ffea8468f18590d76b0d116e 100644 (file)
class deptabs extends tabs
{
- var $base= "";
+ var $base = "";
function deptabs($config, $data, $dn)
{
}
- function save($justsave = false)
+ /* Save all changes (generic tab will do our tagging)
+ if source dn != destination dn then MustBeMoved will be set */
+ function save()
{
- $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);
- $this->by_object['department'] = $baseobject;
- return;
- }
+ $baseobject = $this->by_object['department'];
+
+ $ou = preg_replace('/,/', '\,', $baseobject->ou);
+ $new_dn = @LDAP::convert('ou='.$ou.','.$baseobject->base);
+
+ /* If dn has changed move dep & sub entries */
+ 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{
+ $this->by_object['department']->MustBeMoved = true;
+ $this->by_object['department']->MoveDestination = $new_dn;
+ $this->by_object['department']->MoveSource = $this->dn;
+ $this->by_object['department']->MoveOu = $ou;
+ $this->dn = $this->dn;
+ $baseobject->dn = $this->dn;
+ $this->by_object['department']->ou = $baseobject->attrs['ou'][0];
+ $this->by_object['department'] = $baseobject;
+ return(tabs::save(TRUE));
}
}else{
$this->dn= $new_dn;
+ $baseobject->dn= $this->dn;
+ $this->by_object['department']= $baseobject;
return(tabs::save(TRUE));
}
}
-
}
-// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
-?>
+ // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+ ?>