From d0917227ce935dd4a16d5157fdb7f7e2d92d847b Mon Sep 17 00:00:00 2001 From: hickert Date: Wed, 27 Jan 2010 09:01:59 +0000 Subject: [PATCH] Updated role generic -use new style lists to add elements git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@15351 594d385d-05f5-0310-b6e9-bd551577e9d8 --- .../roleManagement/class_occupantSelect.inc | 163 ------------------ .../roleManagement/class_roleGeneric.inc | 33 ++-- .../admin/roleManagement/occupantSelect.tpl | 49 ------ 3 files changed, 19 insertions(+), 226 deletions(-) delete mode 100644 gosa-plugins/rolemanagement/admin/roleManagement/class_occupantSelect.inc delete mode 100644 gosa-plugins/rolemanagement/admin/roleManagement/occupantSelect.tpl diff --git a/gosa-plugins/rolemanagement/admin/roleManagement/class_occupantSelect.inc b/gosa-plugins/rolemanagement/admin/roleManagement/class_occupantSelect.inc deleted file mode 100644 index 7fc690e9f..000000000 --- a/gosa-plugins/rolemanagement/admin/roleManagement/class_occupantSelect.inc +++ /dev/null @@ -1,163 +0,0 @@ -config = $config; - $this->dn = $dn; - $this->parent = $parent; - $this->skipEntries = $parent->getOccupants(); - - /* Get global filter config */ - if (!session::is_set("roleAddOccupantFilter")){ - $ui= get_userinfo(); - $base= get_base_from_people($ui->dn); - $roleAddOccupantFilter= array( - "dselect" => $base, - "subtrees" => FALSE, - "regex" => "*"); - session::set("roleAddOccupantFilter", $roleAddOccupantFilter); - } - - } - - - function execute() - { - /* Save data */ - $roleAddOccupantFilter= session::get("roleAddOccupantFilter"); - if(isset($_POST['occupantSearched'])){ - - $roleAddOccupantFilter['subtrees'] = false; - if(isset($_POST['subtrees'])){ - $roleAddOccupantFilter['subtrees'] = "checked"; - } - - foreach( array("dselect", "regex") as $type){ - if (isset($_POST[$type])){ - $roleAddOccupantFilter[$type]= $_POST[$type]; - } - } - } - if (isset($_GET['search'])){ - $s= mb_substr($_GET['search'], 0, 1, "UTF8")."*"; - if ($s == "**"){ - $s= "*"; - } - $roleAddOccupantFilter['regex']= $s; - } - session::set("roleAddOccupantFilter", $roleAddOccupantFilter); - - $smarty = get_smarty(); - $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()); - $smarty->assign("hint", print_sizelimit_warning()); - $smarty->assign("apply", apply_filter()); - $smarty->assign("objects", $this->getObjects()); - foreach( array("dselect", "regex", "subtrees") as $type){ - $smarty->assign("$type", $roleAddOccupantFilter[$type]); - } - return($smarty->fetch(get_template_path("occupantSelect.tpl",TRUE, dirname(__FILE__)))); - } - - - function getObjects() - { - - // Initialize variables - $ldap = $this->config->get_ldap_link(); - $roleAddOccupantFilter= session::get("roleAddOccupantFilter"); - $regex = $roleAddOccupantFilter['regex']; - - // Detect the base to be use for ldap search - if($roleAddOccupantFilter['subtrees']){ - $base = $roleAddOccupantFilter['dselect']; - }else{ - $base = get_people_ou().$roleAddOccupantFilter['dselect']; - } - - // Set search flags flat/subsearch - $Get_list_flags = 0; - if($roleAddOccupantFilter['subtrees'] == "checked"){ - $Get_list_flags |= GL_SUBSEARCH; - } - - // Search for matching user objects. - $filter = "(&(objectClass=gosaAccount)(!(uid=*$))(|(uid=$regex)(cn=$regex)))"; - $res = get_list($filter, "users/user" , $base, - array("description", "objectClass", "sn", "givenName", "uid","cn"),$Get_list_flags); - - // Collect data. - $this->objects = array(); - foreach($res as $attrs){ - - // Skip entries which are already part of our role - if(in_array($attrs['dn'], $this->skipEntries)) continue; - - $name = $attrs['cn'][0]; - $dn = $attrs['dn']; - if (isset($attrs["description"][0])){ - $name .= " [".$attrs["description"][0]."]"; - } - - $entry = array(); - $entry['attrs'] = $attrs; - $entry['name'] = $name; - $entry['dn'] = $dn; - $this->objects[] = $entry; - } - uksort ($this->objects, 'strnatcasecmp'); - reset ($this->objects); - - // Create HTML content - $temp = ""; - foreach ($this->objects as $key => $value){ - $temp.= " - \n"; - } - return ($temp); - } - - - function save() - { - $ret = array(); - if(isset($_POST['objects'])){ - $objects = $_POST['objects']; - foreach($objects as $id){ - $ret[] = $this->objects[$id]; - } - } - return($ret); - } -} - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/gosa-plugins/rolemanagement/admin/roleManagement/class_roleGeneric.inc b/gosa-plugins/rolemanagement/admin/roleManagement/class_roleGeneric.inc index f4b821b99..b27fef306 100644 --- a/gosa-plugins/rolemanagement/admin/roleManagement/class_roleGeneric.inc +++ b/gosa-plugins/rolemanagement/admin/roleManagement/class_roleGeneric.inc @@ -140,10 +140,10 @@ class roleGeneric extends plugin { * Dialog handling ***************/ - if(isset($_POST['edit_membership']) && !$this->dialog instanceOf plugin){ - $this->dialog = new occupantSelect($this->config,$this->dn,$this); + if(isset($_POST['edit_membership']) && !$this->dialog instanceOf userSelect){ + $this->dialog = new userSelect($this->config,get_userinfo()); } - if(isset($_POST['delete_membership']) && !$this->dialog instanceOf plugin){ + if(isset($_POST['delete_membership']) && !$this->dialog instanceOf userSelect){ if(isset($_POST['members'])){ foreach($_POST['members'] as $id){ if(isset($this->roleOccupant[$id])){ @@ -154,21 +154,26 @@ class roleGeneric extends plugin { } } - if(isset($_POST['add_object_cancel']) && $this->dialog instanceOf plugin){ + if(isset($_POST['add_users_cancel']) && $this->dialog instanceOf userSelect){ $this->dialog = NULL; } - if(isset($_POST['add_object_finish']) && $this->dialog instanceOf plugin){ - $ret = $this->dialog->save(); - foreach($ret as $key => $entry){ - $this->roleOccupant[] = $entry['dn']; - $this->roleOccCache[$entry['dn']] = $entry['attrs']; - } - $this->reload(); - $this->dialog = NULL; + if(isset($_POST['add_users_finish']) && $this->dialog instanceOf userSelect){ + $users = $this->dialog->detectPostActions(); + if(isset($users['targets'])){ + $headpage = $this->dialog->getHeadpage(); + foreach($users['targets'] as $dn){ + $attrs = $headpage->getEntry($dn); + $this->roleOccupant[] = $dn; + $this->roleOccCache[$dn] = $attrs; + } + } + $this->dialog= FALSE; } - if($this->dialog instanceOf plugin){ - $this->dialog->save_object(); + if($this->dialog instanceOf userSelect){ + + // Build up blocklist + session::set('filterBlacklist', array('dn' => $this->roleOccupant)); return($this->dialog->execute()); } diff --git a/gosa-plugins/rolemanagement/admin/roleManagement/occupantSelect.tpl b/gosa-plugins/rolemanagement/admin/roleManagement/occupantSelect.tpl deleted file mode 100644 index c34e29731..000000000 --- a/gosa-plugins/rolemanagement/admin/roleManagement/occupantSelect.tpl +++ /dev/null @@ -1,49 +0,0 @@ - - - - - -
-
-

- {t}Select objects to add{/t} {$hint} -

-
-
-

- - -

-
-
-
-

[F]{t}Filters{/t}

-
-
- - {$alphabet} -
-

- {t}Search in subtrees{/t}
-

- -
  -
- -
- {$apply} -
-
- - - -

- -   - -

- -- 2.30.2