notification.php 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. <?php
  2. /* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2005-2011 Laurent Destailleur <eldy@users.sourceforge.org>
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 2 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. /**
  19. * \file htdocs/admin/notification.php
  20. * \ingroup notification
  21. * \brief Page to setup notification module
  22. */
  23. require("../main.inc.php");
  24. require_once(DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php");
  25. require_once(DOL_DOCUMENT_ROOT."/core/triggers/interface_50_modNotification_Notification.class.php");
  26. $langs->load("admin");
  27. $langs->load("other");
  28. // Security check
  29. if (!$user->admin)
  30. accessforbidden();
  31. $action = GETPOST("action");
  32. /*
  33. * Actions
  34. */
  35. if ($action == 'setvalue' && $user->admin)
  36. {
  37. $result=dolibarr_set_const($db, "NOTIFICATION_EMAIL_FROM",$_POST["email_from"],'chaine',0,'',$conf->entity);
  38. if ($result >= 0)
  39. {
  40. $mesg = "<font class=\"ok\">".$langs->trans("SetupSaved")."</font>";
  41. }
  42. else
  43. {
  44. $mesg = "<font class=\"error\">".$langs->trans("Error")."</font>";
  45. }
  46. }
  47. /*
  48. * View
  49. */
  50. llxHeader();
  51. $linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
  52. print_fiche_titre($langs->trans("NotificationSetup"),$linkback,'setup');
  53. print $langs->trans("NotificationsDesc").'<br><br>';
  54. print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
  55. print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
  56. print '<input type="hidden" name="action" value="setvalue">';
  57. $var=true;
  58. print '<table class="noborder" width="100%">';
  59. print '<tr class="liste_titre">';
  60. print '<td>'.$langs->trans("Parameter").'</td>';
  61. print '<td>'.$langs->trans("Value").'</td>';
  62. print "</tr>\n";
  63. $var=!$var;
  64. print '<tr '.$bc[$var].'><td>';
  65. print $langs->trans("NotificationEMailFrom").'</td><td>';
  66. print '<input size="32" type="text" name="email_from" value="'.$conf->global->NOTIFICATION_EMAIL_FROM.'">';
  67. if (! empty($conf->global->NOTIFICATION_EMAIL_FROM) && ! isValidEmail($conf->global->NOTIFICATION_EMAIL_FROM)) print ' '.img_warning($langs->trans("BadEMail"));
  68. print '</td></tr>';
  69. print '</table>';
  70. print '<br>';
  71. print '<center><input type="submit" class="button" value="'.$langs->trans("Modify").'"></center>';
  72. print '</form>';
  73. print '<br>';
  74. print_fiche_titre($langs->trans("ListOfAvailableNotifications"),'','');
  75. print '<table class="noborder" width="100%">';
  76. print '<tr class="liste_titre">';
  77. print '<td>'.$langs->trans("Module").'</td>';
  78. print '<td>'.$langs->trans("Code").'</td>';
  79. print '<td>'.$langs->trans("Label").'</td>';
  80. print "</tr>\n";
  81. // Load array of available notifications
  82. $notificationtrigger=new InterfaceNotification($db);
  83. $listofnotifiedevents=$notificationtrigger->getListOfManagedEvents();
  84. foreach($listofnotifiedevents as $notifiedevent)
  85. {
  86. $var=!$var;
  87. $label=$langs->trans("Notify_".$notifiedevent['code']); //!=$langs->trans("Notify_".$notifiedevent['code'])?$langs->trans("Notify_".$notifiedevent['code']):$notifiedevent['label'];
  88. print '<tr '.$bc[$var].'>';
  89. print '<td>'.$notifiedevent['elementtype'].'</td>';
  90. print '<td>'.$notifiedevent['code'].'</td>';
  91. print '<td>'.$label.'</td>';
  92. print '</tr>';
  93. }
  94. print '</table>';
  95. dol_htmloutput_mesg($mesg);
  96. $db->close();
  97. llxFooter();
  98. ?>