From 83dcd9da7b02749e3804520b54ce8c5c89eaa2de Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Mon, 8 Aug 2016 12:49:59 +0200 Subject: [PATCH] do not use '0000-00-00 00:00:00' as date anymore use NULL instead because '0000-00-00 00:00:00' in certain sql_modes --- SeedDMS_Core/Core/inc.ClassDMS.php | 6 ++++-- SeedDMS_Core/Core/inc.ClassTransmittal.php | 4 ++-- SeedDMS_Core/Core/inc.ClassUser.php | 7 ++++--- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/SeedDMS_Core/Core/inc.ClassDMS.php b/SeedDMS_Core/Core/inc.ClassDMS.php index 581d7216d..80c1d57d0 100644 --- a/SeedDMS_Core/Core/inc.ClassDMS.php +++ b/SeedDMS_Core/Core/inc.ClassDMS.php @@ -1639,8 +1639,10 @@ class SeedDMS_Core_DMS { elseif($role == '') $role = '0'; if(trim($pwdexpiration) == '') - $pwdexpiration = '0000-00-00 00:00:00'; - $queryStr = "INSERT INTO tblUsers (login, pwd, fullName, email, language, theme, comment, role, hidden, disabled, pwdExpiration, quota, homefolder) VALUES (".$db->qstr($login).", ".$db->qstr($pwd).", ".$db->qstr($fullName).", ".$db->qstr($email).", '".$language."', '".$theme."', ".$db->qstr($comment).", '".intval($role)."', '".intval($isHidden)."', '".intval($isDisabled)."', ".$db->qstr($pwdexpiration).", '".intval($quota)."', ".($homefolder ? intval($homefolder) : "NULL").")"; + $pwdexpiration = 'NULL'; + else + $pwdexpiration = $db->qstr($pwdexpiration); + $queryStr = "INSERT INTO tblUsers (login, pwd, fullName, email, language, theme, comment, role, hidden, disabled, pwdExpiration, quota, homefolder) VALUES (".$db->qstr($login).", ".$db->qstr($pwd).", ".$db->qstr($fullName).", ".$db->qstr($email).", '".$language."', '".$theme."', ".$db->qstr($comment).", '".intval($role)."', '".intval($isHidden)."', '".intval($isDisabled)."', ".$pwdexpiration.", '".intval($quota)."', ".($homefolder ? intval($homefolder) : "NULL").")"; $res = $this->db->getResult($queryStr); if (!$res) return false; diff --git a/SeedDMS_Core/Core/inc.ClassTransmittal.php b/SeedDMS_Core/Core/inc.ClassTransmittal.php index 2a4dbcf7c..6f847f446 100644 --- a/SeedDMS_Core/Core/inc.ClassTransmittal.php +++ b/SeedDMS_Core/Core/inc.ClassTransmittal.php @@ -79,7 +79,7 @@ class SeedDMS_Core_Transmittal { */ var $_dms; - function SeedDMS_Core_Transmittal($id, $user, $name, $comment, $isPublic=0, $date='0000-00-00 00:00:00') { + function SeedDMS_Core_Transmittal($id, $user, $name, $comment, $isPublic=0, $date='') { $this->_id = $id; $this->_name = $name; $this->_comment = $comment; @@ -312,7 +312,7 @@ class SeedDMS_Core_TransmittalItem { */ var $_date; - function SeedDMS_Core_TransmittalItem($id, $transmittal, $content, $date='0000-00-00 00:00:00') { + function SeedDMS_Core_TransmittalItem($id, $transmittal, $content, $date='') { $this->_id = $id; $this->_transmittal = $transmittal; $this->_content = $content; diff --git a/SeedDMS_Core/Core/inc.ClassUser.php b/SeedDMS_Core/Core/inc.ClassUser.php index 3dbe76a08..27d4a19ce 100644 --- a/SeedDMS_Core/Core/inc.ClassUser.php +++ b/SeedDMS_Core/Core/inc.ClassUser.php @@ -372,7 +372,7 @@ class SeedDMS_Core_User { /* {{{ */ const role_admin = '1'; const role_guest = '2'; - function __construct($id, $login, $pwd, $fullName, $email, $language, $theme, $comment, $role, $isHidden=0, $isDisabled=0, $pwdExpiration='0000-00-00 00:00:00', $loginFailures=0, $quota=0, $homeFolder=null, $secret='') { + function __construct($id, $login, $pwd, $fullName, $email, $language, $theme, $comment, $role, $isHidden=0, $isDisabled=0, $pwdExpiration='', $loginFailures=0, $quota=0, $homeFolder=null, $secret='') { $this->_id = $id; $this->_login = $login; $this->_pwd = $pwd; @@ -529,8 +529,9 @@ class SeedDMS_Core_User { /* {{{ */ $db = $this->_dms->getDB(); if(trim($newPwdExpiration) == '') - $newPwdExpiration = '0000-00-00 00:00:00'; - $queryStr = "UPDATE tblUsers SET pwdExpiration =".$db->qstr($newPwdExpiration)." WHERE id = " . $this->_id; + $queryStr = "UPDATE tblUsers SET pwdExpiration = NULL WHERE id = " . $this->_id; + else + $queryStr = "UPDATE tblUsers SET pwdExpiration =".$db->qstr($newPwdExpiration)." WHERE id = " . $this->_id; $res = $db->getResult($queryStr); if (!$res) return false;