move digest stuff to Digest class
This commit is contained in:
parent
0086a89740
commit
c2f0f24e4c
|
@ -9,9 +9,7 @@ class Backend extends Handler {
|
|||
function digestTest() {
|
||||
header("Content-type: text/html");
|
||||
|
||||
require_once "digest.php";
|
||||
|
||||
$rv = prepare_headlines_digest($_SESSION['uid'], 1, 1000);
|
||||
$rv = Digest::prepare_headlines_digest($_SESSION['uid'], 1, 1000);
|
||||
|
||||
$rv[3] = "<pre>" . $rv[3] . "</pre>";
|
||||
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
class Digest
|
||||
{
|
||||
|
||||
/**
|
||||
* Send by mail a digest of last articles.
|
||||
*
|
||||
|
@ -6,7 +9,7 @@
|
|||
* @param integer $limit The maximum number of articles by digest.
|
||||
* @return boolean Return false if digests are not enabled.
|
||||
*/
|
||||
function send_headlines_digests($debug = false) {
|
||||
static function send_headlines_digests($debug = false) {
|
||||
|
||||
require_once 'classes/ttrssmailer.php';
|
||||
|
||||
|
@ -31,7 +34,8 @@
|
|||
|
||||
// try to send digests within 2 hours of preferred time
|
||||
if ($preferred_ts && time() >= $preferred_ts &&
|
||||
time() - $preferred_ts <= 7200) {
|
||||
time() - $preferred_ts <= 7200
|
||||
) {
|
||||
|
||||
if ($debug) _debug("Sending digest for UID:" . $line['id'] . " - " . $line["email"]);
|
||||
|
||||
|
@ -42,7 +46,7 @@
|
|||
// reset tz_offset global to prevent tz cache clash between users
|
||||
$tz_offset = -1;
|
||||
|
||||
$tuple = prepare_headlines_digest($line["id"], 1, $limit);
|
||||
$tuple = Digest::prepare_headlines_digest($line["id"], 1, $limit);
|
||||
$digest = $tuple[0];
|
||||
$headlines_count = $tuple[1];
|
||||
$affected_ids = $tuple[2];
|
||||
|
@ -77,7 +81,7 @@
|
|||
|
||||
}
|
||||
|
||||
function prepare_headlines_digest($user_id, $days = 1, $limit = 1000) {
|
||||
static function prepare_headlines_digest($user_id, $days = 1, $limit = 1000) {
|
||||
|
||||
require_once "lib/MiniTemplator.class.php";
|
||||
|
||||
|
@ -190,3 +194,4 @@
|
|||
return array($tmp, $headlines_count, $affected_ids, $tmp_t);
|
||||
}
|
||||
|
||||
}
|
|
@ -217,10 +217,8 @@
|
|||
housekeeping_user($owner_uid);
|
||||
}
|
||||
|
||||
require_once "digest.php";
|
||||
|
||||
// Send feed digests by email if needed.
|
||||
send_headlines_digests($debug);
|
||||
Digest::send_headlines_digests($debug);
|
||||
|
||||
return $nf;
|
||||
|
||||
|
|
Loading…
Reference in New Issue