Commit 64ce958b authored by Côme Chilliet's avatar Côme Chilliet
Browse files

Merge branch '1.3-dev' into '1.4-dev'

Merge 1.3-dev in 1.4-dev

See merge request fusiondirectory/fd!277
parents 8b23fa68 cdebf937
......@@ -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
......
......@@ -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] = '';
}
}
......
......@@ -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(
......
......@@ -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
......
  • SonarQube analysis indicates that quality gate is failed.

    • Security Rating on New Code is passed: Actual value 1
    • Reliability Rating on New Code is passed: Actual value 1
    • Maintainability Rating on New Code is passed: Actual value 1
    • Duplicated Lines on New Code (%) is failed: Actual value 10.743801652892563 > 3

    SonarQube analysis reported no issues.

Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment