From: hickert Date: Thu, 28 Jan 2010 09:31:39 +0000 (+0000) Subject: Updated ogroup entry selection X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=35a3f3b0dd61ef0cbe6c994853953c5ff921315b;p=gosa.git Updated ogroup entry selection git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@15397 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/gosa-core/plugins/admin/ogroups/class_ogroup.inc b/gosa-core/plugins/admin/ogroups/class_ogroup.inc index 995c51670..32bbecd37 100644 --- a/gosa-core/plugins/admin/ogroups/class_ogroup.inc +++ b/gosa-core/plugins/admin/ogroups/class_ogroup.inc @@ -50,7 +50,7 @@ class ogroup extends plugin var $orig_dn= ""; var $orig_cn= ""; var $orig_base= ""; - var $group_dialog= FALSE; + var $objectSelect= FALSE; var $view_logged = FALSE; var $accessTo= array(); @@ -208,8 +208,13 @@ class ogroup extends plugin } /* Add objects to group */ - if (isset($_POST['add_object_finish']) && isset($_POST['objects'])){ + if (isset($_POST['objectSelect_save'])){ + $objects = $this->objectSelect->save(); + print_a($objects); + $this->objectSelect= FALSE; + $this->dialog= FALSE; + return; $tmp = ""; foreach($this->memberList as $obj){ $tmp .= $obj['type']; @@ -350,117 +355,19 @@ class ogroup extends plugin /* Add objects? */ if (isset($_POST["edit_membership"])){ - $this->group_dialog= TRUE; + $this->objectSelect= new objectSelect($this->config, get_userinfo()); $this->dialog= TRUE; } /* Add objects finished? */ - if (isset($_POST["add_object_finish"]) || isset($_POST["add_object_cancel"])){ - $this->group_dialog= FALSE; + if (isset($_POST["objectSelect_cancel"])){ + $this->objectSelect= FALSE; $this->dialog= FALSE; } /* Manage object add dialog */ - if ($this->group_dialog){ - - /* Save data */ - $ogfilter= session::get("ogfilter"); - foreach( array("dselect", "regex") as $type){ - if (isset($_POST[$type])){ - $ogfilter[$type]= $_POST[$type]; - } - } - if (isset($_POST['dselect'])){ - foreach( array("accounts", "groups", "applications", "departments", - "servers", "workstations", "winstations", "terminals", "printers","subtrees", - "phones") as $type){ - - if (isset($_POST[$type])) { - $ogfilter[$type]= "checked"; - } else { - $ogfilter[$type]= ""; - } - } - } - if (isset($_GET['search'])){ - $s= mb_substr($_GET['search'], 0, 1, "UTF8")."*"; - if ($s == "**"){ - $s= "*"; - } - $ogfilter['regex']= $s; - } - session::set("ogfilter", $ogfilter); - $this->reload(); - - /* Calculate actual groups / remove entries that are already inside... */ - $strippedObjects= array(); - foreach ($this->objects as $key => $value){ - if (!isset($this->member[$key])){ - $strippedObjects[$key]= $value; - } - } - $smarty->assign("objects", $this->convert_list($strippedObjects)); - - /* Show dialog */ - $smarty->assign("search_image", get_template_path('images/lists/search.png')); - $smarty->assign("launchimage", get_template_path('images/lists/action.png')); - $smarty->assign("tree_image", get_template_path('images/lists/search-subtree.png')); - $smarty->assign("deplist", $this->config->idepartments); - $smarty->assign("alphabet", generate_alphabet()); - foreach( array("dselect", "regex", "subtrees") as $type){ - $smarty->assign("$type", $ogfilter[$type]); - } - $smarty->assign("hint", print_sizelimit_warning()); - $smarty->assign("apply", apply_filter()); - - /* Build up checkboxes - */ - $ar = array( - "departments" => array( - "T" => msgPool::selectToView(_("departments")), - "C" => (isset($ogfilter['departments']) && ($ogfilter['departments'])), - "L" => sprintf(_("Show %s"),_("departments"))), - "accounts" => array( - "T" => msgPool::selectToView(_("people")), - "C" => (isset($ogfilter['accounts']) && ($ogfilter['accounts'])), - "L" => sprintf(_("Show %s"),_("people"))), - "groups"=> array( - "T" => msgPool::selectToView(_("groups")), - "C" => (isset($ogfilter['groups']) && ($ogfilter['groups'])), - "L" => sprintf(_("Show %s"),_("groups"))), - "servers"=> array( - "T" => msgPool::selectToView(_("servers")), - "C" => (isset($ogfilter['servers']) && ($ogfilter['servers'])), - "L" => sprintf(_("Show %s"),_("servers"))), - "workstations"=> array( - "T" => msgPool::selectToView(_("workstations")), - "C" => (isset($ogfilter['workstations']) && ($ogfilter['workstations'])), - "L" => sprintf(_("Show %s"),_("workstations"))), - "terminals"=> array( - "T" => msgPool::selectToView(_("terminals")), - "C" => (isset($ogfilter['terminals']) && ($ogfilter['terminals'])), - "L" => sprintf(_("Show %s"),_("terminals"))), - "printers"=> array( - "T" => msgPool::selectToView(_("printer")), - "C" => (isset($ogfilter['printers']) && ($ogfilter['printers'])), - "L" => sprintf(_("Show %s"),_("printers"))), - "phones"=> array( - "T" => msgPool::selectToView(_("phones")), - "C" => (isset($ogfilter['phones']) && ($ogfilter['phones'])), - "L" => sprintf(_("Show %s"),_("phones")))); - - /* Allow selecting applications if we are having a non - release managed application storage */ - if(!$this->IsReleaseManagementActivated()){ - $ar["applications"] = array( - "T" => msgPool::selectToView(_("applications")), - "C" => (isset($ogfilter['applications']) && ($ogfilter['applications'])), - "L" => sprintf(_("Show %s"),_("applications"))); - } - - $smarty->assign("checkboxes",$ar); - $display= $smarty->fetch (get_template_path('ogroup_objects.tpl', TRUE, dirname(__FILE__))); - return ($display); + if ($this->objectSelect){ + return($this->objectSelect->execute()); } /* Bases / Departments */ diff --git a/gosa-core/plugins/admin/ogroups/objectSelect/class_filterLDAPDepartmentBlacklist.inc b/gosa-core/plugins/admin/ogroups/objectSelect/class_filterLDAPDepartmentBlacklist.inc new file mode 100644 index 000000000..422fc1f38 --- /dev/null +++ b/gosa-core/plugins/admin/ogroups/objectSelect/class_filterLDAPDepartmentBlacklist.inc @@ -0,0 +1,17 @@ + $entry){ + $entries[$key]['cn'] = $entry['ou']; + $entries[$key][ $entries[$key]['count'] ]= 'cn'; + $entries[$key]['count'] ++; + } + return($entries); + } +} + +?> diff --git a/gosa-core/plugins/admin/ogroups/objectSelect/class_objectSelect.inc b/gosa-core/plugins/admin/ogroups/objectSelect/class_objectSelect.inc index e90676e28..13163d5a7 100644 --- a/gosa-core/plugins/admin/ogroups/objectSelect/class_objectSelect.inc +++ b/gosa-core/plugins/admin/ogroups/objectSelect/class_objectSelect.inc @@ -50,10 +50,35 @@ class objectSelect extends management // Build headpage $headpage = new listing(get_template_path("selectObject-list.xml", true, dirname(__FILE__))); + $headpage->registerElementFilter("depLabel", "objectSelect::filterDepLabel"); + $this->registerAction("open","openEntry"); $headpage->setFilter($filter); parent::__construct($config, $ui, "object", $headpage); } + + // An action handler which enables to switch into deparmtment by clicking the names. + function openEntry($action,$entry) + { + $headpage = $this->getHeadpage(); + $headpage->setBase(array_pop($entry)); + } + + + // A filter which allows to open a department by clicking on the departments name. + static function filterDepLabel($row,$dn,$pid,$base,$objectClass, $cn) + { + $cn = $cn[0]; + if(!in_array('gosaDepartment', $objectClass)){ + return($cn); + } + if($dn == $base){ + $cn ="."; + } + $dn= LDAP::fix(func_get_arg(1)); + return("$cn"); + } + function save() { $act = $this->detectPostActions(); diff --git a/gosa-core/plugins/admin/ogroups/objectSelect/selectObject-filter.xml b/gosa-core/plugins/admin/ogroups/objectSelect/selectObject-filter.xml index be500d5ce..69e2ced02 100644 --- a/gosa-core/plugins/admin/ogroups/objectSelect/selectObject-filter.xml +++ b/gosa-core/plugins/admin/ogroups/objectSelect/selectObject-filter.xml @@ -15,6 +15,7 @@ objectClass cn sn + ou uid givenName description @@ -26,6 +27,7 @@ objectClass cn sn + ou uid givenName description diff --git a/gosa-core/plugins/admin/ogroups/objectSelect/selectObject-list.xml b/gosa-core/plugins/admin/ogroups/objectSelect/selectObject-list.xml index 27e68d887..dca51a590 100644 --- a/gosa-core/plugins/admin/ogroups/objectSelect/selectObject-list.xml +++ b/gosa-core/plugins/admin/ogroups/objectSelect/selectObject-list.xml @@ -2,7 +2,7 @@ - true + false false true true @@ -97,7 +97,7 @@ cn string - %{cn} + %{filter:depLabel(row,dn,pid,base,objectClass,cn)} true