diff --git a/install.php b/install.php index d66f657..84a16a5 100644 --- a/install.php +++ b/install.php @@ -16,8 +16,8 @@ ->ensure(); // Standard settings -if (!$this->hasConfig('guestbook_article_id')) { - $this->setConfig('guestbook_article_id', rex_article::getSiteStartArticleId()); +if (!rex_config::has('d2u_guestbook', 'guestbook_article_id')) { + rex_config::set('d2u_guestbook', 'guestbook_article_id', rex_article::getSiteStartArticleId()); } // Update modules @@ -25,7 +25,7 @@ $modules = []; $modules[] = new D2UModule('60-1', 'D2U Guestbook - Gästebuch mit Bootstrap 4 Tabs', - 13); + 14); $modules[] = new D2UModule('60-2', 'D2U Guestbook - Infobox Bewertung', 3); diff --git a/lib/d2u_guestbook_backend_helper.php b/lib/d2u_guestbook_backend_helper.php index 941b80a..8dca86e 100644 --- a/lib/d2u_guestbook_backend_helper.php +++ b/lib/d2u_guestbook_backend_helper.php @@ -4,7 +4,6 @@ use rex; use rex_addon; -use rex_addon_interface; use rex_config; use rex_mailer; use rex_yrewrite; @@ -16,14 +15,14 @@ class d2u_guestbook_backend_helper { /** * Send mail to admin address when news guestbook entry is created. - * @param mixed $yform + * @param \rex_yform_action_callback $yform */ - public static function sendAdminNotification($yform) + public static function sendAdminNotification($yform):void { - if (isset($yform->params['values']) && '' != rex_config::get('d2u_guestbook', 'request_form_email')) { + if (isset($yform->params['values']) && '' !== (string) rex_config::get('d2u_guestbook', 'request_form_email')) { $fields = []; foreach ($yform->params['values'] as $value) { - if ('' != $value->name) { + if ('' !== $value->name) { $fields[$value->name] = $value->value; } } @@ -31,10 +30,10 @@ public static function sendAdminNotification($yform) $mail = new rex_mailer(); $mail->isHTML(false); $mail->CharSet = 'utf-8'; - $mail->From = rex_config::get('d2u_guestbook', 'request_form_email'); - $mail->Sender = rex_config::get('d2u_guestbook', 'request_form_email'); + $mail->From = (string) rex_config::get('d2u_guestbook', 'request_form_email'); + $mail->Sender = (string) rex_config::get('d2u_guestbook', 'request_form_email'); - $mail->addAddress(rex_config::get('d2u_guestbook', 'request_form_email')); + $mail->addAddress((string) rex_config::get('d2u_guestbook', 'request_form_email')); $mail->addReplyTo($fields['email'], $fields['name']); $mail->Subject = 'New Guestbook entry - Neuer Gästebuch eintrag - '. (rex_addon::get('yrewrite')->isAvailable() ? rex_yrewrite::getCurrentDomain()->getUrl() : rex::getServer()); diff --git a/lib/d2u_guestbook_lang_helper.php b/lib/d2u_guestbook_lang_helper.php index a80fc3d..b9594fd 100644 --- a/lib/d2u_guestbook_lang_helper.php +++ b/lib/d2u_guestbook_lang_helper.php @@ -1,5 +1,6 @@ getRows(); if ($num_rows > 0) { - $this->id = $result->getValue('id'); - $this->clang_id = $result->getValue('clang_id'); - $this->name = stripslashes($result->getValue('name')); - $this->email = $result->getValue('email'); - $this->rating = $result->getValue('rating'); - $this->recommendation = 1 == $result->getValue('recommendation') ? true : false; + $this->id = (int) $result->getValue('id'); + $this->clang_id = (int) $result->getValue('clang_id'); + $this->name = stripslashes((string) $result->getValue('name')); + $this->email = (string) $result->getValue('email'); + $this->rating = (int) $result->getValue('rating'); + $this->recommendation = 1 === (int) $result->getValue('recommendation') ? true : false; $this->privacy_policy_accepted = 1 === (int) $result->getValue('privacy_policy_accepted') ? true : false; - $this->description = stripslashes(htmlspecialchars_decode($result->getValue('description'))); - $this->online_status = $result->getValue('online_status'); - $this->create_date = $result->getValue('create_date'); + $this->description = stripslashes(htmlspecialchars_decode((string) $result->getValue('description'))); + $this->online_status = (string) $result->getValue('online_status'); + $this->create_date = (string) $result->getValue('create_date'); } } @@ -125,7 +125,7 @@ public static function getAll($online_only = false) $entries = []; for ($i = 0; $i < $result->getRows(); ++$i) { - $entries[] = new self($result->getValue('id')); + $entries[] = new self((int) $result->getValue('id')); $result->next(); } return $entries; @@ -161,7 +161,7 @@ public static function getRecommendation() /** * Updates or inserts the object into database. - * @return in error code if error occurs + * @return bool true if error occurs */ public function save() { @@ -175,7 +175,7 @@ public function save() ."privacy_policy_accepted = '". ($this->privacy_policy_accepted ? 'yes' : 'no') ."', " ."description = '". addslashes(htmlspecialchars($this->description)) ."', " ."online_status = '". $this->online_status ."' "; - if (0 == $this->id) { + if (0 === $this->id) { $query = 'INSERT INTO '. $query . ', create_date = CURRENT_TIMESTAMP'; } else { $query = 'UPDATE '. $query .' WHERE id = '. $this->id; @@ -183,7 +183,7 @@ public function save() $result = rex_sql::factory(); $result->setQuery($query); - if (0 == $this->id) { + if (0 === $this->id) { $this->id = (int) $result->getLastId(); $error = $result->hasError(); } diff --git a/modules/60/1/output.php b/modules/60/1/output.php index b32f31b..19c7734 100644 --- a/modules/60/1/output.php +++ b/modules/60/1/output.php @@ -11,14 +11,14 @@ echo '