Allow a customized search result.
authorGunnar Wrobel <p@rdus.de>
Sun, 10 May 2009 20:27:58 +0000 (22:27 +0200)
committerGunnar Wrobel <p@rdus.de>
Sun, 10 May 2009 20:27:58 +0000 (22:27 +0200)
koward/lib/Koward/Form/Search.php
koward/lib/Koward/View/Object/search.html.php

index b7f1c56..5b7b049 100644 (file)
@@ -76,7 +76,7 @@ class Koward_Form_Search extends Horde_Form {
         }
     }
 
-    function &execute()
+    function &execute($attributes)
     {
         $this->getInfo($this->_vars, $info);
         if (isset($info['object'])) {
@@ -93,7 +93,7 @@ class Koward_Form_Search extends Horde_Form {
                                              $this->koward->search['criteria']));
             $filter = $this->koward->getServer()->searchQuery($criteria);
             $params = array('scope' => 'sub',
-                            'attributes' => array('dn'));
+                            'attributes' => array_merge(array('dn'), $attributes));
             return $this->koward->getServer()->search($filter, $params);
         }
     }
index 3059c8e..a3e65b3 100644 (file)
@@ -7,8 +7,12 @@
 <table cellspacing="0" width="100%" class="linedRow">
  <thead>
   <tr>
-   <th class="item" width="1%"><?php echo Horde::img('edit.png', _("Edit"), '', $GLOBALS['registry']->getImageDir('horde')) ?></th>
-   <th class="item" width="1%"><?php echo Horde::img('delete.png', _("Delete"), '', $GLOBALS['registry']->getImageDir('horde')) ?></th>
+   <?php if ($this->allowEdit): ?>
+    <th class="item" width="1%"><?php echo Horde::img('edit.png', _("Edit"), '', $GLOBALS['registry']->getImageDir('horde')) ?></th>
+   <?php endif; ?>
+   <?php if ($this->allowDelete): ?>
+    <th class="item" width="1%"><?php echo Horde::img('delete.png', _("Delete"), '', $GLOBALS['registry']->getImageDir('horde')) ?></th>
+   <?php endif; ?>
    <?php foreach ($this->attributes as $attribute => $info): ?>
      <th class="item leftAlign" width="<?php echo $info['width'] ?>%" nowrap="nowrap"><?= $info['title'] ?></th>
    <?php endforeach; ?>
  <tbody>
   <?php foreach ($this->objectlist as $dn => $info): ?>
   <tr>
-   <td>
-    <?= $info['edit_url'] ?>
-   </td> 
-   <td>
-    <?= $info['delete_url'] ?>
-   </td> 
+   <?php if ($this->allowEdit): ?>
+    <td>
+     <?= $info['edit_url'] ?>
+    </td> 
+   <?php endif; ?>
+   <?php if ($this->allowDelete): ?>
+    <td>
+     <?= $info['delete_url'] ?>
+    </td> 
+   <?php endif; ?>
    <?php foreach ($this->attributes as $attribute => $ainfo): ?>
    <td>
+   <?php
+       if (isset($info[$attribute])) {
+           if (is_array($info[$attribute])) {
+               $value = $info[$attribute][0];
+           } else {
+               $value = $info[$attribute];
+           }
+       } else {
+           $value = '';
+       }
+       ?>
    <?php if (!empty($ainfo['link_view'])): ?>
-   <?= $info['view_url'] . $this->escape($info[$attribute]) . '</a>'; ?>
+   <?= $info['view_url'] . $this->escape($value) . '</a>'; ?>
    <?php else: ?>
-    <?= $this->escape($info[$attribute]) ?>
+    <?= $this->escape($value) ?>
    <?php endif; ?>
    </td> 
    <?php endforeach; ?>