From 215064ea74de08d34180ea3f0c16132fafed0135 Mon Sep 17 00:00:00 2001 From: hickert Date: Tue, 26 Jan 2010 13:46:42 +0000 Subject: [PATCH] Added new kind of trust dialog git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@15328 594d385d-05f5-0310-b6e9-bd551577e9d8 --- .../sudo/admin/sudo/class_sudoGeneric.inc | 99 +++++-------------- 1 file changed, 24 insertions(+), 75 deletions(-) diff --git a/gosa-plugins/sudo/admin/sudo/class_sudoGeneric.inc b/gosa-plugins/sudo/admin/sudo/class_sudoGeneric.inc index 9807677d1..628da1b60 100644 --- a/gosa-plugins/sudo/admin/sudo/class_sudoGeneric.inc +++ b/gosa-plugins/sudo/admin/sudo/class_sudoGeneric.inc @@ -38,7 +38,6 @@ class sudo extends plugin protected $trustModel = ""; private $is_default = FALSE; - private $show_ws_dialog = FALSE; private $was_trust_account= FALSE; public $objectclasses = array("top","sudoRole"); @@ -48,6 +47,8 @@ class sudo extends plugin public $orig_dn; + protected $trustSelect; + /*! \brief Returns to the base department for sudo roles. This department is then used to store new roles. @param Object GOsa configuration object. @@ -129,19 +130,28 @@ class sudo extends plugin /* Add user workstation? */ if (isset($_POST["add_ws"])){ - $this->show_ws_dialog= TRUE; + $this->trustSelect= new trustSelect($this->config,get_userinfo()); $this->dialog= TRUE; } - /* Add user workstation? */ - if (isset($_POST["add_ws_finish"]) && isset($_POST['wslist'])){ - foreach($_POST['wslist'] as $ws){ - $this->accessTo[$ws]= $ws; + // Add selected machines to trusted ones. + if (isset($_POST["add_ws_finish"]) && $this->trustSelect){ + $trusts = $this->trustSelect->detectPostActions(); + if(isset($trusts['targets'])){ + + $headpage = $this->trustSelect->getHeadpage(); + foreach($trusts['targets'] as $id){ + $attrs = $headpage->getEntry($id); + $this->accessTo[$attrs['cn'][0]]= $attrs['cn'][0]; + } + ksort($this->accessTo); + $this->is_modified= TRUE; } - ksort($this->accessTo); - $this->is_modified= TRUE; + $this->trustSelect= NULL; + $this->dialog= FALSE; } + /* Remove user workstations? */ if (isset($_POST["delete_ws"]) && isset($_POST['workstation_list'])){ foreach($_POST['workstation_list'] as $name){ @@ -152,13 +162,16 @@ class sudo extends plugin /* Add user workstation finished? */ if (isset($_POST["add_ws_finish"]) || isset($_POST["add_ws_cancel"])){ - $this->show_ws_dialog= FALSE; + $this->trustSelect= NULL; $this->dialog= FALSE; } /* Show ws dialog */ - if ($this->show_ws_dialog){ - return($this->display_trust_add_dialog()); + if ($this->trustSelect){ + + // Build up blocklist + session::set('filterBlacklist', array('cn' => array_values($this->accessTo))); + return($this->trustSelect->execute()); } @@ -579,70 +592,6 @@ class sudo extends plugin } - /*! \brief Display the System Trust Add Workstation dialog - @return String HTML dialog to add a system to the trust list. - - */ - private function display_trust_add_dialog() - { - $smarty = get_smarty(); - - /* Save data */ - $sysfilter= session::get("sysfilter"); - foreach( array("depselect", "regex") as $type){ - if (isset($_POST[$type])){ - $sysfilter[$type]= $_POST[$type]; - } - } - if (isset($_GET['search'])){ - $s= mb_substr($_GET['search'], 0, 1, "UTF8")."*"; - if ($s == "**"){ - $s= "*"; - } - $sysfilter['regex']= $s; - } - session::set("sysfilter", $sysfilter); - - /* Get workstation list */ - $exclude= ""; - foreach($this->accessTo as $ws){ - $exclude.= "(cn=$ws)"; - } - if ($exclude != ""){ - $exclude= "(!(|$exclude))"; - } - $regex= $sysfilter['regex']; - $filter= "(&(|(objectClass=goServer)(objectClass=gotoWorkstation)(objectClass=gotoTerminal))$exclude(cn=*)(cn=$regex))"; - - $res = array(); - $res= array_merge($res,get_sub_list($filter, array("terminal"), get_ou("terminalRDN"), - get_ou("systemRDN").$sysfilter['depselect'], array("cn"), GL_SUBSEARCH | GL_SIZELIMIT)); - $res= array_merge($res,get_sub_list($filter, array("server"), get_ou("serverRDN"), - get_ou("systemRDN").$sysfilter['depselect'], array("cn"), GL_SUBSEARCH | GL_SIZELIMIT)); - $res= array_merge($res,get_sub_list($filter, array("workstation"), get_ou("workstationRDN"), - get_ou("systemRDN").$sysfilter['depselect'], array("cn"), GL_SUBSEARCH | GL_SIZELIMIT)); - - $wslist= array(); - foreach ($res as $attrs){ - $wslist[]= preg_replace('/\$/', '', $attrs['cn'][0]); - } - asort($wslist); - foreach( array("depselect","regex") as $type){ - $smarty->assign("$type", $sysfilter[$type]); - } - $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("wslist", $wslist); - $smarty->assign("apply", apply_filter()); - $display= $smarty->fetch (get_template_path('trust_machines.tpl', TRUE, dirname(__FILE__))); - return ($display); - } - - /*! \brief Force this entry to be handled and saved as 'default' @param BOOL TRUE -force defaults FALSE -normal */ -- 2.30.2