Version 4.5.0
This commit is contained in:
1 parent
1a0c7fd3c2
commit
f79dcf067a
3791 files changed
+248032
-76372
No files matched your search
@@ -11,7 +11,7 @@
|
||||
namespace IPS\core\tasks;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
@@ -35,51 +35,10 @@ class _digest extends \IPS\Task
|
||||
*/
|
||||
public function execute()
|
||||
{
|
||||
/* Doing daily or weekly this run? */
|
||||
$frequencies = array( 'daily', 'weekly' );
|
||||
$frequency = $frequencies[ array_rand( $frequencies ) ];
|
||||
|
||||
/* Grab some members to send digests to. */
|
||||
$members = \IPS\Db::i()->select( 'follow_member_id, follow_notify_sent', 'core_follow', array( 'follow_notify_do=1 AND follow_notify_freq = ? AND follow_notify_sent < ?', $frequency, ( $frequency == 'daily' ) ? time() - 86400 : time() - 604800 ), 'follow_notify_sent ASC', array( 0, 50 ), NULL, NULL, \IPS\Db::SELECT_DISTINCT );
|
||||
|
||||
if( !count( $members ) )
|
||||
$this->runUntilTimeout( function()
|
||||
{
|
||||
/* Nothing to send */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
$memberIDs = array();
|
||||
foreach( $members as $member )
|
||||
{
|
||||
$memberIDs[] = $member['follow_member_id'];
|
||||
}
|
||||
|
||||
/* Fetch the member's follows so we can build their digest */
|
||||
$follows = \IPS\Db::i()->select( '*', 'core_follow', array( 'follow_notify_do=1 AND follow_notify_freq=? AND follow_notify_sent < ? AND ' . \IPS\Db::i()->in( 'follow_member_id', $memberIDs ), $frequency, time() - 86400 ), 'follow_notify_sent ASC, follow_app ASC, follow_area ASC' );
|
||||
|
||||
$groupedFollows = array();
|
||||
foreach( $follows as $follow )
|
||||
{
|
||||
$groupedFollows[ $follow['follow_member_id'] ][ $follow['follow_app'] ][ $follow['follow_area'] ][] = $follow;
|
||||
}
|
||||
|
||||
foreach( $groupedFollows as $id => $data )
|
||||
{
|
||||
$member = \IPS\Member::load( $id );
|
||||
if( !$member->email )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Build it */
|
||||
$digest = new \IPS\core\Digest\Digest;
|
||||
$digest->member = $member;
|
||||
$digest->frequency = $frequency;
|
||||
$digest->build( $data );
|
||||
|
||||
/* Send it */
|
||||
$digest->send();
|
||||
}
|
||||
return \IPS\core\Digest\Digest::sendDigestBatch( 'daily' );
|
||||
});
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user