-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enh #6950: Ability to reset some notification settings to all users w…
…ithout resetting "Like" notifications by email
- Loading branch information
1 parent
72b0bb8
commit a09cc58
Showing
5 changed files
with
78 additions
and
17 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
40 changes: 40 additions & 0 deletions
40
...ected/humhub/modules/notification/migrations/m240422_162959_new_is_untouched_settings.php
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,40 @@ | ||
<?php | ||
|
||
use humhub\modules\notification\components\NotificationManager; | ||
use humhub\modules\notification\Module; | ||
use humhub\modules\user\models\User; | ||
use yii\db\Migration; | ||
|
||
/** | ||
* Class m240422_162959_new_is_untouched_settings | ||
*/ | ||
class m240422_162959_new_is_untouched_settings extends Migration | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function safeUp() | ||
{ | ||
foreach (User::find()->each() as $user) { | ||
/** @var Module $module */ | ||
$module = Yii::$app->getModule('notification'); | ||
try { | ||
$settingsManager = $module->settings->user($user); | ||
if ($settingsManager && $settingsManager->get('notification.like_email') !== null) { | ||
$settingsManager->set(NotificationManager::IS_TOUCHED_SETTINGS, true); | ||
} | ||
} catch (\Throwable $e) { | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function safeDown() | ||
{ | ||
echo "m240422_162959_new_is_untouched_settings cannot be reverted.\n"; | ||
|
||
return 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
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