Code

Updated select list for systems
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 21 Jan 2010 13:37:59 +0000 (13:37 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 21 Jan 2010 13:37:59 +0000 (13:37 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@15234 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-plugins/sudo/admin/sudo/class_target_list_systems.inc
gosa-plugins/sudo/admin/sudo/selectSystem-filter.tpl [new file with mode: 0644]
gosa-plugins/sudo/admin/sudo/selectSystem-filter.xml [new file with mode: 0644]
gosa-plugins/sudo/admin/sudo/selectSystem-list.tpl [new file with mode: 0644]
gosa-plugins/sudo/admin/sudo/selectSystem-list.xml [new file with mode: 0644]

index 81c9de50ad661a8ce6ac96defb1b192f86c19620..44d5af18b7ee5cda809bbb253df85fcd64e17e4a 100644 (file)
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
-class target_list_systems extends MultiSelectWindow
+class target_list_systems extends management
 {
-  public $config;
-  protected $list         =array();
-  private $Targets_used =array();
+  // Tab definition 
+  protected $skipFooter = TRUE;
+  protected $skipHeader = TRUE;
 
-  /* Regex */
-  protected $Regex           = "*";
-
-  /* CheckBoxes, to change default values modify $this->AddCheckBox */
-  protected $servers        ;
-  protected $workstations   ;
-  protected $terminals      ;
-
-
-  /* Subsearch checkbox */
-  protected $SubSearch       ;
-  protected $parent          ;
-  public $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 systems"));
-    $this->SetSummary(      _("Available systems"));
-    $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" => "&nbsp;", "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()
+  function __construct($config,$ui)
   {
-    $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 */
-    $tdeps= array();
-    $tdeps= array_merge($tdeps,$ui->get_module_departments("server"));
-    $tdeps= array_merge($tdeps,$ui->get_module_departments("terminal"));
-    $tdeps= array_merge($tdeps,$ui->get_module_departments("workstation"));
-    $tdeps = array_unique($tdeps); 
-    $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;
-    }
-
-    /* Add default header */
-    $listhead = MultiSelectWindow::get_default_header();
-
-    /* Add department selector */
-    $listhead .= _("Base")."&nbsp;<select name='CurrentMainBase' onChange='mainform.submit()' class='center'>$options</select>".
-      " <input class='center' type='image' src='images/lists/submit.png' align='middle'
-      title='"._("Submit")."' name='submit_department' alt='"._("Submit")."'>&nbsp;";
-    $listhead .="</div>";
-
-    $this->SetListHeader($listhead);
+    $this->config = $config;
+    $this->ui = $ui;
+    $this->storagePoints = array(get_ou("serverRDN"), get_ou("workstationRDN"), get_ou('terminalRDN'));
+
+#    // Build filter
+#    if (session::global_is_set(get_class($this)."_filter")){
+#      $filter= session::global_get(get_class($this)."_filter");
+#    } else {
+      $filter = new filter(get_template_path("selectSystem-filter.xml", true));
+      $filter->setObjectStorage($this->storagePoints);
+#    }
+    $this->setFilter($filter);
+
+    // Build headpage
+    $headpage = new listing(get_template_path("selectSystem-list.xml", true));
+    $headpage->setFilter($filter);
+    parent::__construct($config, $ui, "object", $headpage);
   }
 
+  function save_object() {}
 
   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
-    $editlink = "<a href='?plug=".$_GET['plug']."&amp;id=%s&amp;act=edit_entry'>%s</a>";
-
-    $ui = get_userinfo();
-
-    // Assigning systems 
-    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('/ /', '&nbsp;', LDAP::fix($val['dn']))."'";
-      if(!isset($val['description'][0])){
-        $desc = "";
-      }else{
-        $desc = " - [ ".$val['description'][0]." ]";
-      }
-
-      $img ="?";
-      if(in_array("goServer",$val['objectClass'])){
-        $img = "<img src='plugins/systems/images/select_server.png' alt='"._("Server")."' ".$title.">";
-      }elseif(in_array("gotoWorkstation",$val['objectClass'])){
-        $img = "<img src='plugins/systems/images/select_workstation.png' alt='"._("Workstation")."' ".$title.">";
-      }elseif(in_array("gotoTerminal",$val['objectClass'])){
-        $img = "<img src='plugins/systems/images/select_terminal.png' alt='"._("Terminal")."' ".$title.">";
-      }
-
-      /* 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));
-    }
+    $str = management::execute();
+    $str.= "<p class='separator'>&nbsp;</p>
+      <p style=\"text-align:right\">
+      <input type=submit name=\"SaveMultiSelectWindow\" value=\"".msgPool::okButton()."\">
+      &nbsp; 
+      <input type=submit name=\"CloseMultiSelectWindow\" value=\"".msgPool::cancelButton()."\">
+      </p>";
+    return($str);
   }
 
-  
   function save()
-  { 
+  {
+    $act = $this->detectPostActions();
+    $headpage = $this->getHeadpage();
+    if(!isset($act['targets'])) return(array());
     $ret = array();
-    $items = $this->list_get_selected_items();
-    foreach($items as $item){
-      $ret[] = $this->list[$item];
+    foreach($act['targets'] as $dn){
+      $ret[] = $headpage->getEntry($dn);
     }
     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;
-
-    $filter= "(&(cn=".$Regex.")(|".$filter."))";
-
-    if($this->SubSearch){
-      $res= array();
-      if($this->terminal){
-        $filter = "(objectClass=gotoTerminal)";
-        $filter= "(&(cn=".$Regex.")(|".$filter."))";
-        $res= array_merge($res,get_sub_list($filter,"terminal",get_ou('terminalRDN'),$base, 
-              array("cn","objectClass","description"), GL_SIZELIMIT | GL_SUBSEARCH));
-      }
-      if($this->workstation){
-        $filter = "(objectClass=gotoWorkstation)";  
-        $filter= "(&(cn=".$Regex.")(|".$filter."))";
-        $res= array_merge($res,get_sub_list($filter, "workstation",  get_ou('workstationRDN'),$base, 
-              array("cn","objectClass","description"), GL_SIZELIMIT | GL_SUBSEARCH));
-      }
-      if($this->server){
-        $filter = "(objectClass=goServer)";
-        $filter = "(&(cn=".$Regex.")(|".$filter."))";
-        $res= array_merge($res,get_sub_list($filter, "server", get_ou('serverRDN'),$base, 
-              array("cn","objectClass","description"), GL_SIZELIMIT | GL_SUBSEARCH));
-      }
-    }else{
-      $res= array();
-      if($this->terminal){
-        $filter = "(objectClass=gotoTerminal)";
-        $filter= "(&(cn=".$Regex.")(|".$filter."))";
-        $res= array_merge($res,get_list($filter,"terminal", get_ou('terminalRDN').$base, 
-              array("cn","objectClass","description"), GL_SIZELIMIT ));
-      }
-      if($this->workstation){
-        $filter = "(objectClass=gotoWorkstation)";  
-        $filter= "(&(cn=".$Regex.")(|".$filter."))";
-        $res= array_merge($res,get_list($filter, "workstation",  get_ou('workstationRDN').$base, 
-              array("cn","objectClass","description"), GL_SIZELIMIT ));
-      }
-      if($this->server){
-        $filter = "(objectClass=goServer)";
-        $filter = "(&(cn=".$Regex.")(|".$filter."))";
-        $res= array_merge($res,get_list($filter, "server", get_ou('serverRDN').$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:
 ?>
diff --git a/gosa-plugins/sudo/admin/sudo/selectSystem-filter.tpl b/gosa-plugins/sudo/admin/sudo/selectSystem-filter.tpl
new file mode 100644 (file)
index 0000000..2f09c58
--- /dev/null
@@ -0,0 +1,38 @@
+<div class="contentboxh">
+ <p class="contentboxh">
+  <img src="images/launch.png" align="right" alt="[F]">{t}Filter{/t}
+ </p>
+</div>
+
+<div class="contentboxb">
+
+<div style="border-top:1px solid #AAAAAA"></div>
+
+  {$SERVER}&nbsp;<LABEL for='SERVER'>{t}Show servers{/t}</LABEL><br>
+  {$WORKSTATION}&nbsp;<LABEL for='WORKSTATION'>{t}Show workstations{/t}</LABEL><br>
+  {$TERMINAL}&nbsp;<LABEL for='TERMINAL'>{t}Show terminals{/t}</LABEL><br>
+
+ <div style="border-top:1px solid #AAAAAA"></div>
+ {$SCOPE}
+
+ <table summary="" style="width:100%;border-top:1px solid #B0B0B0;">
+  <tr>
+   <td>
+    <label for="NAME">
+     <img src="images/lists/search.png" align=middle>&nbsp;Name
+    </label>
+   </td>
+   <td>
+    {$NAME}
+   </td>
+  </tr>
+ </table>
+
+ <table summary=""  width="100%"  style="background:#EEEEEE;border-top:1px solid #B0B0B0;">
+  <tr>
+   <td width="100%" align="right">
+    {$APPLY}
+   </td>
+  </tr>
+ </table>
+</div>
diff --git a/gosa-plugins/sudo/admin/sudo/selectSystem-filter.xml b/gosa-plugins/sudo/admin/sudo/selectSystem-filter.xml
new file mode 100644 (file)
index 0000000..6677db5
--- /dev/null
@@ -0,0 +1,64 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<filterdef>
+  <definition>
+    <category>server</category>
+    <template>selectSystem-filter.tpl</template>
+    <initial>true</initial>
+  </definition>
+
+  <search>
+    <query>
+      <backend>LDAP</backend>
+      <filter>(&amp;(|$SERVER $WORKSTATION $TERMINAL ) $NAME)</filter>
+      <attribute>dn</attribute>
+      <attribute>objectClass</attribute>
+      <attribute>cn</attribute>
+      <attribute>description</attribute>
+    </query>
+    <scope>auto</scope>
+  </search>
+
+  <element>
+    <type>textfield</type>
+    <tag>NAME</tag>
+    <size>20</size>
+    <maxlength>60</maxlength>
+    <default></default>
+    <unset></unset>
+    <set>(cn=*$*)</set>
+    <alphabet>true</alphabet>
+    <autocomplete>
+      <backend>LDAP</backend>
+      <filter>(cn=*$NAME*)</filter>
+      <attribute>cn</attribute>
+      <frequency>0.5</frequency>
+      <characters>3</characters>
+    </autocomplete>
+  </element>
+
+  <element>
+    <type>checkbox</type>
+    <tag>SERVER</tag>
+    <default>true</default>
+    <set>(objectClass=goServer)</set>
+    <unset></unset>
+  </element>
+
+  <element>
+    <type>checkbox</type>
+    <tag>WORKSTATION</tag>
+    <default>true</default>
+    <unset></unset>
+    <set>(objectClass=gotoWorkstation)</set>
+  </element>
+
+  <element>
+    <type>checkbox</type>
+    <tag>TERMINAL</tag>
+    <default>true</default>
+    <unset></unset>
+    <set>(objectClass=gotoTerminal)</set>
+  </element>
+
+</filterdef>
diff --git a/gosa-plugins/sudo/admin/sudo/selectSystem-list.tpl b/gosa-plugins/sudo/admin/sudo/selectSystem-list.tpl
new file mode 100644 (file)
index 0000000..b233c58
--- /dev/null
@@ -0,0 +1,31 @@
+<input type='image' src='images/empty.png' name='no_action_posted' value='do_nothing' alt='' style='width:2px;height:2px;'>
+
+<table summary="" style="width:100%; vertical-align:top; text-align:left;" cellpadding=2>
+  <tr>
+    <td style="vertical-align:top; width:50%;">
+      <div class="contentboxh">
+        <p class="contentboxh">&nbsp;{$HEADLINE}&nbsp;{$SIZELIMIT}</p>
+      </div>
+      
+      <div class="contentboxb">
+       <div style='background:white;padding:0px;padding:3px;'>
+        <table><tr>
+          <td>{$ROOT}&nbsp;</td><td>{$BACK}&nbsp;</td><td>{$HOME}&nbsp;</td><td>{$RELOAD}&nbsp;</td><td>{$SEPARATOR}&nbsp;</td><td>{t}Base{/t} {$BASE}&nbsp;<input class='center' type='image' src='images/lists/submit.png' align='middle' title='{t}Update{/t}' name='submit_department' alt='{t}Submit{/t}'>&nbsp;</td><td>{$SEPARATOR}&nbsp;</td><td><img src='images/rocket.png' alt='' class='center'></td><td> {$ACTIONS}</td>
+        </tr></table>
+       </div>
+      </div>
+      
+      <div style='height:4px;'>
+      </div>
+      
+      <input type="hidden" id="d_save" value="450">
+      <input type="hidden" id="d_space" value="760">
+      {$LIST}
+    </td>
+    <td style='vertical-align:top'>
+      {$FILTER}
+    </td>
+  </tr>
+</table>
+
+<input type="hidden" name="ignore">
diff --git a/gosa-plugins/sudo/admin/sudo/selectSystem-list.xml b/gosa-plugins/sudo/admin/sudo/selectSystem-list.xml
new file mode 100644 (file)
index 0000000..0fa7b88
--- /dev/null
@@ -0,0 +1,79 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<list>
+  <definition>
+    <departmentBrowser>true</departmentBrowser>
+    <departmentRootVisible>false</departmentRootVisible>
+    <baseMode>true</baseMode>
+    <multiSelect>true</multiSelect>
+    <template>selectSystem-list.tpl</template>
+    <module>server</module>
+    <label>List of systems</label>
+    <defaultSortColumn>1</defaultSortColumn>
+
+    <objectType>
+      <label>Server</label>
+      <objectClass>goServer</objectClass>
+      <category>server</category>
+      <class>servgeneric</class>
+      <image>plugins/systems/images/select_server.png</image>
+    </objectType>
+
+    <objectType>
+      <label>Workstation</label>
+      <objectClass>gotoWorkstation</objectClass>
+      <category>workstation</category>
+      <class>workgeneric</class>
+      <image>plugins/systems/images/select_workstation.png</image>
+    </objectType>
+
+    <objectType>
+      <label>Terminal</label>
+      <objectClass>gotoTerminal</objectClass>
+      <category>terminal</category>
+      <class>termgeneric</class>
+      <image>plugins/systems/images/select_terminal.png</image>
+    </objectType>
+
+  </definition>
+
+  <table>
+    <layout>|20px;c|220px||</layout>
+
+    <department>
+      <value>%{filter:objectType(dn,objectClass)}</value>
+    </department>
+
+    <department>
+      <value>%{filter:departmentLink(row,dn,description)}</value>
+      <span>1</span>
+    </department>
+
+    <column>
+      <value>%{filter:objectType(dn,objectClass)}</value>
+    </column>
+
+    <column>
+      <label>Name</label>
+      <sortAttribute>cn</sortAttribute>
+      <sortType>string</sortType>
+      <value>%{cn}</value>
+      <export>true</export>
+    </column>
+
+    <column>
+      <label>Description name</label>
+      <sortAttribute>description</sortAttribute>
+      <sortType>string</sortType>
+      <value>%{description}</value>
+      <export>true</export>
+    </column>
+
+  </table>
+
+  <actionmenu>
+  </actionmenu>
+
+  <actiontriggers snapshot="false" copypaste="false">
+  </actiontriggers>
+</list>