diff --git a/modules/notifications/batch/process_event_stack.php b/modules/notifications/batch/process_event_stack.php index 8b44b8c5dc83ac19792af582e244fdc2e23844e9..1d276a93e2014ae6721e17977d7b96e96f6b786a 100755 --- a/modules/notifications/batch/process_event_stack.php +++ b/modules/notifications/batch/process_event_stack.php @@ -85,12 +85,12 @@ while ($state != 'END') { Bt_writeLog(['level' => 'INFO', 'message' => $nbRecipients.' recipients found, checking active and absences']); + $parameter = \Parameter\models\ParameterModel::getById(['select' => ['param_value_int'], 'id' => 'user_quota']); if ($notification['diffusion_type'] === 'dest_entity') { foreach ($recipients as $key => $recipient) { $entity_id = $recipient['entity_id']; Bt_writeLog(['level' => 'INFO', 'message' => 'Recipient entity '.$entity_id]); - $parameter = \Parameter\models\ParameterModel::getById(['select' => ['param_value_int'], 'id' => 'user_quota']); if (($recipient['enabled'] == 'N' && (empty($parameter) || $parameter['param_value_int'] == 0)) || $recipient['mail'] == '') { Bt_writeLog(['level' => 'INFO', 'message' => $entity_id.' is disabled or mail is invalid, this notification will not be send']); unset($recipients[$key]); @@ -106,8 +106,7 @@ while ($state != 'END') { foreach ($recipients as $key => $recipient) { $user_id = $recipient['user_id']; Bt_writeLog(['level' => 'INFO', 'message' => 'Recipient '.$user_id]); - - $parameter = \Parameter\models\ParameterModel::getById(['select' => ['param_value_int'], 'id' => 'user_quota']); + if (($recipient['status'] == 'SPD' && (empty($parameter) || $parameter['param_value_int'] == 0)) || $recipient['status'] == 'DEL') { Bt_writeLog(['level' => 'INFO', 'message' => $user_id.' is disabled or deleted, this notification will not be send']); unset($recipients[$key]); @@ -181,7 +180,7 @@ while ($state != 'END') { $html = str_replace('&', '&', $html); $html = str_replace('&', '#and#', $html); - $recipient_mail = $tmpNotif['recipient']['mail']; + $recipient_mail = $tmpNotif['recipient']['mail']; // Attachments $attachments = array(); diff --git a/src/app/notification/controllers/DiffusionTypesController.php b/src/app/notification/controllers/DiffusionTypesController.php index 079992bd531e1d60f8c167c9513afb0403cd8aca..cbb5f9370f89dadf84ce54323424c631ca8e737e 100644 --- a/src/app/notification/controllers/DiffusionTypesController.php +++ b/src/app/notification/controllers/DiffusionTypesController.php @@ -21,20 +21,20 @@ use User\models\UserModel; class DiffusionTypesController { - public function getRecipients($args = []) + public static function getRecipients($args = []) { $diffusionTypes = NotificationModel::getDiffusionType(); foreach ($diffusionTypes as $diffusionType) { - if ($diffusionType['id'] == $args['notification']['diffusionType']) { - $diffusionInfo = $diffusionType; + if ($diffusionType['id'] == $args['notification']['diffusion_type']) { + $function = $diffusionType['function']; break; } } - $recipients = DiffusionTypesController::$diffusionInfo['function'](['request' => $args['request'], 'notification' => $args['notification']]); + $recipients = DiffusionTypesController::$function(['request' => $args['request'], 'notification' => $args['notification']]); return $recipients; } - public function getRecipientsByContact($args = []) + public static function getRecipientsByContact($args = []) { if ($args['request'] == 'recipients') { $contactsMatch = DatabaseModel::select([ @@ -50,7 +50,7 @@ class DiffusionTypesController } } - public function getRecipientsByCopie($args = []) + public static function getRecipientsByCopie($args = []) { switch ($request) { case 'recipients': @@ -171,7 +171,7 @@ class DiffusionTypesController } } - public function getRecipientsByDestEntity($args = []) + public static function getRecipientsByDestEntity($args = []) { switch ($request) { case 'recipients': @@ -243,7 +243,7 @@ class DiffusionTypesController } } - public function getRecipientsByDestUserSign($args = []) + public static function getRecipientsByDestUserSign($args = []) { switch ($request) { case 'recipients': @@ -355,7 +355,7 @@ class DiffusionTypesController } } - public function getRecipientsByDestUserVisa($args = []) + public static function getRecipientsByDestUserVisa($args = []) { switch ($request) { case 'recipients': @@ -467,7 +467,7 @@ class DiffusionTypesController } } - public function getRecipientsByDestUser($args = []) + public static function getRecipientsByDestUser($args = []) { switch ($request) { case 'recipients': @@ -577,7 +577,7 @@ class DiffusionTypesController } } - public function getRecipientsByEntity($args = []) + public static function getRecipientsByEntity($args = []) { if ($args['request'] == 'recipients') { $aEntities = explode(",", $args['notification']['diffusion_properties']); @@ -593,14 +593,14 @@ class DiffusionTypesController } } - public function getRecipientsByGroup($args = []) + public static function getRecipientsByGroup($args = []) { if ($args['request'] == 'recipients') { $aGroups = explode(",", $args['notification']['diffusion_properties']); $recipients = DatabaseModel::select([ 'select' => ['us.*'], 'table' => ['usergroup_content ug, users us, usergroups'], - 'where' => ['us.id = ug.user_id', 'ug.group_id = usergroups.group_id', 'usergroups.group_id in (?)', 'us.status != ?'], + 'where' => ['us.id = ug.user_id', 'ug.group_id = usergroups.id', 'usergroups.group_id in (?)', 'us.status != ?'], 'data' => [$aGroups, 'DEL'] ]); return $recipients; @@ -609,7 +609,7 @@ class DiffusionTypesController } } - public function getRecipientsByUser($args = []) + public static function getRecipientsByUser($args = []) { if ($args['request'] == 'recipients') { $aUsers = explode(",", $args['notification']['diffusion_properties']); diff --git a/src/app/notification/models/NotificationModelAbstract.php b/src/app/notification/models/NotificationModelAbstract.php index e23fade5d92d88b4b81364af692433ecc363f2db..d550b9fb189c1c8bfaab426427d1375687afdceb 100755 --- a/src/app/notification/models/NotificationModelAbstract.php +++ b/src/app/notification/models/NotificationModelAbstract.php @@ -172,13 +172,13 @@ abstract class NotificationModelAbstract 'id' => 'group', 'label' => 'Groupe', 'add_attachment' => 'true', - 'function' => 'getRecipientsByContact' + 'function' => 'getRecipientsByGroup' ); $diffusionTypes[] = array( 'id' => 'entity', 'label' => 'Entité', 'add_attachment' => 'true', - 'function' => 'getRecipientsByCopie' + 'function' => 'getRecipientsByEntity' ); $diffusionTypes[] = array( 'id' => 'dest_entity', @@ -190,7 +190,7 @@ abstract class NotificationModelAbstract 'id' => 'dest_user', 'label' => 'Liste de diffusion du document', 'add_attachment' => 'false', - 'function' => 'getRecipientsByDestUserSign' + 'function' => 'getRecipientsByDestUser' ); $diffusionTypes[] = array( 'id' => 'dest_user_visa', @@ -202,27 +202,27 @@ abstract class NotificationModelAbstract 'id' => 'dest_user_sign', 'label' => 'Signataire actuel du document', 'add_attachment' => 'true', - 'function' => 'getRecipientsByDestUser' + 'function' => 'getRecipientsByDestUserSign' ); $diffusionTypes[] = array( 'id' => 'user', 'label' => 'Utilisateur désigné', 'add_attachment' => 'true', - 'function' => 'getRecipientsByEntity' + 'function' => 'getRecipientsByUser' ); $diffusionTypes[] = array( 'id' => 'copy_list', 'label' => 'Liste de diffusion du document', 'add_attachment' => 'false', - 'function' => 'getRecipientsByGroup' + 'function' => 'getRecipientsByCopie' ); $diffusionTypes[] = array( 'id' => 'contact', 'label' => 'Contact du document', 'add_attachment' => 'true', - 'function' => 'getRecipientsByUser' + 'function' => 'getRecipientsByContact' ); return $diffusionTypes;