From: hickert Date: Tue, 25 Mar 2008 13:39:07 +0000 (+0000) Subject: Updated groupGeneric X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=f942718a59f4057e4501bd209008e5d2eb22b7d1;p=gosa.git Updated groupGeneric -Added trustFilter - requires code cleanup. git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@9974 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/gosa-core/plugins/admin/groups/class_groupGeneric.inc b/gosa-core/plugins/admin/groups/class_groupGeneric.inc index 703d2c0a3..2b89f0556 100644 --- a/gosa-core/plugins/admin/groups/class_groupGeneric.inc +++ b/gosa-core/plugins/admin/groups/class_groupGeneric.inc @@ -59,8 +59,12 @@ class group extends plugin var $view_logged = FALSE; var $allowGroupsWithSameNameInOtherSubtrees = true; + var $accessTo= array(); + var $trustModel= ""; + var $show_ws_dialog = FALSE; + /* attribute list for save action */ - var $attributes= array("cn", "description", "gidNumber","memberUid","sambaGroupType","sambaSID"); + var $attributes= array("cn", "description", "gidNumber","memberUid","sambaGroupType","sambaSID","accessTo","trustModel"); var $objectclasses= array("top", "posixGroup"); var $CopyPasteVars = array("force_gid","fon_group","smbgroup","groupType","sambaSID","sambaDomainName","SID","nagios_group","sambaGroupType"); @@ -186,6 +190,23 @@ class group extends plugin $this->base =preg_replace ("/^[^,]+,".normalizePreg(get_groups_ou())."/","",$this->dn); } + /* Is this account a trustAccount? */ + if (isset($this->attrs['trustModel'])){ + $this->trustModel= $this->attrs['trustModel'][0]; + $this->was_trust_account= TRUE; + } else { + $this->was_trust_account= FALSE; + $this->trustModel= ""; + } + + $this->accessTo = array(); + if (isset($this->attrs['accessTo'])){ + for ($i= 0; $i<$this->attrs['accessTo']['count']; $i++){ + $tmp= $this->attrs['accessTo'][$i]; + $this->accessTo[$tmp]= $tmp; + } + } + /* This is always an account */ $this->is_account= TRUE; $this->reload(); @@ -270,8 +291,104 @@ class group extends plugin } } - /* Assign templating stuff */ + + /* Add user workstation? */ + if (isset($_POST["add_ws"])){ + $this->show_ws_dialog= TRUE; + $this->dialog= TRUE; + } + + /* Add user workstation? */ + if (isset($_POST["add_ws_finish"]) && isset($_POST['wslist'])){ + foreach($_POST['wslist'] as $ws){ + $this->accessTo[$ws]= $ws; + } + ksort($this->accessTo); + $this->is_modified= TRUE; + } + + /* Remove user workstations? */ + if (isset($_POST["delete_ws"]) && isset($_POST['workstation_list'])){ + foreach($_POST['workstation_list'] as $name){ + unset ($this->accessTo[$name]); + } + $this->is_modified= TRUE; + } + + /* Add user workstation finished? */ + if (isset($_POST["add_ws_finish"]) || isset($_POST["add_ws_cancel"])){ + $this->show_ws_dialog= FALSE; + $this->dialog= FALSE; + } + $smarty= get_smarty(); + + /* Show ws dialog */ + if ($this->show_ws_dialog){ + + /* 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))"; + + $deps_a = array(get_ou("serverou"), + get_ou("terminalou"), + get_ou("workstationou")); + + $res= get_sub_list($filter, array("terminal","server","workstation"), $deps_a, get_ou("systemsou").$sysfilter['depselect'], array("cn"), GL_SUBSEARCH | GL_SIZELIMIT); + $wslist= array(); + foreach ($res as $attrs){ + $wslist[]= preg_replace('/\$/', '', $attrs['cn'][0]); + } + asort($wslist); + $smarty->assign("search_image", get_template_path('images/search.png')); + $smarty->assign("launchimage", get_template_path('images/small_filter.png')); + $smarty->assign("tree_image", get_template_path('images/tree.png')); + $smarty->assign("deplist", $this->config->idepartments); + $smarty->assign("alphabet", generate_alphabet()); + foreach( array("depselect", "regex") as $type){ + $smarty->assign("$type", $sysfilter[$type]); + } + $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); + } + + + + + + + + + + + + /* Assign templating stuff */ if ($this->samba3){ $smarty->assign("samba3", "true"); } else { @@ -361,6 +478,45 @@ class group extends plugin /* Members and users */ $smarty->assign("members", $this->members); + + + + + + + + + /* Work on trust modes */ + $smarty->assign("trusthide", " disabled "); + $smarty->assign("trustmodeACL", $this->getacl("trustModel")); + if ($this->trustModel == "fullaccess"){ + $trustmode= 1; + // pervent double disable tag in html code, this will disturb our clean w3c html + $smarty->assign("trustmode", $this->getacl("trustModel")); + + } elseif ($this->trustModel == "byhost"){ + $trustmode= 2; + $smarty->assign("trusthide", ""); + } else { + // pervent double disable tag in html code, this will disturb our clean w3c html + $smarty->assign("trustmode", $this->getacl("trustModel")); + $trustmode= 0; + } + $smarty->assign("trustmode", $trustmode); + $smarty->assign("trustmodes", array( 0 => _("disabled"), 1 => _("full access"), + 2 => _("allow access to these hosts"))); + + if((count($this->accessTo))==0){ + $smarty->assign("emptyArrAccess",true); + } else{ + $smarty->assign("emptyArrAccess",false); + + } + + $smarty->assign("workstations", $this->accessTo); + + + /* Checkboxes */ foreach (array("force_gid", "smbgroup") as $val){ if ($this->$val == "1"){ @@ -673,6 +829,24 @@ class group extends plugin } } } + + /* Trust mode - special handling */ + if($this->acl_is_writeable("trustModel")){ + if (isset($_POST['trustmode'])){ + $saved= $this->trustModel; + if ($_POST['trustmode'] == "1"){ + $this->trustModel= "fullaccess"; + } elseif ($_POST['trustmode'] == "2"){ + $this->trustModel= "byhost"; + } else { + $this->trustModel= ""; + } + if ($this->trustModel != $saved){ + $this->is_modified= TRUE; + } + } + } + } @@ -702,6 +876,33 @@ class group extends plugin plugin::save(); + /* Trust accounts */ + $objectclasses= array(); + foreach ($this->attrs['objectClass'] as $key => $class){ + if (preg_match('/trustAccount/i', $class)){ + continue; + } + $objectclasses[]= $this->attrs['objectClass'][$key]; + } + $this->attrs['objectClass']= $objectclasses; + if ($this->trustModel != ""){ + $this->attrs['objectClass'][]= "trustAccount"; + $this->attrs['trustModel']= $this->trustModel; + $this->attrs['accessTo']= array(); + if ($this->trustModel == "byhost"){ + foreach ($this->accessTo as $host){ + $this->attrs['accessTo'][]= $host; + } + } + } else { + if ($this->was_trust_account){ + $this->attrs['accessTo']= array(); + $this->attrs['trustModel']= array(); + } + } + + + /* Remove objectClass for samba/phone support */ $tmp= array(); for ($i= 0; $iattrs["objectClass"]); $i++){ diff --git a/gosa-core/plugins/admin/groups/generic.tpl b/gosa-core/plugins/admin/groups/generic.tpl index c287d6005..2c965ef0f 100644 --- a/gosa-core/plugins/admin/groups/generic.tpl +++ b/gosa-core/plugins/admin/groups/generic.tpl @@ -157,6 +157,41 @@ {/if} + +
+ + +
+ + + + {t}Trust mode{/t}  + {render acl=$trustmodeACL} + + {/render} + {render acl=$trustmodeACL} + + {/render} +
+ {render acl=$trustmodeACL} +   + {/render} + {render acl=$trustmodeACL} + + {/render} + + + diff --git a/gosa-core/plugins/admin/groups/trust_machines.tpl b/gosa-core/plugins/admin/groups/trust_machines.tpl new file mode 100644 index 000000000..1678dfbf7 --- /dev/null +++ b/gosa-core/plugins/admin/groups/trust_machines.tpl @@ -0,0 +1,42 @@ + + + + + +
+
+

+ {t}Select systems to add{/t} {$hint}
+

+
+
+

+ +

+
+
+
+

[F]{ +t}Filters{/t}

+
+
+ + {$alphabet} +
+ +
 {t}Display systems of department{/t}
+ +
 {t}Display systems matching{/t}
+ {$apply} +
+
+ +

+ +   + +