Version 3.4.5

This commit is contained in:
Neo committed 2025-12-19 00:38:12 -08:00
1 parent fb6b5baabc
commit e4478369d8
1360 files changed
+228921 -179445

No files matched your search

File diff suppressed because it is too large. Load diff
@@ -3,18 +3,18 @@
/**
* <pre>
* Invision Power Services
* IP.Board v3.3.4
* IP.Board v3.4.5
* Notification library
* Last Updated: $Date: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
* Last Updated: $Date: 2012-10-30 18:24:46 -0400 (Tue, 30 Oct 2012) $
* </pre>
*
* @author $Author: bfarber $ (Original: bfarber)
* @author $Author: AndyMillne $ (Original: bfarber)
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.invisionpower.com/company/standards.php#license
* @package IP.Board
* @link http://www.invisionpower.com
* @since Thursday Jan 7, 2010
* @version $Revision: 10914 $
* @version $Revision: 11530 $
*
*/
@@ -89,7 +89,8 @@ class notifications
*/
protected $_notificationText_forDisplay = '';
protected $_notificationText_forEmails = '';
protected $_notificationHtml = '';
/**
* Notification title
*
@@ -275,6 +276,15 @@ class notifications
$this->_notificationText_forEmails = $text;
}
/**
* Set notification HTML for emails
* @param string $html
*/
public function setNotificationHtml( $html )
{
$this->_notificationHtml = $html;
}
/**
* Set notification text
*
@@ -640,7 +650,7 @@ class notifications
}
$_config = $this->getMemberNotificationConfig( $r );
/* update msg show notification for inline pop-up */
if ( in_array( $this->_notificationKey, $this->_showInlinePopUp ) )
{
@@ -752,15 +762,16 @@ class notifications
}
$subject = ( ! empty( $this->_emailTitle ) ) ? strip_tags( $this->_emailTitle ) : strip_tags( $this->_notificationTitle );
/* Add to mail queue */
$this->DB->insert( 'mail_queue', array( 'mail_to' => $to,
'mail_cc' => ( count($cc) ? implode( ',', $cc ) : '' ),
'mail_from' => $this->settings['email_out'],
'mail_date' => time(),
'mail_html_on' => intval( $this->_mail_html_on ),
'mail_subject' => $subject,
'mail_content' => $this->_notificationText_forEmails ) );
$this->DB->insert( 'mail_queue', array( 'mail_to' => $to,
'mail_cc' => ( count($cc) ? implode( ',', $cc ) : '' ),
'mail_from' => $this->settings['email_out'],
'mail_date' => time(),
'mail_html_on' => intval( $this->_mail_html_on ),
'mail_subject' => $subject,
'mail_content' => $this->_notificationText_forEmails,
'mail_html_content' => ( $this->_notificationHtml ) ? $this->_notificationHtml : '' ) );
$cache = $this->cache->getCache('systemvars');
$cache['mail_queue'] += 1;
@@ -827,8 +838,14 @@ class notifications
if ( ! $hidden )
{
$this->DB->update( 'members', 'notification_cnt=notification_cnt+1', 'member_id=' . $member['member_id'], true, true );
}
// Do we have a notification limit?
$_limit = $this->getGroupLimit( $member );
if( $_limit > $member['notification_cnt'] || !$_limit )
{
$this->DB->update( 'members', 'notification_cnt=notification_cnt+1', 'member_id=' . $member['member_id'], true, true );
}
}
return true;
}
@@ -846,35 +863,8 @@ class notifications
// Determine member's limit first
//-----------------------------------------
$groups = array( $member['member_group_id'] );
$_limit = $this->getGroupLimit( $member );
if( $member['mgroup_others'] )
{
$_others = IPSText::cleanPermString( $member['mgroup_others'] );
$groups = ( is_array( $groups ) AND is_array( $_others ) ) ? array_merge( $_others, $groups ) : array();
}
//-----------------------------------------
// 0 is best, otherwise higher is better
//-----------------------------------------
$_limit = 0;
foreach( $groups as $_group )
{
$_thisLimit = $this->caches['group_cache'][ $_group ]['g_max_notifications'];
if( !$_thisLimit )
{
$_limit = 0;
break;
}
else if( $_thisLimit > $_limit )
{
$_limit = $_thisLimit;
}
}
//-----------------------------------------
// We have a limit
//-----------------------------------------
@@ -1104,6 +1094,8 @@ class notifications
$detail['member_PhotoTag'] = IPSMember::buildPhotoTag( $author, 'mini' );
$detail['member_HoverCard'] = $this->registry->getClass('output')->getTemplate('global')->userHoverCard( $author );
/* Slap on the URL */
$detail['url'] = $latest['notify_url'];
@@ -1292,6 +1284,45 @@ class notifications
return 0;
}
/**
* Determine member's notification limit
* @return int $_limit
*/
public function getGroupLimit( $member )
{
$groups = array( $member['member_group_id'] );
if( $member['mgroup_others'] )
{
$_others = explode( ",", IPSText::cleanPermString( $member['mgroup_others'] ) );
$groups = ( is_array( $groups ) AND is_array( $_others ) ) ? array_merge( $_others, $groups ) : array();
}
//-----------------------------------------
// 0 is best, otherwise higher is better
//-----------------------------------------
$_limit = 0;
foreach( $groups as $_group )
{
$_thisLimit = $this->caches['group_cache'][ $_group ]['g_max_notifications'];
if( !$_thisLimit )
{
$_limit = 0;
break;
}
else if( $_thisLimit > $_limit )
{
$_limit = $_thisLimit;
}
}
return intval( $_limit );
}
/**
* Do we have an application class?
* @return boolean
File diff suppressed because it is too large. Load diff
+143 -43
View File
@@ -3,7 +3,7 @@
* <pre>
* Status Updates Class
* Holds various functions
* Last Updated: $Date: 2012-06-21 10:57:38 -0400 (Thu, 21 Jun 2012) $
* Last Updated: $Date: 2013-02-13 11:25:39 -0500 (Wed, 13 Feb 2013) $
* </pre>
*
* @author $author$
@@ -12,7 +12,7 @@
* @package IP.Board
* @author MattMecham
* @link http://www.invisionpower.com
* @version $Rev: 10966 $
* @version $Rev: 11985 $
*
* Example: Create new status update
* <code>
@@ -300,6 +300,7 @@ class memberStatus
* The 'friends_only' flag will only fetch status updates from authors friends
* The 'type' flag can contain 'all', 'mine', 'theirs' - default is 'mine'.
* The 'isApproved' flag can contain true, false or null (true, approved only, false, unapproved only, null both)
* The 'ignorePermissions' flag can be set to true (do not verify we can view) or false (pull only statuses we can see based on other filters), defaulting to false
* getCount - returns a count of all matches without the limit
*
* @param mixed [Array of member data OR member ID INT for member updating their status - will use ->getAuthor() if null]
@@ -385,6 +386,22 @@ class memberStatus
$where[] = "s.status_member_id IN (" . implode( ",", $friends ) . ")";
}
/* Don't return statuses we can't see */
if ( !isset( $filters['ignorePermissions'] ) || $filters['ignorePermissions'] != true )
{
if ( ! $author['g_is_supmod'] )
{
if( IPSMember::isOnModQueue( $author['member_id'] ) )
{
$where[] = "s.status_approved=1";
}
else
{
$where[] = "(s.status_approved=1 OR s.status_member_id=" . $author['member_id'] . ')';
}
}
}
$sort_dir = ( isset( $filters['sort_dir'] ) AND $filters['sort_dir'] == 'asc' ) ? 'asc' : 'desc';
$sort_field = ( isset( $filters['sort_field'] ) ) ? $filters['sort_field'] : 'status_date';
@@ -438,6 +455,7 @@ class memberStatus
$row['_canUnlock'] = $this->canUnlockStatus( $author, $row );
$row['_creatorImg'] = $this->creatorImage( $row );
$row['_creatorText'] = $this->creatorText( $row );
$row['_canApprove'] = $this->canApproveStatus( $author, $row );
/* For someone else? */
if ( $row['status_member_id'] != $row['status_author_id'] )
@@ -590,7 +608,7 @@ class memberStatus
/* Already imported this one */
return FALSE;
}
$data = array( 'status_member_id' => $owner['member_id'],
'status_author_id' => $author['member_id'],
'status_date' => time(),
@@ -598,7 +616,7 @@ class memberStatus
'status_hash' => $hash,
'status_replies' => 0,
'status_author_ip' => $this->member->ip_address,
'status_approved' => $this->getIsApproved(),
'status_approved' => ( ( $owner['pp_setting_moderate_comments'] && $owner['member_id'] != $author['member_id'] ) || IPSMember::isOnModQueue( $author['member_id'] ) ) ? 0 : $this->getIsApproved(),
'status_imported' => intval( $this->_internalData['IsImport'] ),
'status_creator' => trim( addslashes( $this->_internalData['Creator'] ) ),
'status_last_ids' => '' );
@@ -650,7 +668,7 @@ class memberStatus
}
}
if( count($friends) )
if( count($friends) )
{
//-----------------------------------------
// Notifications library
@@ -661,31 +679,44 @@ class memberStatus
$friends = IPSMember::load( $friends );
$statusUrl = $this->registry->output->buildSEOUrl( 'app=members&amp;module=profile&amp;section=status&amp;type=single&amp;status_id=' . $status_id, 'publicNoSession', 'true', 'members_status_single' );
$statusUrl = $this->registry->output->buildSEOUrl( 'app=members&amp;module=profile&amp;section=status&amp;type=single&amp;status_id=' . $status_id, 'publicNoSession', array( $owner['member_id'], $owner['members_seo_name'] ), 'members_status_single' );
/* Build message as few times as possible */
$ndata = array( 'NAME' => '#friend.name#',
'OWNER' => $owner['members_display_name'],
'STATUS' => $data['status_content'],
'URL' => $this->registry->output->buildSEOUrl( 'app=core&amp;module=usercp&amp;tab=core&amp;area=notifications', 'publicNoSession' ) );
/* Get languages */
$langMessages = array();
foreach( $friends as $friend )
{
$ndata = array( 'NAME' => $friend['members_display_name'],
'OWNER' => $owner['members_display_name'],
'STATUS' => $data['status_content'],
'URL' => $this->registry->output->buildSEOUrl( 'app=core&amp;module=usercp&amp;tab=core&amp;area=notifications', 'publicNoSession' ) );
IPSText::getTextClass('email')->getTemplate( 'new_status', $friend['language'] );
IPSText::getTextClass('email')->buildMessage( $ndata );
IPSText::getTextClass('email')->subject = sprintf(
IPSText::getTextClass('email')->subject,
$this->registry->output->buildSEOUrl( 'showuser=' . $owner['member_id'], 'publicNoSession', $owner['members_seo_name'], 'showuser' ),
$owner['members_display_name'],
$statusUrl
);
if ( ! isset( $langMessages[ $friend['language'] ] ) )
{
IPSText::getTextClass('email')->getTemplate( 'new_status', $friend['language'] );
IPSText::getTextClass('email')->buildMessage( $ndata );
$_subject = sprintf( IPSText::getTextClass('email')->subject,
$this->registry->output->buildSEOUrl( 'showuser=' . $owner['member_id'], 'publicNoSession', $owner['members_seo_name'], 'showuser' ),
$owner['members_display_name'],
$statusUrl );
$langMessages[ $friend['language'] ] = array( 'subject' => $_subject, 'message' => IPSText::getTextClass('email')->message );
}
}
foreach( $friends as $friend )
{
$message = $langMessages[ $friend['language'] ]['message'];
$message = str_replace( '#friend.name#', $friend['members_display_name'], $message );
$notifyLibrary->setMember( $friend );
$notifyLibrary->setFrom( $author );
$notifyLibrary->setNotificationKey( 'friend_status_update' );
$notifyLibrary->setNotificationUrl( $statusUrl );
$notifyLibrary->setNotificationText( IPSText::getTextClass('email')->message );
$notifyLibrary->setNotificationTitle( IPSText::getTextClass('email')->subject );
$notifyLibrary->setNotificationText( $message );
$notifyLibrary->setNotificationTitle( $langMessages[ $friend['language'] ]['subject'] );
try
{
@@ -756,7 +787,7 @@ class memberStatus
* @todo [Future] At some point it could be expanded into a mini framework with plugins
*/
protected function _triggerExternalUpdates( $updates, $status_id=0, $author=null, $content=null )
{
{
$author = ( $author === null ) ? $this->getAuthor() : $author;
$content = ( $content ) ? $this->_cleanContent( $content ) : $this->_cleanContent( $this->getContent() );
@@ -766,8 +797,8 @@ class memberStatus
return false;
}
$url = $this->registry->output->buildSEOUrl( 'app=members&amp;module=profile&amp;section=status&amp;type=single&amp;status_id=' . $status_id, 'publicNoSession', 'true', 'members_status_single' );
$url = $this->registry->output->buildSEOUrl( 'app=members&amp;module=profile&amp;section=status&amp;type=single&amp;status_id=' . $status_id, 'publicNoSession', array( $author['member_id'], $author['members_seo_name'] ), 'members_status_single' );
/* Twitter */
if ( $updates['twitter'] )
{
@@ -822,7 +853,7 @@ class memberStatus
/* Init vars */
$_ids = array();
$members = array();
$statusUrl = $this->registry->output->buildSEOUrl( 'app=members&amp;module=profile&amp;section=status&amp;type=single&amp;status_id=' . $status['status_id'], 'publicNoSession', 'true', 'members_status_single' );
$statusUrl = $this->registry->output->buildSEOUrl( 'app=members&amp;module=profile&amp;section=status&amp;type=single&amp;status_id=' . $status['status_id'], 'publicNoSession', array( $_owner['member_id'], $_owner['members_seo_name'] ), 'members_status_single' );
/* Did the status owner want an email? */
if ( $_owner['member_id'] != $_replier['member_id'] )
@@ -1066,6 +1097,35 @@ class memberStatus
return FALSE;
}
/**
* Approve status
*
* @param array [Array of member data for member updating their status - will use ->getAuthor() if null]
* @param array [Array of status information OR status ID OR uses $this->_internalData['StatusData'] if none]
* @return boolean
*/
public function approveStatus( $author=null, $status=null )
{
$author = ( $author === null ) ? $this->getAuthor() : $author;
$status = ( $status === null ) ? $this->_internalData['StatusData'] : ( ( is_array( $status ) ) ? $status : $this->_loadStatus( $status ) );
if ( $status['status_id'] )
{
if ( $this->canApproveStatus( $author, $status ) )
{
/* Update status */
$this->DB->update( 'member_status_updates', array( 'status_approved' => 1 ), 'status_id=' . $status['status_id'] );
/* Rebuild latest */
$this->rebuildOwnerLatest( $author );
return TRUE;
}
}
return FALSE;
}
/**
* Delete all user's status'
@@ -1468,6 +1528,11 @@ class memberStatus
{
$author = ( $author === null ) ? $this->getAuthor() : $author;
if ( $author['restrict_post'] )
{
return FALSE;
}
if ( $owner !== null AND $author['member_id'] != $owner['member_id'] )
{
/* Not a new status by user */
@@ -1500,7 +1565,7 @@ class memberStatus
* @return bool
*/
public function canComment( $author=null, $owner=null, $status=null )
{
{
$author = ( $author === null ) ? $this->getAuthor() : $author;
$owner = ( $owner === null ) ? $this->_internalData['StatusOwner'] : $owner;
@@ -1529,15 +1594,10 @@ class memberStatus
return false;
}
}
$_you_are_being_ignored = explode( ",", $owner['ignored_users'] );
if ( is_array( $_you_are_being_ignored ) and count( $_you_are_being_ignored ) )
if ( IPSMember::checkIgnoredStatus( $author['member_id'], $owner['member_id'], 'messages' ) )
{
if ( in_array( $author['member_id'], $_you_are_being_ignored ) )
{
return false;
}
return false;
}
return true;
@@ -1691,6 +1751,51 @@ class memberStatus
return TRUE;
}
/**
* Perm Check: Can approve a status
*
* @param array [Array of author data, uses getAuthor if none]
* @param array [Array of status information OR status ID OR uses $this->_internalData['StatusData'] if none]
* @return bool
*/
public function canApproveStatus( $author=null, $status=null )
{
$author = ( $author === null ) ? $this->getAuthor() : $author;
$status = ( $status === null ) ? $this->_internalData['StatusData'] : ( ( is_array( $status ) ) ? $status : $this->_loadStatus( $status ) );
if ( ! $author['member_id'] OR ! $status['status_id'] )
{
return FALSE;
}
if ( ! $this->isEnabled() )
{
return FALSE;
}
if ( ! $author['g_is_supmod'] )
{
if ( $author['member_id'] == $status['status_member_id'] && !IPSMember::isOnModQueue( $author['member_id'] ))
{
return TRUE;
}
return FALSE;
}
else
{
return true;
}
/* is left by someone else */
if ( ( $status['status_member_id'] != $status['status_author_id'] ) && $status['status_member_id'] != $author['member_id'] )
{
return false;
}
return TRUE;
}
/**
* Perm Check: Can lock a status
* status_is_locked: 1 means user lock, so owner can unlock, 2 means admin lock, so cannot unlock.
@@ -2078,14 +2183,9 @@ class memberStatus
}
/* Member is ignoring you! */
$_you_are_being_ignored = explode( ",", $owner['ignored_users'] );
if ( is_array( $_you_are_being_ignored ) and count( $_you_are_being_ignored ) )
if ( IPSMember::checkIgnoredStatus( $author['member_id'], $owner['member_id'], 'messages' ) )
{
if ( in_array( $author['member_id'], $_you_are_being_ignored ) )
{
return FALSE;
}
return false;
}
return TRUE;