-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New notification when user marks "Attend" and attach ICS files
- Loading branch information
1 parent
191f6b3
commit 4638f33
Showing
7 changed files
with
155 additions
and
127 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?php | ||
/** | ||
* @link https://www.humhub.org/ | ||
* @copyright Copyright (c) HumHub GmbH & Co. KG | ||
* @license https://www.humhub.com/licences | ||
*/ | ||
|
||
namespace humhub\modules\calendar\notifications; | ||
|
||
use humhub\modules\calendar\models\CalendarEntry; | ||
use humhub\modules\notification\components\BaseNotification; | ||
use yii\mail\MessageInterface; | ||
|
||
/* @property CalendarEntry $source */ | ||
abstract class BaseEventNotification extends BaseNotification | ||
{ | ||
/** | ||
* @inheritdoc | ||
*/ | ||
public $moduleId = 'calendar'; | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public $viewName = 'participationInfoNotification'; | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function category() | ||
{ | ||
return new CalendarNotificationCategory(); | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function beforeMailSend(MessageInterface $message) | ||
{ | ||
$ics = $this->source->generateIcs(); | ||
|
||
if (!empty($ics)) { | ||
$message->attachContent($ics, [ | ||
'fileName' => $this->source->getUid() . '.ics', | ||
'contentType' => 'text/calendar', | ||
]); | ||
} | ||
|
||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?php | ||
/** | ||
* @link https://www.humhub.org/ | ||
* @copyright Copyright (c) HumHub GmbH & Co. KG | ||
* @license https://www.humhub.com/licences | ||
*/ | ||
|
||
namespace humhub\modules\calendar\notifications; | ||
|
||
use humhub\libs\Html; | ||
use humhub\modules\space\models\Space; | ||
use Yii; | ||
|
||
class MarkAttend extends BaseEventNotification | ||
{ | ||
public ?int $participationStatus = null; | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public $suppressSendToOriginator = false; | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function html() | ||
{ | ||
$params = [ | ||
'contentTitle' => $this->getContentInfo($this->source, false), | ||
'time' => $this->source->getFormattedTime(), | ||
]; | ||
|
||
if ($this->source->content->container instanceof Space) { | ||
return Yii::t('CalendarModule.base', 'You have been registered for the event "{contentTitle}" in {spaceName}, starting at {time}', array_merge($params, [ | ||
'spaceName' => Html::encode($this->source->content->container->displayName), | ||
])); | ||
} | ||
|
||
return Yii::t('CalendarModule.base', 'You have been registered for the event "{contentTitle}", starting at {time}.', $params); | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function getMailSubject() | ||
{ | ||
return Yii::t('CalendarModule.base', 'You have been registered for the event "{contentTitle}".', [ | ||
'contentTitle' => $this->getContentInfo($this->source, false), | ||
]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.