From 2eab3691c97a3cfb7d6f20ac582bbf04a57af636 Mon Sep 17 00:00:00 2001 From: grandeljay Date: Fri, 25 Nov 2022 15:21:06 +0100 Subject: [PATCH] Add option to enable advertisements --- src/assets/css/default/dark.css | 4 ++++ src/assets/js/profile.js | 3 +++ src/classes/page.php | 18 +++++++++++++++ src/classes/user.php | 1 + src/pages/changelog.php | 6 +++++ src/pages/install.php | 1 + src/pages/profile.php | 41 +++++++++++++++++++++++++++++++++ src/update/1-7-1.sql | 8 +++++++ 8 files changed, 82 insertions(+) diff --git a/src/assets/css/default/dark.css b/src/assets/css/default/dark.css index 5d543b34..7dd62803 100644 --- a/src/assets/css/default/dark.css +++ b/src/assets/css/default/dark.css @@ -153,6 +153,10 @@ /** * Checkbox */ + .ui.checkbox label, + .ui.checkbox + label { + color: rgba(255, 255, 255, .9) !important; + } .ui.toggle.checkbox input:checked ~ label { color: #fff !important; } diff --git a/src/assets/js/profile.js b/src/assets/js/profile.js index e00e5c2f..e5a868a5 100644 --- a/src/assets/js/profile.js +++ b/src/assets/js/profile.js @@ -92,4 +92,7 @@ $(function() { }); } } + + /** Advertisements */ + $('.ui.checkbox.advertisements').checkbox(); }); diff --git a/src/classes/page.php b/src/classes/page.php index 18d30f56..4efff11b 100644 --- a/src/classes/page.php +++ b/src/classes/page.php @@ -231,6 +231,8 @@ class Page public function header(): void { global $locales; + + $user = isset($_SESSION['user']->id) ? $_SESSION['user'] : new User(); ?> @@ -395,6 +397,22 @@ class Page data-domain="" src="https://plausible.io/js/plausible.js"> + advertisements || $CrawlerDetect->isCrawler())) { + ?> + + <?= $this->title ?> - wishthis - <?= __('Make a wish') ?> diff --git a/src/classes/user.php b/src/classes/user.php index 5e6939d8..0db2d073 100644 --- a/src/classes/user.php +++ b/src/classes/user.php @@ -51,6 +51,7 @@ class User */ public int $power = 0; public ?\Gettext\Translations $translations = null; + public bool $advertisements = false; public function __construct(array $fields = array()) { diff --git a/src/pages/changelog.php b/src/pages/changelog.php index b268fcdc..47eaa26a 100644 --- a/src/pages/changelog.php +++ b/src/pages/changelog.php @@ -112,6 +112,12 @@ $page->navigation(); echo __('Compact/list view for wishes'); ?> +
  • + +
  • diff --git a/src/pages/install.php b/src/pages/install.php index 222e5352..b3690acc 100644 --- a/src/pages/install.php +++ b/src/pages/install.php @@ -162,6 +162,7 @@ switch ($step) { `name_last` VARCHAR(32) NULL DEFAULT NULL, `name_nick` VARCHAR(32) NULL DEFAULT NULL, `channel` VARCHAR(24) NULL DEFAULT NULL, + `advertisements` TINYINT(1) NOT NULL DEFAULT 0, INDEX `idx_password` (`password`) );' diff --git a/src/pages/profile.php b/src/pages/profile.php index 4bcd79c5..2fe388e9 100644 --- a/src/pages/profile.php +++ b/src/pages/profile.php @@ -115,6 +115,18 @@ if (isset($_POST['user-id'], $_POST['section'])) { } } + /** Advertisements */ + if (isset($_POST['enable-advertisements'])) { + $_SESSION['user']->advertisements = true; + + $set[] = '`advertisements` = TRUE'; + } else { + $_SESSION['user']->advertisements = false; + + $set[] = '`advertisements` = FALSE'; + } + + /** Save */ if ($set) { $database ->query( @@ -343,6 +355,35 @@ $page->navigation(); +
    + + +
    + id) ? $_SESSION['user'] : new User(); + ?> + + advertisements) { ?> + + + + + + +
    +
    +
    +

    + ' . __('sponsor me') . '' + ); + ?> +

    +
    +