Verified Commit a44509a5 authored by Côme Chilliet's avatar Côme Chilliet
Browse files

:tractor: feat(audit,posix) Moved DateAttributes subclasses to core

issue #5927
Showing with 2 additions and 60 deletions
+2 -60
...@@ -19,21 +19,6 @@ ...@@ -19,21 +19,6 @@
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/ */
class GeneralizedTimeDisplayAttribute extends GeneralizedTimeDateAttribute
{
function getValue ()
{
return $this->computeLdapValue();
}
function renderFormInput ()
{
$date = $this->getDateValue();
$date->setTimezone(timezone::getDefaultTimeZone());
return htmlentities($date->format('Y-m-d, H:i:s'), ENT_COMPAT, 'UTF-8');
}
}
class auditEvent extends simplePlugin class auditEvent extends simplePlugin
{ {
public $base; public $base;
......
<?php <?php
/* /*
This code is part of FusionDirectory (http://www.fusiondirectory.org/) This code is part of FusionDirectory (http://www.fusiondirectory.org/)
Copyright (C) 2003 Cajus Pollmeier Copyright (C) 2003 Cajus Pollmeier
Copyright (C) 2011-2016 FusionDirectory Copyright (C) 2011-2019 FusionDirectory
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
...@@ -30,50 +31,6 @@ ...@@ -30,50 +31,6 @@
does syntax checking and displays the formulars required. does syntax checking and displays the formulars required.
*/ */
class EpochDaysDateAttribute extends DateAttribute
{
/* 24 * 60 * 60 = 86400 */
public static $secondsPerDay = 86400;
function __construct ($label, $description, $ldapName, $required, $defaultValue = 'now', $defaultDate = NULL, $acl = '')
{
parent::__construct($label, $description, $ldapName, $required, '', $defaultValue, $defaultDate, $acl);
}
protected function ldapToDate ($ldapValue)
{
$date = DateTime::createFromFormat('U', $ldapValue * static::$secondsPerDay, timezone::utc());
if ($date !== FALSE) {
return $date;
} else {
trigger_error('LDAP value for '.$this->getLdapName().' was not in the right date format.');
return new DateTime($ldapValue, timezone::utc());
}
}
protected function dateToLdap (DateTime $dateValue)
{
return floor($dateValue->format('U') / static::$secondsPerDay);
}
function getEpochDays ()
{
if (empty($this->value)) {
return 0;
} else {
try {
return $this->dateToLdap($this->getDateValue());
} catch (Exception $e) {
if (is_object($this->plugin) && $this->plugin->is_template) {
return $this->value;
} else {
throw $e;
}
}
}
}
}
class posixAccount extends simplePlugin class posixAccount extends simplePlugin
{ {
var $displayHeader = TRUE; var $displayHeader = TRUE;
......
Supports Markdown
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