Skip to content

Commit

Permalink
Fix activity and notification wording from User and Dashboard
Browse files Browse the repository at this point in the history
  • Loading branch information
yurabakhtin committed Dec 12, 2024
1 parent d304c1e commit 1f47cc0
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 7 deletions.
22 changes: 18 additions & 4 deletions activities/views/shared.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,27 @@
*/

use humhub\modules\sharebetween\models\Share;
use humhub\modules\space\models\Space;
use humhub\modules\user\models\User;
use yii\helpers\Html;

/* @var User $originator */
/* @var Share $source */

echo Yii::t('SharebetweenModule.base', '{user} shared something interesting from Space {space}.', [
'{user}' => '<strong>' . Html::encode($originator->displayName) . '</strong>',
'{space}' => '<strong>' . Html::encode($source->sharedContent->container->displayName) . '</strong>',
]);
$container = $source->sharedContent->container;

if ($container instanceof Space) {
echo Yii::t('SharebetweenModule.base', '{user} shared something interesting from Space {space}.', [
'user' => Html::tag('strong', Html::encode($originator->displayName)),
'space' => Html::tag('strong', Html::encode($container->displayName)),
]);
} elseif ($container instanceof User) {
echo Yii::t('SharebetweenModule.base', '{user} shared something interesting from user {sourceUser}.', [
'user' => Html::tag('strong', Html::encode($originator->displayName)),
'sourceUser' => Html::tag('strong', Html::encode($container->displayName)),
]);
} else {
echo Yii::t('SharebetweenModule.base', '{user} shared something interesting from dashboard.', [
'user' => Html::tag('strong', Html::encode($originator->displayName)),
]);
}
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.0.9 (Unreleased)
-------------------------
- Enh #68: Fix activity and notification wording from User and Dashboard

1.0.8 (December 12, 2024)
-------------------------
- Enh #67: Update text for activity and notification of shared contents
Expand Down
2 changes: 1 addition & 1 deletion module.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "Share content",
"description": "Share content between Spaces in the simplest way possible.",
"keywords": ["share", "between", "content"],
"version": "1.0.8",
"version": "1.0.9",
"humhub": {
"minVersion": "1.14"
},
Expand Down
21 changes: 19 additions & 2 deletions notifications/SharedContentCreated.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

use humhub\modules\content\notifications\ContentCreated;
use humhub\modules\sharebetween\models\Share;
use humhub\modules\space\models\Space;
use humhub\modules\user\models\User;
use Yii;
use yii\bootstrap\Html;

Expand All @@ -26,9 +28,24 @@ class SharedContentCreated extends ContentCreated
*/
public function html()
{
return Yii::t('SharebetweenModule.base', '{user} shared something interesting from Space {space}.', [
$container = $this->source->sharedContent->container;

if ($container instanceof Space) {
return Yii::t('SharebetweenModule.base', '{user} shared something interesting from Space {space}.', [
'user' => Html::tag('strong', Html::encode($this->originator->displayName)),
'space' => Html::tag('strong', Html::encode($container->displayName)),
]);
}

if ($container instanceof User) {
return Yii::t('SharebetweenModule.base', '{user} shared something interesting from user {sourceUser}.', [
'user' => Html::tag('strong', Html::encode($this->originator->displayName)),
'sourceUser' => Html::tag('strong', Html::encode($container->displayName)),
]);
}

return Yii::t('SharebetweenModule.base', '{user} shared something interesting from dashboard.', [
'user' => Html::tag('strong', Html::encode($this->originator->displayName)),
'space' => Html::tag('strong', Html::encode($this->source->sharedContent->container->displayName)),
]);
}
}

0 comments on commit 1f47cc0

Please sign in to comment.