diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index cc5f3cd105e62404e81f859b9906b5c083efa90b..388ff6fab89b98e020313750d65c7142f728b674 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -124,24 +124,26 @@ sonar_preview: # fusiondirectory-update-locale fusiondirectory-update-locale: + image: php:cli-stretch stage: transifex only: - branches before_script: - apt-get update -qq - - apt-get install -y -qq gettext git php-cli + - apt-get install -y -qq gettext git script: - git clone https://gitlab.fusiondirectory.org/fusiondirectory/dev-tools.git ../dev-tools - ../dev-tools/locale-scripts/fusiondirectory-update-locale -g # Update transifex update-transifex: + image: php:cli-stretch stage: transifex only: - /^1.*$/ before_script: - apt-get update -qq - - apt-get install -y -qq gettext git php-cli transifex-client + - apt-get install -y -qq gettext git transifex-client script: - git clone https://gitlab.fusiondirectory.org/fusiondirectory/dev-tools.git ../dev-tools - echo $'[https://www.transifex.com]\nhostname = https://www.transifex.com\nusername = '"$TRANSIFEX_USER"$'\npassword = '"$TRANSIFEX_PASSWORD"$'\ntoken = '"$TRANSIFEX_API_TOKEN"$'\n' > ~/.transifexrc diff --git a/include/class_filter.inc b/include/class_filter.inc index 95d52598c8a1e51a7afc3179d097603bfceebdc5..ddf2403ef7831a0b70b66c70dcec496421b1d758 100644 --- a/include/class_filter.inc +++ b/include/class_filter.inc @@ -2,7 +2,7 @@ /* This code is part of FusionDirectory (http://www.fusiondirectory.org/) Copyright (C) 2003-2010 Cajus Pollmeier - Copyright (C) 2011-2016 FusionDirectory + Copyright (C) 2011-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 @@ -229,6 +229,32 @@ class filter return $result; } + + /*! + * \brief Get the date picker + * + * \param array $element + */ + function getDatePicker($element) + { + global $lang; + $tag = $element['tag']; + $value = ''; + if (!empty($this->elementValues[$tag])) { + try { + $value = LdapGeneralizedTime::fromString($this->elementValues[$tag])->format('d.m.Y'); + } catch (Exception $e) { + $value = $this->elementValues[$tag]; + } + } + return '<input type="text" name="'.$tag.'" id="'.$tag.'"'. + ' value="'.$value.'"'. + ' class="date" />'. + '<script type="text/javascript"> + var datepicker = new DatePicker({ relative : \''.$tag.'\', language : \''.preg_replace('/_.*$/', '', $lang).'\', keepFieldEmpty : true, enableCloseEffect : false, enableShowEffect : false }); + </script>'; + } + /*! * \brief Set the combobox options * @@ -385,6 +411,10 @@ class filter $htmlCode = $this->getCombobox($element); break; + case 'date': + $htmlCode = $this->getDatePicker($element); + break; + default: throw new FusionDirectoryException ('Unknown element type specified: '.$element['type'].'!'); } @@ -487,7 +517,6 @@ class filter ) ); } - // Now call filter method and merge resulting entries. $result = array_merge($result, call_user_func(array($backend, 'query'), $this, $this->base, $this->scope, $filter, $attributes, $this->category, $branches)); @@ -529,10 +558,19 @@ class filter // Load post values and adapt filter, base and scope accordingly - but // only if we didn't get a _GET foreach ($this->elements as $tag => $element) { - if (isset($_POST[$tag])) { - $this->elementValues[$tag] = validate($_POST[$tag]); + if (!empty($_POST[$tag])) { + if ($element['type'] == 'date') { + try { + $date = new DateTime($_POST[$tag], new DateTimeZone('UTC')); + $this->elementValues[$tag] = LdapGeneralizedTime::toString($date); + } catch (Exception $e) { + $this->elementValues[$tag] = validate($_POST[$tag]); + } + } else { + $this->elementValues[$tag] = validate($_POST[$tag]); + } } else { - $this->elementValues[$tag] = ""; + $this->elementValues[$tag] = ''; } } diff --git a/include/class_ldap.inc b/include/class_ldap.inc index 73385666c3d8ff7a4f0826cf09df61e0853b539e..04040b108649926f5e023701ae46a708bce84dff 100644 --- a/include/class_ldap.inc +++ b/include/class_ldap.inc @@ -953,7 +953,7 @@ class LDAP $admin = escapeshellarg($this->binddn); $filter = escapeshellarg($filter); - $cmd = "ldapsearch -x -LLLL -D {$admin} {$filter} {$limit} {$scope} -H {$host} -b {$dn} -w {$pwd} "; + $cmd = 'ldapsearch'.($this->tls ? ' -ZZ' : '')." -x -LLLL -D {$admin} {$filter} {$limit} {$scope} -H {$host} -b {$dn} -w {$pwd} "; // Create list of process pipes $descriptorspec = array( diff --git a/include/simpleplugin/attributes/class_SelectAttribute.inc b/include/simpleplugin/attributes/class_SelectAttribute.inc index 9afaff9ff5b1bfe0e316d3e5f5d69a0e758a46dc..74e0f70cc0468279de040dbf70b0ed68b8d42392 100644 --- a/include/simpleplugin/attributes/class_SelectAttribute.inc +++ b/include/simpleplugin/attributes/class_SelectAttribute.inc @@ -66,6 +66,12 @@ class SelectAttribute extends Attribute array_unshift($outputs, _('None')); } } + if ($this->isTemplate() && !in_array('%askme%', $choices)) { + $choices[] = '%askme%'; + if (is_array($outputs)) { + $outputs[] = '%askme%'; + } + } $this->choices = $choices; if (!in_array($this->defaultValue, $this->choices, TRUE) && isset($this->choices[0])) { $this->defaultValue = $this->choices[0]; @@ -202,6 +208,15 @@ class SelectAttribute extends Attribute { $this->size = $size; } + + function setParent (&$plugin) + { + parent::setParent($plugin); + if ($this->isTemplate() && !in_array('%askme%', $this->choices)) { + $this->choices[] = '%askme%'; + $this->outputs['%askme%'] = '%askme%'; + } + } } /*! \brief This class allows to handle a select attribute which allow to choose an object