From 9b78e6e88570d861b5049267639d19f4a431091c Mon Sep 17 00:00:00 2001 From: hickert Date: Tue, 19 Sep 2006 04:47:34 +0000 Subject: [PATCH] Added new base method git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@4717 594d385d-05f5-0310-b6e9-bd551577e9d8 --- include/class_plugin.inc | 36 +++++++++++++++++++ .../applications/class_applicationGeneric.inc | 4 +-- .../departments/class_departmentGeneric.inc | 12 ++----- plugins/admin/groups/class_groupGeneric.inc | 22 ++---------- .../admin/mimetypes/class_mimetypeGeneric.inc | 4 +-- plugins/admin/ogroups/class_ogroup.inc | 13 ++----- plugins/personal/generic/class_user.inc | 17 +-------- plugins/personal/generic/main.inc | 2 +- 8 files changed, 49 insertions(+), 61 deletions(-) diff --git a/include/class_plugin.inc b/include/class_plugin.inc index 239e89fc5..72994996b 100644 --- a/include/class_plugin.inc +++ b/include/class_plugin.inc @@ -1465,6 +1465,42 @@ echo "FIXME: remove_snapshot uses old acl's
"; return $ui->get_permissions($this->acl_base, $this->acl_category.get_class($this), $attribute,$skip_write); } + /* Get all allowed bases to move an object to or to create a new object. + Idepartments also contains all base departments which lead to the allowed bases */ + function acl_get_bases($category = "") + { + $ui = get_userinfo(); + $deps = array(); + + /* Set category */ + if(empty($category)){ + $category = $this->acl_category.get_class($this); + } + + /* Is this a new object ? Or just an edited existing object */ + if(!$this->initially_was_account && $this->is_account){ + $new = true; + }else{ + $new = false; + } + + /* Add current base */ + if(isset($this->base) && isset($this->config->idepartments[$this->base])){ + $deps[$this->base] = $this->config->idepartments[$this->base]; + }else{ + echo "No default base found.
"; + } + + foreach($this->config->idepartments as $dn => $name){ + $acl = $ui->get_permissions($dn,$category); + if($new && preg_match("/c/",$acl)){ + $deps[$dn] = $name; + }elseif(!$new && preg_match("/m/",$acl)){ + $deps[$dn] = $name; + } + } + return($deps); + } } // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: diff --git a/plugins/admin/applications/class_applicationGeneric.inc b/plugins/admin/applications/class_applicationGeneric.inc index 21c7de461..68b2ac8f5 100644 --- a/plugins/admin/applications/class_applicationGeneric.inc +++ b/plugins/admin/applications/class_applicationGeneric.inc @@ -154,7 +154,7 @@ class application extends plugin /* Fill templating stuff */ $smarty->assign("cn", $this->cn); - $smarty->assign("bases", $this->config->idepartments); + $smarty->assign("bases", $this->acl_get_bases()); if ($this->dn == "new"){ $smarty->assign("selectmode", ""); $smarty->assign("namemode", ""); @@ -168,7 +168,7 @@ class application extends plugin foreach($_POST as $name => $value){ if(preg_match("/^chooseBase/",$name) && $once){ $once = false; - $this->dialog = new baseSelectDialog($this->config,$this); + $this->dialog = new baseSelectDialog($this->config,$this,$this->acl_get_bases()); $this->dialog->setCurrentBase($this->base); } } diff --git a/plugins/admin/departments/class_departmentGeneric.inc b/plugins/admin/departments/class_departmentGeneric.inc index 8bda16997..a29b3edc4 100644 --- a/plugins/admin/departments/class_departmentGeneric.inc +++ b/plugins/admin/departments/class_departmentGeneric.inc @@ -101,21 +101,12 @@ class department extends plugin $smarty->assign($name."ACL",$this->getacl($name)); } - /* Get bases */ - $ui = get_userinfo(); - $check = $ui->get_module_departments("department"); - $check[] = $this->base; - $bases = array(); - foreach($check as $dn_allowed){ - $bases[$dn_allowed] = $this->config->idepartments[$dn_allowed]; - } - /* 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,$bases); + $this->dialog = new baseSelectDialog($this->config,$this,$this->acl_get_bases()); $this->dialog->setCurrentBase($this->base); } } @@ -136,6 +127,7 @@ class department extends plugin } /* Hide all departments, that are subtrees of this department */ + $bases = $this->acl_get_bases(); if(($this->dn == "new")||($this->dn == "")){ $tmp = $bases; }else{ diff --git a/plugins/admin/groups/class_groupGeneric.inc b/plugins/admin/groups/class_groupGeneric.inc index c7c47dd85..ef5341b24 100644 --- a/plugins/admin/groups/class_groupGeneric.inc +++ b/plugins/admin/groups/class_groupGeneric.inc @@ -205,21 +205,13 @@ class group extends plugin $this->reload(); } - /* Get bases */ - $ui = get_userinfo(); - $check = $ui->get_module_departments("groups"); - $bases = array(); - foreach($check as $dn_allowed){ - $bases[$dn_allowed] = $this->config->idepartments[$dn_allowed]; - } - /* 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,$bases); + $this->dialog = new baseSelectDialog($this->config,$this,$this->acl_get_bases()); $this->dialog->setCurrentBase($this->base); } } @@ -301,15 +293,7 @@ class group extends plugin $smarty->assign("launchimage", get_template_path('images/small_filter.png')); $smarty->assign("tree_image", get_template_path('images/tree.png')); - /* Get bases */ - $ui = get_userinfo(); - $check = $ui->get_module_departments("groups"); - $bases = array(); - foreach($check as $dn_allowed){ - $bases[$dn_allowed] = $this->config->idepartments[$dn_allowed]; - } - - $smarty->assign("deplist", $bases_user_select); + $smarty->assign("deplist", $this->acl_get_bases("users/user")); $smarty->assign("alphabet", generate_alphabet()); foreach( array("dselect", "regex","SubSearchGroup") as $type){ $smarty->assign("$type", $gufilter[$type]); @@ -326,7 +310,7 @@ class group extends plugin $this->base= $_POST['base']; } - $smarty->assign("bases", $bases); + $smarty->assign("bases", $this->acl_get_bases()); $smarty->assign("base_select", $this->base); if ($this->samba3){ diff --git a/plugins/admin/mimetypes/class_mimetypeGeneric.inc b/plugins/admin/mimetypes/class_mimetypeGeneric.inc index cdadb5be2..37d45ca79 100644 --- a/plugins/admin/mimetypes/class_mimetypeGeneric.inc +++ b/plugins/admin/mimetypes/class_mimetypeGeneric.inc @@ -165,7 +165,7 @@ class mimetype extends plugin foreach($_POST as $name => $value){ if(preg_match("/^chooseBase/",$name) && $once){ $once = false; - $this->dialog = new baseSelectDialog($this->config,$this); + $this->dialog = new baseSelectDialog($this->config,$this,$this->acl_get_bases()); echo $this->base; $this->dialog->setCurrentBase($this->base); } @@ -313,7 +313,7 @@ class mimetype extends plugin $fields = array($field1,$field2); $DivEApps -> AddEntry($fields); } - $smarty->assign("bases", $this->config->idepartments); + $smarty->assign("bases", $this->acl_get_bases()); $smarty->assign("base_select", $this->base); $smarty->assign("isReleaseMimeType", $this->isReleaseMimeType); $smarty->assign("gotoMimeFilePatterns", $DivPatterns->DrawList()); diff --git a/plugins/admin/ogroups/class_ogroup.inc b/plugins/admin/ogroups/class_ogroup.inc index 6add55443..f619d71f9 100644 --- a/plugins/admin/ogroups/class_ogroup.inc +++ b/plugins/admin/ogroups/class_ogroup.inc @@ -182,21 +182,12 @@ class ogroup extends plugin } $smarty->assign("baseACL", $baseACL); - - /* Get bases */ - $ui = get_userinfo(); - $check = $ui->get_module_departments("ogroups"); - $bases = array(); - foreach($check as $dn_allowed){ - $bases[$dn_allowed] = $this->config->idepartments[$dn_allowed]; - } - /* 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,$bases); + $this->dialog = new baseSelectDialog($this->config,$this,$this->acl_get_bases()); $this->dialog->setCurrentBase($this->base); } } @@ -315,7 +306,7 @@ class ogroup extends plugin } /* Assign variables */ - $smarty->assign("bases", $bases); + $smarty->assign("bases", $this->acl_get_bases()); $smarty->assign("base_select", $this->base); $smarty->assign("department", $this->department); $smarty->assign("members", $this->convert_list($this->memberList)); diff --git a/plugins/personal/generic/class_user.inc b/plugins/personal/generic/class_user.inc index df0c7c983..117b015d9 100644 --- a/plugins/personal/generic/class_user.inc +++ b/plugins/personal/generic/class_user.inc @@ -1230,22 +1230,7 @@ class user extends plugin function allowedBasesToMoveTo() { /* Get bases */ - $ui = get_userinfo(); - $check = $ui->get_module_departments("ogroups"); - $bases = array(); - - foreach($check as $dn_allowed){ - $bases[$dn_allowed] = $this->config->idepartments[$dn_allowed]; - } - - foreach($bases as $key => $base ){ - $acl = $ui->get_permissions($key,"users/user"); - - /* Remove those bases, which are not allowed to move to, but keep current base ... */ - if(!preg_match("/m/",$acl) && $key != $this->base){ - unset($bases[$key]); - } - } + $bases = $this->acl_get_bases(); return($bases); } diff --git a/plugins/personal/generic/main.inc b/plugins/personal/generic/main.inc index 729d9d5c1..ef1fa7c71 100644 --- a/plugins/personal/generic/main.inc +++ b/plugins/personal/generic/main.inc @@ -141,7 +141,7 @@ if (!$remove_lock){ $info = ""; /* Show page footer depending on the mode */ - if (!$user->cert_dialog && !$user->picture_dialog && $user->is_account){ + if (!$user->cert_dialog && !$user->picture_dialog && !$user->dialog && $user->is_account){ $display.= "

"; /* Are we in edit mode? */ -- 2.30.2