b2evolution PHP Cross Reference Blogging Systems

Source: /inc/cron/jobs/_comment_notifications.job.php - 68 lines - 2075 bytes - Text - Print

Description: This file implements the comment notifications Cron controller

   1  <?php
   2  /**
   3   * This file implements the comment notifications Cron controller
   4   *
   5   * @author efy-asimo: Attila Simo
   6   *
   7   * @version $Id: _comment_notifications.job.php 5555 2014-01-03 00:10:21Z fplanque $
   8   */
   9  if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );
  10  
  11  global $Settings, $Messages, $UserSettings;
  12  
  13  // Get the ID of the comment we are supposed notify:
  14  if( empty( $job_params['comment_ID'] ) )
  15  {
  16      $result_message = 'No comment_ID parameter received.'; // No trans.
  17      return 3;
  18  }
  19  
  20  if( empty( $UserSettings ) )
  21  { // initialize UserSettings, because in CLI mode is not initialized yet
  22      load_class( 'users/model/_usersettings.class.php', 'UserSettings' );
  23      $UserSettings = new UserSettings();
  24  }
  25  
  26  $except_moderators = ( ! empty( $job_params['except_moderators'] ) ) ? $job_params['except_moderators'] : false;
  27  $executed_by_userid = ( ! empty( $job_params['executed_by_userid'] ) ) ? $job_params['executed_by_userid'] : NULL;
  28  
  29  $comment_ID = $job_params['comment_ID'];
  30  
  31  // Notify that we are going to take care of that comment's notifications:
  32  $DB->query( 'UPDATE T_comments
  33                                  SET comment_notif_status = "started"
  34                              WHERE comment_ID = '.$comment_ID.'
  35                                AND comment_notif_status = "todo"
  36                                AND comment_notif_ctsk_ID = '.$job_params['ctsk_ID'] );
  37  
  38  if( $DB->rows_affected != 1 )
  39  {    // We would not "lock" the requested post
  40      $result_message = sprintf( T_('Could not lock comment #%d. It may already be processed.'), $comment_ID );
  41      return 4;
  42  }
  43  
  44  // Get the Comment:
  45  $CommentCache = & get_CommentCache();
  46  /**
  47   * @var Comment
  48   */
  49  $edited_Comment = & $CommentCache->get_by_ID( $comment_ID );
  50  
  51  // Send email notifications now!
  52  $edited_Comment->send_email_notifications( false, $except_moderators, $executed_by_userid );
  53  
  54  // Record that processing has been done:
  55  $edited_Comment->set( 'notif_status', 'finished' );
  56  
  57  // Save the new processing status to DB
  58  $edited_Comment->dbupdate();
  59  
  60  $edited_Comment = $Messages->get_string( '', '', "\n" );
  61  if( empty( $result_message ) )
  62  {
  63      $result_message = T_('Done.');
  64  }
  65  
  66  return 1; /* ok */
  67  
  68  ?>

title

Description

title

Description

title

Description

title

title

Body