Skip to content

Commit bcb8a7a

Browse files
committed
add form names and other stuff
1 parent 062532f commit bcb8a7a

File tree

7 files changed

+56
-731
lines changed

7 files changed

+56
-731
lines changed

LICENSE

Lines changed: 0 additions & 674 deletions
This file was deleted.

install.php

Lines changed: 37 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,44 @@
11
<?php
22

3-
$sql = rex_sql::factory();
4-
53
// Install database
6-
$sql->setQuery('CREATE TABLE IF NOT EXISTS `'. rex::getTablePrefix() .'d2u_guestbook` (
7-
`id` int(11) NOT NULL AUTO_INCREMENT,
8-
`name` varchar(255) NOT NULL,
9-
`email` varchar(255) NOT NULL,
10-
`description` text NOT NULL,
11-
`clang_id` int(10) NOT NULL,
12-
`rating` tinyint(1) DEFAULT 0,
13-
`recommendation` tinyint(1) DEFAULT 0,
14-
`privacy_policy_accepted` tinyint(1) DEFAULT 0,
15-
`online_status` varchar(10) DEFAULT NULL,
16-
`create_date` DATETIME NOT NULL,
17-
PRIMARY KEY (`id`)
18-
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci AUTO_INCREMENT=1;');
4+
\rex_sql_table::get(\rex::getTable('d2u_guestbook'))
5+
->ensureColumn(new rex_sql_column('id', 'INT(11) unsigned', false, null, 'auto_increment'))
6+
->setPrimaryKey('id')
7+
->ensureColumn(new \rex_sql_column('name', 'VARCHAR(255)', true))
8+
->ensureColumn(new \rex_sql_column('email', 'VARCHAR(255)', true))
9+
->ensureColumn(new \rex_sql_column('description', 'TEXT', true))
10+
->ensureColumn(new \rex_sql_column('clang_id', 'INT(11)', true))
11+
->ensureColumn(new \rex_sql_column('rating', 'TINYINT(1)', true))
12+
->ensureColumn(new \rex_sql_column('recommendation', 'TINYINT(1)', true))
13+
->ensureColumn(new \rex_sql_column('privacy_policy_accepted', 'TINYINT(1)', true))
14+
->ensureColumn(new \rex_sql_column('online_status', 'VARCHAR(10)', true))
15+
->ensureColumn(new \rex_sql_column('create_date', 'DATETIME'))
16+
->ensure();
1917

2018
// Standard settings
21-
if (!$this->hasConfig()) {
19+
if (!$this->hasConfig('guestbook_article_id')) {
2220
$this->setConfig('guestbook_article_id', rex_article::getSiteStartArticleId());
23-
$this->setConfig('allow_answer', 'false');
24-
$this->setConfig('no_entries_page', 10);
2521
}
22+
23+
// Update modules
24+
if (class_exists('D2UModuleManager')) {
25+
$modules = [];
26+
$modules[] = new D2UModule('60-1',
27+
'D2U Guestbook - Gästebuch mit Bootstrap 4 Tabs',
28+
12);
29+
$modules[] = new D2UModule('60-2',
30+
'D2U Guestbook - Infobox Bewertung',
31+
2);
32+
$modules[] = new D2UModule('60-3',
33+
'D2U Guestbook - Gästebuch ohne Tabs',
34+
10);
35+
$d2u_module_manager = new D2UModuleManager($modules, '', 'd2u_guestbook');
36+
$d2u_module_manager->autoupdate();
37+
}
38+
39+
// Update language replacements
40+
if (!class_exists('d2u_guestbook_lang_helper')) {
41+
// Load class in case addon is deactivated
42+
require_once 'lib/d2u_guestbook_lang_helper.php';
43+
}
44+
d2u_guestbook_lang_helper::factory()->install();

lib/d2u_guestbook_module_manager.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public static function getModules()
2121
2);
2222
$modules[] = new D2UModule('60-3',
2323
'D2U Guestbook - Gästebuch ohne Tabs',
24-
9);
24+
10);
2525
return $modules;
2626
}
2727
}

modules/60/3/output.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ function click_stars(wert) {
7979
$yform->setObjectparams('real_field_names', true);
8080
$yform->setObjectparams('form_action', rex_getUrl(rex_article::getCurrentId(), null, ['entry' => 'add']));
8181
$yform->setObjectparams('Error-occured', $tag_open .'d2u_guestbook_form_validate_title'. $tag_close);
82+
$yform->setObjectparams('form_name', 'd2u_guestbook_module_60_3_'. rand(1, 100));
8283

8384
// action - showtext
8485
$yform->setActionField('showtext', [$tag_open .'d2u_guestbook_form_thanks'. $tag_close]);

package.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
package: d2u_guestbook
2-
version: '1.1.0'
2+
version: '1.0.10'
33
author: Tobias Krais
44
supportpage: http://github.com/tobiaskrais/d2u_guestbook
55

@@ -18,6 +18,10 @@ requires:
1818
d2u_helper: '>=1.5.2'
1919
sprog: '>=1.0.0'
2020
yform: '>=3.0'
21-
21+
22+
default_config:
23+
allow_answer: 'false'
24+
no_entries_page: 10
25+
2226
installer_ignore:
2327
- .github

pages/setup.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,15 @@
5454
<h2>Support</h2>
5555
<p>Fehlermeldungen bitte im <a href="https://github.com/TobiasKrais/d2u_guestbook" target="_blank">GitHub Repository</a> melden.</p>
5656
<h2>Changelog</h2>
57-
<p>1.1.0-DEV:</p>
57+
<p>1.0.10:</p>
5858
<ul>
5959
<li>PHP-CS-Fixer Code Verbesserungen.</li>
6060
<li>Anpassungen an Publish Github Release to Redaxo.</li>
6161
<li>Abhängigkeit zum emailobfuscator Addon entfernt.</li>
62-
<li>Modul "60-1 D2U Guestbook - Gästebuch mit Bootstrap 4 Tabs": Gesamtbreite kann eingestellt werden.</li>
62+
<li>Erste rexstan Verbesserungen.</li>
63+
<li>install.php und update.php vereinheitlicht.</li>
64+
<li>Modul "60-1 D2U Guestbook - Gästebuch mit Bootstrap 4 Tabs": Gesamtbreite kann eingestellt werden und Formularname hinzugefügt, damit mehrere Formulare auf einer Webseite it YFrom Spamprotection funktionieren..</li>
65+
<li>Modul "60-3 D2U Guestbook - Gästebuch ohne Tabs": Formularname hinzugefügt, damit mehrere Formulare auf einer Webseite it YFrom Spamprotection funktionieren.</li>
6366
</ul>
6467
<p>1.0.9:</p>
6568
<ul>

update.php

Lines changed: 6 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,16 @@
11
<?php
22

3-
// Update language replacements
4-
if (!class_exists('d2u_guestbook_lang_helper')) {
5-
// Load class in case addon is deactivated
6-
require_once 'lib/d2u_guestbook_lang_helper.php';
7-
}
8-
d2u_guestbook_lang_helper::factory()->install();
9-
10-
// Update modules
11-
if (class_exists('D2UModuleManager')) {
12-
$modules = [];
13-
$modules[] = new D2UModule('60-1',
14-
'D2U Guestbook - Gästebuch mit Bootstrap 4 Tabs',
15-
12);
16-
$modules[] = new D2UModule('60-2',
17-
'D2U Guestbook - Infobox Bewertung',
18-
2);
19-
$modules[] = new D2UModule('60-3',
20-
'D2U Guestbook - Gästebuch ohne Tabs',
21-
9);
22-
$d2u_module_manager = new D2UModuleManager($modules, '', 'd2u_guestbook');
23-
$d2u_module_manager->autoupdate();
24-
}
25-
26-
// remove default lang setting
27-
if (!$this->hasConfig()) {
3+
// remove old default lang setting
4+
if ($this->hasConfig('default_lang')) {
285
$this->removeConfig('default_lang');
29-
$this->setConfig('allow_answer', 'false');
30-
$this->setConfig('no_entries_page', 10);
316
}
327

338
$sql = rex_sql::factory();
34-
// 1.0.3 Update database
35-
$sql->setQuery('SHOW COLUMNS FROM '. \rex::getTablePrefix() ."d2u_guestbook LIKE 'privacy_policy_accepted';");
36-
if (0 === (int) $sql->getRows()) {
37-
$sql->setQuery('ALTER TABLE '. \rex::getTablePrefix() .'d2u_guestbook '
38-
. 'ADD privacy_policy_accepted tinyint(1) DEFAULT 0 AFTER recommendation;');
39-
}
409
// 1.0.6 Update database
4110
if (rex_version::compare($this->getVersion(), '1.0.6', '<')) {
4211
$sql->setQuery('UPDATE '. \rex::getTablePrefix() ."d2u_guestbook SET privacy_policy_accepted = '0' WHERE privacy_policy_accepted = 'no';");
4312
$sql->setQuery('UPDATE '. \rex::getTablePrefix() ."d2u_guestbook SET privacy_policy_accepted = '1' WHERE privacy_policy_accepted = 'yes';");
44-
$sql->setQuery('ALTER TABLE '. \rex::getTablePrefix() .'d2u_guestbook CHANGE privacy_policy_accepted privacy_policy_accepted tinyint(1) DEFAULT 0;');
13+
$sql->setQuery('ALTER TABLE '. \rex::getTablePrefix() .'d2u_guestbook CHANGE privacy_policy_accepted privacy_policy_accepted TINYINT(1) DEFAULT 0;');
4514
}
4615

4716
// Update database to 1.0.7
@@ -52,3 +21,6 @@
5221
$sql->setQuery('ALTER TABLE '. \rex::getTablePrefix() .'d2u_guestbook DROP create_date;');
5322
$sql->setQuery('ALTER TABLE '. \rex::getTablePrefix() .'d2u_guestbook CHANGE `create_date_new` `create_date` DATETIME NOT NULL;');
5423
}
24+
25+
// use path relative to __DIR__ to get correct path in update temp dir
26+
$this->includeFile(__DIR__.'/install.php'); /** @phpstan-ignore-line */

0 commit comments

Comments
 (0)