Code

Updated User selection dialog
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 22 Jan 2010 09:20:50 +0000 (09:20 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 22 Jan 2010 09:20:50 +0000 (09:20 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@15246 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-plugins/goto/addons/goto/events/class_DaemonEvent_notify.inc
gosa-plugins/goto/addons/goto/events/class_EventAddUserDialog.inc
gosa-plugins/goto/addons/goto/events/eventTargetUser-filter.tpl [new file with mode: 0644]
gosa-plugins/goto/addons/goto/events/eventTargetUser-filter.xml [new file with mode: 0644]
gosa-plugins/goto/addons/goto/events/eventTargetUser-list.tpl [new file with mode: 0644]
gosa-plugins/goto/addons/goto/events/eventTargetUser-list.xml [new file with mode: 0644]

index 44565dd9e24756f1ccc4a5a6808600ded9eb618b..3765b2f1bf6b1d5a0f2fed715aead4a8993b2291 100644 (file)
@@ -174,10 +174,8 @@ class DaemonEvent_notify extends DaemonEvent
     if($this->target_divlist == NULL){
       $this->target_divlist = new EventAddUserDialog($this->config,$this);
     }
-    $this->target_divlist->execute();
-
     $smarty = get_smarty();
-    $smarty->assign("divlist",$this->target_divlist->Draw());
+    $smarty->assign("divlist",$this->target_divlist->execute());
     return($smarty->fetch(get_template_path('target_list.tpl', TRUE, dirname(__FILE__))));
   }
 
index de812ba948b6c6cd34c2ab2f9f39e1be28282717..569bedf32532bb5b6681a37a6a78daf78b8ec5aa 100644 (file)
@@ -3,7 +3,7 @@
  * This code is part of GOsa (http://www.gosa-project.org)
  * Copyright (C) 2003-2008 GONICUS GmbH
  *
- * ID: $$Id: class_EventAddUserDialog.inc 9597 2008-03-10 14:16:59Z hickert $$
+ * ID: $$Id: class_EventAddSystemDialog.inc 15243 2010-01-22 08:53:18Z 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
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
-class EventAddUserDialog extends MultiSelectWindow
+class EventAddUserDialog extends management
 {
-  public $display_server = TRUE;
-  public $display_workstation = TRUE;
-  public $display_ogroup = TRUE;
-  public $filter_iprange = FALSE;
+  // Tab definition 
+  protected $skipFooter = TRUE;
+  protected $skipHeader = TRUE;
 
-  public $regex  = "*";
-  public $ipfrom = "0.0.0.0";
-  public $ipto   = "*";
-  public $_target_list = array();
-
-  function __construct(&$config,$parent)
-  {
-    MultiSelectWindow::MultiSelectWindow($config, "EventAddUserDialog", 
-        array("users","groups"));
-
-    $this->parent       = $parent;
-    $this->ui           = get_userinfo();
-
-
-    $this->target_divlist = new MultiSelectWindow($this->config,"EventAddTargetUserList","gotomasses");
-    $this->SetSummary(_("Targets"));
-    $this->EnableCloseButton(FALSE);
-    $this->EnableSaveButton(FALSE);
-
-    $this->SetInformation(_("This dialog shows all available targets for your event, check the targets you want to add and use the 'Use' button to accept."));
-
-    /* Toggle all selected / deselected */
-    $chk = "<input type='checkbox' id='select_all' name='select_all'
-      onClick='toggle_all_(\"^item_selected_[0-9]*$\",\"select_all\");' >";
-
-    $this->EnableAplhabet(TRUE);
-
-    /* set Page header */
-    $this->AddHeader(array("string"=> $chk,          "attach"=>"style='width:20px;'"));
-    $this->AddHeader(array("string"=>"&nbsp;","attach"=>"style='width:20px;'"));
-    $this->AddHeader(array("string"=>_("System / Department")));
-
-    //$name,$string,$value,$conn,$image="images/lists/search.png")
-    $this->AddRegex("regex" ,"regex"  ,"*"                , TRUE);
-
-    $this->AddCheckBox("display_users"  ,"1", _("Display users"),TRUE);
-    $this->AddCheckBox("display_groups" ,"1", _("Display groups"),TRUE);
-  }
-
-
-  function execute()
-  {
-    $this->ClearElementsList();
-    $this->AddDepartments($this->selectedBase,2,1);
-    $this->setEntries();
-    $this->GenHeader();
-  }
-
-
-  function GenHeader()
-  {
-    $modules = array("users","groups");
-
-    /* Add base */
-    $tmp = array();
-    $base = $this->config->current['BASE'];
-    $tmp[] = array("dn"=>$this->config->current['BASE']);
-    $tmp=  array_merge($tmp,get_list("(&(|(ou=*)(description=*))(objectClass=gosaDepartment))", $modules, $base,
-          array("ou", "description"), GL_SIZELIMIT | GL_SUBSEARCH));
-
-    $deps = array();
-    foreach($tmp as $tm){
-      $deps[$tm['dn']] = $tm['dn'];
-    }
-
-    $department = $departments = array();
-    $ui= get_userinfo();
-    $d = $ui->get_module_departments($modules);
-    foreach($d as $department){
-      $departments[$department] = $department;
-    }
-
-    /* Load possible departments */
-    $ids = $this->config->idepartments;
-    $first = "";
-    $found = FALSE;
-    $options = array();
-    foreach($ids as $dep => $name){
-      if(isset($deps[$dep]) && in_array_ics($dep, $departments)){
-
-        /* 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>";
-        }
-      }
-    }
-
-    $listhead = $this->get_default_header();
-
-    /* Add base selection */
-    $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 department")."' name='submit_department' alt='". _("Submit")."'>&nbsp;";
-
-    $this->SetListHeader($listhead);
-
-  }
-
-
-  function setEntries()
-  {
-    $_target_list = array();
-
-    if($this->display_users){
-      $_target_list = array_merge($_target_list,
-          get_sub_list("(&(objectClass=person)(objectClass=gosaAccount))","users",get_people_ou(),get_people_ou().$this->selectedBase,
-          array("cn","objectClass","description","uid"),GL_NONE));
-    }
-    if($this->display_groups){
-      $_target_list = array_merge($_target_list,
-          get_sub_list("(objectClass=posixGroup)","groups",get_groups_ou(),get_groups_ou().$this->selectedBase,
-            array("cn","objectClass","description"),GL_NONE));
-    }
-    $this->_target_list = $_target_list;
-
-    $tmp = array();
-    foreach($this->_target_list as $key => $object){
-      $tmp[$key] = $object['cn'][0];
-    }
-    natcasesort($tmp);
-
-    foreach($tmp as $key => $obj){
-
-      $obj = $this->_target_list[$key];
-      $name = $obj['cn'][0];
-      if(isset($obj['description'])){
-        $name .= "&nbsp;[".$obj['description'][0]."]";
-      }
-
-      $img ="";
-      if(in_array("gosaAccount",$obj['objectClass'])){
-        $img = '<img class="center" src="plugins/users/images/select_user.png" alt="U" title="'._("User").'">';
-      }elseif(in_array("posixGroup",$obj['objectClass'])){
-        $img = '<img class="center" src="plugins/groups/images/groups.png" alt="G" title="'._("Group").'">';
-      }
-
-      $field1 = array("string" => "<input type='checkbox' id='item_selected_".$key."' name='item_selected_".$key."'>",
-                      "attach" => "style='width:20px;'");
-      $field2 = array("string" => $img,
-                      "attach" => "style='width:20px;'");
-      $field3 = array("string" => $name , "attach" => "title='".$obj['dn']."'");
-      $this->AddElement(array($field1,$field2,$field3));
-    }
-  }
-
-
-  function get_selected_targets()
+  function __construct($config,$ui)
   {
-    $a_targets = array("USERS" => array(),"GROUPS" => array());
-
-    foreach($this->list_get_selected_items() as $id){
-      $obj = $this->_target_list[$id];
-      if(in_array("posixGroup",$obj['objectClass'])){
-        $a_targets['GROUPS'][] = $obj['cn'][0];
-      }
-      if(in_array("gosaAccount",$obj['objectClass'])){
-        $a_targets['USERS'][] = $obj['uid'][0];
-      }
-    }
-
-    return($a_targets);
+    $this->config = $config;
+    $this->ui = $ui;
+    $this->storagePoints = array(
+        get_ou("userRDN"), 
+        get_ou("groupRDN")); 
+
+    // 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("../../addons/goto/events/eventTargetUser-filter.xml", TRUE));
+      $filter->setObjectStorage($this->storagePoints);
+   # }
+    $this->setFilter($filter);
+
+    // Build headpage
+    $headpage = new listing(get_template_path("../../addons/goto/events/eventTargetUser-list.xml", TRUE));
+    $headpage->setFilter($filter);
+    parent::__construct($config, $ui, "object", $headpage);
   }
 
+  function save_object() {}
 
-  /*! \brief  Returns a set of elements selected in a MultiSelectWindow
-    @return Array[integer]=integer
-   */
-  protected  function list_get_selected_items()
+  function save()
   {
-    $ids = array();
-    foreach($_POST as $name => $value){
-      if(preg_match("/^item_selected_[0-9]*$/",$name)){
-        $id   = preg_replace("/^item_selected_/","",$name);
-        $ids[$id] = $id;
-      }
+    $act = $this->detectPostActions();
+    $headpage = $this->getHeadpage();
+    if(!isset($act['targets'])) return(array());
+    $ret = array();
+    foreach($act['targets'] as $dn){
+      $ret[] = $headpage->getEntry($dn);
     }
-    return($ids);
+    return($ret);
   }
 }
 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
diff --git a/gosa-plugins/goto/addons/goto/events/eventTargetUser-filter.tpl b/gosa-plugins/goto/addons/goto/events/eventTargetUser-filter.tpl
new file mode 100644 (file)
index 0000000..031ad39
--- /dev/null
@@ -0,0 +1,37 @@
+<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>
+
+  {$GROUP}&nbsp;<LABEL for='SERVER'>{t}Show groups{/t}</LABEL><br>
+  {$USER}&nbsp;<LABEL for='TERMINAL'>{t}Show users{/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/goto/addons/goto/events/eventTargetUser-filter.xml b/gosa-plugins/goto/addons/goto/events/eventTargetUser-filter.xml
new file mode 100644 (file)
index 0000000..e08a9d1
--- /dev/null
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<filterdef>
+  <definition>
+    <category>server</category>
+    <template>../../addons/goto/events/eventTargetUser-filter.tpl</template>
+    <initial>true</initial>
+  </definition>
+
+  <search>
+    <query>
+      <backend>LDAP</backend>
+      <filter>(&amp;(|$USER $GROUP) $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>GROUP</tag>
+    <default>true</default>
+    <set>(objectClass=posixGroup)</set>
+    <unset></unset>
+  </element>
+
+  <element>
+    <type>checkbox</type>
+    <tag>USER</tag>
+    <default>true</default>
+    <set>(objectClass=gosaAccount)</set>
+    <unset></unset>
+  </element>
+
+</filterdef>
diff --git a/gosa-plugins/goto/addons/goto/events/eventTargetUser-list.tpl b/gosa-plugins/goto/addons/goto/events/eventTargetUser-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/goto/addons/goto/events/eventTargetUser-list.xml b/gosa-plugins/goto/addons/goto/events/eventTargetUser-list.xml
new file mode 100644 (file)
index 0000000..f01d29f
--- /dev/null
@@ -0,0 +1,71 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<list>
+  <definition>
+    <departmentBrowser>true</departmentBrowser>
+    <departmentRootVisible>false</departmentRootVisible>
+    <baseMode>true</baseMode>
+    <multiSelect>true</multiSelect>
+    <template>../../addons/goto/events/eventTargetUser-list.tpl</template>
+    <module>users</module>
+    <label>List of users</label>
+    <defaultSortColumn>1</defaultSortColumn>
+
+    <objectType>
+      <label>User</label>
+      <objectClass>gosaAccount</objectClass>
+      <category>users</category>
+      <class>user</class>
+      <image>plugins/users/images/select_user.png</image>
+    </objectType>
+
+    <objectType>
+      <label>Group</label>
+      <objectClass>posixGroup</objectClass>
+      <category>groups</category>
+      <class>group</class>
+      <image>plugins/groups/images/groups.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>