Version 3.4.5
This commit is contained in:
1 parent
fb6b5baabc
commit
e4478369d8
1360 files changed
+228921
-179445
No files matched your search
@@ -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&module=profile&section=status&type=single&status_id=' . $status_id, 'publicNoSession', 'true', 'members_status_single' );
|
||||
$statusUrl = $this->registry->output->buildSEOUrl( 'app=members&module=profile&section=status&type=single&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&module=usercp&tab=core&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&module=usercp&tab=core&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&module=profile&section=status&type=single&status_id=' . $status_id, 'publicNoSession', 'true', 'members_status_single' );
|
||||
|
||||
$url = $this->registry->output->buildSEOUrl( 'app=members&module=profile&section=status&type=single&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&module=profile&section=status&type=single&status_id=' . $status['status_id'], 'publicNoSession', 'true', 'members_status_single' );
|
||||
$statusUrl = $this->registry->output->buildSEOUrl( 'app=members&module=profile&section=status&type=single&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;
|
||||
|
||||
Reference in new issue
Block a user