Version 3.2.3
This commit is contained in:
1 parent
ae5c01cc78
commit
78706903a2
2641 files changed
+228363
-201264
No files matched your search
@@ -2,18 +2,18 @@
|
||||
/**
|
||||
* <pre>
|
||||
* Invision Power Services
|
||||
* IP.Board v3.1.4
|
||||
* IP.Board v3.2.3
|
||||
* Moderator actions
|
||||
* Last Updated: $Date: 2010-10-20 09:03:17 -0400 (Wed, 20 Oct 2010) $
|
||||
* Last Updated: $Date: 2011-05-05 07:03:47 -0400 (Thu, 05 May 2011) $
|
||||
* </pre>
|
||||
*
|
||||
* @author $Author: ips_terabyte $
|
||||
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/community/board/license.html
|
||||
* @license This is NULLED!
|
||||
* @package IP.Board
|
||||
* @subpackage Forums
|
||||
* @link http://www.invisionpower.com
|
||||
* @version $Revision: 7003 $
|
||||
* @link http://hatynka.in
|
||||
* @version $Revision: 8644 $
|
||||
*/
|
||||
|
||||
if ( ! defined( 'IN_IPB' ) )
|
||||
@@ -37,34 +37,6 @@ class digestLibrary
|
||||
* @var string topic|forum
|
||||
*/
|
||||
public $digest_type = 'topic';
|
||||
|
||||
/**
|
||||
* Midnight time
|
||||
*
|
||||
* @var integer Timestamp
|
||||
*/
|
||||
public $midnight = 0;
|
||||
|
||||
/**
|
||||
* Last week timestamp
|
||||
*
|
||||
* @var integer Timestamp
|
||||
*/
|
||||
public $last_week = 0;
|
||||
|
||||
/**
|
||||
* Yesterday timestamp
|
||||
*
|
||||
* @var integer Timestamp
|
||||
*/
|
||||
public $last_day = 0;
|
||||
|
||||
/**
|
||||
* Last time timestamp
|
||||
*
|
||||
* @var integer Timestamp
|
||||
*/
|
||||
public $last_time = 0;
|
||||
|
||||
/**#@+
|
||||
* Registry Object Shortcuts
|
||||
@@ -86,7 +58,7 @@ class digestLibrary
|
||||
* Constructor
|
||||
*
|
||||
* @param object Registry reference
|
||||
* @return void
|
||||
* @return @e void
|
||||
*/
|
||||
public function __construct( ipsRegistry $registry )
|
||||
{
|
||||
@@ -110,387 +82,51 @@ class digestLibrary
|
||||
$this->registry->class_forums->forumsInit();
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Get midnight (GMT - roughly)
|
||||
//-----------------------------------------
|
||||
|
||||
$this->midnight = mktime( 0, 0 );
|
||||
|
||||
//-----------------------------------------
|
||||
// Midnight today minus a weeks worth of secs
|
||||
//-----------------------------------------
|
||||
|
||||
$this->last_week = $this->midnight - 604800;
|
||||
|
||||
//-----------------------------------------
|
||||
// Midnight today minus a day worth of secs
|
||||
//-----------------------------------------
|
||||
|
||||
$this->last_day = $this->midnight - 86400;
|
||||
|
||||
//-----------------------------------------
|
||||
// Get some lang bits
|
||||
//-----------------------------------------
|
||||
|
||||
ipsRegistry::getClass('class_localization')->loadLanguageFile( array( 'public_emails' ), 'core' );
|
||||
/* Load language files */
|
||||
ipsRegistry::getClass('class_localization')->loadLanguageFile( array( 'public_emails', 'public_email_content' ), 'core' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the digest
|
||||
*
|
||||
* @return void
|
||||
* @param string Frequency (daily/weekly)
|
||||
* @param string Type (topic/forum)
|
||||
* @return @e void
|
||||
*/
|
||||
public function runDigest()
|
||||
public function runDigest( $frequency='daily', $type='topic' )
|
||||
{
|
||||
$this->last_time = $this->digest_time == 'daily' ? $this->last_day : $this->last_week;
|
||||
|
||||
if ( $this->digest_type == 'topic' )
|
||||
if ( $type == 'topic' )
|
||||
{
|
||||
$this->_sendTopicDigest();
|
||||
$this->_sendTopicDigest( $frequency );
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->_sendForumDigest();
|
||||
$this->_sendForumDigest( $frequency );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the digest
|
||||
*
|
||||
* @return void
|
||||
* @param string Frequency (daily/weekly)
|
||||
* @return @e void
|
||||
*/
|
||||
private function _sendTopicDigest()
|
||||
protected function _sendTopicDigest( $frequency )
|
||||
{
|
||||
//-----------------------------------------
|
||||
// Notifications library
|
||||
//-----------------------------------------
|
||||
|
||||
$classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . '/sources/classes/member/notifications.php', 'notifications' );
|
||||
$notifyLibrary = new $classToLoad( $this->registry );
|
||||
|
||||
//-----------------------------------------
|
||||
// Get all posts / topics
|
||||
//-----------------------------------------
|
||||
|
||||
$this->DB->build( array( 'select' => 'tr.trid, tr.topic_id, tr.member_id as trmid',
|
||||
'from' => array( 'tracker' => 'tr' ),
|
||||
'where' => "tr.topic_track_type='{$this->digest_time}' AND t.approved=1 AND t.last_post > {$this->last_time}",
|
||||
'add_join' => array(
|
||||
array( 'select' => 'm.member_group_id, m.mgroup_others, m.org_perm_id, m.members_display_name, m.email, m.posts, m.member_id, m.email_full, m.language, m.last_activity',
|
||||
'from' => array( 'members' => 'm' ),
|
||||
'where' => 'm.member_id=tr.member_id',
|
||||
'type' => 'left'
|
||||
),
|
||||
array( 'select' => 't.*',
|
||||
'from' => array( 'topics' => 't' ),
|
||||
'where' => 't.tid=tr.topic_id',
|
||||
'type' => 'left'
|
||||
),
|
||||
) ) );
|
||||
$topic_query = $this->DB->execute();
|
||||
|
||||
//-----------------------------------------
|
||||
// Now, loop print and send to subscribers
|
||||
//-----------------------------------------
|
||||
|
||||
$main_output = "";
|
||||
$count = 0;
|
||||
$cached = array();
|
||||
$subject = $this->digest_time == 'daily' ? 'digest_topic_daily' : 'digest_topic_weekly';
|
||||
$trids = array();
|
||||
|
||||
while( $t = $this->DB->fetch( $topic_query ) )
|
||||
{
|
||||
//-----------------------------------------
|
||||
// Can access forum/topic?
|
||||
//-----------------------------------------
|
||||
require_once( IPS_ROOT_PATH . 'sources/classes/like/composite.php' );/*noLibHook*/
|
||||
$_like = classes_like::bootstrap( 'forums','topics' );
|
||||
|
||||
if( !$this->registry->getClass('class_forums')->checkEmailAccess($t) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Topic approved or is a mod?
|
||||
//-----------------------------------------
|
||||
|
||||
if( !$this->registry->getClass('class_forums')->checkEmailApproved($t) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Build email
|
||||
//-----------------------------------------
|
||||
|
||||
$main_output = "";
|
||||
$others_posted = 0;
|
||||
|
||||
if ( ! $cached[ $t['tid'] ] )
|
||||
{
|
||||
$topic_title = $t['title'];
|
||||
$forum_name = ipsRegistry::getClass('class_forums')->allForums[ $t['forum_id'] ]['name'];
|
||||
|
||||
//-----------------------------------------
|
||||
// Get posts...
|
||||
//-----------------------------------------
|
||||
|
||||
$this->DB->build( array( 'select' => '*',
|
||||
'from' => 'posts',
|
||||
'where' => "topic_id={$t['tid']} AND queued=0 AND post_date > {$this->last_time}",
|
||||
'order' => 'post_date' ) );
|
||||
|
||||
$post_query = $this->DB->execute();
|
||||
|
||||
$post_output = "";
|
||||
|
||||
while( $p = $this->DB->fetch( $post_query ) )
|
||||
{
|
||||
//-----------------------------------------
|
||||
// Do we have other posters?
|
||||
//-----------------------------------------
|
||||
|
||||
if ( $t['trmid'] != $p['author_id'] )
|
||||
{
|
||||
$others_posted = 1;
|
||||
}
|
||||
|
||||
$post_author = $p['author_name'];
|
||||
$post_date = ipsRegistry::getClass( 'class_localization')->getDate( $p['post_date'], 'SHORT' );
|
||||
$post_content = $p['post'];
|
||||
|
||||
$post_output .= "<br />-------------------------------------------<br />"
|
||||
. "{$post_author} -- {$post_date}<br />{$post_content}<br /><br />";
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Skip if there is no content...
|
||||
//-----------------------------------------
|
||||
|
||||
if( !$post_output )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Process
|
||||
//-----------------------------------------
|
||||
|
||||
$main_output .= $this->lang->words['topic_langbit'] . ": {$topic_title} (" . $this->lang->words['forum_langbit'] . ": {$forum_name})<br />"
|
||||
. $this->registry->getClass('output')->buildSEOUrl( $this->settings['board_url'] . '/index.php?showtopic=' . $t['tid'], 'none', $t['title_seo'], 'showtopic' ) . "<br />"
|
||||
. "=====================================<br />"
|
||||
. $post_output
|
||||
. "<br />=====================================<br />";
|
||||
|
||||
$cached[ $t['tid'] ] = $main_output;
|
||||
}
|
||||
else
|
||||
{
|
||||
$others_posted = 1;
|
||||
$main_output = $cached[ $t['tid'] ];
|
||||
}
|
||||
|
||||
if ( $others_posted )
|
||||
{
|
||||
$trids[ $t['trid'] ] = intval( $t['trid'] );
|
||||
|
||||
//-----------------------------------------
|
||||
// Send notification...
|
||||
//-----------------------------------------
|
||||
|
||||
IPSText::getTextClass('email')->getTemplate( $subject, $t['language'] );
|
||||
|
||||
IPSText::getTextClass( 'email' )->buildMessage( array(
|
||||
'TOPIC_ID' => $t['tid'],
|
||||
'FORUM_ID' => $t['forum_id'],
|
||||
'TITLE' => $topic_title,
|
||||
'NAME' => $t['members_display_name'],
|
||||
'CONTENT' => $main_output,
|
||||
) );
|
||||
|
||||
$notifyLibrary->setMember( $t );
|
||||
$notifyLibrary->setFrom( array() );
|
||||
$notifyLibrary->setNotificationKey( 'new_reply' );
|
||||
$notifyLibrary->setNotificationText( IPSText::getTextClass('email')->message );
|
||||
$notifyLibrary->setNotificationTitle( IPSText::getTextClass('email')->subject );
|
||||
|
||||
try
|
||||
{
|
||||
$notifyLibrary->sendNotification();
|
||||
}
|
||||
catch( Exception $e ){}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* Update sent time */
|
||||
if ( count( $trids ) )
|
||||
{
|
||||
$this->DB->update( 'tracker', array( 'last_sent' => time() ), 'trid IN (' . implode( ',', $trids ) . ')' );
|
||||
}
|
||||
$_like->sendDigestNotifications( ( $frequency == 'daily' ) ? 'daily' : 'weekly' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the digest
|
||||
*
|
||||
* @return void
|
||||
* @return @e void
|
||||
*/
|
||||
private function _sendForumDigest()
|
||||
{
|
||||
//-----------------------------------------
|
||||
// Notifications library
|
||||
//-----------------------------------------
|
||||
|
||||
$classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . '/sources/classes/member/notifications.php', 'notifications' );
|
||||
$notifyLibrary = new $classToLoad( $this->registry );
|
||||
|
||||
//-----------------------------------------
|
||||
// Get all posts / topics
|
||||
//-----------------------------------------
|
||||
|
||||
$this->DB->build( array( 'select' => 'ft.*',
|
||||
'from' => array( 'forum_tracker' => 'ft' ),
|
||||
'where' => "ft.forum_track_type='{$this->digest_time}'",
|
||||
'add_join' => array(
|
||||
array( 'select' => 'm.members_display_name, m.member_group_id, m.mgroup_others, m.org_perm_id, m.member_id, m.email, m.language, m.posts',
|
||||
'from' => array( 'members' => 'm' ),
|
||||
'where' => 'm.member_id=ft.member_id',
|
||||
'type' => 'left'
|
||||
)
|
||||
) ) );
|
||||
$forum_query = $this->DB->execute();
|
||||
|
||||
//-----------------------------------------
|
||||
// Now, loop print and send to subscribers
|
||||
//-----------------------------------------
|
||||
|
||||
$main_output = "";
|
||||
$count = 0;
|
||||
$cached = array();
|
||||
$subject = $this->digest_time == 'daily' ? 'digest_forum_daily' : 'digest_forum_weekly';
|
||||
$frids = array();
|
||||
|
||||
while( $t = $this->DB->fetch( $forum_query ) )
|
||||
{
|
||||
$main_output = "";
|
||||
$others_posted = 0;
|
||||
protected function _sendForumDigest( $frequency )
|
||||
{
|
||||
require_once( IPS_ROOT_PATH . 'sources/classes/like/composite.php' );/*noLibHook*/
|
||||
$_like = classes_like::bootstrap( 'forums', 'forums' );
|
||||
|
||||
$forum_name = ipsRegistry::getClass('class_forums')->allForums[ $t['forum_id'] ]['name'];
|
||||
|
||||
//-----------------------------------------
|
||||
// Get topics...
|
||||
//-----------------------------------------
|
||||
|
||||
$this->DB->build( array( 'select' => '*',
|
||||
'from' => 'topics',
|
||||
'where' => "forum_id={$t['forum_id']} AND last_post > {$this->last_time}",
|
||||
) );
|
||||
$topic_query = $this->DB->execute();
|
||||
|
||||
$post_output = "";
|
||||
|
||||
while( $p = $this->DB->fetch( $topic_query ) )
|
||||
{
|
||||
//-----------------------------------------
|
||||
// Check access
|
||||
//-----------------------------------------
|
||||
|
||||
if( !$this->registry->getClass('class_forums')->checkEmailAccess( array_merge($t,$p) ) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Topic approved or is a mod?
|
||||
//-----------------------------------------
|
||||
|
||||
if( !$this->registry->getClass('class_forums')->checkEmailApproved( array_merge($t,$p) ) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$post = $this->DB->buildAndFetch( array( 'select' => '*',
|
||||
'from' => 'posts',
|
||||
'where' => 'topic_id=' . $p['tid'],
|
||||
'order' => 'post_date DESC',
|
||||
'limit' => array( 1 )
|
||||
) );
|
||||
|
||||
//-----------------------------------------
|
||||
// Do we have other posters?
|
||||
//-----------------------------------------
|
||||
|
||||
if ( $t['member_id'] != $post['author_id'] )
|
||||
{
|
||||
$others_posted = 1;
|
||||
}
|
||||
|
||||
$post_author = $post['author_name'];
|
||||
$post_date = ipsRegistry::getClass('class_localization')->getDate( $post['post_date'], 'SHORT' );
|
||||
$post_content = $post['post'];
|
||||
$topic_title = $p['title'];
|
||||
|
||||
$post_output .= "<br />-------------------------------------------<br />"
|
||||
. $this->lang->words['topic_langbit'] . ": {$topic_title} ({$post_author} -- {$post_date})<br />"
|
||||
. $this->registry->getClass('output')->buildSEOUrl( $this->settings['board_url'] . '/index.php?showtopic=' . $p['tid'], 'none', $p['title_seo'], 'showtopic' )
|
||||
. "<br />............................................<br />"
|
||||
. "{$post_content}<br /><br />";
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Skip if there is no content...
|
||||
//-----------------------------------------
|
||||
|
||||
if( $post_output == '' )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Process
|
||||
//-----------------------------------------
|
||||
|
||||
$main_output = $this->lang->words['forum_langbit'] . ": {$forum_name}<br />"
|
||||
. "=====================================<br />"
|
||||
. $post_output
|
||||
. "<br />=====================================<br />";
|
||||
|
||||
if ( $others_posted )
|
||||
{
|
||||
$frids[ $t['frid'] ] = intval( $t['frid'] );
|
||||
|
||||
//-----------------------------------------
|
||||
// Send notification...
|
||||
//-----------------------------------------
|
||||
|
||||
IPSText::getTextClass('email')->getTemplate( $subject, $t['language'] );
|
||||
|
||||
IPSText::getTextClass( 'email' )->buildMessage( array(
|
||||
'FORUM_ID' => $t['forum_id'],
|
||||
'FORUM_NAME' => $forum_name,
|
||||
'NAME' => $t['members_display_name'],
|
||||
'CONTENT' => $main_output,
|
||||
) );
|
||||
|
||||
$notifyLibrary->setMember( $t );
|
||||
$notifyLibrary->setFrom( array() );
|
||||
$notifyLibrary->setNotificationKey( 'new_topic' );
|
||||
$notifyLibrary->setNotificationText( IPSText::getTextClass('email')->message );
|
||||
$notifyLibrary->setNotificationTitle( IPSText::getTextClass('email')->subject );
|
||||
|
||||
try
|
||||
{
|
||||
$notifyLibrary->sendNotification();
|
||||
}
|
||||
catch( Exception $e ){}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* Update sent time */
|
||||
if ( count( $frids ) )
|
||||
{
|
||||
$this->DB->update( 'forum_tracker', array( 'last_sent' => time() ), 'frid IN (' . implode( ',', $frids ) . ')' );
|
||||
}
|
||||
$_like->sendDigestNotifications( ( $frequency == 'daily' ) ? 'daily' : 'weekly' );
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user