Version 4.1.19

This commit is contained in:
Neo committed 2025-12-19 05:38:56 -08:00
1 parent 28bd025b35
commit 2bd5025018
2674 files changed
+233518 -77766

No files matched your search

+46 -28
View File
@@ -2,9 +2,9 @@
/**
* @brief Digest Class
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Social Suite
* @package IPS Community Suite
* @since 08 May 2014
* @version SVN_VERSION_NUMBER
*/
@@ -56,17 +56,33 @@ class _Digest
*/
public function build( $data )
{
$this->mail = \IPS\Email::buildFromTemplate( 'core', 'digest', array( $this->member, $this->frequency ) );
/* Banned members should not be emailed */
if( $this->member->isBanned() )
{
return;
}
/* We just do it this way because for backwards-compatibility, template parsing expects an \IPS\Email object with a $language property
This email is never actually sent and a new one is generated in send() */
$this->mail = \IPS\Email::buildFromTemplate( 'core', 'digest', array( $this->member, $this->frequency ), \IPS\Email::TYPE_LIST );
$this->mail->language = $this->member->language();
$max = ceil( 80 / count( array_keys( $data ) ) );
$count = 0;
$total = count( array_keys( $data ) );
$numberOfItems = 0;
foreach( $data as $app => $area )
{
foreach ( $area as $items )
{
$numberOfItems += count( $items );
}
}
$max = ceil( 80 / $numberOfItems );
foreach( $data as $app => $area )
{
foreach( $area as $key => $follows )
{
$count = 0;
$areaPlainOutput = NULL;
$areaHtmlOutput = NULL;
$added = FALSE;
@@ -91,7 +107,7 @@ class _Digest
$itemClass::$databaseTable . '.' . $itemClass::$databasePrefix . $itemClass::$databaseColumnMap['date'] . ' ASC',
$max,
'read',
FALSE,
\IPS\Content\Hideable::FILTER_OWN_HIDDEN,
NULL,
$this->member,
TRUE
@@ -99,13 +115,14 @@ class _Digest
{
try
{
$areaPlainOutput .= \IPS\Email\Theme\Theme::i()->getTemplate( 'digests', $app, 'plain' )->item( $item, $this->mail );
$areaHtmlOutput .= \IPS\Email\Theme\Theme::i()->getTemplate( 'digests', $app, 'html' )->item( $item, $this->mail );
$areaPlainOutput .= \IPS\Email::template( $app, 'digests__item', 'plaintext', array( $item, $this->mail ) );
$areaHtmlOutput .= \IPS\Email::template( $app, 'digests__item', 'html', array( $item, $this->mail ) );
$added = TRUE;
++$count;
}
catch ( \BadMethodCallException $e ) {}
catch ( \UnderflowException $e ) {}
}
}
}
@@ -117,19 +134,22 @@ class _Digest
try
{
$item = $class::load( $follow['follow_rel_id'] );
foreach( $item->comments( 5, NULL, 'date', 'asc', NULL, FALSE, \IPS\DateTime::ts( $follow['follow_notify_sent'] ?: $follow['follow_added'] ) ) as $comment )
{
/* If an app forgot digest templates, we don't want the entire task to fail to ever run again */
if( !method_exists( \IPS\Email\Theme\Theme::i()->getTemplate( 'digests', $app, 'plain' ), 'comment' ) OR
!method_exists( \IPS\Email\Theme\Theme::i()->getTemplate( 'digests', $app, 'html' ), 'comment' ) )
try
{
$areaPlainOutput .= \IPS\Email::template( $app, 'digests__comment', 'plaintext', array( $comment, $this->mail ) );
$areaHtmlOutput .= \IPS\Email::template( $app, 'digests__comment', 'html', array( $comment, $this->mail ) );
}
catch ( \UnderflowException $e )
{
/* If an app forgot digest templates, we don't want the entire task to fail to ever run again */
\IPS\Log::debug( $e, 'digestBuild' );
throw new \OutOfRangeException;
}
$areaPlainOutput .= \IPS\Email\Theme\Theme::i()->getTemplate( 'digests', $app, 'plain' )->comment( $comment, $this->mail );
$areaHtmlOutput .= \IPS\Email\Theme\Theme::i()->getTemplate( 'digests', $app, 'html' )->comment( $comment, $this->mail );
$added = TRUE;
++$count;
}
@@ -139,12 +159,12 @@ class _Digest
}
}
}
/* Wrapper */
if( $added )
{
$this->output['plain'] .= \IPS\Email\Theme\Theme::i()->getTemplate( 'digests', 'core', 'plain' )->areaWrapper( $areaPlainOutput, $app, $key, $max, $count, $total, $this->mail );
$this->output['html'] .= \IPS\Email\Theme\Theme::i()->getTemplate( 'digests', 'core', 'html' )->areaWrapper( $areaHtmlOutput, $app, $key, $max, $count, $total, $this->mail );
$this->output['plain'] .= \IPS\Email::template( 'core', 'digests__areaWrapper', 'plaintext', array( $areaPlainOutput, $app, $key, $max, $count, $this->mail ) );
$this->output['html'] .= \IPS\Email::template( 'core', 'digests__areaWrapper', 'html', array( $areaHtmlOutput, $app, $key, $max, $count, $this->mail ) );
$this->hasContent = TRUE;
}
@@ -159,17 +179,15 @@ class _Digest
* @return void
*/
public function send()
{
{
if( $this->hasContent )
{
$this->mail->parseTemplate();
$this->mail->emailBody['html'] = str_replace( "<%digest%>", $this->output['html'], $this->mail->emailBody['html'] );
$this->mail->emailBody['plain'] = str_replace( "<%digest%>", $this->output['plain'], $this->mail->emailBody['plain'] );
$this->mail->setUnsubscribe( 'core', 'unsubscribeDigest' );
$subject = $this->mail->compileSubject( $this->member );
$htmlContent = str_replace( "<%digest%>", $this->output['html'], $this->mail->compileContent( 'html', $this->member ) );
$plaintextContent = str_replace( "<%digest%>", $this->output['plain'], $this->mail->compileContent( 'plaintext', $this->member ) );
//$this->mail->emailBody = $this->mail->wrapEmail();
$this->mail->send( $this->member );
\IPS\Email::buildFromContent( $subject, $htmlContent, $plaintextContent, \IPS\Email::TYPE_LIST, FALSE )->send( $this->member );
}
/* After sending digest update core_follows to set notify_sent (don't forget where clause for frequency) */