Code

Updated property filtering
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 4 May 2010 15:31:36 +0000 (15:31 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 4 May 2010 15:31:36 +0000 (15:31 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@18050 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-core/plugins/addons/configViewer/class_configViewer.inc
gosa-core/plugins/addons/configViewer/class_filterProperties.inc
gosa-core/plugins/addons/configViewer/property-filter.xml
gosa-core/plugins/addons/configViewer/property-list.xml

index 74e2ddc7860326ef8d090e7a9276905433e78b9d..f209392ec0a69ecb7c7034adc615675e70f289b2 100644 (file)
@@ -23,83 +23,53 @@ class configViewer extends management
 
         // Build headpage
         $headpage = new listing(get_template_path("property-list.xml", true));
+        $headpage->registerElementFilter("propertyName", "configViewer::propertyName");
+        $headpage->registerElementFilter("propertyGroup", "configViewer::propertyGroup");
+        $headpage->registerElementFilter("propertyClass", "configViewer::propertyClass");
+        $headpage->registerElementFilter("propertyValue", "configViewer::propertyValue");
         $headpage->setFilter($filter);
         parent::__construct($config, $ui, "property", $headpage);
     }
-}
-
-class configViewer_old extends plugin
-{
-
-    var $configRegistry = NULL;    
-    var $viewType = 'byClass';
-    var $viewTypes = array();
 
-    function __construct (&$config, $dn= NULL)
+    static function propertyGroup($group, $description = array())
     {
-        $this->config = &$config;
-        $this->configRegistry = &$config->configRegistry;
-        $this->viewTypes = array(
-                'byClass' => _("By class name"), 
-                'byName'  => _("By property name"), 
-                'byStatus'=> _("By status"), 
-                'byGroup' => _('By group'));
-
-        
-        $this->propertyList = new sortableListing();
-        $this->propertyList->setDeleteable(false);
-        $this->propertyList->setEditable(false);
-        $this->propertyList->setWidth("100%");
-        $this->propertyList->setHeight("500px");
-        $this->propertyList->setHeader(array(_("Group"),_("Class"),_("Name"),_("Value"), _("Status")));
-        $this->propertyList->setDefaultSortColumn(0);
-        $this->propertyList->setAcl('rwcdm');
+        $title = _("No description");
+        if(!empty($description[0])) $title=$description[0];
+        return("<span title=\"{$title}\">{$group[0]}</span>");
     }
-
-    function execute()
+    static function propertyClass($class, $description = array())
     {
-        $all = $this->configRegistry->getAllProperties();
-        $data = $lData = array();
-        foreach($all as $id => $p){
-            $value = htmlentities($p->getValue(), ENT_COMPAT, 'UTF-8');
-            $data[$id] = $p;
-
-
-            $status = $p->getStatus();
-            if($status == 'modified'){
-                $status = "<button name='save_{$p->getClass()}:{$p->getName()}'>".msgPool::saveButton()."</button>";
-                $status.= "<button name='reset_{$p->getClass()}:{$p->getName()}'>".("Reset")."</button>";
-            }
-            if($status == 'ldap'){
-                $status = "<button name='del_{$p->getClass()}:{$p->getName()}'>".msgPool::delButton()."</button>";
-            }
-
-            $lData[$id] = array('data' => array(
-                        $p->getGroup(),
-                        $this->configRegistry->classToName[$p->getClass()],
-                        $p->getName(),
-                        "<input type='text' value=\"{$value}\" name='{$p->getClass()}:{$p->getName()}'>",
-                        $status
-                        ));
+        global $config;
+        if(isset($config->configRegistry->classToName[$class[0]])){
+            $class = $config->configRegistry->classToName[$class[0]];
+        }else{
+            $class = $class[0];
         }
-        $this->propertyList->setListData($data,$lData);
-        $this->propertyList->update();
-        $smarty = get_smarty();
-        $smarty->assign('content', $this->propertyList->render());
-        return($smarty->fetch(get_template_path('generic.tpl', TRUE)));
+        $title = _("No description");
+        if(!empty($description[0])) $title=$description[0];
+        return("<span title=\"{$title}\">{$class}</span>");
     }
-
-    function save_object()
+    static function propertyName($cn, $description = array())
     {
-        $all = $this->configRegistry->getAllProperties();
-        foreach($all as $id => $p){
-            if(isset($_POST[$p->getClass().":".$p->getName()])){
-                $val = get_post($p->getClass().":".$p->getName());
-                if($val != $p->getValue()){
-                    $p->setValue($val);
-                }
-            }
+        $title = _("No description");
+        if(!empty($description[0])) $title=$description[0];
+        return("<span title=\"{$title}\">{$cn[0]}</span>");
+    }
+    static function propertyValue($class,$cn, $value,$type,$default,$description)
+    {
+        $name  = "{$class[0]}:{$cn[0]}";
+        $value = htmlentities($value[0], ENT_COMPAT , 'UTF-8');
+        $title = _("No description");
+        if(!empty($description[0])) $title=$description[0];
+        switch($type[0]){
+            case 'string':
+            case 'integer':
+                $res = "<input style='width:97%' title=\"{$title}\" type='text' value=\"{$value}\" name={$name}>";
+                break;
+            default: $res = ""; 
         }
+        
+        return($res);
     }
 }
 ?>
index b95a1eec3a19e433346690632bf673860bbb96c2..08a1c2f0182d5cbdd22fc38ef75b920ad75fbf9c 100644 (file)
@@ -18,6 +18,7 @@ class filterCONFIGPROPERTIES {
         $entry = filterCONFIGPROPERTIES::fakeLdapResult($entry, 'value', $property->getValue());
         $entry = filterCONFIGPROPERTIES::fakeLdapResult($entry, 'default', $property->getDefault());
         $entry = filterCONFIGPROPERTIES::fakeLdapResult($entry, 'check', $property->getCheck());
+        $entry = filterCONFIGPROPERTIES::fakeLdapResult($entry, 'class', $property->getClass());
         $entry = filterCONFIGPROPERTIES::fakeLdapResult($entry, 'type', $property->getType());
         $entry = filterCONFIGPROPERTIES::fakeLdapResult($entry, 'migrate', $property->getMigrate());
         $entry = filterCONFIGPROPERTIES::fakeLdapResult($entry, 'group', $property->getGroup());
index bda7d3f1502eaa050d980a42bf9af31008256f37..b4bc1e511e5ab5e196d732235e3afb222cce0e0c 100644 (file)
@@ -25,7 +25,7 @@
   </search>
 
   <search>
-    <tag>default2</tag>
+    <tag>all</tag>
     <label>All properties</label>
     <query>
       <backend>CONFIGPROPERTIES</backend>
index 2c452ac4edca160bafd90a367e51e0dade9530b3..15e51d37e896bfb6f334ed2b33e241e1abd09673 100644 (file)
@@ -46,7 +46,7 @@
   </definition>
 
   <table>
-    <layout>|20px;c|120px||||170px;r|</layout>
+    <layout>|20px;c|80px|100px|100px||60px;r|</layout>
 
     <column>
       <value>%{filter:objectType(dn,objectClass)}</value>
       <label>Group</label>
       <sortAttribute>group</sortAttribute>
       <sortType>string</sortType>
-      <value>%{group}</value>
+      <value>%{filter:propertyGroup(group,description)}</value>
       <export>true</export>
     </column>
 
     <column>
-      <label>Name</label>
-      <sortAttribute>cn</sortAttribute>
+      <label>Class</label>
+      <sortAttribute>group</sortAttribute>
       <sortType>string</sortType>
-      <value>%{cn}</value>
+      <value>%{filter:propertyClass(class,description)}</value>
       <export>true</export>
     </column>
 
     <column>
-      <label>Value</label>
-      <sortAttribute>value</sortAttribute>
+      <label>Name</label>
+      <sortAttribute>cn</sortAttribute>
       <sortType>string</sortType>
-      <value>%{value}</value>
+      <value>%{filter:propertyName(cn,description)}</value>
       <export>true</export>
     </column>
 
     <column>
-      <label>Description</label>
-      <sortAttribute>description</sortAttribute>
+      <label>Value</label>
+      <sortAttribute>value</sortAttribute>
       <sortType>string</sortType>
-      <value>%{description}</value>
+      <value>%{filter:propertyValue(class,cn,value,type,default,description)}</value>
       <export>true</export>
     </column>
 
 
   </actionmenu>
 
-  <actiontriggers snapshot="true" copypaste="true">
-
-    <action>
-      <name>cp</name>
-      <type>copypaste</type>
-    </action>
-
-    <action>
-      <name>edit</name>
-      <type>entry</type>
-      <image>images/lists/edit.png</image>
-      <label>Edit sudo role</label>
-    </action>
-
-    <action>
-      <name>snapshot</name>
-      <type>snapshot</type>
-    </action>
+  <actiontriggers snapshot="false" copypaste="false">
 
     <action>
       <name>remove</name>
       <type>entry</type>
+      <objectclass>ldap</objectclass>
       <image>images/lists/trash.png</image>
-      <acl>sudo/sudo[d]</acl>
-      <label>Remove sudo role</label>
+      <label>Restore to default</label>
     </action>
 
   </actiontriggers>