Skip to content

Commit

Permalink
add form names and other stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
TobiasKrais committed Mar 24, 2023
1 parent 062532f commit bcb8a7a
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 731 deletions.
674 changes: 0 additions & 674 deletions LICENSE

This file was deleted.

55 changes: 37 additions & 18 deletions install.php
Original file line number Diff line number Diff line change
@@ -1,25 +1,44 @@
<?php

$sql = rex_sql::factory();

// Install database
$sql->setQuery('CREATE TABLE IF NOT EXISTS `'. rex::getTablePrefix() .'d2u_guestbook` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL,
`email` varchar(255) NOT NULL,
`description` text NOT NULL,
`clang_id` int(10) NOT NULL,
`rating` tinyint(1) DEFAULT 0,
`recommendation` tinyint(1) DEFAULT 0,
`privacy_policy_accepted` tinyint(1) DEFAULT 0,
`online_status` varchar(10) DEFAULT NULL,
`create_date` DATETIME NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci AUTO_INCREMENT=1;');
\rex_sql_table::get(\rex::getTable('d2u_guestbook'))
->ensureColumn(new rex_sql_column('id', 'INT(11) unsigned', false, null, 'auto_increment'))
->setPrimaryKey('id')
->ensureColumn(new \rex_sql_column('name', 'VARCHAR(255)', true))
->ensureColumn(new \rex_sql_column('email', 'VARCHAR(255)', true))
->ensureColumn(new \rex_sql_column('description', 'TEXT', true))
->ensureColumn(new \rex_sql_column('clang_id', 'INT(11)', true))
->ensureColumn(new \rex_sql_column('rating', 'TINYINT(1)', true))
->ensureColumn(new \rex_sql_column('recommendation', 'TINYINT(1)', true))
->ensureColumn(new \rex_sql_column('privacy_policy_accepted', 'TINYINT(1)', true))
->ensureColumn(new \rex_sql_column('online_status', 'VARCHAR(10)', true))
->ensureColumn(new \rex_sql_column('create_date', 'DATETIME'))
->ensure();

// Standard settings
if (!$this->hasConfig()) {
if (!$this->hasConfig('guestbook_article_id')) {
$this->setConfig('guestbook_article_id', rex_article::getSiteStartArticleId());
$this->setConfig('allow_answer', 'false');
$this->setConfig('no_entries_page', 10);
}

// Update modules
if (class_exists('D2UModuleManager')) {
$modules = [];
$modules[] = new D2UModule('60-1',
'D2U Guestbook - Gästebuch mit Bootstrap 4 Tabs',
12);
$modules[] = new D2UModule('60-2',
'D2U Guestbook - Infobox Bewertung',
2);
$modules[] = new D2UModule('60-3',
'D2U Guestbook - Gästebuch ohne Tabs',
10);
$d2u_module_manager = new D2UModuleManager($modules, '', 'd2u_guestbook');
$d2u_module_manager->autoupdate();
}

// Update language replacements
if (!class_exists('d2u_guestbook_lang_helper')) {
// Load class in case addon is deactivated
require_once 'lib/d2u_guestbook_lang_helper.php';
}
d2u_guestbook_lang_helper::factory()->install();
2 changes: 1 addition & 1 deletion lib/d2u_guestbook_module_manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public static function getModules()
2);
$modules[] = new D2UModule('60-3',
'D2U Guestbook - Gästebuch ohne Tabs',
9);
10);
return $modules;
}
}
1 change: 1 addition & 0 deletions modules/60/3/output.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ function click_stars(wert) {
$yform->setObjectparams('real_field_names', true);
$yform->setObjectparams('form_action', rex_getUrl(rex_article::getCurrentId(), null, ['entry' => 'add']));
$yform->setObjectparams('Error-occured', $tag_open .'d2u_guestbook_form_validate_title'. $tag_close);
$yform->setObjectparams('form_name', 'd2u_guestbook_module_60_3_'. rand(1, 100));

// action - showtext
$yform->setActionField('showtext', [$tag_open .'d2u_guestbook_form_thanks'. $tag_close]);
Expand Down
8 changes: 6 additions & 2 deletions package.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package: d2u_guestbook
version: '1.1.0'
version: '1.0.10'
author: Tobias Krais
supportpage: http://github.com/tobiaskrais/d2u_guestbook

Expand All @@ -18,6 +18,10 @@ requires:
d2u_helper: '>=1.5.2'
sprog: '>=1.0.0'
yform: '>=3.0'


default_config:
allow_answer: 'false'
no_entries_page: 10

installer_ignore:
- .github
7 changes: 5 additions & 2 deletions pages/setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,15 @@
<h2>Support</h2>
<p>Fehlermeldungen bitte im <a href="https://github.com/TobiasKrais/d2u_guestbook" target="_blank">GitHub Repository</a> melden.</p>
<h2>Changelog</h2>
<p>1.1.0-DEV:</p>
<p>1.0.10:</p>
<ul>
<li>PHP-CS-Fixer Code Verbesserungen.</li>
<li>Anpassungen an Publish Github Release to Redaxo.</li>
<li>Abhängigkeit zum emailobfuscator Addon entfernt.</li>
<li>Modul "60-1 D2U Guestbook - Gästebuch mit Bootstrap 4 Tabs": Gesamtbreite kann eingestellt werden.</li>
<li>Erste rexstan Verbesserungen.</li>
<li>install.php und update.php vereinheitlicht.</li>
<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>
<li>Modul "60-3 D2U Guestbook - Gästebuch ohne Tabs": Formularname hinzugefügt, damit mehrere Formulare auf einer Webseite it YFrom Spamprotection funktionieren.</li>
</ul>
<p>1.0.9:</p>
<ul>
Expand Down
40 changes: 6 additions & 34 deletions update.php
Original file line number Diff line number Diff line change
@@ -1,47 +1,16 @@
<?php

// Update language replacements
if (!class_exists('d2u_guestbook_lang_helper')) {
// Load class in case addon is deactivated
require_once 'lib/d2u_guestbook_lang_helper.php';
}
d2u_guestbook_lang_helper::factory()->install();

// Update modules
if (class_exists('D2UModuleManager')) {
$modules = [];
$modules[] = new D2UModule('60-1',
'D2U Guestbook - Gästebuch mit Bootstrap 4 Tabs',
12);
$modules[] = new D2UModule('60-2',
'D2U Guestbook - Infobox Bewertung',
2);
$modules[] = new D2UModule('60-3',
'D2U Guestbook - Gästebuch ohne Tabs',
9);
$d2u_module_manager = new D2UModuleManager($modules, '', 'd2u_guestbook');
$d2u_module_manager->autoupdate();
}

// remove default lang setting
if (!$this->hasConfig()) {
// remove old default lang setting
if ($this->hasConfig('default_lang')) {
$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';");
if (0 === (int) $sql->getRows()) {
$sql->setQuery('ALTER TABLE '. \rex::getTablePrefix() .'d2u_guestbook '
. 'ADD privacy_policy_accepted tinyint(1) DEFAULT 0 AFTER recommendation;');
}
// 1.0.6 Update database
if (rex_version::compare($this->getVersion(), '1.0.6', '<')) {
$sql->setQuery('UPDATE '. \rex::getTablePrefix() ."d2u_guestbook SET privacy_policy_accepted = '0' WHERE privacy_policy_accepted = 'no';");
$sql->setQuery('UPDATE '. \rex::getTablePrefix() ."d2u_guestbook SET privacy_policy_accepted = '1' WHERE privacy_policy_accepted = 'yes';");
$sql->setQuery('ALTER TABLE '. \rex::getTablePrefix() .'d2u_guestbook CHANGE privacy_policy_accepted privacy_policy_accepted tinyint(1) DEFAULT 0;');
$sql->setQuery('ALTER TABLE '. \rex::getTablePrefix() .'d2u_guestbook CHANGE privacy_policy_accepted privacy_policy_accepted TINYINT(1) DEFAULT 0;');
}

// Update database to 1.0.7
Expand All @@ -52,3 +21,6 @@
$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;');
}

// use path relative to __DIR__ to get correct path in update temp dir
$this->includeFile(__DIR__.'/install.php'); /** @phpstan-ignore-line */

0 comments on commit bcb8a7a

Please sign in to comment.