From: Gunnar Wrobel Date: Tue, 28 Apr 2009 20:53:51 +0000 (+0200) Subject: Added a draft for the search view. X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=652cc8d27b275009c4f7ded0312013c5326f406d;p=horde.git Added a draft for the search view. --- diff --git a/koward/app/controllers/ApplicationController.php b/koward/app/controllers/ApplicationController.php index 55cfd478e..212890b23 100644 --- a/koward/app/controllers/ApplicationController.php +++ b/koward/app/controllers/ApplicationController.php @@ -30,11 +30,11 @@ class Koward_ApplicationController extends Horde_Controller_Base _("_Objects"), 'user.png', $registry->getImageDir('horde')); $menu->add($this->urlFor(array('controller' => 'object', 'action' => 'edit')), _("_Add"), 'plus.png', $registry->getImageDir('horde')); - $menu->add(Horde::applicationUrl('search'), _("_Search"), 'search.png', $registry->getImageDir('horde')); + $menu->add($this->urlFor(array('controller' => 'object', 'action' => 'search')), + _("_Search"), 'search.png', $registry->getImageDir('horde')); $menu->add(Horde::applicationUrl('Queries'), _("_Queries"), 'query.png', $registry->getImageDir('koward')); $menu->add($this->urlFor(array('controller' => 'check', 'action' => 'show')), _("_Test"), 'problem.png', $registry->getImageDir('horde')); - return $menu; } } diff --git a/koward/app/views/Object/search.html.php b/koward/app/views/Object/search.html.php new file mode 100644 index 000000000..3059c8e50 --- /dev/null +++ b/koward/app/views/Object/search.html.php @@ -0,0 +1,40 @@ +renderPartial('header'); ?> +renderPartial('menu'); ?> +objectlist)): ?> + form->renderActive(new Horde_Form_Renderer(), $this->vars, + $this->post, 'post'); ?> + + + + + + + attributes as $attribute => $info): ?> + + + + + + objectlist as $dn => $info): ?> + + + + attributes as $attribute => $ainfo): ?> + + + + + +
getImageDir('horde')) ?>getImageDir('horde')) ?>
+ + + + + + escape($info[$attribute]) . ''; ?> + + escape($info[$attribute]) ?> + +
+ + diff --git a/koward/config/search.php b/koward/config/search.php new file mode 100644 index 000000000..fb6264f6b --- /dev/null +++ b/koward/config/search.php @@ -0,0 +1,15 @@ + array( + 'givenName' => array( + 'label' => _("First Name"), + 'type' => 'text', + 'params' => array('regex' => '', 'size' => 40, 'maxlength' => 255) + ), + ) +); + +if (file_exists(dirname(__FILE__) . '/search.local.php')) { + require_once(dirname(__FILE__) . '/search.local.php'); +} diff --git a/koward/lib/Form/Search.php b/koward/lib/Form/Search.php new file mode 100644 index 000000000..7e8a8a70d --- /dev/null +++ b/koward/lib/Form/Search.php @@ -0,0 +1,100 @@ +koward = &Koward_Koward::singleton(); + + $this->object = &$object; + + parent::Horde_Form($vars); + + $type = false; + + $this->setButtons(_("Search")); + $this->_addFields($this->koward->search); + } + + + /** + * Sort fields for an object type + */ + function _sortFields($a, $b) + { + if ($a['order'] == -1) { + return 1; + } + if ($b['order'] == -1) { + return -1; + } + if ($a['order'] == $b['order']) { + return 0; + } + return ($a['order'] < $b['order']) ? -1 : 1; + } + + /** + * Set up the Horde_Form fields for the attributes of this object type. + */ + function _addFields($config) + { + // Now run through and add the form variables. + $tabs = isset($config['tabs']) ? $config['tabs'] : array('' => $config['fields']); + + foreach ($tabs as $tab => $tab_fields) { + if (!empty($tab)) { + $this->setSection($tab, $tab); + } + foreach ($tab_fields as $key => $field) { + if (!in_array($key, array_keys($config['fields']))) { + continue; + } + $attribute = $field; + $params = isset($attribute['params']) ? $attribute['params'] : array(); + $desc = isset($attribute['desc']) ? $attribute['desc'] : null; + + $v = &$this->addVariable($attribute['label'], 'object[' . $key . ']', $attribute['type'], $attribute['required'], null, $desc, $params); + } + + if (isset($attribute['default'])) { + $v->setDefault($attribute['default']); + } + } + } + + function &execute() + { + $this->getInfo($this->_vars, $info); + if (isset($info['object'])) { + $search_criteria = array(); + foreach ($info['object'] as $key => $value) { + if (!empty($value)) { + $search_criteria[] = array('field' => $key, + 'op' => 'contains', + 'test' => $value); + } + } + $search_criteria = array('AND' => $search_criteria); + $criteria = array('AND' => array($search_criteria, + $this->koward->search['criteria'])); + $filter = $this->koward->getServer()->searchQuery($criteria); + $params = array('scope' => 'sub', + 'attributes' => array('dn')); + return $this->koward->getServer()->search($filter, $params); + } + } +}