mirror of
https://gitlab.easter-eggs.com/ee/ldapsaisie.git
synced 2024-12-23 08:53:47 +01:00
Add LSattr_ldap :: naiveDate
This commit is contained in:
parent
278b084214
commit
2fa55a1332
4 changed files with 92 additions and 0 deletions
|
@ -8,6 +8,7 @@
|
|||
&conf-LSattr_ldap_compositeValueToJSON;
|
||||
&conf-LSattr_ldap_date;
|
||||
&conf-LSattr_ldap_image;
|
||||
&conf-LSattr_ldap_naiveDate;
|
||||
&conf-LSattr_ldap_numeric;
|
||||
&conf-LSattr_ldap_password;
|
||||
&conf-LSattr_ldap_postaladdress;
|
||||
|
|
|
@ -4,6 +4,9 @@
|
|||
<!ENTITY conf-LSattr_ldap_compositeValueToJSON SYSTEM "LSattr_ldap_compositeValueToJSON.docbook">
|
||||
<!ENTITY conf-LSattr_ldap_date SYSTEM "LSattr_ldap_date.docbook">
|
||||
<!ENTITY conf-LSattr_ldap_image SYSTEM "LSattr_ldap_image.docbook">
|
||||
<!ENTITY conf-LSattr_ldap_naiveDate SYSTEM "LSattr_ldap_naiveDate.docbook">
|
||||
<!ENTITY conf-LSattr_ldap_numeric SYSTEM "LSattr_ldap_numeric.docbook">
|
||||
<!ENTITY conf-LSattr_ldap_password SYSTEM "LSattr_ldap_password.docbook">
|
||||
<!ENTITY conf-LSattr_ldap_postaladdress SYSTEM "LSattr_ldap_postaladdress.docbook">
|
||||
|
||||
<!ENTITY LSattr_ldap_date "<link linkend='config-LSattr_ldap_date'>LSattr_ldap_date</link>">
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
<sect4 id="config-LSattr_ldap_naiveDate">
|
||||
<title>LSattr_ldap_naiveDate</title>
|
||||
<para>Ce type est utilisé pour la gestion des attributs dont la valeur est
|
||||
une date dont la <emphasis>timezone</emphasis> doit être ignorée. Côté LDAP,
|
||||
les dates seront stockées au format UTC étant donnée que la syntaxe LDAP exige
|
||||
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>
|
||||
|
||||
</sect4>
|
79
public_html/includes/class/class.LSattr_ldap_naiveDate.php
Normal file
79
public_html/includes/class/class.LSattr_ldap_naiveDate.php
Normal file
|
@ -0,0 +1,79 @@
|
|||
<?php
|
||||
/*******************************************************************************
|
||||
* Copyright (C) 2007 Easter-eggs
|
||||
* http://ldapsaisie.labs.libre-entreprise.org
|
||||
*
|
||||
* Author: See AUTHORS file in top-level directory.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License version 2
|
||||
* as published by the Free Software Foundation.
|
||||
*
|
||||
* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
/**
|
||||
* LDAP attribute type naiveDate
|
||||
*
|
||||
* Convert LDAP generalized time string as timestamp without handling LDAP timezone
|
||||
*
|
||||
*/
|
||||
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
|
||||
*
|
||||
* @param[in] $data mixed The LDAP attribute value
|
||||
*
|
||||
* @retval mixed The display value ot the attribute
|
||||
*/
|
||||
public function getDisplayValue($data) {
|
||||
if(!is_array($data)) {
|
||||
$data=array($data);
|
||||
}
|
||||
$retval=array();
|
||||
foreach($data as $val) {
|
||||
$date = strptime($val, self::FORMAT);
|
||||
if (is_array($date)) {
|
||||
$retval[] = mktime(
|
||||
$date['tm_hour'],
|
||||
$date['tm_min'],
|
||||
$date['tm_sec'],
|
||||
$date['tm_mon']+1,
|
||||
$date['tm_mday'],
|
||||
$date['tm_year']+1900
|
||||
);
|
||||
}
|
||||
}
|
||||
return $retval;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the value of the LDAP attribute after handling is LDAP type
|
||||
*
|
||||
* @param[in] $data mixed The value of the attribute
|
||||
*
|
||||
* @retval mixed The LDAP value of the attribute
|
||||
*/
|
||||
public function getUpdateData($data) {
|
||||
$retval=array();
|
||||
if(is_array($data)) {
|
||||
foreach($data as $val) {
|
||||
$retval[] = strftime(self::FORMAT, $val).'Z';
|
||||
}
|
||||
}
|
||||
return $retval;
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in a new issue