Skip to content

Commit f3ba33c

Browse files
committed
Add exception handling for AdminNotifications #524
1 parent 641d8bb commit f3ba33c

File tree

6 files changed

+76
-26
lines changed

6 files changed

+76
-26
lines changed

adm_program/modules/announcements/announcements_function.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,16 @@
9696
if($getAnnId === 0)
9797
{
9898
$message = $gL10n->get('ANN_EMAIL_NOTIFICATION_MESSAGE', $gCurrentOrganization->getValue('org_longname'), $_POST['ann_headline'], $gCurrentUser->getValue('FIRST_NAME').' '.$gCurrentUser->getValue('LAST_NAME'), date($gPreferences['system_date'], time()));
99-
$notification = new Email();
100-
$notification->adminNotfication($gL10n->get('ANN_EMAIL_NOTIFICATION_TITLE'), $message, $gCurrentUser->getValue('FIRST_NAME').' '.$gCurrentUser->getValue('LAST_NAME'), $gCurrentUser->getValue('EMAIL'));
99+
100+
try
101+
{
102+
$notification = new Email();
103+
$notification->adminNotfication($gL10n->get('ANN_EMAIL_NOTIFICATION_TITLE'), $message, $gCurrentUser->getValue('FIRST_NAME').' '.$gCurrentUser->getValue('LAST_NAME'), $gCurrentUser->getValue('EMAIL'));
104+
}
105+
catch(AdmException $e)
106+
{
107+
$e->showHtml();
108+
}
101109
}
102110
}
103111

adm_program/modules/dates/dates_function.php

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -343,23 +343,30 @@
343343
$teilnehmer = 'n/a';
344344
}
345345

346-
$notification = new Email();
347-
348-
if($getMode === 1)
346+
try
349347
{
350-
$message = $gL10n->get('DAT_EMAIL_NOTIFICATION_MESSAGE_PART1', $gCurrentOrganization->getValue('org_longname'), $_POST['dat_headline'], $datum.' ('.$zeit.')', $calendar)
351-
.$gL10n->get('DAT_EMAIL_NOTIFICATION_MESSAGE_PART2', $ort, $raum, $teilnehmer, $gCurrentUser->getValue('FIRST_NAME').' '.$gCurrentUser->getValue('LAST_NAME'))
352-
.$gL10n->get('DAT_EMAIL_NOTIFICATION_MESSAGE_PART3', date($gPreferences['system_date'], time()));
353-
$notification->adminNotfication($gL10n->get('DAT_EMAIL_NOTIFICATION_TITLE'), $message,
354-
$gCurrentUser->getValue('FIRST_NAME').' '.$gCurrentUser->getValue('LAST_NAME'), $gCurrentUser->getValue('EMAIL'));
348+
$notification = new Email();
349+
350+
if($getMode === 1)
351+
{
352+
$message = $gL10n->get('DAT_EMAIL_NOTIFICATION_MESSAGE_PART1', $gCurrentOrganization->getValue('org_longname'), $_POST['dat_headline'], $datum.' ('.$zeit.')', $calendar)
353+
.$gL10n->get('DAT_EMAIL_NOTIFICATION_MESSAGE_PART2', $ort, $raum, $teilnehmer, $gCurrentUser->getValue('FIRST_NAME').' '.$gCurrentUser->getValue('LAST_NAME'))
354+
.$gL10n->get('DAT_EMAIL_NOTIFICATION_MESSAGE_PART3', date($gPreferences['system_date'], time()));
355+
$notification->adminNotfication($gL10n->get('DAT_EMAIL_NOTIFICATION_TITLE'), $message,
356+
$gCurrentUser->getValue('FIRST_NAME').' '.$gCurrentUser->getValue('LAST_NAME'), $gCurrentUser->getValue('EMAIL'));
357+
}
358+
else
359+
{
360+
$message = $gL10n->get('DAT_EMAIL_NOTIFICATION_CHANGE_MESSAGE_PART1', $gCurrentOrganization->getValue('org_longname'), $_POST['dat_headline'], $datum.' ('.$zeit.')', $calendar)
361+
.$gL10n->get('DAT_EMAIL_NOTIFICATION_CHANGE_MESSAGE_PART2', $ort, $raum, $teilnehmer, $gCurrentUser->getValue('FIRST_NAME').' '.$gCurrentUser->getValue('LAST_NAME'))
362+
.$gL10n->get('DAT_EMAIL_NOTIFICATION_CHANGE_MESSAGE_PART3', date($gPreferences['system_date'], time()));
363+
$notification->adminNotfication($gL10n->get('DAT_EMAIL_NOTIFICATION_CHANGE_TITLE'), $message,
364+
$gCurrentUser->getValue('FIRST_NAME').' '.$gCurrentUser->getValue('LAST_NAME'), $gCurrentUser->getValue('EMAIL'));
365+
}
355366
}
356-
else
367+
catch(AdmException $e)
357368
{
358-
$message = $gL10n->get('DAT_EMAIL_NOTIFICATION_CHANGE_MESSAGE_PART1', $gCurrentOrganization->getValue('org_longname'), $_POST['dat_headline'], $datum.' ('.$zeit.')', $calendar)
359-
.$gL10n->get('DAT_EMAIL_NOTIFICATION_CHANGE_MESSAGE_PART2', $ort, $raum, $teilnehmer, $gCurrentUser->getValue('FIRST_NAME').' '.$gCurrentUser->getValue('LAST_NAME'))
360-
.$gL10n->get('DAT_EMAIL_NOTIFICATION_CHANGE_MESSAGE_PART3', date($gPreferences['system_date'], time()));
361-
$notification->adminNotfication($gL10n->get('DAT_EMAIL_NOTIFICATION_CHANGE_TITLE'), $message,
362-
$gCurrentUser->getValue('FIRST_NAME').' '.$gCurrentUser->getValue('LAST_NAME'), $gCurrentUser->getValue('EMAIL'));
369+
$e->showHtml();
363370
}
364371
}
365372

adm_program/modules/guestbook/guestbook_function.php

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -236,8 +236,15 @@
236236
$gbo_email = $gPreferences['email_administrator'];
237237
$sender_name = 'Administrator '.$gCurrentOrganization->getValue('org_homepage');
238238
}
239-
$notification = new Email();
240-
$notification->adminNotfication($gL10n->get('GBO_EMAIL_NOTIFICATION_TITLE'), $gL10n->get('GBO_EMAIL_NOTIFICATION_MESSAGE', $gCurrentOrganization->getValue('org_longname'), $gbo_text, $gbo_name, date($gPreferences['system_date'], time())), $sender_name, $gbo_email);
239+
try
240+
{
241+
$notification = new Email();
242+
$notification->adminNotfication($gL10n->get('GBO_EMAIL_NOTIFICATION_TITLE'), $gL10n->get('GBO_EMAIL_NOTIFICATION_MESSAGE', $gCurrentOrganization->getValue('org_longname'), $gbo_text, $gbo_name, date($gPreferences['system_date'], time())), $sender_name, $gbo_email);
243+
}
244+
catch(AdmException $e)
245+
{
246+
$e->showHtml();
247+
}
241248
}
242249

243250
// Der Inhalt des Formulars wird bei erfolgreichem insert/update aus der Session geloescht
@@ -423,9 +430,15 @@
423430
$sender_name = 'Administrator '.$gCurrentOrganization->getValue('org_homepage');
424431
}
425432
$message = $gL10n->get('GBO_EMAIL_NOTIFICATION_GBC_MESSAGE', $gCurrentOrganization->getValue('org_longname'), $guestbook_comment->getValue('gbc_text'), $gbc_name, date($gPreferences['system_date'], time()));
426-
$notification = new Email();
427-
$notification->adminNotfication($gL10n->get('GBO_EMAIL_NOTIFICATION_GBC_TITLE'), $message, $sender_name, $gbc_email);
428-
433+
try
434+
{
435+
$notification = new Email();
436+
$notification->adminNotfication($gL10n->get('GBO_EMAIL_NOTIFICATION_GBC_TITLE'), $message, $sender_name, $gbc_email);
437+
}
438+
catch(AdmException $e)
439+
{
440+
$e->showHtml();
441+
}
429442
}
430443

431444
// Der Inhalt des Formulars wird bei erfolgreichem insert/update aus der Session geloescht

adm_program/modules/links/links_function.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,15 @@
9999
{
100100
// Benachrichtigungs-Email für neue Einträge
101101
$message = $gL10n->get('LNK_EMAIL_NOTIFICATION_MESSAGE', $gCurrentOrganization->getValue('org_longname'), $_POST['lnk_url']. ' ('.$_POST['lnk_name'].')', $gCurrentUser->getValue('FIRST_NAME').' '.$gCurrentUser->getValue('LAST_NAME'), date($gPreferences['system_date'], time()));
102-
$notification = new Email();
103-
$notification->adminNotfication($gL10n->get('LNK_EMAIL_NOTIFICATION_TITLE'), $message, $gCurrentUser->getValue('FIRST_NAME').' '.$gCurrentUser->getValue('LAST_NAME'), $gCurrentUser->getValue('EMAIL'));
102+
try
103+
{
104+
$notification = new Email();
105+
$notification->adminNotfication($gL10n->get('LNK_EMAIL_NOTIFICATION_TITLE'), $message, $gCurrentUser->getValue('FIRST_NAME').' '.$gCurrentUser->getValue('LAST_NAME'), $gCurrentUser->getValue('EMAIL'));
106+
}
107+
catch(AdmException $e)
108+
{
109+
$e->showHtml();
110+
}
104111
}
105112

106113
unset($_SESSION['links_request']);

adm_program/modules/photos/photo_album_function.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,15 @@
157157
{
158158
// Benachrichtigungs-Email für neue Einträge
159159
$notification = new Email();
160-
$message = $gL10n->get('PHO_EMAIL_NOTIFICATION_MESSAGE', $gCurrentOrganization->getValue('org_longname'), $_POST['pho_name'], $gCurrentUser->getValue('FIRST_NAME').' '.$gCurrentUser->getValue('LAST_NAME'), date($gPreferences['system_date'], time()));
161-
$notification->adminNotfication($gL10n->get('PHO_EMAIL_NOTIFICATION_TITLE'), $message, $gCurrentUser->getValue('FIRST_NAME').' '.$gCurrentUser->getValue('LAST_NAME'), $gCurrentUser->getValue('EMAIL'));
160+
try
161+
{
162+
$message = $gL10n->get('PHO_EMAIL_NOTIFICATION_MESSAGE', $gCurrentOrganization->getValue('org_longname'), $_POST['pho_name'], $gCurrentUser->getValue('FIRST_NAME').' '.$gCurrentUser->getValue('LAST_NAME'), date($gPreferences['system_date'], time()));
163+
$notification->adminNotfication($gL10n->get('PHO_EMAIL_NOTIFICATION_TITLE'), $message, $gCurrentUser->getValue('FIRST_NAME').' '.$gCurrentUser->getValue('LAST_NAME'), $gCurrentUser->getValue('EMAIL'));
164+
}
165+
catch(AdmException $e)
166+
{
167+
$e->showHtml();
168+
}
162169
}
163170

164171
$getPhotoId = $photo_album->getValue('pho_id');

adm_program/system/classes/email.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,15 @@ public function adminNotfication($subject, $message, $editorName = '', $editorEm
391391
$this->setText($message);
392392

393393
// Verschicken
394-
return $this->sendEmail();
394+
$returnCode = $this->sendEmail();
395+
396+
// if something went wrong then throw an exception with the error message
397+
if($returnCode !== true)
398+
{
399+
throw new AdmException('SYS_EMAIL_NOT_SEND', $gPreferences['email_administrator'], $this->sendEmail());
400+
}
401+
402+
return true;
395403
}
396404

397405
return false;

0 commit comments

Comments
 (0)