From 33e0bd6ca1446cd9562ff6026fc1418f2fced549 Mon Sep 17 00:00:00 2001 From: Yuriy Bakhtin Date: Mon, 22 Jun 2026 15:47:56 +0300 Subject: [PATCH 1/3] Fix reminder notification --- docs/CHANGELOG.md | 4 ++++ module.json | 2 +- notifications/RemindStart.php | 16 ++++++++++++---- notifications/views/layouts/remind.php | 13 +++++++------ notifications/views/remind.php | 17 ++++++++++++++--- 5 files changed, 38 insertions(+), 14 deletions(-) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index b7cfd536..678d5914 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -1,6 +1,10 @@ Changelog ========= +1.9.6 (Unreleased) +-------------------- +- Fix #322: Fix reminder notification + 1.9.5 (May 15, 2026) -------------------- - Enh: Automated code refactoring for HumHub 1.18.0-beta.6 using Rector diff --git a/module.json b/module.json index a65c82bc..41deaaf6 100644 --- a/module.json +++ b/module.json @@ -8,7 +8,7 @@ "project", "management" ], - "version": "1.9.5", + "version": "1.9.6", "homepage": "https://github.com/humhub/tasks", "humhub": { "minVersion": "1.18.0-beta.6", diff --git a/notifications/RemindStart.php b/notifications/RemindStart.php index cf4108d9..7067fecf 100644 --- a/notifications/RemindStart.php +++ b/notifications/RemindStart.php @@ -32,14 +32,22 @@ class RemindStart extends BaseNotification public $moduleId = 'tasks'; /** - * @inheritdoc + * @var Task */ - public $viewName = "remind.php"; + public $source; /** - * @var Task + * @inheritdoc */ - public $source; + public function init() + { + if (Yii::$app->request->isConsoleRequest) { + // Use this layout only for Email mode + $this->viewName = 'remind'; + } + + parent::init(); + } /** * @inheritdoc diff --git a/notifications/views/layouts/remind.php b/notifications/views/layouts/remind.php index 3b980bd7..f65bad41 100644 --- a/notifications/views/layouts/remind.php +++ b/notifications/views/layouts/remind.php @@ -6,15 +6,16 @@ * */ +use humhub\modules\notification\models\Notification; +use humhub\modules\space\models\Space; use humhub\widgets\bootstrap\Badge; use humhub\widgets\TimeAgo; -/** @var \humhub\modules\user\models\User $originator */ -/** @var \humhub\modules\space\models\Space $space */ -/** @var \humhub\modules\notification\models\Notification $record */ -/** @var boolean $isNew */ -/** @var string $content */ - +/* @var Space $space */ +/* @var Notification $record */ +/* @var boolean $isNew */ +/* @var string $content */ +/* @var string $url */ ?> data-notification-id="id ?>"> diff --git a/notifications/views/remind.php b/notifications/views/remind.php index fdc44b91..50400f3c 100644 --- a/notifications/views/remind.php +++ b/notifications/views/remind.php @@ -6,10 +6,21 @@ */ use humhub\components\View; +use humhub\modules\notification\models\Notification; +use humhub\modules\space\models\Space; -/* @var $this View */ -/* @var $html string */ +/* @var View $this */ +/* @var string $html */ +/* @var bool $isNew */ +/* @var Space $space */ +/* @var Notification $record */ +/* @var string $url */ ?> -beginContent('@tasks/notifications/views/layouts/remind.php') ?> +beginContent('@tasks/notifications/views/layouts/remind.php', [ + 'isNew' => $isNew, + 'space' => $space, + 'url' => $url, + 'record' => $record, +]) ?> endContent() ?> \ No newline at end of file From f412b47d818ddaf3ee008dea503c72b44eb41163 Mon Sep 17 00:00:00 2001 From: Yuriy Bakhtin Date: Tue, 23 Jun 2026 11:04:06 +0300 Subject: [PATCH 2/3] Fix reminder notification --- models/scheduling/TaskReminder.php | 61 +--------------------- notifications/RemindEnd.php | 9 ++-- notifications/RemindStart.php | 20 +++----- notifications/views/layouts/remind.php | 70 +++++++++++++++----------- notifications/views/remind.php | 3 ++ 5 files changed, 57 insertions(+), 106 deletions(-) diff --git a/models/scheduling/TaskReminder.php b/models/scheduling/TaskReminder.php index 2fee89c5..6a51fca2 100644 --- a/models/scheduling/TaskReminder.php +++ b/models/scheduling/TaskReminder.php @@ -48,20 +48,6 @@ class TaskReminder extends ActiveRecord public const REMIND_THREE_WEEKS = 7; public const REMIND_ONE_MONTH = 8; - /** - * @var array all given remind modes as array - */ - public static $remindModes = [ - self::REMIND_NONE, - self::REMIND_ONE_HOUR, - self::REMIND_TWO_HOURS, - self::REMIND_ONE_DAY, - self::REMIND_TWO_DAYS, - self::REMIND_TWO_WEEKS, - self::REMIND_THREE_WEEKS, - self::REMIND_ONE_MONTH, - ]; - /** * @return string the associated database table name */ @@ -78,7 +64,7 @@ public function rules() return [ [['task_id', 'remind_mode'], 'required'], [['task_id', 'start_reminder_sent', 'end_reminder_sent'], 'integer'], - [['remind_mode'], 'in', 'range' => self::$remindModes], + [['remind_mode'], 'in', 'range' => array_keys(self::getRemindModeItems())], ]; } @@ -115,41 +101,6 @@ public static function getRemindModeItems() ]; } - public function getRemindMode() - { - switch ($this->remind_mode) { - case (self::REMIND_NONE): - return Yii::t('TasksModule.base', 'Do not remind'); - break; - case (self::REMIND_ONE_HOUR): - return Yii::t('TasksModule.base', 'At least 1 Hour before'); - break; - case (self::REMIND_TWO_HOURS): - return Yii::t('TasksModule.base', 'At least 2 Hours before'); - break; - case (self::REMIND_ONE_DAY): - return Yii::t('TasksModule.base', '1 Day before'); - break; - case (self::REMIND_TWO_DAYS): - return Yii::t('TasksModule.base', '2 Days before'); - break; - case (self::REMIND_ONE_WEEK): - return Yii::t('TasksModule.base', '1 Week before'); - break; - case (self::REMIND_TWO_WEEKS): - return Yii::t('TasksModule.base', '2 Weeks before'); - break; - case (self::REMIND_THREE_WEEKS): - return Yii::t('TasksModule.base', '3 Weeks before'); - break; - case (self::REMIND_ONE_MONTH): - return Yii::t('TasksModule.base', '1 Month before'); - break; - default: - return; - } - } - public function canSendRemind(DateTime $now, DateTime $dateTime) { if ($now === '' || $dateTime === '') { @@ -160,9 +111,6 @@ public function canSendRemind(DateTime $now, DateTime $dateTime) $modifiedEnd = clone $dateTime; switch ($this->remind_mode) { - case self::REMIND_NONE : - return false; - break; case self::REMIND_ONE_HOUR : $modifiedStart = $modifiedStart->modify('-2 hours'); $modifiedEnd = $modifiedEnd->modify('-1 hour'); @@ -209,14 +157,9 @@ public function canSendRemind(DateTime $now, DateTime $dateTime) break; default: return false; - break; } - if ($modifiedEnd > $now && $modifiedStart <= $now) { - return true; - } else { - return false; - } + return $modifiedEnd > $now && $modifiedStart <= $now; } /** diff --git a/notifications/RemindEnd.php b/notifications/RemindEnd.php index 77329a62..28278559 100644 --- a/notifications/RemindEnd.php +++ b/notifications/RemindEnd.php @@ -9,10 +9,10 @@ namespace humhub\modules\tasks\notifications; -use Yii; -use humhub\modules\tasks\models\Task; -use humhub\modules\notification\components\BaseNotification; use humhub\helpers\Html; +use humhub\modules\notification\components\BaseNotification; +use humhub\modules\tasks\models\Task; +use Yii; /** * Notifies an admin about reported content @@ -34,7 +34,7 @@ class RemindEnd extends BaseNotification /** * @inheritdoc */ - public $viewName = "remind"; + public $viewName = 'remind'; /** * @var Task @@ -56,7 +56,6 @@ public function html() '{spaceName}' => Html::tag('strong', Html::encode($this->source->content->container->displayName)), '{dateTime}' => Html::encode($this->source->schedule->getFormattedEndDateTime()), ]); - } /** diff --git a/notifications/RemindStart.php b/notifications/RemindStart.php index 7067fecf..c83b4d7e 100644 --- a/notifications/RemindStart.php +++ b/notifications/RemindStart.php @@ -9,10 +9,10 @@ namespace humhub\modules\tasks\notifications; +use humhub\helpers\Html; +use humhub\modules\notification\components\BaseNotification; use humhub\modules\tasks\models\Task; use Yii; -use humhub\modules\notification\components\BaseNotification; -use humhub\helpers\Html; /** * Notifies an admin about reported content @@ -32,22 +32,14 @@ class RemindStart extends BaseNotification public $moduleId = 'tasks'; /** - * @var Task + * @inheritdoc */ - public $source; + public $viewName = 'remind'; /** - * @inheritdoc + * @var Task */ - public function init() - { - if (Yii::$app->request->isConsoleRequest) { - // Use this layout only for Email mode - $this->viewName = 'remind'; - } - - parent::init(); - } + public $source; /** * @inheritdoc diff --git a/notifications/views/layouts/remind.php b/notifications/views/layouts/remind.php index f65bad41..193137c7 100644 --- a/notifications/views/layouts/remind.php +++ b/notifications/views/layouts/remind.php @@ -6,45 +6,59 @@ * */ +use humhub\helpers\Html; use humhub\modules\notification\models\Notification; use humhub\modules\space\models\Space; +use humhub\modules\space\widgets\Image as SpaceImage; +use humhub\modules\user\models\User; +use humhub\modules\user\widgets\Image as UserImage; use humhub\widgets\bootstrap\Badge; use humhub\widgets\TimeAgo; /* @var Space $space */ +/* @var User $originator */ /* @var Notification $record */ /* @var boolean $isNew */ /* @var string $content */ /* @var string $url */ ?> - data-notification-id="id ?>"> - - - - +
+ + + +
+ diff --git a/notifications/views/remind.php b/notifications/views/remind.php index 50400f3c..6c31295d 100644 --- a/notifications/views/remind.php +++ b/notifications/views/remind.php @@ -8,11 +8,13 @@ use humhub\components\View; use humhub\modules\notification\models\Notification; use humhub\modules\space\models\Space; +use humhub\modules\user\models\User; /* @var View $this */ /* @var string $html */ /* @var bool $isNew */ /* @var Space $space */ +/* @var User $originator */ /* @var Notification $record */ /* @var string $url */ ?> @@ -21,6 +23,7 @@ 'space' => $space, 'url' => $url, 'record' => $record, + 'originator' => $originator, ]) ?> endContent() ?> \ No newline at end of file From b80144db63927a3ed6ce0304782ef9bf28a6fdc2 Mon Sep 17 00:00:00 2001 From: Yuriy Bakhtin Date: Tue, 7 Jul 2026 11:36:27 +0300 Subject: [PATCH 3/3] Fix reminder notification --- notifications/views/layouts/remind.php | 1 + notifications/views/remind.php | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/notifications/views/layouts/remind.php b/notifications/views/layouts/remind.php index 193137c7..d5093e0d 100644 --- a/notifications/views/layouts/remind.php +++ b/notifications/views/layouts/remind.php @@ -21,6 +21,7 @@ /* @var boolean $isNew */ /* @var string $content */ /* @var string $url */ +/* @var string $relativeUrl */ ?> beginContent('@tasks/notifications/views/layouts/remind.php', [ 'isNew' => $isNew, 'space' => $space, 'url' => $url, + 'relativeUrl' => $relativeUrl, 'record' => $record, 'originator' => $originator, ]) ?> -endContent() ?> \ No newline at end of file +endContent() ?>