Code

Updated posix plugin to use the new kind of lists for trust machines.
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 26 Jan 2010 10:28:05 +0000 (10:28 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 26 Jan 2010 10:28:05 +0000 (10:28 +0000)
-Not yet completely finished.

git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@15310 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-core/plugins/personal/posix/class_posixAccount.inc
gosa-core/plugins/personal/posix/trustSelect/class_trustSelect.inc [new file with mode: 0644]
gosa-core/plugins/personal/posix/trustSelect/trust-filter.tpl [new file with mode: 0644]
gosa-core/plugins/personal/posix/trustSelect/trust-filter.xml [new file with mode: 0644]
gosa-core/plugins/personal/posix/trustSelect/trust-list.tpl [new file with mode: 0644]
gosa-core/plugins/personal/posix/trustSelect/trust-list.xml [new file with mode: 0644]

index 94f10da0a8ba3b319892121ec1ab6ccae18e5178..8d7fe104fae62da63f7c5164c30e8bb4deab37d9 100644 (file)
@@ -69,7 +69,7 @@ class posixAccount extends plugin
   var $force_ids= 0;
   var $gotoLastSystemLogin= "";
   var $groupSelect= FALSE;
-  var $show_ws_dialog= FALSE;
+  var $trustDialog= FALSE;
   var $secondaryGroups= array();
   var $primaryGroup= 0;
   var $was_trust_account= FALSE;
@@ -363,7 +363,7 @@ class posixAccount extends plugin
 
     /* Add user workstation? */
     if (isset($_POST["add_ws"])){
-      $this->show_ws_dialog= TRUE;
+      $this->trustDialog= new trustSelect($this->config,get_userinfo());
       $this->dialog= TRUE;
     }
 
@@ -386,7 +386,7 @@ class posixAccount extends plugin
 
     /* Add user workstation finished? */
     if (isset($_POST["add_ws_finish"]) || isset($_POST["add_ws_cancel"])){
-      $this->show_ws_dialog= FALSE;
+      $this->trustDialog= NULL;
       $this->dialog= FALSE;
     }
 
@@ -395,101 +395,13 @@ class posixAccount extends plugin
     $smarty->assign("usePrototype", "true");
 
     /* 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'];
-
-      $acls = array();
-      if(class_available("servgeneric")) $acls[] = "server";
-      if(class_available("workgeneric")) $acls[] = "worstation";
-      if(class_available("termgeneric")) $acls[] = "terminal";
-
-      $filter= "(&(|(objectClass=goServer)(objectClass=gotoWorkstation)(objectClass=gotoTerminal))$exclude(cn=*)(cn=$regex))";
-
-      $deps_a = array(get_ou("serverRDN"),
-                      get_ou("terminalRDN"),
-                      get_ou("workstationRDN")); 
-
-      $res= get_sub_list($filter, $acls, $deps_a, 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);
-      $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());
-      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);
+    if ($this->trustDialog){
+      return($this->trustDialog->execute());
     }
 
     /* Manage group add dialog */
     if ($this->groupSelect){
-
       return($this->groupSelect->execute());
-
-      /* Get global filter config */
-      $this->reload();
-
-      /* remove already assigned groups */
-      $glist= array();
-      foreach ($this->grouplist as $key => $value){
-        if (!isset($this->groupMembership[$key]) && obj_is_writable($key,"groups/group","memberUid")){
-          $glist[$key]= $value;
-        }
-      }
-
-      if($this->SubSearch){
-        $smarty->assign("SubSearchCHK"," checked ");
-      }else{
-        $smarty->assign("SubSearchCHK","");
-      }
-
-      $smarty->assign("regex",$this->GroupRegex);
-      $smarty->assign("guser",$this->GroupUserRegex);
-      $smarty->assign("groups", $glist);
-      $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("depselect", session::get('CurrentMainBase'));
-      $smarty->assign("hint", print_sizelimit_warning());
-      $smarty->assign("apply", apply_filter());
-
-      $display.= $smarty->fetch (get_template_path('posix_groups.tpl', TRUE, dirname(__FILE__)));
-      return ($display);
     }
 
     // Handle ssh dialog?
diff --git a/gosa-core/plugins/personal/posix/trustSelect/class_trustSelect.inc b/gosa-core/plugins/personal/posix/trustSelect/class_trustSelect.inc
new file mode 100644 (file)
index 0000000..df39484
--- /dev/null
@@ -0,0 +1,122 @@
+<?php
+/*
+ * This code is part of GOsa (http://www.gosa-project.org)
+ * Copyright (C) 2003-2008 GONICUS GmbH
+ *
+ * ID: $$Id: class_groupManagement.inc 14766 2009-11-05 14:30:35Z 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 trustSelect extends management
+{
+
+  protected $skipFooter = TRUE;
+  protected $skipHeader = TRUE;
+
+  function __construct($config,$ui)
+  {
+    $this->config = $config;
+    $this->ui = $ui;
+   
+    $this->storagePoints = array(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("trust-filter.xml", true, dirname(__FILE__)));
+      $filter->setObjectStorage($this->storagePoints);
+#    }
+    $this->setFilter($filter);
+
+    // Build headpage
+    $headpage = new listing(get_template_path("trust-list.xml", true, dirname(__FILE__)));
+    $headpage->registerElementFilter("filterProperties", "groupManagement::filterProperties");
+    $headpage->setFilter($filter);
+    parent::__construct($config, $ui, "groups", $headpage);
+  }
+
+
+  static function filterProperties($row, $classes)
+  {
+    $result= "";
+
+    $map = array(
+        "posixGroup" => 
+        array(
+          "image" => "plugins/groups/images/groups.png",
+          "plugin" => "group",
+          "alt" => _("Posix"),
+          "title" => _("Edit posix properties")
+          ),
+
+        "gosaMailAccount" => 
+        array(
+          "image" => "plugins/groups/images/mail.png",
+          "plugin" => "mailgroup",
+          "alt" => _("Mail"),
+          "title" => _("Edit mail properties")
+          ),
+
+        "sambaGroupMapping" => 
+        array(
+          "image" => "plugins/groups/images/samba.png",
+          "plugin" => "group",
+          "alt" => _("Samba"),
+          "title" => _("Edit samba properties")
+          ),
+
+        "goFonPickupGroup" => 
+          array(
+              "image" => "plugins/groups/images/asterisk.png",
+              "plugin" => "group",
+              "alt" => _("Phone"),
+              "title" => _("Edit phone properties")
+              ),
+
+        "gotoMenuGroup" => 
+          array(
+              "image" => "plugins/groups/images/menu.png",
+              "plugin" => "appgroup",
+              "alt" => _("Menu"),
+              "title" => _("Edit start menu properties")
+              ),
+
+        "gotoEnvironment" => 
+          array(
+              "image" => "plugins/groups/images/environment.png",
+              "plugin" => "environment",
+              "alt" => _("Environment"),
+              "title" => _("Edit environment properties")
+              )
+          );
+
+
+    // Walk thru map
+    foreach ($map as $oc => $properties) {
+      if (in_array_ics($oc, $classes)) {
+        $result.="<input class='center' type='image' src='".$properties['image']."' ".
+          "alt='".$properties['alt']."' title='".$properties['title'].
+                 "' name='listing_edit_".$properties['plugin']."_$row' style='padding:1px'>";
+      } else {
+        $result.="<img src='images/empty.png' alt=' ' class='center' style='padding:1px'>";
+      }
+    }
+    return $result;
+  }
+} 
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
diff --git a/gosa-core/plugins/personal/posix/trustSelect/trust-filter.tpl b/gosa-core/plugins/personal/posix/trustSelect/trust-filter.tpl
new file mode 100644 (file)
index 0000000..c115cd0
--- /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>
+
+ {$PRIMARY}&nbsp;<LABEL for='TEMPLATES'>{t}Show primary groups{/t}</LABEL><br>
+ {$SAMBA}&nbsp;<LABEL for='TEMPLATES'>{t}Show samba groups{/t}</LABEL><br>
+ {$MAIL}&nbsp;<LABEL for='TEMPLATES'>{t}Show mail groups{/t}</LABEL><br>
+
+ {$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-core/plugins/personal/posix/trustSelect/trust-filter.xml b/gosa-core/plugins/personal/posix/trustSelect/trust-filter.xml
new file mode 100644 (file)
index 0000000..17abcd7
--- /dev/null
@@ -0,0 +1,64 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<filterdef>
+  <definition>
+    <category>groups</category>
+    <template>../plugins/personal/posix/trustSelect/trust-filter.tpl</template>
+    <initial>true</initial>
+  </definition>
+
+  <search>
+    <query>
+      <backend>LDAP</backend>
+      <filter>(&amp;(objectClass=posixGroup)$NAME(|$PRIMARY$MAIL$SAMBA))</filter>
+      <attribute>dn</attribute>
+      <attribute>objectClass</attribute>
+      <attribute>cn</attribute>
+      <attribute>description</attribute>
+    </query>
+    <scope>auto</scope>
+  </search>
+
+  <element>
+    <type>checkbox</type>
+    <tag>PRIMARY</tag>
+    <default>true</default>
+    <unset></unset>
+    <set>(!(objectClass=gosaObject))</set>
+  </element>
+
+  <element>
+    <type>checkbox</type>
+    <tag>MAIL</tag>
+    <default>true</default>
+    <unset></unset>
+    <set>(objectClass=gosaMailAccount)</set>
+  </element>
+
+  <element>
+    <type>checkbox</type>
+    <tag>SAMBA</tag>
+    <default>true</default>
+    <unset></unset>
+    <set>(objectClass=sambaGroupMapping)</set>
+  </element>
+
+  <element>
+    <type>textfield</type>
+    <tag>NAME</tag>
+    <size>20</size>
+    <maxlength>60</maxlength>
+    <default></default>
+    <unset></unset>
+    <set>(|(cn=*$*)(description=*$*))</set>
+    <alphabet>true</alphabet>
+    <autocomplete>
+      <backend>LDAP</backend>
+      <filter>(&amp;(objectClass=posixGroup)(|(cn=*$NAME*)(description=*$NAME*)))</filter>
+      <attribute>cn</attribute>
+      <frequency>0.5</frequency>
+      <characters>3</characters>
+    </autocomplete>
+  </element>
+
+</filterdef>
diff --git a/gosa-core/plugins/personal/posix/trustSelect/trust-list.tpl b/gosa-core/plugins/personal/posix/trustSelect/trust-list.tpl
new file mode 100644 (file)
index 0000000..92449a6
--- /dev/null
@@ -0,0 +1,38 @@
+<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>
+
+
+<p class="plugbottom">
+  <input type=submit name="add_ws_finish" value="{msgPool type=addButton}">
+  &nbsp;
+  <input type=submit name="add_ws_cancel" value="{msgPool type=cancelButton}">
+</p>
+
+<input type="hidden" name="ignore">
diff --git a/gosa-core/plugins/personal/posix/trustSelect/trust-list.xml b/gosa-core/plugins/personal/posix/trustSelect/trust-list.xml
new file mode 100644 (file)
index 0000000..c9c3c8d
--- /dev/null
@@ -0,0 +1,64 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<list>
+  <definition>
+    <departmentBrowser>true</departmentBrowser>
+    <departmentRootVisible>false</departmentRootVisible>
+    <baseMode>true</baseMode>
+    <multiSelect>true</multiSelect>
+    <template>../plugins/personal/posix/trustSelect/trust-list.tpl</template>
+    <module>groups</module>
+    <label>List of groups</label>
+    <defaultSortColumn>1</defaultSortColumn>
+
+    <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|||</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>%{filter:link(row,dn,"%s",cn)}</value>
+      <export>true</export>
+    </column>
+
+    <column>
+      <label>Description</label>
+      <sortAttribute>description</sortAttribute>
+      <sortType>string</sortType>
+      <value>%{filter:link(row,dn,"%s",description)}</value>
+      <export>true</export>
+    </column>
+
+  </table>
+
+  <actionmenu>
+  </actionmenu>
+
+  <actiontriggers snapshot="false" copypaste="false">
+  </actiontriggers>
+
+</list>