Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
61 changes: 2 additions & 59 deletions models/scheduling/TaskReminder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand All @@ -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())],
];
}

Expand Down Expand Up @@ -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 === '') {
Expand All @@ -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');
Expand Down Expand Up @@ -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;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion module.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
9 changes: 4 additions & 5 deletions notifications/RemindEnd.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -34,7 +34,7 @@ class RemindEnd extends BaseNotification
/**
* @inheritdoc
*/
public $viewName = "remind";
public $viewName = 'remind';

/**
* @var Task
Expand All @@ -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()),
]);

}

/**
Expand Down
6 changes: 3 additions & 3 deletions notifications/RemindStart.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -34,7 +34,7 @@ class RemindStart extends BaseNotification
/**
* @inheritdoc
*/
public $viewName = "remind.php";
public $viewName = 'remind';

/**
* @var Task
Expand Down
84 changes: 50 additions & 34 deletions notifications/views/layouts/remind.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,44 +6,60 @@
*
*/

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 \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 User $originator */
/* @var Notification $record */
/* @var boolean $isNew */
/* @var string $content */
/* @var string $url */
/* @var string $relativeUrl */
?>
<li<?= $isNew ? ' class="new"' : '' ?> data-notification-id="<?= $record->id ?>">
<a href="<?= $url ?>">
<div class="d-flex">

<!-- show module image -->
<img class="rounded float-start"
data-src="holder.js/32x32" alt="32x32"
style="width: 32px; height: 32px;"
src="<?= Yii::$app->moduleManager->getModule('tasks')->getImage() ?>" />

<!-- show space image -->
<?php if ($space !== null) : ?>
<img class="rounded img-space float-start"
data-src="holder.js/20x20" alt="20x20"
style="width: 20px; height: 20px;"
src="<?= $space->getProfileImage()->getUrl() ?>">
<?php endif; ?>

<!-- show content -->
<div class="flex-grow-1">
<a
class="d-flex<?= $isNew ? ' new' : '' ?>"
href="<?= $relativeUrl ?? $url ?>"
data-notification-id="<?= $record->id ?>"
data-notification-group="<?= !empty($record->baseModel->getGroupkey())
? Html::encode($record->baseModel::class . ':' . $record->baseModel->getGroupKey())
: '' ?>">

<?= $content ?>
<div class="flex-shrink-0 me-3 pt-1 img-profile-space">
<?php if ($originator) : ?>
<?= UserImage::widget([
'user' => $originator,
'width' => 32,
'link' => false,
'hideOnlineStatus' => true,
]) ?>
<?php endif; ?>
<?php if ($space instanceof Space) : ?>
<?= SpaceImage::widget([
'space' => $space,
'width' => 20,
'link' => false,
'htmlOptions' => ['class' => 'img-space'],
]) ?>
<?php endif; ?>
</div>

<br> <?= TimeAgo::widget(['timestamp' => $record->created_at]) ?>
<?= $isNew ? Badge::danger(Yii::t('NotificationModule.views_notificationLayout', 'New')) : '' ?>
<?= Badge::accent(Yii::t('TasksModule.base', 'Reminder')) ?>
</div>
<div class="flex-grow-1">
<?= $content ?>
<br>
<?= TimeAgo::widget(['timestamp' => $record->created_at]) ?>
<?= Badge::accent(Yii::t('TasksModule.base', 'Reminder')) ?>
</div>

</div>
</a>
</li>
<div class="flex-shrink-0 ms-2 order-last text-center">
<?php if ($isNew) : ?>
<span class="badge badge-new"></span>
<?php endif; ?>
</div>
</a>
24 changes: 20 additions & 4 deletions notifications/views/remind.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,26 @@
*/

use humhub\components\View;
use humhub\modules\notification\models\Notification;
use humhub\modules\space\models\Space;
use humhub\modules\user\models\User;

/* @var $this View */
/* @var $html string */
/* @var View $this */
/* @var string $html */
/* @var bool $isNew */
/* @var Space $space */
/* @var User $originator */
/* @var Notification $record */
/* @var string $url */
/* @var string $relativeUrl */
?>
<?php $this->beginContent('@tasks/notifications/views/layouts/remind.php') ?>
<?php $this->beginContent('@tasks/notifications/views/layouts/remind.php', [
'isNew' => $isNew,
'space' => $space,
'url' => $url,
Comment thread
luke- marked this conversation as resolved.
'relativeUrl' => $relativeUrl,
'record' => $record,
'originator' => $originator,
]) ?>
<?= $html ?>
<?php $this->endContent() ?>
<?php $this->endContent() ?>
Loading