Tommy Grignon - 2017-08-10

I have the case here to be able to send to multiple emails when something in my network goes down. The normal thing to do is create a user for each email and select the specifis equipment for these users. The problem is : I don't want to do this!

I modified different portions of code to ba able, for a user, to specifie multiple emails with the formula multi:email1@domain.com,email2@domain.com,email3@domain.com....

src\templates\default\module\user\profile.tpl.html line 38

<!--<input type="text" id="email" name="email" value="{{ email }}" maxlength="255" required>-->
<textarea id="email" name="email" cols="40" rows="5" required>{{ email }}</textarea>
<p class="help-block"><b>Envoyer multi-utilisateurs taper</b> multi:email1@domain.com,email2@domain.com...</p>

src\templates\default\module\user\user\update.tpl.html line 44

<!--<input type="text" id="email" name="email" value="{{ edit_value_email }}" maxlength="255" required>-->
<textarea id="email" name="email" cols="40" rows="5" required>{{ edit_value_email }}</textarea>
<p class="help-block"><b>Envoyer multi-utilisateurs taper</b> multi:email1@domain.com,email2@domain.com...</p>

src\psm\Module\User\Controller\UserController.php ligne 232

//$user_validator->email($clean['email']);

src\psm\Module\User\Controller\ProfileController.php ligne 109

//$validator->email($clean['email']);

src\psm\Util\Server\Updater\StatusNotifier.php ligne 221

if (mb_ereg("multi:", $user['email'])){
      $multiemail = str_replace("multi:", "", $user['email']);
      $multiemail = explode(",", $multiemail);

      foreach ($multiemail as $memails) {
            $mail->AddAddress($memails, $user['name']);
            $mail->Send();
            $mail->ClearAddresses();
      }
}else{
      $mail->AddAddress($user['email'], $user['name']);
      $mail->Send();
      $mail->ClearAddresses();
}

In the same time, to view correctly the information in the users list, I modified the code

src\templates\default\module\user\user\list.tpl.html line 52 (the line where the email show)

<td class="hidden-phone tight"><div class="table-cell-title">
<script>
var ema = "{{ user.email }}";
var res = ema.replace("multi:", "");
var re = new RegExp(",", 'g');

str = res.replace(re, '<br>');
document.write(str);
</script>
</div></td>
 

Last edit: Tommy Grignon 2017-08-10