Commit 8713b7c0 authored by Aster's avatar Aster Committed by waltermazza
Browse files

General Bug Fixes and Improvements

parent 820496c2
{ {
"name": "arter/amos-notify", "name": "arter/amos-notify",
"description": "Modulo di gestione notifiche - plugin", "description": "Modulo di gestione notifiche - plugin",
"keywords": [ "keywords": [
"amos", "amos",
"notifiche", "notifiche",
"yii2" "yii2"
], ],
"homepage": "http://www.arter.it/", "homepage": "http://www.arter.it/",
"type": "component", "type": "component",
"license": "BSD-3-Clause", "license": "BSD-3-Clause",
"support": { "support": {
"issues": "https://github.com/yiisoft/yii2/issues?state=open", "issues": "https://github.com/yiisoft/yii2/issues?state=open",
"forum": "http://www.yiiframework.com/forum/", "forum": "http://www.yiiframework.com/forum/",
"wiki": "http://www.yiiframework.com/wiki/", "wiki": "http://www.yiiframework.com/wiki/",
"irc": "irc://irc.freenode.net/yii", "irc": "irc://irc.freenode.net/yii",
"source": "https://github.com/yiisoft/yii2" "source": "https://github.com/yiisoft/yii2"
}, },
"require": { "require": {
"php": ">=5.4.0", "php": ">=7.0",
"arter/amos-admin": "^2.2.0", "arter/amos-admin": "^2.2.0",
"arter/amos-core": "^1.11.0", "arter/amos-core": "^1.19.0",
"arter/amos-email-manager": "^1.1", "arter/amos-email-manager": "^1.1.19",
"arter/amos-workflow": "^1.0" "arter/amos-workflow": "^1.0"
}, },
"config": { "config": {
"process-timeout": 1800, "process-timeout": 1800,
"secure-http": false "secure-http": false
}, },
"autoload": { "autoload": {
"psr-4": { "psr-4": {
"arter\\amos\\notificationmanager\\": "src" "arter\\amos\\notificationmanager\\": "src"
}
},
"scripts": {
"post-install-cmd": "php yii migrate --migrationPath=@vendor/arter/amos-notify/migrations --interactive=0"
} }
} },
\ No newline at end of file "scripts": {
"post-install-cmd": "php yii migrate --migrationPath=@vendor/arter/amos-notify/migrations --interactive=0"
}
}
...@@ -4,11 +4,11 @@ ...@@ -4,11 +4,11 @@
* EROI - Emilia Romagna Open Innovation is based on: * EROI - Emilia Romagna Open Innovation is based on:
* https://www.open2.0.regione.lombardia.it * https://www.open2.0.regione.lombardia.it
* *
* @see https://repo.art-er.it Developers' community * @see http://example.com Developers'community
* @license GPLv3 * @license GPLv3
* @license https://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3 * @license https://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3
* *
* @package arter\amos\notificationmanager * @package arter\amos\notify
* @category CategoryName * @category CategoryName
* @author Elite Division S.r.l. * @author Elite Division S.r.l.
*/ */
...@@ -16,7 +16,6 @@ ...@@ -16,7 +16,6 @@
namespace arter\amos\notificationmanager; namespace arter\amos\notificationmanager;
/** /**
*
* Plugin per la gestione delle notifiche. * Plugin per la gestione delle notifiche.
* *
* Si basa su una Behavior (NotifyBehavior) che aggiunge funzionalità al modello con gli Events: * Si basa su una Behavior (NotifyBehavior) che aggiunge funzionalità al modello con gli Events:
...@@ -71,13 +70,42 @@ use yii\log\Logger; ...@@ -71,13 +70,42 @@ use yii\log\Logger;
*/ */
class AmosNotify extends AmosModule implements \yii\base\BootstrapInterface, NotifyWidget class AmosNotify extends AmosModule implements \yii\base\BootstrapInterface, NotifyWidget
{ {
public $batchFromDate; // format 'yyyy-mm-dd' public $batchFromDate; // format 'yyyy-mm-dd'
public $defaultSchedule = NotificationsConfOpt::EMAIL_DAY; public $defaultSchedule = NotificationsConfOpt::EMAIL_DAY;
public $confirmEmailNotification = false; public $confirmEmailNotification = false;
/**
* disable notification for default behavior.
* enable notification only with post parameter: saveNotificationSendEmail = 1
*/
public $disableDefaultBehaviorClasses = [
];
public $orderEmailSummary = [
'arter\amos\events\models\Event',
'arter\amos\news\models\News',
'arter\amos\partnershipprofiles\models\PartnershipProfile',
'arter\amos\discussioni\models\DiscussioniTopic',
'arter\amos\sondaggi\models\Sondaggi',
];
/** @var bool */
public $enableNotificationContentLanguage = false; public $enableNotificationContentLanguage = false;
public $sleepingUserDayLimit = 30; // If the user is inactive for those days he is sleeping
private static $notifyworkflowlistener; public $contentsLimit = 2; // max items foreach content in email to userNotification
public $usersLimit = 5; // max users in email to userNotification (es max contatti, max visits)
public $enableNewsletter = false;
public $enableSuggestions = false;
/**
* @var array
* $personalizedValidatedEmail => [
* "arter\amos\admin\models\UserProfile" => [
'class' => 'backend\modules\poiadmin\utility\PoiAdminEmailUtility',
'method' => 'sendEmailUserValidated'
]
* ]
*/
public $personalizedValidatedEmail = [];
/** /**
* @var null |string * @var null |string
...@@ -98,6 +126,34 @@ class AmosNotify extends AmosModule implements \yii\base\BootstrapInterface, Not ...@@ -98,6 +126,34 @@ class AmosNotify extends AmosModule implements \yii\base\BootstrapInterface, Not
*/ */
public $viewPathEmailNotifyValidated = []; public $viewPathEmailNotifyValidated = [];
/**
*
* @var boolean $enableLegacyNotify
*/
public $enableLegacyNotify = false;
private static $notifyworkflowlistener;
private static $registerEvent = false;
/**
* @var array $customIconPlugins
*/
public $customIconPlugins = [];
public $contentToNotNotify = [];
/**
* @var string[] $mailThemeColor
*/
public $mailThemeColor = [
'bgPrimary' => '#297A38',
'bgPrimaryDark' => '#204D28',
'textContrastBgPrimary' => '#FFFFFF',
'textContrastBgPrimaryDark' => '#FFFFFF',
'textPrimary' => '#FFFFFF',
'textPrimaryDark' => '#FFFFFF'
];
/** /**
* @inheritdoc * @inheritdoc
*/ */
...@@ -126,9 +182,22 @@ class AmosNotify extends AmosModule implements \yii\base\BootstrapInterface, Not ...@@ -126,9 +182,22 @@ class AmosNotify extends AmosModule implements \yii\base\BootstrapInterface, Not
public function init() public function init()
{ {
parent::init(); parent::init();
if (isset(Yii::$app->params['layoutMailConfigurations']['bgPrimary'])) {
$this->mailThemeColor['bgPrimary'] = Yii::$app->params['layoutMailConfigurations']['bgPrimary'];
}
if (isset(Yii::$app->params['layoutMailConfigurations']['bgPrimaryDark'])) {
$this->mailThemeColor['bgPrimaryDark'] = Yii::$app->params['layoutMailConfigurations']['bgPrimaryDark'];
}
if (isset(Yii::$app->params['layoutMailConfigurations']['textContrastBgPrimary'])) {
$this->mailThemeColor['textContrastBgPrimary'] = Yii::$app->params['layoutMailConfigurations']['textContrastBgPrimary'];
}
if (isset(Yii::$app->params['layoutMailConfigurations']['textContrastBgPrimaryDark'])) {
$this->mailThemeColor['textContrastBgPrimaryDark'] = Yii::$app->params['layoutMailConfigurations']['textContrastBgPrimaryDark'];
}
\Yii::setAlias('@arter/amos/notificationmanager/commands', __DIR__ . '/commands/'); \Yii::setAlias('@arter/amos/notificationmanager/commands', __DIR__ . '/commands/');
// initialize the module with the configuration loaded from config.php // initialize the module with the configuration loaded from config.php
\Yii::configure($this, require(__DIR__ . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'config.php')); \Yii::configure($this, require(__DIR__ . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'config.php'));
$this->orderEmailSummary = array_unique($this->orderEmailSummary);
} }
/** /**
...@@ -139,11 +208,13 @@ class AmosNotify extends AmosModule implements \yii\base\BootstrapInterface, Not ...@@ -139,11 +208,13 @@ class AmosNotify extends AmosModule implements \yii\base\BootstrapInterface, Not
if ($app instanceof \yii\console\Application) { if ($app instanceof \yii\console\Application) {
$this->controllerNamespace = 'arter\amos\notificationmanager\commands'; $this->controllerNamespace = 'arter\amos\notificationmanager\commands';
} else { } else {
Event::on( if (self::$registerEvent == false) {
Record::className(), self::$registerEvent = true;
SimpleWorkflowBehavior::EVENT_AFTER_CHANGE_STATUS, Event::on(
[self::$notifyworkflowlistener, 'afterChangeStatus'] Record::className(), SimpleWorkflowBehavior::EVENT_AFTER_CHANGE_STATUS,
); [self::$notifyworkflowlistener, 'afterChangeStatus']
);
}
} }
} }
...@@ -154,13 +225,21 @@ class AmosNotify extends AmosModule implements \yii\base\BootstrapInterface, Not ...@@ -154,13 +225,21 @@ class AmosNotify extends AmosModule implements \yii\base\BootstrapInterface, Not
{ {
return [ return [
'ChangeStatusEmail' => __NAMESPACE__ . '\\' . 'models\ChangeStatusEmail', 'ChangeStatusEmail' => __NAMESPACE__ . '\\' . 'models\ChangeStatusEmail',
'Newsletter' => __NAMESPACE__ . '\\' . 'models\Newsletter',
'NewsletterContents' => __NAMESPACE__ . '\\' . 'models\NewsletterContents',
'NewsletterContentsConf' => __NAMESPACE__ . '\\' . 'models\NewsletterContentsConf',
'NewsletterSearch' => __NAMESPACE__ . '\\' . 'models\search\NewsletterSearch',
'Notification' => __NAMESPACE__ . '\\' . 'models\Notification', 'Notification' => __NAMESPACE__ . '\\' . 'models\Notification',
'NotificationChannels' => __NAMESPACE__ . '\\' . 'models\NotificationChannels', 'NotificationChannels' => __NAMESPACE__ . '\\' . 'models\NotificationChannels',
'NotificationConf' => __NAMESPACE__ . '\\' . 'models\NotificationConf', 'NotificationConf' => __NAMESPACE__ . '\\' . 'models\NotificationConf',
'NotificationsConfOpt' => __NAMESPACE__ . '\\' . 'models\NotificationsConfOpt',
'NotificationconfNetwork' => __NAMESPACE__ . '\\' . 'models\NotificationconfNetwork', 'NotificationconfNetwork' => __NAMESPACE__ . '\\' . 'models\NotificationconfNetwork',
'NotificationsRead' => __NAMESPACE__ . '\\' . 'models\NotificationsRead', 'NotificationContentLanguage' => __NAMESPACE__ . '\\' . 'models\NotificationContentLanguage',
'NotificationLanguagePreferences' => __NAMESPACE__ . '\\' . 'models\NotificationLanguagePreferences',
'NotificationsConfOpt' => __NAMESPACE__ . '\\' . 'models\NotificationsConfOpt',
'NotificationSendEmail' => __NAMESPACE__ . '\\' . 'models\NotificationSendEmail', 'NotificationSendEmail' => __NAMESPACE__ . '\\' . 'models\NotificationSendEmail',
'NotificationsRead' => __NAMESPACE__ . '\\' . 'models\NotificationsRead',
'NotificationsSent' => __NAMESPACE__ . '\\' . 'models\NotificationsSent',
'NotificationConfContent' => __NAMESPACE__ . '\\' . 'models\NotificationConfContent',
]; ];
} }
...@@ -180,6 +259,24 @@ class AmosNotify extends AmosModule implements \yii\base\BootstrapInterface, Not ...@@ -180,6 +259,24 @@ class AmosNotify extends AmosModule implements \yii\base\BootstrapInterface, Not
return []; return [];
} }
/**
* Same as calling AmosNotify::t('amosnotify', ...$args)
* @return string
*/
public static function txt($txt, ...$args)
{
return static::t('amosnotify', $txt, ...$args);
}
/**
* Same as calling AmosNotify::tHtml('amosnotify', ...$args)
* @return string
*/
public static function txtHtml($txt, ...$args)
{
return static::tHtml('amosnotify', $txt, ...$args);
}
/** /**
* @param int $uid * @param int $uid
* @param string $class_name * @param string $class_name
...@@ -227,7 +324,7 @@ class AmosNotify extends AmosModule implements \yii\base\BootstrapInterface, Not ...@@ -227,7 +324,7 @@ class AmosNotify extends AmosModule implements \yii\base\BootstrapInterface, Not
} catch (\Exception $ex) { } catch (\Exception $ex) {
Yii::getLogger()->log($ex->getTraceAsString(), Logger::LEVEL_ERROR); Yii::getLogger()->log($ex->getTraceAsString(), Logger::LEVEL_ERROR);
} }
return $result; return $result;
} }
...@@ -245,7 +342,7 @@ class AmosNotify extends AmosModule implements \yii\base\BootstrapInterface, Not ...@@ -245,7 +342,7 @@ class AmosNotify extends AmosModule implements \yii\base\BootstrapInterface, Not
} catch (\Exception $ex) { } catch (\Exception $ex) {
Yii::getLogger()->log($ex->getTraceAsString(), Logger::LEVEL_ERROR); Yii::getLogger()->log($ex->getTraceAsString(), Logger::LEVEL_ERROR);
} }
return $result; return $result;
} }
...@@ -265,7 +362,7 @@ class AmosNotify extends AmosModule implements \yii\base\BootstrapInterface, Not ...@@ -265,7 +362,7 @@ class AmosNotify extends AmosModule implements \yii\base\BootstrapInterface, Not
} catch (\Exception $ex) { } catch (\Exception $ex) {
Yii::getLogger()->log($ex->getTraceAsString(), Logger::LEVEL_ERROR); Yii::getLogger()->log($ex->getTraceAsString(), Logger::LEVEL_ERROR);
} }
return $retval; return $retval;
} }
...@@ -284,7 +381,7 @@ class AmosNotify extends AmosModule implements \yii\base\BootstrapInterface, Not ...@@ -284,7 +381,7 @@ class AmosNotify extends AmosModule implements \yii\base\BootstrapInterface, Not
} catch (\Exception $ex) { } catch (\Exception $ex) {
Yii::getLogger()->log($ex->getTraceAsString(), Logger::LEVEL_ERROR); Yii::getLogger()->log($ex->getTraceAsString(), Logger::LEVEL_ERROR);
} }
return $ok; return $ok;
} }
...@@ -303,7 +400,7 @@ class AmosNotify extends AmosModule implements \yii\base\BootstrapInterface, Not ...@@ -303,7 +400,7 @@ class AmosNotify extends AmosModule implements \yii\base\BootstrapInterface, Not
} catch (\Exception $ex) { } catch (\Exception $ex) {
Yii::getLogger()->log($ex->getTraceAsString(), Logger::LEVEL_ERROR); Yii::getLogger()->log($ex->getTraceAsString(), Logger::LEVEL_ERROR);
} }
return $ok; return $ok;
} }
...@@ -316,8 +413,26 @@ class AmosNotify extends AmosModule implements \yii\base\BootstrapInterface, Not ...@@ -316,8 +413,26 @@ class AmosNotify extends AmosModule implements \yii\base\BootstrapInterface, Not
{ {
$result = false; $result = false;
try { try {
//$repository = new NotifierRepository(); $repository = new NotifierRepository();
//$result = $repository->isFavorite($model, $uid); $result = $repository->isFavorite($model, $uid);
} catch (\Exception $ex) {
Yii::getLogger()->log($ex->getTraceAsString(), Logger::LEVEL_ERROR);
}
return $result;
}
/**
* @param $class_name
* @param int|null $uid
* @return bool
*/
public function getAllFavourites($class_name, $uid)
{
$result = false;
try {
$repository = new NotifierRepository();
$result = $repository->getAllFavourites($class_name, $uid);
} catch (\Exception $ex) { } catch (\Exception $ex) {
Yii::getLogger()->log($ex->getTraceAsString(), Logger::LEVEL_ERROR); Yii::getLogger()->log($ex->getTraceAsString(), Logger::LEVEL_ERROR);
} }
...@@ -333,7 +448,7 @@ class AmosNotify extends AmosModule implements \yii\base\BootstrapInterface, Not ...@@ -333,7 +448,7 @@ class AmosNotify extends AmosModule implements \yii\base\BootstrapInterface, Not
* @return bool * @return bool
*/ */
public function saveNotificationConf($userId, $emailFrequency = 0, $smsFrequency = 0, $params = []) public function saveNotificationConf($userId, $emailFrequency = 0, $smsFrequency = 0, $params = [])
{ {
$notifyUtility = new NotifyUtility(); $notifyUtility = new NotifyUtility();
return $notifyUtility->saveNotificationConf($userId, $emailFrequency, $smsFrequency, $params); return $notifyUtility->saveNotificationConf($userId, $emailFrequency, $smsFrequency, $params);
} }
...@@ -348,4 +463,10 @@ class AmosNotify extends AmosModule implements \yii\base\BootstrapInterface, Not ...@@ -348,4 +463,10 @@ class AmosNotify extends AmosModule implements \yii\base\BootstrapInterface, Not
$notifyUtility = new NotifyUtility(); $notifyUtility = new NotifyUtility();
return $notifyUtility->setDefaultNotificationsConfs($userId); return $notifyUtility->setDefaultNotificationsConfs($userId);
} }
public function contactAccepted($user, $invitedUser)
{
$notifyUtility = new NotifyUtility();
$notifyUtility->contactAccepted($user, $invitedUser);
}
} }
<?php
/**
* Copyright 2020 Art-ER S. Cons. P.A.
* EROI - Emilia Romagna Open Innovation is based on:
* https://www.open2.0.regione.lombardia.it
*
* @see http://example.com Developers'community
* @license GPLv3
* @license https://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3
*
* @package arter\amos\notificationmanager\base\builder
* @category CategoryName
* @author Elite Division S.r.l.
*/
namespace arter\amos\notificationmanager\assets;
use yii\web\AssetBundle;
/**
* Class NotifyAsset
* @package arter\amos\notificationmanager\assets
*/
class NotifyAsset extends AssetBundle
{
/**
* @inheritdoc
*/
public $sourcePath = '@vendor/arter/amos-notify/src/assets/web';
/**
* @inheritdoc
*/
public $css = [
'less/notify.less',
];
/**
* @inheritdoc
*/
public $js = [
'js/notify.js'
];
/**
* @inheritdoc
*/
public $depends = [
];
/**
* @inheritdoc
*/
public function init()
{
$moduleL = \Yii::$app->getModule('layout');
if (!is_null($moduleL)) {
$this->depends [] = 'arter\amos\layout\assets\BaseAsset';
} else {
$this->depends [] = 'arter\amos\core\views\assets\AmosCoreAsset';
}
parent::init();
}
}
/**
IMPORT AMOS-LAYOUT VARIABLES
*/
@import (optional) "../../vendor/arter/amos-layout/src/assets/resources/base/less/variables.less";
@import (optional) "../../vendor/arter/amos-layout/src/assets/resources/base/less/utility.less";
/**
IMPORT STYLE-CUSTOM
*/
@import (optional) "../../backend/web/less/style_custom.less";
/**
NOTIFY
*/
.modal-utility.modal-send-test-newsletter {
.modal-dialog .modal-content .modal-body {
.notify-textinput-class {
width: 100%;
white-space: normal;
}
}
}
.newsletter-can-be-sent {
font-weight: bold;
color: #29b043;
}
.newsletter-cannot-be-sent {
font-weight: bold;
color: #ff0000;
}
\ No newline at end of file
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
* EROI - Emilia Romagna Open Innovation is based on: * EROI - Emilia Romagna Open Innovation is based on:
* https://www.open2.0.regione.lombardia.it * https://www.open2.0.regione.lombardia.it
* *
* @see https://repo.art-er.it Developers' community * @see http://example.com Developers'community
* @license GPLv3 * @license GPLv3
* @license https://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3 * @license https://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3
* *
...@@ -35,4 +35,11 @@ interface Builder ...@@ -35,4 +35,11 @@ interface Builder
* @return string * @return string
*/ */
public function getSubject(array $resultset); public function getSubject(array $resultset);
/**
* @param array $resultSetNormal
* @param array $resultSetNetwork
* @param User $user
* @return mixed
*/
} }
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
* EROI - Emilia Romagna Open Innovation is based on: * EROI - Emilia Romagna Open Innovation is based on:
* https://www.open2.0.regione.lombardia.it * https://www.open2.0.regione.lombardia.it
* *
* @see https://repo.art-er.it Developers' community * @see http://example.com Developers'community
* @license GPLv3 * @license GPLv3
* @license https://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3 * @license https://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3
* *
...@@ -15,32 +15,49 @@ ...@@ -15,32 +15,49 @@
namespace arter\amos\notificationmanager\base; namespace arter\amos\notificationmanager\base;
use arter\amos\notificationmanager\base\builder\ContactAcceptedMailBuilder;
use arter\amos\notificationmanager\base\builder\ContentImmediateMailBuilder; use arter\amos\notificationmanager\base\builder\ContentImmediateMailBuilder;
use arter\amos\notificationmanager\base\builder\ContentMailBuilder; use arter\amos\notificationmanager\base\builder\ContentMailBuilder;
use arter\amos\notificationmanager\base\builder\CustomMailBuilder; use arter\amos\notificationmanager\base\builder\CustomMailBuilder;
use arter\amos\notificationmanager\base\builder\NewsletterBuilder;
use arter\amos\notificationmanager\base\builder\SleepingUserMailBuilder;
use arter\amos\notificationmanager\base\builder\SuccessfulContentMailBuilder;
use arter\amos\notificationmanager\base\builder\SuccessfulUserMailBuilder;
use arter\amos\notificationmanager\base\builder\SuggestedLinkMailBuilder;
use arter\amos\notificationmanager\base\builder\ValidatedMailBuilder; use arter\amos\notificationmanager\base\builder\ValidatedMailBuilder;
use arter\amos\notificationmanager\base\builder\ValidatorsMailBuilder; use arter\amos\notificationmanager\base\builder\ValidatorsMailBuilder;
use arter\amos\notificationmanager\models\ChangeStatusEmail; use arter\amos\notificationmanager\models\ChangeStatusEmail;
use yii\base\BaseObject; use yii\base\BaseObject;
class BuilderFactory extends BaseObject { /**
* Class BuilderFactory
* @package arter\amos\notificationmanager\base
*/
class BuilderFactory extends BaseObject
{
const CONTENT_MAIL_BUILDER = 1; const CONTENT_MAIL_BUILDER = 1;
const VALIDATORS_MAIL_BUILDER = 2; const VALIDATORS_MAIL_BUILDER = 2;
const VALIDATED_MAIL_BUILDER = 3; const VALIDATED_MAIL_BUILDER = 3;
const CUSTOM_MAIL_BUILDER = 4; const CUSTOM_MAIL_BUILDER = 4;
const CONTENT_IMMEDIATE_MAIL_BUILDER = 5; const CONTENT_IMMEDIATE_MAIL_BUILDER = 5;
const CONTENT_SLEEPING_USER_BUILDER = 6;
const CONTENT_SUCCESSFUL_CONTENT_BUILDER = 7;
const CONTENT_SUCCESSFUL_USER_BUILDER = 8;
const CONTENT_SUGGESTED_LINK_BUILDER = 9;
const CONTENT_CONTACT_ACCEPTED_BUILDER = 10;
const NEWSLETTER_BUILDER = 11;
/** /**
* @param $type * @param int $type
* @param ChangeStatusEmail|null $email