From 631bd9cc6030a0ef458139b0e68f6f1c93b92d0d Mon Sep 17 00:00:00 2001 From: janw Date: Thu, 4 Jan 2007 08:35:10 +0000 Subject: [PATCH] Fixed problem related to template-based user-creation and dates (dateOfBirth, shadowExpire). git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.5@5467 594d385d-05f5-0310-b6e9-bd551577e9d8 --- plugins/personal/generic/class_user.inc | 7 ++++++- plugins/personal/posix/class_posixAccount.inc | 20 +++++++++++++++---- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/plugins/personal/generic/class_user.inc b/plugins/personal/generic/class_user.inc index 46ecbc77d..063a974c3 100644 --- a/plugins/personal/generic/class_user.inc +++ b/plugins/personal/generic/class_user.inc @@ -219,7 +219,12 @@ class user extends plugin } else { if(is_array($this->dateOfBirth)){ $date = $this->dateOfBirth; - }else{ + + // Trigger on dates like 1985-04-01, getdate only understands timestamps + } else if (!is_numeric($this->dateOfBirth)){ + $date= getdate(strtotime($this->dateOfBirth)); + + } else { $date = getdate($this->dateOfBirth); } } diff --git a/plugins/personal/posix/class_posixAccount.inc b/plugins/personal/posix/class_posixAccount.inc index 901caa244..847f8dafe 100644 --- a/plugins/personal/posix/class_posixAccount.inc +++ b/plugins/personal/posix/class_posixAccount.inc @@ -1053,16 +1053,28 @@ class posixAccount extends plugin } /* Adjust shadow checkboxes */ - foreach (array("shadowMin", "shadowMax", "shadowWarning", "shadowInactive", - "shadowExpire") as $val){ - + foreach (array("shadowMin", "shadowMax", "shadowWarning", "shadowInactive") as $val){ if ($this->$val != 0){ $oval= "use_".$val; $this->$oval= "1"; } } - $this->shadowExpire= $this->convertToSeconds($this->shadowExpire); + /* FIXME: NEED review of this section */ + /* Need to check shadowExpire separately */ + + /* + * If shadowExpire is not enabled in the template, it's a UNIX timestamp - so don't convert it to seconds. + * The check is a hack - if difference between timestamp generated above and here is max 1 day. + */ + if(abs($this->shadowExpire - time())>86400) { + $this->shadowExpire= $this->convertToSeconds($this->shadowExpire); + } + + /* Only enable checkbox, if shadowExpire is in the future */ + if($this->shadowExpire > time()) { + $this->use_shadowExpire= "1"; + } } function get_next_id($attrib) -- 2.30.2