From ec2413db23159069935684bc98a051c9aa0f7478 Mon Sep 17 00:00:00 2001 From: cajus Date: Fri, 28 Apr 2006 10:52:03 +0000 Subject: [PATCH] Moved get_departments to class config git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@3166 594d385d-05f5-0310-b6e9-bd551577e9d8 --- html/main.php | 6 +- include/class_config.inc | 29 +++++++++ include/class_plugin.inc | 21 +++++- include/functions.inc | 28 -------- .../departments/class_departmentGeneric.inc | 65 +++++++++++++++++-- .../class_departmentManagement.inc | 2 +- plugins/admin/departments/generic.tpl | 12 ++++ 7 files changed, 125 insertions(+), 38 deletions(-) diff --git a/html/main.php b/html/main.php index 8c096eb3b..e589f9597 100644 --- a/html/main.php +++ b/html/main.php @@ -232,9 +232,11 @@ if ($_SERVER["REQUEST_METHOD"] == "POST"){ compromise between speed and beeing up to date */ if (isset($_GET['reset'])){ if (!isset($_SESSION['cached_departments'])){ - $_SESSION['cached_departments']= get_departments(); + $config->get_departments(); + $_SESSION['cached_departments']= $config->departments; + } else { + $config->departments= $_SESSION['cached_departments']; } - $config->departments= $_SESSION['cached_departments']; $config->make_idepartments (); if (isset($_SESSION['objectinfo'])){ unset ($_SESSION['objectinfo']); diff --git a/include/class_config.inc b/include/class_config.inc index bca1f5bdc..ef1c93c66 100644 --- a/include/class_config.inc +++ b/include/class_config.inc @@ -462,6 +462,35 @@ class config { } } + + function get_departments($ignore_dn= "") + { + global $config; + + /* Initialize result hash */ + $result= array(); + $result['/']= $this->current['BASE']; + + /* Get list of department objects */ + $ldap= $this->get_ldap_link(); + $ldap->cd ($this->current['BASE']); + $ldap->search ("(objectClass=gosaDepartment)", array("ou")); + while ($attrs= $ldap->fetch()){ + $dn= $ldap->getDN(); + if ($dn == $ignore_dn){ + continue; + } + + /* Only assign non-root departments */ + if ($dn != $result['/']){ + $result[convert_department_dn($dn)]= $dn; + } + } + + $this->departments= $result; + } + + function make_idepartments($max_size= 28) { global $config; diff --git a/include/class_plugin.inc b/include/class_plugin.inc index 66a191fc8..9d7de4e59 100644 --- a/include/class_plugin.inc +++ b/include/class_plugin.inc @@ -204,7 +204,9 @@ class plugin $_SESSION['LOCK_VARS_TO_USE'] =array(); } - /* remove object from parent */ + /*! \brief execute plugin + Removes object from parent + */ function remove_from_parent() { /* include global link_info */ @@ -846,6 +848,23 @@ class plugin } } + + function handle_object_tagging() + { + /* Watch out for an administrative unit below own base */ + echo "handle_object_tagging()
";
+    echo "DN  : ".$this->dn."\n";
+    echo "Base: ".$this->config->current['BASE']."\n";
+    echo "
"; + + /* Make a base search on every department */ + //FIXME: evaluate if these informations should be cached, too + #$parts= split(',', preg_replace("/,".normalizePreg($this->config->current['BASE'])."$/", '', $this->dn)); + + /* Set objectclass and attribute */ + + } + } // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: ?> diff --git a/include/functions.inc b/include/functions.inc index d93aa8909..e051a3948 100644 --- a/include/functions.inc +++ b/include/functions.inc @@ -819,34 +819,6 @@ function get_base_from_people($dn) } -function get_departments($ignore_dn= "") -{ - global $config; - - /* Initialize result hash */ - $result= array(); - $result['/']= $config->current['BASE']; - - /* Get list of department objects */ - $ldap= $config->get_ldap_link(); - $ldap->cd ($config->current['BASE']); - $ldap->search ("(objectClass=gosaDepartment)", array("ou")); - while ($attrs= $ldap->fetch()){ - $dn= $ldap->getDN(); - if ($dn == $ignore_dn){ - continue; - } - - /* Only assign non-root departments */ - if ($dn != $result['/']){ - $result[convert_department_dn($dn)]= $dn; - } - } - - return ($result); -} - - function chkacl($acl, $name) { /* Look for attribute in ACL */ diff --git a/plugins/admin/departments/class_departmentGeneric.inc b/plugins/admin/departments/class_departmentGeneric.inc index bf6b7e821..97bc429ef 100644 --- a/plugins/admin/departments/class_departmentGeneric.inc +++ b/plugins/admin/departments/class_departmentGeneric.inc @@ -31,16 +31,13 @@ class department extends plugin 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 ? - function am_i_moved() - { - return $this->rec_cpy; - } - /* Headpage attributes */ var $last_dep_sorting= "invalid"; var $departments= array(); @@ -71,10 +68,16 @@ class department extends plugin } else { $this->base= preg_replace ("/^[^,]+,/", "", $this->dn); } + /* set permissions */ $ui= get_userinfo(); $acl= get_permissions ($ui->dn, $ui->subtreeACL); $this->acl= get_module_permission($acl, "department", $ui->dn); + + /* Is administrational Unit? */ + if ($dn != "new" && in_array_ics('gosaAdministrationalUnit', $this->attrs['objectClass'])){ + $this->is_administrational_unit= true; + } } function execute() @@ -83,7 +86,7 @@ class department extends plugin plugin::execute(); /* Reload departments */ - $this->config->departments= get_departments($this->dn); + $this->config->get_departments($this->dn); $this->config->make_idepartments(); $smarty= get_smarty(); @@ -133,6 +136,15 @@ class department extends plugin $smarty->assign("$val"."ACL", chkacl($this->acl, "$val")); } $smarty->assign("base_select", $this->base); + + /* Set admin unit flag */ + if ($this->is_administrational_unit) { + $smarty->assign("unitTag", "checked"); + } else { + $smarty->assign("unitTag", ""); + } + $smarty->assign("unitTag"."ACL", chkacl($this->acl, "unitTag")); + return($smarty->fetch (get_template_path('generic.tpl', TRUE))); } @@ -169,6 +181,15 @@ class department extends plugin if (chkacl($this->acl, "create") == ""){ $this->base= $_POST['base']; } + + /* Save tagging flag */ + if (chkacl($this->acl, "unitTag") == ""){ + if (isset($_POST['unitTag'])){ + $this->is_administrational_unit= true; + } else { + $this->is_administrational_unit= false; + } + } } } @@ -224,6 +245,14 @@ class department extends plugin /* Save to LDAP */ function save() { + /* Add tag objects if needed */ + if ($this->is_administrational_unit){ + $this->objectclasses[]= "gosaAdministrationalUnit"; + $this->attributes[]= "gosaUnitTag"; + } else { + plugin::handle_object_tagging(); + } + plugin::save(); /* Write back to ldap */ @@ -231,6 +260,7 @@ class department extends plugin $ldap->cat($this->dn); $a= $ldap->fetch(); $ldap->cd($this->dn); + if (count($a)){ $this->cleanup(); $ldap->modify ($this->attrs); @@ -242,10 +272,29 @@ class department extends plugin } show_ldap_error($ldap->get_error()); + if ($this->is_administrational_unit){ + $this->tag_objects(); + } else { + $this->untag_objects(); + } + /* Optionally execute a command after we're done */ $this->postcreate(); } + + /* Tag objects to have the gosaAdministrationalUnitTag */ + function tag_objects() + { + echo "Tag"; + } + + /* Remove the gosaAdministrationalUnitTag from objects */ + function untag_objects() + { + echo "Untag"; + } + /* Move/Rename complete trees */ function recursive_move($src_dn, $dst_dn,$force = false) { @@ -339,6 +388,10 @@ class department extends plugin } } + function am_i_moved() + { + return $this->rec_cpy; + } } diff --git a/plugins/admin/departments/class_departmentManagement.inc b/plugins/admin/departments/class_departmentManagement.inc index eb5788976..c15e2a2d6 100644 --- a/plugins/admin/departments/class_departmentManagement.inc +++ b/plugins/admin/departments/class_departmentManagement.inc @@ -65,7 +65,7 @@ class departmentManagement extends plugin $_SESSION['LOCK_VARS_TO_USE'] = array("/^act$/","/^id$/","/^dep_edit_.*/","/^dep_del_.*/"); /* Reload departments */ - $this->config->departments = get_departments(); + $this->config->get_departments(); $smarty = get_smarty(); $display = ""; $depfilter = get_global("depfilter"); diff --git a/plugins/admin/departments/generic.tpl b/plugins/admin/departments/generic.tpl index ef30d12d1..620c971dd 100644 --- a/plugins/admin/departments/generic.tpl +++ b/plugins/admin/departments/generic.tpl @@ -69,6 +69,18 @@ +

 

+ + + + + +
+

{t}Administrational settings{/t}

+ + +
+