mirror of
https://github.com/e107inc/e107.git
synced 2025-03-13 17:09:46 +01:00
Add cron files to PM plugin
This commit is contained in:
parent
3c5ee524c3
commit
3150b31d46
160
e107_plugins/pm/e_cron.php
Normal file
160
e107_plugins/pm/e_cron.php
Normal file
@ -0,0 +1,160 @@
|
||||
<?php
|
||||
/*
|
||||
* e107 website system
|
||||
*
|
||||
* Copyright (C) 2001-2009 e107 Inc (e107.org)
|
||||
* Released under the terms and conditions of the
|
||||
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
|
||||
*
|
||||
* Plugin configuration module - gsitemap
|
||||
*
|
||||
* $Source: /cvs_backup/e107_0.8/e107_plugins/pm/e_cron.php,v $
|
||||
* $Revision: 1.1 $
|
||||
* $Date: 2010-01-22 21:18:09 $
|
||||
* $Author: e107steved $
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* e107 Private Messenger plugin
|
||||
*
|
||||
* @package e107_plugins
|
||||
* @subpackage pm
|
||||
* @version $Id: e_cron.php,v 1.1 2010-01-22 21:18:09 e107steved Exp $;
|
||||
*/
|
||||
|
||||
if (!defined('e107_INIT')) { exit; }
|
||||
|
||||
|
||||
include_lan(e_PLUGIN.'/pm/languages/English_mailer.php');
|
||||
|
||||
class pm_cron // include plugin-folder in the name.
|
||||
{
|
||||
private $logRequirement = 0; // Flag to determine logging level
|
||||
private $debugLevel = 0; // Used for internal debugging
|
||||
private $logHandle = NULL;
|
||||
private $pmClass; // Calendar library routines
|
||||
private $e107;
|
||||
private $mailManager;
|
||||
private $ourDB; // Used for some things
|
||||
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->e107 = e107::getInstance();
|
||||
$this->ourDB = new db;
|
||||
//$this->debugLevel = 2;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Cron configuration
|
||||
*
|
||||
* Defines one or more cron tasks to be performed
|
||||
*
|
||||
* @return array of task arrays
|
||||
*/
|
||||
public function config()
|
||||
{
|
||||
$cron = array();
|
||||
$cron[] = array('name' => LAN_EC_PM_04, 'function' => 'processPM', 'description' => LAN_EC_PM_05);
|
||||
return $cron;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Logging routine - writes lines to a text file
|
||||
*
|
||||
* Auto-opens log file (if necessary) on first call
|
||||
*
|
||||
* @param string $logText - body of text to write
|
||||
* @param boolean $closeAfter - if TRUE, log file closed before exit; otherwise left open
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
function logLine($logText, $closeAfter = FALSE, $addTimeDate = FALSE)
|
||||
{
|
||||
if ($this->logRequirement == 0) return;
|
||||
|
||||
$logFilename = e_LOG.'pm_bulk.txt';
|
||||
if ($this->logHandle == NULL)
|
||||
{
|
||||
if (!($this->logHandle = fopen($logFilename, "a")))
|
||||
{ // Problem creating file?
|
||||
echo "File open failed!<br />";
|
||||
$this->logRequirement = 0;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (fwrite($this->logHandle,($addTimeDate ? date('D j M Y G:i:s').': ' : '').$logText."\r\n") == FALSE)
|
||||
{
|
||||
$this->logRequirement = 0;
|
||||
echo 'File write failed!<br />';
|
||||
}
|
||||
|
||||
if ($closeAfter)
|
||||
{
|
||||
fclose($this->logHandle);
|
||||
$this->logHandle = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Called to process outstanding PMs (which are always bulk lists)
|
||||
*
|
||||
* Emails are added to the queue.
|
||||
* Various events are logged in a text file
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
public function processPM()
|
||||
{
|
||||
global $pref;
|
||||
|
||||
require_once(e_PLUGIN.'pm/pm_class.php');
|
||||
|
||||
$this->startTime = mktime(0, 0, 0, date('n'), date('d'), date('Y')); // Date for start processing
|
||||
|
||||
$this->logRequirement = varset($pref['eventpost_emaillog'], 0);
|
||||
if ($this->debugLevel >= 2) $this->logRequirement = 2; // Force full logging if debug
|
||||
|
||||
|
||||
// Start of the 'real' code
|
||||
|
||||
if ($this->ourDB->db_Select('generic', '*', "`gen_type` = 'pm_bulk' LIMIT 1"))
|
||||
{
|
||||
$pmRow = $this->ourDB->db_Fetch(MYSQL_ASSOC);
|
||||
$this->logLine("\r\n\r\n".str_replace('--NUM--',$pmRow['gen_intdata'],LAN_EC_PM_06).date('D j M Y G:i:s'));
|
||||
$this->ourDB->db_Delete('generic', "`gen_type` = 'pm_bulk' AND `gen_id` = ".$pmRow['gen_id']);
|
||||
$array = new ArrayData;
|
||||
$pmData = $array->ReadArray($pmRow['gen_chardata']);
|
||||
unset($pmRow);
|
||||
$this->pmClass = new private_message;
|
||||
$this->pmClass->add($pmData);
|
||||
$this->logLine(' .. Run completed',TRUE, TRUE);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private function checkMailManager()
|
||||
{
|
||||
if ($this->mailManager == NULL)
|
||||
{
|
||||
require_once(e_HANDLER .'mail_manager_class.php');
|
||||
$this->mailManager = new e107MailManager();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
?>
|
35
e107_plugins/pm/languages/English_mailer.php
Normal file
35
e107_plugins/pm/languages/English_mailer.php
Normal file
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
/*
|
||||
* e107 website system
|
||||
*
|
||||
* Copyright (C) 2008-2009 e107 Inc (e107.org)
|
||||
* Released under the terms and conditions of the
|
||||
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
|
||||
*
|
||||
* Private Messenger - language file for cron-related routines
|
||||
*
|
||||
* $Source: /cvs_backup/e107_0.8/e107_plugins/pm/languages/English_mailer.php,v $
|
||||
* $Revision: 1.1 $
|
||||
* $Date: 2010-01-22 21:18:11 $
|
||||
* $Author: e107steved $
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* e107 Private messenger plugin
|
||||
*
|
||||
* @package e107_plugins
|
||||
* @subpackage pm
|
||||
* @version $Id: English_mailer.php,v 1.1 2010-01-22 21:18:11 e107steved Exp $;
|
||||
*/
|
||||
define('LAN_EC_PM_01', '');
|
||||
define('LAN_EC_PM_02', '');
|
||||
define('LAN_EC_PM_03', '');
|
||||
define('LAN_EC_PM_04', 'PM Handler');
|
||||
define('LAN_EC_PM_05', 'Process large sends of PMs');
|
||||
define('LAN_EC_PM_06', 'Start bulk PM processing for --NUM-- recipients ');
|
||||
define('LAN_EC_PM_07', '');
|
||||
|
||||
|
||||
?>
|
Loading…
x
Reference in New Issue
Block a user