diff --git a/ihtml/themes/breezy/management/filter-element-date.tpl b/ihtml/themes/breezy/management/filter-element-date.tpl new file mode 100644 index 0000000000000000000000000000000000000000..74d7bf65bdfe6e13e00fa83d8e7142f886435bee --- /dev/null +++ b/ihtml/themes/breezy/management/filter-element-date.tpl @@ -0,0 +1,10 @@ +<fieldset><legend>{$NAME}</legend> + <label for="nt_{$attribute}" title="{t 1=$NAME}Minimum date for %1{/t}"> + {t}Newer than{/t} + <input type="date" id="nt_{$attribute}" name="nt_{$attribute}" value="{$nt_value}"/> + </label> + <label for="ot_{$attribute}" title="{t 1=$NAME}Maximum date for %1{/t}"> + {t}Older than{/t} + <input type="date" id="ot_{$attribute}" name="ot_{$attribute}" value="{$ot_value}"/> + </label> +</fieldset> diff --git a/include/management/class_DateFilterElement.inc b/include/management/class_DateFilterElement.inc new file mode 100644 index 0000000000000000000000000000000000000000..9368fa401253e61a01841be2f2e6094f3e42d52f --- /dev/null +++ b/include/management/class_DateFilterElement.inc @@ -0,0 +1,80 @@ +<?php +/* + This code is part of FusionDirectory (http://www.fusiondirectory.org/) + Copyright (C) 2017-2018 FusionDirectory + + 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +/*! + * \brief Filter on member types + */ +class DateFilterElement extends FilterElement +{ + protected $attribute; + protected $label; + protected $min; + protected $max; + protected $types; + + public function __construct(managementFilter $parent, $attribute, $label, $types = array()) + { + global $config; + + parent::__construct($parent); + + $this->attribute = $attribute; + $this->label = $label; + $this->types = $types; + } + + public function update() + { + if (!empty($_POST['nt_'.$this->attribute])) { + $this->min = $_POST['nt_'.$this->attribute]; + } else { + $this->min = ''; + } + if (!empty($_POST['ot_'.$this->attribute])) { + $this->max = $_POST['ot_'.$this->attribute]; + } else { + $this->max = ''; + } + } + + public function render() + { + $smarty = get_smarty(); + $smarty->assign('NAME', $this->label); + $smarty->assign('attribute', $this->attribute); + $smarty->assign('nt_value', $this->min); + $smarty->assign('ot_value', $this->max); + return $smarty->fetch(get_template_path('management/filter-element-date.tpl')); + } + + public function getFilters($type, array &$filters) + { + if (!empty($this->types) && !in_array_ics($type, $this->types)) { + return FALSE; + } + if (!empty($this->min)) { + $filters[] = '('.$this->attribute.'>='.LdapGeneralizedTime::toString(new DateTime($this->min)).')'; + } + if (!empty($this->max)) { + $filters[] = '('.$this->attribute.'<='.LdapGeneralizedTime::toString(new DateTime($this->max)).')'; + } + return FALSE; + } +} diff --git a/include/management/class_FilterElement.inc b/include/management/class_FilterElement.inc index 83e2c64ed18cd335273420e7bd1dab4fc8c117d7..6791d85febdec938018b0d5820bdfcda2f3380c6 100644 --- a/include/management/class_FilterElement.inc +++ b/include/management/class_FilterElement.inc @@ -1,7 +1,8 @@ <?php /* This code is part of FusionDirectory (http://www.fusiondirectory.org/) - Copyright (C) 2017-2018 FusionDirectory + + Copyright (C) 2017-2019 FusionDirectory 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 @@ -45,77 +46,3 @@ class FilterElement return FALSE; } } - -class TabFilterElement extends FilterElement -{ - protected $tabs; - - public function __construct(managementFilter $parent) - { - global $config; - - parent::__construct($parent); - - $this->tabs = array(); - foreach ($this->parent->parent->objectTypes as $type) { - $infos = objects::infos($type); - foreach ($config->data['TABS'][$infos['tabGroup']] as $plug) { - $class = $plug['CLASS']; - if ($class == $infos['mainTab']) { - continue; - } - if (isset($this->tabs[$class])) { - continue; - } - if (class_available($class)) { - $classInfos = pluglist::pluginInfos($class); - if (isset($classInfos['plFilterObject'])) { - $this->tabs[$class] = array( - 'filter' => $classInfos['plFilterObject'], - 'infos' => $classInfos, - 'checked' => FALSE, - ); - } - } - } - } - } - - public function update() - { - foreach ($this->tabs as $class => &$tab) { - $tab['checked'] = isset($_POST['filter_tab_'.$class]); - } - unset($tab); - } - - public function render() - { - if (empty($this->tabs)) { - return ''; - } - $inputs = array(); - foreach ($this->tabs as $class => $tab) { - $inputs['filter_tab_'.$class] = array( - 'name' => $tab['infos']['plShortName'], - 'desc' => $tab['infos']['plShortName'].' '.$tab['filter'], - 'icon' => (isset($tab['infos']['plSmallIcon']) ? $tab['infos']['plSmallIcon'] : NULL), - 'checked' => $tab['checked'], - ); - } - $smarty = get_smarty(); - $smarty->assign('NAME', _('Tabs')); - $smarty->assign('INPUTS', $inputs); - return $smarty->fetch(get_template_path('management/filter-element.tpl')); - } - - public function getFilters($type, array &$filters) - { - foreach ($this->tabs as $tab) { - if ($tab['checked']) { - $filters[] = $tab['filter']; - } - } - return FALSE; - } -} diff --git a/include/management/class_TabFilterElement.inc b/include/management/class_TabFilterElement.inc new file mode 100644 index 0000000000000000000000000000000000000000..b0bff3ce9bbd0397c8d125b68dbc144076c37c02 --- /dev/null +++ b/include/management/class_TabFilterElement.inc @@ -0,0 +1,94 @@ +<?php +/* + This code is part of FusionDirectory (http://www.fusiondirectory.org/) + + Copyright (C) 2017-2019 FusionDirectory + + 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +class TabFilterElement extends FilterElement +{ + protected $tabs; + + public function __construct(managementFilter $parent) + { + global $config; + + parent::__construct($parent); + + $this->tabs = array(); + foreach ($this->parent->parent->objectTypes as $type) { + $infos = objects::infos($type); + foreach ($config->data['TABS'][$infos['tabGroup']] as $plug) { + $class = $plug['CLASS']; + if ($class == $infos['mainTab']) { + continue; + } + if (isset($this->tabs[$class])) { + continue; + } + if (class_available($class)) { + $classInfos = pluglist::pluginInfos($class); + if (isset($classInfos['plFilterObject'])) { + $this->tabs[$class] = array( + 'filter' => $classInfos['plFilterObject'], + 'infos' => $classInfos, + 'checked' => FALSE, + ); + } + } + } + } + } + + public function update() + { + foreach ($this->tabs as $class => &$tab) { + $tab['checked'] = isset($_POST['filter_tab_'.$class]); + } + unset($tab); + } + + public function render() + { + if (empty($this->tabs)) { + return ''; + } + $inputs = array(); + foreach ($this->tabs as $class => $tab) { + $inputs['filter_tab_'.$class] = array( + 'name' => $tab['infos']['plShortName'], + 'desc' => $tab['infos']['plShortName'].' '.$tab['filter'], + 'icon' => (isset($tab['infos']['plSmallIcon']) ? $tab['infos']['plSmallIcon'] : NULL), + 'checked' => $tab['checked'], + ); + } + $smarty = get_smarty(); + $smarty->assign('NAME', _('Tabs')); + $smarty->assign('INPUTS', $inputs); + return $smarty->fetch(get_template_path('management/filter-element.tpl')); + } + + public function getFilters($type, array &$filters) + { + foreach ($this->tabs as $tab) { + if ($tab['checked']) { + $filters[] = $tab['filter']; + } + } + return FALSE; + } +} diff --git a/include/management/columns/class_LdapGeneralizedTimeColumn.inc b/include/management/columns/class_LdapGeneralizedTimeColumn.inc new file mode 100644 index 0000000000000000000000000000000000000000..78518b4301a1f792ea0ccd51c1ce874ea942ec11 --- /dev/null +++ b/include/management/columns/class_LdapGeneralizedTimeColumn.inc @@ -0,0 +1,40 @@ +<?php +/* + This code is part of FusionDirectory (http://www.fusiondirectory.org/) + + Copyright (C) 2018-2019 FusionDirectory + + 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +/*! + * \brief Column rendering LdapGeneralizedTime attributes + */ +class LdapGeneralizedTimeColumn extends LinkColumn +{ + protected $type = 'string'; + + function renderCell(ListingEntry $entry) + { + $value = $this->getAttributeValue($entry); + if ($value != '') { + $dateObject = LdapGeneralizedTime::fromString($value); + if (is_object($dateObject)) { + return $this->renderLink($entry, $dateObject->format('Y-m-d, H:i:s')); + } + } + return ' '; + } +}