From d45314fc176d179e94f598dbf49ba04be5b7b011 Mon Sep 17 00:00:00 2001 From: Tobias Krais Date: Tue, 9 Apr 2019 23:32:28 +0200 Subject: [PATCH] change updatedate to redaxo style --- install.php | 2 +- lib/d2u_guestbook_module_manager.php | 4 ++-- lib/entries.php | 6 +++--- modules/60/1/output.php | 2 +- modules/60/3/output.php | 2 +- pages/setup.php | 3 ++- update.php | 26 ++++++++++++++++---------- 7 files changed, 26 insertions(+), 19 deletions(-) diff --git a/install.php b/install.php index 8ab9583..4570a1c 100644 --- a/install.php +++ b/install.php @@ -12,7 +12,7 @@ `recommendation` tinyint(1) DEFAULT 0, `privacy_policy_accepted` tinyint(1) DEFAULT 0, `online_status` varchar(10) DEFAULT NULL, - `create_date` int(11) NOT NULL, + `create_date` DATETIME NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci AUTO_INCREMENT=1;"); diff --git a/lib/d2u_guestbook_module_manager.php b/lib/d2u_guestbook_module_manager.php index e6d8895..de5135c 100644 --- a/lib/d2u_guestbook_module_manager.php +++ b/lib/d2u_guestbook_module_manager.php @@ -13,13 +13,13 @@ public static function getModules() { $modules = []; $modules[] = new D2UModule("60-1", "D2U Guestbook - Gästebuch mit Bootstrap 4 Tabs", - 8); + 9); $modules[] = new D2UModule("60-2", "D2U Guestbook - Infobox Bewertung", 2); $modules[] = new D2UModule("60-3", "D2U Guestbook - Gästebuch ohne Tabs", - 7); + 8); return $modules; } } \ No newline at end of file diff --git a/lib/entries.php b/lib/entries.php index 4d56b18..b9661db 100644 --- a/lib/entries.php +++ b/lib/entries.php @@ -56,9 +56,9 @@ class Entry { var $online_status = "online"; /** - * @var int create date + * @var string create date */ - var $create_date = 0; + var $create_date = ""; /** * Constructor. Reads a contact stored in database. @@ -185,7 +185,7 @@ public function save() { ."description = '". addslashes(htmlspecialchars($this->description)) ."', " ."online_status = '". $this->online_status ."' "; if($this->id == 0) { - $query = "INSERT INTO ". $query . ", create_date = ". time(); + $query = "INSERT INTO ". $query . ", create_date = CURRENT_TIMESTAMP"; } else { $query = "UPDATE ". $query ." WHERE id = ". $this->id; diff --git a/modules/60/1/output.php b/modules/60/1/output.php index 98aa356..fd6a504 100644 --- a/modules/60/1/output.php +++ b/modules/60/1/output.php @@ -55,7 +55,7 @@ function sendAdminNotification($yform) { print $entry->name; } print ''; - print '
'. date('d.m.Y H:i', $entry->create_date) .' '. $tag_open .'d2u_guestbook_oclock'. $tag_close .'
'; + print '
'. date('d.m.Y H:i', strtotime($entry->create_date)) .' '. $tag_open .'d2u_guestbook_oclock'. $tag_close .'
'; print ''; print ''; diff --git a/modules/60/3/output.php b/modules/60/3/output.php index 3b18cab..bcf434d 100644 --- a/modules/60/3/output.php +++ b/modules/60/3/output.php @@ -116,7 +116,7 @@ function click_stars(wert) { print $entry->name; } print ''; - print '
'. date('d.m.Y H:i', $entry->create_date) .' '. $tag_open .'d2u_guestbook_oclock'. $tag_close .'
'; + print '
'. date('d.m.Y H:i', strtotime($entry->create_date)) .' '. $tag_open .'d2u_guestbook_oclock'. $tag_close .'
'; print ''; print ''; diff --git a/pages/setup.php b/pages/setup.php index ae13bd8..5b659ff 100644 --- a/pages/setup.php +++ b/pages/setup.php @@ -22,7 +22,7 @@ if(rex_request('import', 'string') == "tvsgb" && $tvsgb_available) { $sql->setQuery("UPDATE `". rex::getTablePrefix() ."771_entries` SET description = REPLACE(description, '\r\n', '
'); INSERT INTO ". rex::getTablePrefix() ."d2u_guestbook (`name`, `email`, `description`, `clang_id`, `online_status`, `create_date`) - SELECT `create_user`, `email`, `description`, `clang`, `status`, `create_date` FROM ". rex::getTablePrefix() ."771_entries; + SELECT `create_user`, `email`, `description`, `clang`, `status`, FROM_UNIXTIME(`create_date`) FROM ". rex::getTablePrefix() ."771_entries; UPDATE `". rex::getTablePrefix() ."d2u_guestbook` SET `online_status` = 'online' WHERE `online_status` = '1'; UPDATE `". rex::getTablePrefix() ."d2u_guestbook` SET `online_status` = 'offline' WHERE `online_status` = '0'; UPDATE `". rex::getTablePrefix() ."d2u_guestbook` SET rating = 0 WHERE rating = NULL; @@ -60,6 +60,7 @@

1.0.6:

diff --git a/update.php b/update.php index cee7e5c..c89220f 100644 --- a/update.php +++ b/update.php @@ -11,17 +11,24 @@ $modules = []; $modules[] = new D2UModule("60-1", "D2U Guestbook - Gästebuch mit Bootstrap 4 Tabs", - 8); + 9); $modules[] = new D2UModule("60-2", "D2U Guestbook - Infobox Bewertung", 2); $modules[] = new D2UModule("60-3", "D2U Guestbook - Gästebuch ohne Tabs", - 7); + 8); $d2u_module_manager = new D2UModuleManager($modules, "", "d2u_address"); $d2u_module_manager->autoupdate(); } +// remove default lang setting +if (!$this->hasConfig()) { + $this->removeConfig('default_lang'); + $this->setConfig('allow_answer', 'false'); + $this->setConfig('no_entries_page', 10); +} + $sql = rex_sql::factory(); // 1.0.3 Update database $sql->setQuery("SHOW COLUMNS FROM ". \rex::getTablePrefix() ."d2u_guestbook LIKE 'privacy_policy_accepted';"); @@ -36,12 +43,11 @@ $sql->setQuery("ALTER TABLE ". \rex::getTablePrefix() ."d2u_guestbook CHANGE privacy_policy_accepted privacy_policy_accepted tinyint(1) DEFAULT 0;"); } -// remove default lang setting -if (!$this->hasConfig()) { - $this->removeConfig('default_lang'); - $this->setConfig('allow_answer', 'false'); - $this->setConfig('no_entries_page', 10); -} - // Update database to 1.0.7 -$sql->setQuery("ALTER TABLE `". rex::getTablePrefix() ."d2u_guestbook` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;"); \ No newline at end of file +$sql->setQuery("ALTER TABLE `". rex::getTablePrefix() ."d2u_guestbook` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;"); +if (rex_string::versionCompare($this->getVersion(), '1.0.7', '<')) { + $sql->setQuery("ALTER TABLE ". \rex::getTablePrefix() ."d2u_guestbook ADD COLUMN `create_date_new` DATETIME NOT NULL AFTER `create_date`;"); + $sql->setQuery("UPDATE ". \rex::getTablePrefix() ."d2u_guestbook SET `create_date_new` = FROM_UNIXTIME(`create_date`);"); + $sql->setQuery("ALTER TABLE ". \rex::getTablePrefix() ."d2u_guestbook DROP create_date;"); + $sql->setQuery("ALTER TABLE ". \rex::getTablePrefix() ."d2u_guestbook CHANGE `create_date_new` `create_date` DATETIME NOT NULL;"); +} \ No newline at end of file