summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 859917c)
raw | patch | inline | side by side (parent: 859917c)
author | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Mon, 7 Apr 2008 08:08:55 +0000 (08:08 +0000) | ||
committer | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Mon, 7 Apr 2008 08:08:55 +0000 (08:08 +0000) |
-Added dialog to add systems
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@10219 594d385d-05f5-0310-b6e9-bd551577e9d8
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@10219 594d385d-05f5-0310-b6e9-bd551577e9d8
gosa-plugins/sudo/admin/sudo/class_sudoGeneric.inc | patch | blob | history | |
gosa-plugins/sudo/admin/sudo/class_target_list_systems.inc | [new file with mode: 0644] | patch | blob |
diff --git a/gosa-plugins/sudo/admin/sudo/class_sudoGeneric.inc b/gosa-plugins/sudo/admin/sudo/class_sudoGeneric.inc
index 9bb9e9c84ebf46103b405722ccc3df80605dc131..3debbed1d0e6115b12450abefe7a59345196023e 100644 (file)
var $cn= "";
var $description= "";
- var $sudoUser = array();
+ var $sudoUser = array("ALL");
var $sudoCommand= array();
- var $sudoHost = array();
- var $sudoRunas = array();
+ var $sudoHost = array("ALL");
+ var $sudoRunas = array("ALL");
var $objectclasses = array("top","sudoRole");
var $attributes = array("cn","description","sudoUser","sudoCommand","sudoHost","sudoRunas");
var $is_account = TRUE;
+ var $dialog;
+
/*! \brief Returns to the base department for sudo roles.
This department is then used to store new roles.
@param Object GOsa configuration object.
{
plugin::plugin ($config, $dn);
- foreach(array("sudoUser","sudoCommand","sudoHost","sudoRunas") as $attr){
- $this->$attr = array();
- if(isset($this->attrs[$attr])){
- $tmp = array();
- for($i = 0 ; $i < $this->attrs[$attr]['count']; $i++){
- $tmp[] = $this->attrs[$attr][$i];
+ if($this->initially_was_account){
+ foreach(array("sudoUser","sudoCommand","sudoHost","sudoRunas") as $attr){
+ $this->$attr = array();
+ if(isset($this->attrs[$attr])){
+ $tmp = array();
+ for($i = 0 ; $i < $this->attrs[$attr]['count']; $i++){
+ $tmp[] = $this->attrs[$attr][$i];
+ }
+ $this->$attr = $tmp;
}
- $this->$attr = $tmp;
}
}
{
/* Call parent execute */
plugin::execute();
+
+ /*********************
+ Add systems
+ *********************/
+
+ if(isset($_POST['list_sudoHost']) && !is_object($this->dialog)){
+ $this->dialog =new target_list_systems($this->config,array());
+ }
+
+ /* Add selected hosts to the sudoHost list */
+ if(isset($_POST['SaveMultiSelectWindow']) && is_object($this->dialog)){
+ foreach($this->dialog->list_get_selected_items() as $id){
+ $cn = trim($this->dialog->list[$id]['cn'][0]);
+ if(!in_array($cn,$this->sudoHost)){
+ $this->sudoHost[] = $cn;
+ }
+ }
+ unset($this->dialog);
+ $this->dialog = NULL;
+ }
+
+ if(isset($_POST['CloseMultiSelectWindow']) && is_object($this->dialog)){
+ unset($this->dialog);
+ $this->dialog = NULL;
+ }
+
+ if(is_object($this->dialog)){
+ return($this->dialog->execute());
+ }
/*********************
NEGATE values
function save_object()
{
plugin::save_object();
+
+ if(is_object($this->dialog)){
+ $this->dialog->save_object();
+ }
}
diff --git a/gosa-plugins/sudo/admin/sudo/class_target_list_systems.inc b/gosa-plugins/sudo/admin/sudo/class_target_list_systems.inc
--- /dev/null
@@ -0,0 +1,306 @@
+<?php
+/*
+ * This code is part of GOsa (http://www.gosa-project.org)
+ * Copyright (C) 2003-2008 GONICUS GmbH
+ *
+ * ID: $$Id: class_target_list.inc 9850 2008-03-14 14:15:12Z hickert $$
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+class target_list_systems extends MultiSelectWindow
+{
+ var $config;
+ var $list =array();
+ var $Targets_used =array();
+
+ /* Current base */
+ var $selectedBase = "";
+ var $departments = array();
+
+ /* Regex */
+ var $Regex = "*";
+
+ /* CheckBoxes, to change default values modify $this->AddCheckBox */
+ var $ogroups ;
+ var $servers ;
+ var $workstations ;
+ var $incoming ;
+
+
+ /* Subsearch checkbox */
+ var $SubSearch ;
+ var $IPMatch ;
+ var $parent ;
+ var $ui ;
+
+
+ function target_list_systems(&$config,$Targets_used)
+ {
+ MultiSelectWindow::MultiSelectWindow($config, "Targetselection", array("server","terminal","workstation"));
+
+ $this->Targets_used = $Targets_used;
+
+ $this->SetInformation( _("Select the target objects for your scheduled action."));
+ $this->SetTitle( _("Available targets"));
+ $this->SetSummary( _("Available targets"));
+ $this->SetHeadpageMode(FALSE);
+
+ /* set Page header */
+ $chk = "<input type='checkbox' id='select_all' name='select_all'
+ onClick='toggle_all_(\"^item_selected_[0-9]*$\",\"select_all\");' >";
+ $this->AddHeader(array("string"=> $chk, "attach"=>"style='width:20px;'"));
+
+ $this->AddHeader(array("string" => " ", "attach" => "style='text-align:center;width:20px;'"));
+ $this->AddHeader(array("string" => _("Object name"), "attach" => "style=''"));
+
+ /* Text ,Value, Name, Is selected */
+ $this->AddCheckBox("terminal", _("Select to see terminals"), _("Show terminals"), true);
+ $this->AddCheckBox("server", _("Select to see servers") , _("Show servers"), true);
+ $this->AddCheckBox("workstation", _("Select to see workstations"),_("Show workstations"), true);
+
+ /* Add SubSearch checkbox */
+ $this->AddCheckBox(SEPERATOR);
+ $this->AddCheckBox("SubSearch", msgPool::selectToView("","subsearch"), msgPool::selectToView("","subsearch_small"), false);
+
+ /* Name,Text,Default , Connect with alphabet */
+ $this->AddRegex ("Regex", _("Regular expression for matching group names"), "*" , true);
+ $this->EnableAplhabet(TRUE);
+ }
+
+
+ function GenHeader()
+ {
+ $options= "";
+
+ /* Get all departments within this subtree */
+ $ui= get_userinfo();
+ $first = "";
+ $found = FALSE;
+ $base = $this->config->current['BASE'];
+
+ /* Add base */
+ $tmp = array();
+ $tmp[] = array("dn"=>$this->config->current['BASE']);
+ $tmp= array_merge($tmp,get_list("(&(|(ou=*)(description=*))(objectClass=gosaDepartment))", $this->module, $base,
+ array("ou", "description"), GL_SIZELIMIT | GL_SUBSEARCH));
+
+ $deps = array();
+ foreach($tmp as $tm){
+ $deps[$tm['dn']] = $tm['dn'];
+ }
+
+ /* Load possible departments */
+ $ui= get_userinfo();
+ $tdeps= $ui->get_module_departments("ogroups");
+ $ids = $this->config->idepartments;
+ $first = "";
+ $found = FALSE;
+ foreach($ids as $dep => $name){
+ if(isset($deps[$dep]) && in_array_ics($dep, $tdeps)){
+
+ /* Keep first base dn in mind, we could need this
+ * info if no valid base was found
+ */
+ if(empty($first)) {
+ $first = $dep['dn'];
+ }
+
+ $value = $ids[$dep];
+ if ($this->selectedBase == $dep){
+ $found = TRUE;
+ $options.= "<option selected='selected' value='".$dep."'>$value</option>";
+ } else {
+ $options.= "<option value='".$dep."'>$value</option>";
+ }
+ }
+ }
+
+ /* The currently used base is not visible with your acl setup.
+ * Set base to first useable base.
+ */
+ if(!$found){
+ $this->selectedBase = $first;
+ }
+
+ /* Get copy & paste icon */
+ $acls = $ui->get_permissions($this->selectedBase,"ogroups/ogroup");
+ $acl_all= $ui->has_complete_category_acls($this->selectedBase,"ogroups");
+
+ /* Add default header */
+ $listhead = MultiSelectWindow::get_default_header();
+
+ /* Add department selector */
+ $listhead .= _("Base")." <select name='CurrentMainBase' onChange='mainform.submit()' class='center'>$options</select>".
+ " <input class='center' type='image' src='images/list_submit.png' align='middle'
+ title='"._("Submit department")."' name='submit_department' alt='"._("Submit")."'> ";
+ $listhead .="</div>";
+
+ $this->SetListHeader($listhead);
+ }
+
+
+ function execute()
+ {
+ $this->ClearElementsList();
+ $this->GenHeader();
+ $this->reload();
+ $this->SetEntries($this->list);
+ return($this->Draw());
+ }
+
+
+ function SetEntries($list)
+ {
+ /* Add Copy & Paste buttons if copy&paste is enabled
+ */
+ // Defining Links
+ $linkopen = "<a href='?plug=".$_GET['plug']."&act=dep_open&dep_id=%s'>%s</a>";
+ $editlink = "<a href='?plug=".$_GET['plug']."&id=%s&act=edit_entry'>%s</a>";
+
+ $ui = get_userinfo();
+
+ // Assigning ogroups
+ foreach($list as $key => $val){
+
+ if(in_array($val['cn'][0],$this->Targets_used) ||
+ isset($val['macAddress'][0]) && in_array($val['macAddress'][0],$this->Targets_used)) continue;
+
+ $title = "title='".preg_replace('/ /', ' ', @LDAP::fix($val['dn']))."'";
+ if(!isset($val['description'][0])){
+ $desc = "";
+ }else{
+ $desc = " - [ ".$val['description'][0]." ]";
+ }
+ if(!isset($val['ipHostNumber'][0])){
+ $desc.= "";
+ }else{
+ $desc.= " - ".$val['ipHostNumber'][0]."";
+ }
+
+
+ $img ="Hmm";
+ if(in_array("goServer",$val['objectClass'])){
+ $img = "<img src='images/select_server.png' alt='"._("Server")."' ".$title.">";
+ }elseif(in_array("gotoWorkstation",$val['objectClass'])){
+ $img = "<img src='images/select_workstation.png' alt='"._("Workstation")."' ".$title.">";
+ }elseif(in_array("gotoTerminal",$val['objectClass'])){
+ $img = "<img src='images/select_terminal.png' alt='"._("Terminal")."' ".$title.">";
+ }else{
+ print_a($val);
+ }
+
+ /* Create each field */
+ $field0 = array("string" => "<input type='checkbox' id='item_selected_".$key."' name='item_selected_".$key."'>" ,
+ "attach" => "style='width:20px;'");
+ $field1 = array("string" => $img,
+ "attach" => "style='text- align:center;width: 20px;'");
+ $field2 = array("string" => $val['cn'][0].$desc,
+ "attach" => "style='border-right:0px;' ".$title);
+
+ $this->AddElement(array($field0,$field1,$field2));
+ }
+ }
+
+
+ function save()
+ {
+ $ret = array();
+ $items = $this->list_get_selected_items();
+ foreach($items as $item){
+ $ret[] = $this->list[$item];
+ }
+ return($ret);
+ }
+
+
+ function save_object()
+ {
+ MultiSelectWindow::save_object();
+ }
+
+
+ function reload()
+ {
+ /* Set base for all searches && initialise some vars */
+ $this->list= array();
+ $base = $this->selectedBase;
+ $filter = "";
+ $Regex = $this->Regex;
+
+ $chk = array(
+ "terminal" => "(objectClass=gotoTerminal)",
+ "server" => "(objectClass=goServer)" ,
+ "workstation" => "(objectClass=gotoWorkstation)");
+
+ /* Create filter */
+ foreach($chk as $chkBox => $FilterPart){
+ if($this->$chkBox){
+ $filter .= $FilterPart;
+ }
+ }
+ $filter= "(&(cn=".$Regex.")(|".$filter."))";
+
+ if($this->SubSearch){
+ $res= get_list($filter, array("terminal","workstation","server"), $base,
+ array("cn","objectClass","gosaGroupObjects","ipHostNumber","description"), GL_SIZELIMIT | GL_SUBSEARCH);
+ }else{
+ $res= get_list($filter, "terminal", get_ou('terminalou').$base,
+ array("cn","objectClass","description"), GL_SIZELIMIT );
+ $res= array_merge($res,get_list($filter, "workstation", get_ou('workstationou').$base,
+ array("cn","objectClass","description"), GL_SIZELIMIT ));
+ $res= array_merge($res,get_list($filter, "server", get_ou('serverou').$base,
+ array("cn","objectClass","description"), GL_SIZELIMIT ));
+
+ $deps_a = array(
+ get_ou("workstationou"),
+ get_ou("terminalou"),
+ get_ou("serverou"));
+
+ $res = get_sub_list($filter,array("server","terminal","workstation"),
+ $deps_a,get_ou("systemsou").$base,array("cn","objectClass","description"),GL_SIZELIMIT);
+ }
+
+ $this->list= $res;
+ ksort ($this->list);
+ reset ($this->list);
+ $tmp=array();
+ foreach($this->list as $tkey => $val ){
+ $tmp[strtolower($val['cn'][0]).$val['cn'][0]]=$val;
+ }
+ ksort($tmp);
+ $this->list=array();
+ foreach($tmp as $val){
+ $this->list[]=$val;
+ }
+ reset ($this->list);
+ }
+
+ function list_get_selected_items()
+ {
+ $ids = array();
+ foreach($_POST as $name => $value){
+ if(preg_match("/^item_selected_[0-9]*$/",$name)){
+ $id = preg_replace("/^item_selected_/","",$name);
+ $ids[$id] = $id;
+ }
+ }
+ return($ids);
+ }
+}
+
+
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>