com.lokorin.lokorin.lib
[ class tree: com.lokorin.lokorin.lib ] [ index: com.lokorin.lokorin.lib ] [ all elements ]

Source for file lib_event_digest.php

Documentation is available at lib_event_digest.php

  1. <?php
  2. /*
  3. * Lokorin.com
  4. * Copyright 2004-2006
  5. * Licensed under the GNU LGPL. See COPYING for full terms.
  6. */
  7. /**
  8. * A library that contains functions for digesting information about important
  9. * events and relaying it to the webmaster.
  10. * @author Andreas Launila
  11. * @version $Revision: 1.6 $
  12. * @package com.lokorin.lokorin.lib
  13. * @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
  14. */
  15.  
  16. /**
  17. * For access to common constants and functions.
  18. */
  19. require_once('common.php');
  20.  
  21. /**
  22. * Performs all the event digest work available.
  23. * @throws Exception If something goes wrong.
  24. * @access public
  25. */
  26. function doEventDigest() {
  27. checkErrors();
  28. checkMplfArchive();
  29. return true;
  30. }
  31.  
  32. /**
  33. * Checks if there are any unresolved errors that should be sent to the
  34. * webmaster.
  35. * @access private
  36. */
  37. function checkErrors() {
  38. global $db;
  39. $mailMessage = '';
  40. $mailTitle = 'Digest: ';
  41. //Check for errors
  42. $rows = $db->querySelect(TABLE_ERRORS,
  43. array('message', 'timestamp'),
  44. "WHERE investigated != 1");
  45. if(count($rows) > 0) {
  46. $mailTitle .= sizeof($rows).' Errors';
  47. foreach($rows as $row) {
  48. $mailMessage .= 'Error ('.date(DATE_LONG, $row['timestamp']).
  49. '): "'.$row['message'].'"'."\r\n\r\n";
  50. }
  51. sendDigestEmail($mailTitle, $mailMessage);
  52. }
  53. }
  54.  
  55. /**
  56. * Checks if there are any filters or suggested modifications awaiting
  57. * approval.
  58. * @access private
  59. */
  60. function checkMplfArchive() {
  61. global $db;
  62. //Check for filters
  63. $count = $db->queryCount(TABLE_MPLF_FILTERS,
  64. $db->buildSqlSelector(array('moderator_id' => 0)));
  65. if($count != 0) {
  66. sendDigestEmail('Digest: '.$count.' filter awaiting approval',
  67. 'There are currently '.$count.' filters that need approval ' .
  68. 'at http://www.lokorin.com/mplf/mod/approve.php .');
  69. }
  70. //Check for changes
  71. $count = $db->queryCount(TABLE_MPLF_CHANGES);
  72. if($count != 0) {
  73. sendDigestEmail('Digest: '.$count.' changes awaiting approval',
  74. 'There are currently '.$count.' changes that need approval ' .
  75. 'at http://www.lokorin.com/mplf/mod/changes.php .');
  76. }
  77. }
  78.  
  79. /**
  80. * Sends a digest email to the webmaster.
  81. * @param string $title The title of the email.
  82. * @param string $message The message body of the email.
  83. * @access private
  84. */
  85. function sendDigestEmail($title, $message) {
  86. doInclude('lib_util');
  87. sendEmail($title, $message, 'lokobot@lokorin.com');
  88. }
  89. ?>

Documentation generated on Sun, 16 Apr 2006 21:03:23 +0200 by phpDocumentor 1.3.0RC4