mirror of
https://gitlab.easter-eggs.com/ee/ldapsaisie.git
synced 2024-11-22 18:09:06 +01:00
LSattr_ldap::naiveDate: Add format option
This commit is contained in:
parent
eccb234210
commit
8dbbda801a
2 changed files with 43 additions and 4 deletions
|
@ -6,4 +6,35 @@
|
||||||
une <emphasis>timezone</emphasis>, cependant celle-ci sera complètement ignorée.
|
une <emphasis>timezone</emphasis>, cependant celle-ci sera complètement ignorée.
|
||||||
Ce type peut-être utilisé à la place du type &LSattr_ldap_date;.</para>
|
Ce type peut-être utilisé à la place du type &LSattr_ldap_date;.</para>
|
||||||
|
|
||||||
|
<programlisting linenumbering="unnumbered">
|
||||||
|
<citetitle>Structure</citetitle><![CDATA[...
|
||||||
|
'ldap_options' => array (
|
||||||
|
'format' => '[Format de stockage]', // Default : "%Y%m%d%H%M%SZ"
|
||||||
|
),
|
||||||
|
...]]>
|
||||||
|
</programlisting>
|
||||||
|
|
||||||
|
<variablelist>
|
||||||
|
<title>Paramètres de configuration</title>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term>format</term>
|
||||||
|
<listitem>
|
||||||
|
<para>Format de stockage de la date dans l'annuaire. Ce format est composé à
|
||||||
|
partir des motifs clés gérés par la fonction <function>strftime()</function>
|
||||||
|
de &php;. Pour plus d'information, consulter
|
||||||
|
<ulink url='http://www.php.net/strftime'>la documentation officielle</ulink>.
|
||||||
|
<note><simpara>La valeur par défaut est <emphasis>%Y%m%d%H%M%SZ</emphasis>,
|
||||||
|
correspondant à la syntaxe <literal>Generalized Time</literal> (sans les
|
||||||
|
micro-secondes) telle que définie dans la
|
||||||
|
<ulink url='https://tools.ietf.org/html/rfc4517'>RFC4517</ulink>. Exemples :
|
||||||
|
<literal>20091206230506Z</literal>
|
||||||
|
<emphasis>(=2009/12/06 23:05:66 UTC)</emphasis>.</simpara></note>
|
||||||
|
</para>
|
||||||
|
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
|
</variablelist>
|
||||||
|
|
||||||
</sect4>
|
</sect4>
|
||||||
|
|
|
@ -28,8 +28,6 @@
|
||||||
*/
|
*/
|
||||||
class LSattr_ldap_naiveDate extends LSattr_ldap {
|
class LSattr_ldap_naiveDate extends LSattr_ldap {
|
||||||
|
|
||||||
const FORMAT = "%Y%m%d%H%M%S";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the display value of the attribute after handling is LDAP type
|
* Return the display value of the attribute after handling is LDAP type
|
||||||
*
|
*
|
||||||
|
@ -40,7 +38,7 @@ class LSattr_ldap_naiveDate extends LSattr_ldap {
|
||||||
public function getDisplayValue($data) {
|
public function getDisplayValue($data) {
|
||||||
$retval = array();
|
$retval = array();
|
||||||
foreach(ensureIsArray($data) as $val) {
|
foreach(ensureIsArray($data) as $val) {
|
||||||
$date = strptime($val, self::FORMAT);
|
$date = strptime($val, $this -> getFormat());
|
||||||
if (is_array($date)) {
|
if (is_array($date)) {
|
||||||
$retval[] = mktime(
|
$retval[] = mktime(
|
||||||
$date['tm_hour'],
|
$date['tm_hour'],
|
||||||
|
@ -65,9 +63,19 @@ class LSattr_ldap_naiveDate extends LSattr_ldap {
|
||||||
public function getUpdateData($data) {
|
public function getUpdateData($data) {
|
||||||
$retval = array();
|
$retval = array();
|
||||||
foreach(ensureIsArray($data) as $val) {
|
foreach(ensureIsArray($data) as $val) {
|
||||||
$retval[] = strftime(self::FORMAT, $val).'Z';
|
$retval[] = strftime($this -> getFormat(), $val);
|
||||||
}
|
}
|
||||||
return $retval;
|
return $retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the storage format of the date (as accept by strptime()/strftime())
|
||||||
|
*
|
||||||
|
* @retval string the storage format of the date
|
||||||
|
**/
|
||||||
|
public function getFormat() {
|
||||||
|
return $this -> getConfig('ldap_options.format', "%Y%m%d%H%M%SZ");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue