[debian-edu-commits] debian-edu/pkg-team/ 01/01: debian/patches: Add 1015_allow-iso8601-date-format-in-user-API.patch. Allow writing ISO8601 conform date strings into the dateOfBirth field.

Mike Gabriel sunweaver at debian.org
Thu Sep 3 03:24:29 UTC 2015


This is an automated email from the git hooks/post-receive script.

sunweaver pushed a commit to branch master
in repository gosa.

commit 3e278666a5cc866063b3715d023695ccac439d3a
Author: Mike Gabriel <mike.gabriel at das-netzwerkteam.de>
Date:   Thu Sep 3 05:23:57 2015 +0200

    debian/patches: Add 1015_allow-iso8601-date-format-in-user-API.patch. Allow writing ISO8601 conform date strings into the dateOfBirth field.
---
 ...015_allow-iso8601-date-format-in-user-API.patch | 57 ++++++++++++++++++++++
 debian/patches/series                              |  1 +
 2 files changed, 58 insertions(+)

diff --git a/debian/patches/1015_allow-iso8601-date-format-in-user-API.patch b/debian/patches/1015_allow-iso8601-date-format-in-user-API.patch
new file mode 100644
index 0000000..a53598b
--- /dev/null
+++ b/debian/patches/1015_allow-iso8601-date-format-in-user-API.patch
@@ -0,0 +1,57 @@
+--- a/gosa-core/include/utils/class_tests.inc
++++ b/gosa-core/include/utils/class_tests.inc
+@@ -324,6 +324,23 @@
+ 
+     return checkdate($matches[2],$matches[1],$matches[3]);
+   }
++
++  /* Check if entry value is a valid date */
++  public static function is_iso8601_date($date)
++  {
++    global $lang;
++
++    if ($date == ""){
++      return (TRUE);
++    }
++
++    if (!preg_match("/^(\d{4})-(\d{2})-(\d{2})$/", $date, $matches)) {
++      return false;
++    }
++
++    return checkdate($matches[2],$matches[3],$matches[1]);
++  }
++
+   /*
+    * Compares two dates
+    * @param $dataA as String in german dateformat
+--- a/gosa-core/plugins/personal/generic/class_user.inc
++++ b/gosa-core/plugins/personal/generic/class_user.inc
+@@ -917,9 +917,16 @@
+ 
+     if ($this->dateOfBirth != ""){
+       if(!is_array($this->attrs['dateOfBirth'])) {
+-        #TODO: use $lang to convert date
+-        list($day, $month, $year)= explode(".", $this->dateOfBirth);
+-        $this->attrs['dateOfBirth'] = sprintf("%04d-%02d-%02d", $year, $month, $day);
++        if (tests::is_iso8601_date($this->dateOfBirth))
++        {
++            /* allow ISO8601 date format as dateOfBirth */
++            $this->attrs['dateOfBirth'] = $this->dateOfBirth;
++        }
++        else {
++            // TODO: use $lang to convert date
++            list($day, $month, $year)= explode(".", $this->dateOfBirth);
++            $this->attrs['dateOfBirth'] = sprintf("%04d-%02d-%02d", $year, $month, $day);
++        }
+       }
+     }
+ 
+@@ -1370,7 +1377,7 @@
+     }
+ 
+     /* Check dates */
+-    if (!tests::is_date($this->dateOfBirth)){
++    if ((!tests::is_date($this->dateOfBirth)) && (!tests::is_iso8601_date($this->dateOfBirth))){
+       $message[]= msgPool::invalid(_("Date of birth"), $this->dateOfBirth,"" ,"23.02.2009");
+     }
+ 
diff --git a/debian/patches/series b/debian/patches/series
index acd3747..b583200 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -17,6 +17,7 @@
 1012_allow-one-level-domains-in-email-addresses.patch
 1013_fix-smarty-gettext-tags-recognition.patch
 1014_fix-description-of-new-prim-groups.patch
+1015_allow-iso8601-date-format-in-user-API.patch
 2001_fix-smarty-location.patch
 2002_fix-template-location.patch
 2003_fix-class-mapping.patch

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-edu/pkg-team/gosa.git



More information about the debian-edu-commits mailing list