b2evolution PHP Cross Reference Blogging Systems

Source: /inc/cron/jobs/_post_notifications.job.php - 74 lines - 2077 bytes - Text - Print

Description: This file implements the post notifications Cron controller

   1  <?php
   2  /**
   3   * This file implements the post notifications Cron controller
   4   *
   5   * @author fplanque: Francois PLANQUE
   6   *
   7   * @todo dh> Should this also handle feedback notifications (according to the "outbound_notifications_mode" setting)?
   8   * fp> No. The feedback notifications should have their own job.
   9   *
  10   * @version $Id: _post_notifications.job.php 5555 2014-01-03 00:10:21Z fplanque $
  11   */
  12  if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );
  13  
  14  global $Settings, $Messages;
  15  
  16  if( $Settings->get( 'outbound_notifications_mode' ) != 'cron' )
  17  { // Autopruning is NOT requested
  18      $result_message = T_('Post notifications are not set to run as a scheduled task.');
  19      return 2;
  20  }
  21  
  22  // Get the ID of the post we are supposed to post-process:
  23  if( empty( $job_params['item_ID'] ) )
  24  {
  25      $result_message = 'No item_ID parameter received.'; // No trans.
  26      return 3;
  27  }
  28  
  29  $item_ID = $job_params['item_ID'];
  30  
  31  
  32  // Notify that we are going to take care of that post's post processing:
  33  $DB->query( 'UPDATE T_items__item
  34                                  SET post_notifications_status = "started"
  35                              WHERE post_ID = '.$item_ID.'
  36                                AND post_notifications_status = "todo"
  37                                AND post_notifications_ctsk_ID = '.$job_params['ctsk_ID'] );
  38  if( $DB->rows_affected != 1 )
  39  {    // We would not "lock" the requested post
  40      $result_message = sprintf( T_('Could not lock post #%d. It may already be processed.'), $item_ID );
  41      return 4;
  42  }
  43  
  44  // Get the Item:
  45  $ItemCache = & get_ItemCache();
  46  /**
  47   * @var Item
  48   */
  49  $edited_Item = & $ItemCache->get_by_ID( $item_ID );
  50  
  51  // send outbound pings:
  52  if( ! $edited_Item->send_outbound_pings() )
  53  {
  54      $result_message = $Messages->get_string( '', '', "\n" );
  55      return 5;
  56  }
  57  
  58  // Send email notifications now!
  59  $edited_Item->send_email_notifications( false );
  60  
  61  // Record that processing has been done:
  62  $edited_Item->set( 'notifications_status', 'finished' );
  63  
  64  // Save the new processing status to DB
  65  $edited_Item->dbupdate();
  66  
  67  $result_message = $Messages->get_string( '', '', "\n" );
  68  if( empty( $result_message ) )
  69  {
  70      $result_message = T_('Done.');
  71  }
  72  
  73  return 1; /* ok */
  74  ?>

title

Description

title

Description

title

Description

title

title

Body