From: cajus Date: Fri, 29 Jan 2010 15:05:58 +0000 (+0000) Subject: Updated base selectors X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=2274d64c94b69218e890419926ba10548cc2d098;p=gosa.git Updated base selectors git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@15454 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/gosa-core/plugins/admin/departments/class_department.inc b/gosa-core/plugins/admin/departments/class_department.inc index 78e514f1e..35baf3a11 100644 --- a/gosa-core/plugins/admin/departments/class_department.inc +++ b/gosa-core/plugins/admin/departments/class_department.inc @@ -22,42 +22,43 @@ 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 $is_administrational_unit= false; - var $gosaUnitTag= ""; + /* department attributes */ + var $ou= ""; + var $description= ""; + var $base= ""; + var $st= ""; + var $l= ""; + var $postalAddress= ""; + var $businessCategory= ""; + var $telephoneNumber= ""; + var $facsimileTelephoneNumber= ""; + var $is_administrational_unit= false; + var $gosaUnitTag= ""; var $view_logged = FALSE; var $type ="organizationalUnit"; var $namingAttr = "ou"; - /* Headpage attributes */ - var $last_dep_sorting= "invalid"; - var $departments= array(); + /* Headpage attributes */ + var $last_dep_sorting= "invalid"; + var $departments= array(); var $must_be_tagged = false; - /* attribute list for save action */ - var $attributes= array("ou", "description", "businessCategory", "st", "l", "postalAddress", + /* attribute list for save action */ + var $attributes= array("ou", "description", "businessCategory", "st", "l", "postalAddress", "telephoneNumber", "facsimileTelephoneNumber", "gosaUnitTag"); /* Do not append the structural object classes here, they are added dynamically in the constructor */ - var $objectclasses= array("top", "gosaDepartment"); + var $objectclasses= array("top", "gosaDepartment"); var $structuralOC = array("organizationalUnit"); var $initially_was_tagged = false; var $orig_base = ""; var $orig_ou = ""; + var $baseSelector; - function department (&$config, $dn) - { + function department (&$config, $dn) + { /* Add the default structural obejct class 'locality' if this is a new entry */ $ldap = $config->get_ldap_link(); @@ -80,11 +81,11 @@ class department extends plugin } $this->objectclasses = array_unique($this->objectclasses); - plugin::plugin($config, $dn); - $this->is_account= TRUE; - $this->ui= get_userinfo(); - $this->dn= $dn; - $this->orig_dn= $dn; + plugin::plugin($config, $dn); + $this->is_account= TRUE; + $this->ui= get_userinfo(); + $this->dn= $dn; + $this->orig_dn= $dn; /* Save current naming attribuet */ @@ -92,28 +93,34 @@ class department extends plugin $orig_nA = "orig_".$nA; $this->$orig_nA = $this->$nA; - $this->config= $config; + $this->config= $config; - /* Set base */ - if ($this->dn == "new"){ - $ui= get_userinfo(); - if(session::is_set('CurrentMainBase')){ - $this->base = session::get('CurrentMainBase'); - }else{ - $this->base= dn2base($ui->dn); - } - } else { - $this->base= preg_replace ("/^[^,]+,/", "", $this->dn); - } + /* Set base */ + if ($this->dn == "new"){ + $ui= get_userinfo(); + if(session::is_set('CurrentMainBase')){ + $this->base = session::get('CurrentMainBase'); + }else{ + $this->base= dn2base($ui->dn); + } + } else { + $this->base= preg_replace ("/^[^,]+,/", "", $this->dn); + } $this->orig_base = $this->base; - /* Is administrational Unit? */ - if ($dn != "new" && in_array_ics('gosaAdministrativeUnit', $this->attrs['objectClass'])){ - $this->is_administrational_unit= true; - $this->initially_was_tagged = true; - } - } + /* Is administrational Unit? */ + if ($dn != "new" && in_array_ics('gosaAdministrativeUnit', $this->attrs['objectClass'])){ + $this->is_administrational_unit= true; + $this->initially_was_tagged = true; + } + + /* Instanciate base selector */ + $this->baseSelector= new baseSelector($this->get_allowed_bases(), $this->base); + $this->baseSelector->setSubmitButton(false); + $this->baseSelector->setHeight(300); + $this->baseSelector->update(true); + } function execute() { @@ -130,6 +137,7 @@ class department extends plugin $this->config->get_departments($this->dn); $this->config->make_idepartments(); $smarty= get_smarty(); + $smarty->assign("usePrototype", "true"); $tmp = $this->plInfo(); foreach($tmp['plProvidedAcls'] as $name => $translation){ @@ -145,56 +153,25 @@ class department extends plugin $smarty->assign($nA,$this->getacl($this->namingAttr,TRUE)); } - /* Base select dialog */ - $once = true; - foreach($_POST as $name => $value){ - if((preg_match("/^chooseBase/",$name) && $once) && ($this->acl_is_moveable())){ - $once = false; - $this->dialog = new baseSelectDialog($this->config,$this,$this->get_allowed_bases()); - $this->dialog->setCurrentBase($this->base); - } - } - - /* Dialog handling */ - if(is_object($this->dialog)){ - /* Must be called before save_object */ - $this->dialog->save_object(); - - if($this->dialog->isClosed()){ - $this->dialog = false; - }elseif($this->dialog->isSelected()){ - - /* A new base was selected, check if it is a valid one */ - $tmp = $this->get_allowed_bases(); - if(isset($tmp[$this->dialog->isSelected()])){ - $this->base = $this->dialog->isSelected(); - } - - $this->dialog= false; - }else{ - return($this->dialog->execute()); - } - } - - /* Hide all departments, that are subtrees of this department */ + /* Hide all departments, that are subtrees of this department */ $bases = $this->get_allowed_bases(); - if(($this->dn == "new")||($this->dn == "")){ - $tmp = $bases; - }else{ - $tmp = array(); - foreach($bases as $dn=>$base){ - /* Only attach departments which are not a subtree of this one */ - if(!preg_match("/".preg_quote($this->dn)."/",$dn)){ - $tmp[$dn]=$base; - } - } - } - $smarty->assign("bases", $tmp); + if(($this->dn == "new")||($this->dn == "")){ + $tmp = $bases; + }else{ + $tmp = array(); + foreach($bases as $dn=>$base){ + /* Only attach departments which are not a subtree of this one */ + if(!preg_match("/".preg_quote($this->dn)."/",$dn)){ + $tmp[$dn]=$base; + } + } + } + $this->baseSelector->setBases($tmp); - foreach ($this->attributes as $val){ - $smarty->assign("$val", $this->$val); - } - $smarty->assign("base_select", $this->base); + foreach ($this->attributes as $val){ + $smarty->assign("$val", $this->$val); + } + $smarty->assign("base", $this->baseSelector->render()); /* Set admin unit flag */ if ($this->is_administrational_unit) { @@ -252,11 +229,22 @@ class department extends plugin /* Save data to object */ function save_object() - { - if (isset($_POST['dep_generic_posted'])){ + { + /* Refresh base */ + if ($this->acl_is_moveable($this->base)){ + if (!$this->baseSelector->update()) { + msg_dialog::display(_("Error"), msgPool::permMove(), ERROR_DIALOG); + } + if ($this->base != $this->baseSelector->getBase()) { + $this->base= $this->baseSelector->getBase(); + $this->is_modified= TRUE; + } + } - $nA = $this->namingAttr; - $old_nA = $this->$nA; + if (isset($_POST['dep_generic_posted'])){ + + $nA = $this->namingAttr; + $old_nA = $this->$nA; @@ -267,14 +255,6 @@ class department extends plugin plugin::save_object(); $this->base = $base_tmp; - /* Set new base if allowed */ - $tmp = $this->get_allowed_bases(); - if(isset($_POST['base'])){ - if(isset($tmp[$_POST['base']])){ - $this->base= $_POST['base']; - } - } - /* Save tagging flag */ if ($this->acl_is_writeable("gosaUnitTag")){ if (isset($_POST['is_administrational_unit'])){ diff --git a/gosa-core/plugins/admin/departments/country.tpl b/gosa-core/plugins/admin/departments/country.tpl index 21081bc7d..eff9c73a1 100644 --- a/gosa-core/plugins/admin/departments/country.tpl +++ b/gosa-core/plugins/admin/departments/country.tpl @@ -28,13 +28,7 @@ {$must} {render acl=$baseACL} - -{/render} - -{render acl=$baseACL disable_picture='images/lists/folder_grey.png'} - + {$base} {/render} diff --git a/gosa-core/plugins/admin/departments/dcObject.tpl b/gosa-core/plugins/admin/departments/dcObject.tpl index 2a3c28540..51a6ec459 100644 --- a/gosa-core/plugins/admin/departments/dcObject.tpl +++ b/gosa-core/plugins/admin/departments/dcObject.tpl @@ -28,13 +28,7 @@ {$must} {render acl=$baseACL} - -{/render} - -{render acl=$baseACL disable_picture='images/lists/folder_grey.png'} - + {$base} {/render} diff --git a/gosa-core/plugins/admin/departments/domain.tpl b/gosa-core/plugins/admin/departments/domain.tpl index 17d4b90dd..c30170e6a 100644 --- a/gosa-core/plugins/admin/departments/domain.tpl +++ b/gosa-core/plugins/admin/departments/domain.tpl @@ -28,13 +28,7 @@ {$must} {render acl=$baseACL} - -{/render} - -{render acl=$baseACL disable_picture='images/lists/folder_grey.png'} - + {$base} {/render} diff --git a/gosa-core/plugins/admin/departments/generic.tpl b/gosa-core/plugins/admin/departments/generic.tpl index 14b997cf0..022098f82 100644 --- a/gosa-core/plugins/admin/departments/generic.tpl +++ b/gosa-core/plugins/admin/departments/generic.tpl @@ -40,13 +40,7 @@ {render acl=$baseACL} - -{/render} - -{render acl=$baseACL disable_picture='images/lists/folder_grey.png'} - + {$base} {/render} diff --git a/gosa-core/plugins/admin/departments/locality.tpl b/gosa-core/plugins/admin/departments/locality.tpl index 26d802d56..e009c37f8 100644 --- a/gosa-core/plugins/admin/departments/locality.tpl +++ b/gosa-core/plugins/admin/departments/locality.tpl @@ -28,13 +28,7 @@ {$must} {render acl=$baseACL} - -{/render} - -{render acl=$baseACL disable_picture='images/lists/folder_grey.png'} - + {$base} {/render} diff --git a/gosa-core/plugins/admin/departments/organization.tpl b/gosa-core/plugins/admin/departments/organization.tpl index 67ceee88d..e7c825ce4 100644 --- a/gosa-core/plugins/admin/departments/organization.tpl +++ b/gosa-core/plugins/admin/departments/organization.tpl @@ -40,13 +40,7 @@ {render acl=$baseACL} - -{/render} - -{render acl=$baseACL disable_picture='images/lists/folder_grey.png'} - + {$base} {/render} diff --git a/gosa-core/plugins/admin/groups/class_group.inc b/gosa-core/plugins/admin/groups/class_group.inc index a2519c1c3..456eb4c25 100644 --- a/gosa-core/plugins/admin/groups/class_group.inc +++ b/gosa-core/plugins/admin/groups/class_group.inc @@ -291,17 +291,6 @@ class group extends plugin $this->dialog= FALSE; } - /* Base select dialog */ - $once = true; - foreach($_POST as $name => $value){ - if((preg_match("/^chooseBase/",$name) && $once) && $this->acl_is_writeable("base")){ - - $once = false; - $this->dialog = new baseSelectDialog($this->config,$this,$this->get_allowed_bases()); - $this->dialog->setCurrentBase($this->base); - } - } - /* Dialog handling */ if(is_object($this->dialog)){ /* Must be called before save_object */ diff --git a/gosa-core/plugins/admin/ogroups/class_ogroup.inc b/gosa-core/plugins/admin/ogroups/class_ogroup.inc index d6ff10d0a..5c51363c5 100644 --- a/gosa-core/plugins/admin/ogroups/class_ogroup.inc +++ b/gosa-core/plugins/admin/ogroups/class_ogroup.inc @@ -286,16 +286,6 @@ class ogroup extends plugin $smarty->assign($name."ACL",$this->getacl($name)); } - /* Base select dialog */ - $once = true; - foreach($_POST as $name => $value){ - if(preg_match("/^chooseBase/",$name) && $once && $this->acl_is_moveable()){ - $once = false; - $this->dialog = new baseSelectDialog($this->config,$this,$this->get_allowed_bases()); - $this->dialog->setCurrentBase($this->base); - } - } - /*********** * Trusts ***********/ @@ -513,7 +503,12 @@ class ogroup extends plugin Ende Trust account ******/ + /* Create a base backup and reset the + base directly after calling plugin::save_object(); + Base will be set seperatly a few lines below */ + $base_tmp = $this->base; plugin::save_object(); + $this->base = $base_tmp; } } diff --git a/gosa-core/plugins/personal/generic/class_user.inc b/gosa-core/plugins/personal/generic/class_user.inc index 7c3d54846..aec8e0340 100644 --- a/gosa-core/plugins/personal/generic/class_user.inc +++ b/gosa-core/plugins/personal/generic/class_user.inc @@ -308,16 +308,6 @@ class user extends plugin return($str); } - /* Base select dialog */ - $once = true; - foreach($_POST as $name => $value){ - if(preg_match("/^chooseBase/",$name) && $once && $this->acl_is_writeable("base")){ - $once = false; - $this->dialog = new baseSelectDialog($this->config,$this,$this->allowedBasesToMoveTo()); - $this->dialog->setCurrentBase($this->base); - } - } - /* Password configure dialog handling */ if(is_object($this->pwObject) && $this->pwObject->display){ $output= $this->pwObject->configure();