Code

Added icons and descriptions to tree lists
authorcajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 3 Feb 2010 17:41:59 +0000 (17:41 +0000)
committercajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 3 Feb 2010 17:41:59 +0000 (17:41 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@15582 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-core/include/class_baseSelector.inc
gosa-core/include/class_config.inc

index 1d35ea4fba22616d1768b27c311c1dd0d58a6c39..4a41a8dc0db2596efd1a16bf04dd87ed74ae353d 100644 (file)
@@ -31,14 +31,6 @@ class baseSelector {
   protected $pathMapping;
   protected $lastState;
 
-  // It would be better to get a dn -> [name, description, type] array
-  // to avoid these tasks be done several times. Skipping for the moment.
-  #'dc' => 'plugins/departments/images/domain.png',
-  #'dc' => 'plugins/departments/images/dc.png',
-  #'l' => 'plugins/departments/images/locality.png',
-  #'c' => 'plugins/departments/images/country.png',
-  #'o' => 'plugins/departments/images/organization.png',
-  #'ou' => 'plugins/departments/images/folder.png',
 
   function __construct($bases, $base= "")
   {
@@ -193,7 +185,11 @@ class baseSelector {
       }
       $selected= $this->base == $base?" class='treeListSelected'":"";
       $link= "onclick=\"\$('bs_rebase_".$this->pid."').value='".base64_encode($base)."';$('submit_tree_base_".$this->pid."').click();\"";
-      $this->tree.= "<li><a$selected $link>".str_replace('-', '&#8209;', str_replace(' ', '&nbsp;', ldap::fix(preg_replace('/^[a-z0-9]+=([^,]+),.*$/i', '$1', $base))))."</a>";
+      $this->tree.= "<li><a$selected $link>".
+                    "<img src='".$config->department_info[$base]['img']."'>&nbsp;".
+                    str_replace('-', '&#8209;', str_replace(' ', '&nbsp;', $config->department_info[$base]['name'].
+                    ($config->department_info[$base]['description']==''?'':' ['.$config->department_info[$base]['description'].']'))).
+                    "</a>";
 
       $last_indent= $indent;
       $first= false;
index 52b22958330de79d5cc734492635314902891040..8a87aa3f97313889b5cb5f8b6d43938fc9807431 100644 (file)
@@ -60,6 +60,7 @@ class config  {
   var $idepartments= array();
   var $adepartments= array();
   var $tdepartments= array();
+  var $department_info= array();
   var $filename = "";
   var $last_modified = 0;
 
@@ -720,7 +721,7 @@ class config  {
     $types = departmentManagement::get_support_departments();
     
     /* Create a list of attributes to fetch */
-    $ldap_values = array("objectClass","gosaUnitTag");
+    $ldap_values = array("objectClass","gosaUnitTag", "description");
     $filter = "";
     foreach($types as $type){
       $ldap_values[] = $type['ATTR'];
@@ -743,12 +744,14 @@ class config  {
         }
       }
 
-      /* Unknown department type -> skip 
-       */
+      /* Unknown department type -> skip */
       if(!count($type_data)) continue;
 
       $dn= $ldap->getDN();
       $this->tdepartments[$dn]= "";
+      $this->department_info[$dn]= array("img" => $type_data['IMG'],
+                                         "description" => isset($attrs['description'][0])?$attrs['description'][0]:"",
+                                         "name" => $attrs[$type_data['ATTR']][0]);
 
       /* Save administrative departments */
       if (in_array_ics("gosaAdministrativeUnit", $attrs['objectClass']) &&