Skip to content

Commit

Permalink
change updatedate to redaxo style
Browse files Browse the repository at this point in the history
  • Loading branch information
TobiasKrais committed Apr 9, 2019
1 parent b2fdd6e commit d45314f
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 19 deletions.
2 changes: 1 addition & 1 deletion install.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;");

Expand Down
4 changes: 2 additions & 2 deletions lib/d2u_guestbook_module_manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
6 changes: 3 additions & 3 deletions lib/entries.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion modules/60/1/output.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ function sendAdminNotification($yform) {
print $entry->name;
}
print '</b></div>';
print '<div class="col-6 right">'. date('d.m.Y H:i', $entry->create_date) .' '. $tag_open .'d2u_guestbook_oclock'. $tag_close .'</div>';
print '<div class="col-6 right">'. date('d.m.Y H:i', strtotime($entry->create_date)) .' '. $tag_open .'d2u_guestbook_oclock'. $tag_close .'</div>';
print '</div>';
print '</div>';

Expand Down
2 changes: 1 addition & 1 deletion modules/60/3/output.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ function click_stars(wert) {
print $entry->name;
}
print '</b></div>';
print '<div class="col-6 right">'. date('d.m.Y H:i', $entry->create_date) .' '. $tag_open .'d2u_guestbook_oclock'. $tag_close .'</div>';
print '<div class="col-6 right">'. date('d.m.Y H:i', strtotime($entry->create_date)) .' '. $tag_open .'d2u_guestbook_oclock'. $tag_close .'</div>';
print '</div>';
print '</div>';

Expand Down
3 changes: 2 additions & 1 deletion pages/setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -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', '<br>');
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;
Expand Down Expand Up @@ -60,6 +60,7 @@
<ul>
<li>Listen im Backend werden jetzt nicht mehr in Seiten unterteilt.</li>
<li>YRewrite Multidomain support.</li>
<li>Datenbankfeld "create_date" in Redaxo Standard DATETIME umgewandelt. Beispielmodule sind angepasst.</li>
<li>Konvertierung der Datenbanktabellen zu utf8mb4.</li>
</ul>
<p>1.0.6:</p>
Expand Down
26 changes: 16 additions & 10 deletions update.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';");
Expand All @@ -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;");
$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;");
}

0 comments on commit d45314f

Please sign in to comment.