diff --git a/plugins/admin/departments/class_departmentGeneric.inc b/plugins/admin/departments/class_departmentGeneric.inc
index a540a15576b12174f6e6c6eb401ec027292b5e23..b1fd4b313884f6bf7a3843ae0fb6c71786af6107 100644 (file)
$this->config= $config;
/* Set base */
- if ($this->dn == "new"){
+ if ($this->dn == "new"){
$ui= get_userinfo();
- $this->base= dn2base($ui->dn);
+ if(isset($_SESSION['depfilter']['depselect'])){
+ $this->base = $_SESSION['depfilter']['depselect'];
+ }else{
+ $this->base= dn2base($ui->dn);
+ }
} else {
$this->base= preg_replace ("/^[^,]+,/", "", $this->dn);
}
$this->config->make_idepartments();
$smarty= get_smarty();
-
- /* Show main page */
- $smarty->assign("bases", $this->config->idepartments);
+ /* Hide all departments, that are subtrees of this department */
+ $bases = $this->config->idepartments;
+ $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);
foreach ($this->attributes as $val){
$smarty->assign("$val", $this->$val);
$smarty->assign("$val"."ACL", chkacl($this->acl, "$val"));
}
- $smarty->assign("bases", $this->config->idepartments);
$smarty->assign("base_select", $this->base);
return($smarty->fetch (get_template_path('generic.tpl', TRUE)));
}
/* Save data to object */
function save_object()
{
- plugin::save_object();
+ if (isset($_POST['base'])){
+ plugin::save_object();
- /* Save base, since this is no LDAP attribute */
- if (isset($_POST['base']) && chkacl($this->acl, "create") == ""){
- $this->base= $_POST['base'];
+ /* Save base, since this is no LDAP attribute */
+ if (chkacl($this->acl, "create") == ""){
+ $this->base= $_POST['base'];
+ }
}
}
}
/* All required fields are set? */
- if ($_POST["ou"] == ""){
+ if ($this->ou == ""){
$message[]= _("Required field 'Name' is not set.");
}
- if ($_POST["description"] == ""){
+ if ($this->description == ""){
$message[]= _("Required field 'Description' is not set.");
}
/* Validate and modify - or: spaghetti rules! */
- if ($_POST['ou'] == "incoming"){
+ if ($this->ou == "incoming"){
$message[]= _("The field 'Name' contains the reserved word 'incoming'.".
" Please choose another name.");
}
- if (preg_match ('/[,#+:=>\\\\]/', $_POST['ou'])){
+ if (preg_match ('/[,#+:=>\\\\\/]/', $this->ou)){
$message[]= _("The field 'Name' contains invalid characters.");
}
- if (!is_phone_nr($_POST['telephoneNumber'])){
+ if (!is_phone_nr($this->telephoneNumber)){
$message[]= _("The field 'Phone' contains an invalid phone number.");
}
- if (!is_phone_nr($_POST['facsimileTelephoneNumber'])){
+ if (!is_phone_nr($this->facsimileTelephoneNumber)){
$message[]= _("The field 'Fax' contains an invalid phone number.");
}