Version 3.2.3

This commit is contained in:
Neo committed 2025-12-19 00:34:03 -08:00
1 parent ae5c01cc78
commit 78706903a2
2641 files changed
+228363 -201264

No files matched your search

+353 -188
View File
@@ -3,16 +3,16 @@
* <pre>
* Status Updates Class
* Holds various functions
* Last Updated: $Date: 2010-11-16 11:26:43 -0500 (Tue, 16 Nov 2010) $
* Last Updated: $Date: 2011-10-05 15:30:51 -0400 (Wed, 05 Oct 2011) $
* </pre>
*
* @author $author$
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.invisionpower.com/community/board/license.html
* @license This is NULLED!
* @package IP.Board
* @author MattMecham
* @link http://www.invisionpower.com
* @version $Rev: 7195 $
* @link http://hatynka.in
* @version $Rev: 9582 $
*
* Example: Create new status update
* <code>
@@ -58,20 +58,23 @@
class memberStatus
{
/**
* Registry Object Shortcuts
*/
* Registry Object Shortcuts
*
* @var object
*/
protected $registry;
protected $DB;
protected $settings;
protected $request;
protected $lang;
protected $member;
protected $memberData;
protected $cache;
protected $caches;
/**
* Status set via status Id entry
*
* @access protected
* @var array
*/
protected $_statusData = array();
@@ -79,7 +82,6 @@ class memberStatus
/**
* Owner data of status set via status Id entry
*
* @access protected
* @var array
*/
protected $_statusOwner = array();
@@ -88,18 +90,18 @@ class memberStatus
* Bypass all permission checks
*
* Use with care, this will allow the class to be used within an API
* @access protected
*
* @var boolean
*/
protected $_bypassPermChecks = false;
protected $_statusCount = 0;
/**
* Allowed items to be saved in the get/set array
*
* @access protected
* @var array
*/
protected $_internalData = array( 'IsImport' => 0, 'Creator' => 'ipb', 'ExternalUpdates' => array() );
protected $_internalData = array( 'IsApproved' => 1, 'IsImport' => 0, 'Creator' => 'ipb', 'ExternalUpdates' => array() );
protected $_allowedInternalData = array( 'Author',
'Friend',
'StatusData',
@@ -109,15 +111,15 @@ class memberStatus
'ReplyData',
'ReplyOwner',
'ExternalUpdates',
'IsApproved',
'Content' );
/**
* CONSTRUCTOR
*
* @access public
* @param object Registry
* @return void
**/
* @return @e void
*/
public function __construct( ipsRegistry $registry )
{
/* Make registry objects */
@@ -140,12 +142,20 @@ class memberStatus
$this->settings['tc_parse_names'] = 1;
}
/**
* Gets the count stored by 'fetch'
* @return number
*/
public function getStatusCount()
{
return intval( $this->_statusCount );
}
/**
* Set the bypass permission flag
*
* @access public
* @param boolean
* @return void
* @return @e void
*/
public function setBypassPermissionCheck( $bool=false )
{
@@ -155,7 +165,6 @@ class memberStatus
/**
* Master check to see if statuses are enabled globally
*
* @access public
* @return boolean
*/
public function isEnabled()
@@ -164,12 +173,11 @@ class memberStatus
}
/**
* Is status locked?
*
* @access public
* @param array [Array of status information OR status ID OR uses $this->_internalData['StatusData'] if none]
* @return bool
*/
* Is status locked?
*
* @param array [Array of status information OR status ID OR uses $this->_internalData['StatusData'] if none]
* @return bool
*/
public function isLocked( $status=null )
{
$status = ( $status === null ) ? $this->_internalData['StatusData'] : ( ( is_array( $status ) ) ? $status : $this->_loadStatus( $status ) );
@@ -186,7 +194,6 @@ class memberStatus
* Fetch status actions
* Default filters are last 10 status actions from everyone sorted in desc date order.
* 'not_theirs' pulls all actions that are not on their own statuses
* @access public
* @param mixed [Array of member data OR member ID INT for member updating their status - will use ->getAuthor() if null]
* @param array Array of sort/filter data ( member_id [int], status_id [int], offset [int], limit [int], unix_cutoff [int], sort_dir [asc,desc], sort_field [string], 'not_theirs' [0,1] )
*/
@@ -254,7 +261,7 @@ class memberStatus
$row['action_date_formatted_short'] = $this->registry->getClass('class_localization')->getDate( $row['action_date'], 'SHORT' );
/* Format member */
$row = IPSMember::buildDisplayData( $row, array( 'reputation' => 0, 'warn' => 0, 'avatar' => 0 ) );
$row = IPSMember::buildDisplayData( $row, array( 'reputation' => 0, 'warn' => 0 ) );
/* Status owner */
if ( $row['status_member_id'] )
@@ -274,7 +281,7 @@ class memberStatus
{
if ( $row['status_member_id'] )
{
$actions[ $id ]['owner'] = IPSMember::buildDisplayData( $members[ $row['status_member_id'] ], array( 'reputation' => 0, 'warn' => 0, 'avatar' => 0 ) );
$actions[ $id ]['owner'] = IPSMember::buildDisplayData( $members[ $row['status_member_id'] ], array( 'reputation' => 0, 'warn' => 0 ) );
}
}
}
@@ -287,13 +294,16 @@ class memberStatus
* Fetch status updates
* Default filters are last 10 status updates from everyone sorted in desc date order.
* The 'latest_only' flag will grab the last 10 member's updates. Otherwise it'll just grab the last 10 updates which could be from 1 or more people
* The 'member_id' field will only fetch status updates made by member_id (int)
* The 'member_id' field will only fetch status updates made by member_id (int) UNLESS type set
* The 'owner_id' field will fetch status updates made by author_id (INT)
* The 'status_id' field will only fetch status updates made by status_id (int)
* The 'friends_only' flag will only fetch status updates from authors friends
*
* @access public
* 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)
* 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]
* @param array Array of sort/filter data ( member_id [int], latest_only [0,1], offset [int], limit [int], unix_cutoff [int], sort_dir [asc,desc], sort_field [string] )
* @param array Array of sort/filter data ( member_id [int], latest_only [0,1], offset [int], limit [int], unix_cutoff [int], sort_dir [asc,desc], sort_field [string], type [string] )
*/
public function fetch( $author=null, $filters=array() )
{
@@ -302,10 +312,29 @@ class memberStatus
$statuses = array();
$mids = array();
$friends = array();
$authors = array();
/* Set up some filters */
$filters['type'] = ( empty( $filters['type'] ) ) ? 'mine' : $filters['type'];
if ( isset( $filters['member_id'] ) )
{
$where[] = "s.status_member_id=" . intval( $filters['member_id'] );
if ( $filters['type'] == 'mine' )
{
$where[] = "s.status_author_id=" . intval( $filters['member_id'] );
}
}
if ( isset( $filters['relatedTo'] ) )
{
$where[] = "s.status_member_id=" . intval( $filters['relatedTo'] ) . ' OR s.status_author_id=' . intval( $filters['relatedTo'] );
}
if ( isset( $filters['ownerOnly'] ) )
{
$where[] = "s.status_author_id=s.status_member_id";
}
if ( isset( $filters['status_id'] ) )
@@ -323,13 +352,24 @@ class memberStatus
$where[] = "s.status_is_latest =" . intval( $filters['status_is_latest'] );
}
if ( isset( $filters['friends_only'] ) AND $filters['friends_only'] )
if ( isset( $filters['isApproved'] ) && $filters['isApproved'] !== null )
{
if ( $filters['isApproved'] === true )
{
$where[] = "s.status_approved=1";
}
else if ( $filters['isApproved'] === false )
{
$where[] = "s.status_approved=0";
}
}
if ( !empty( $filters['friends_only'] ) )
{
/* Hard limit to 300 friends */
$this->DB->build( array( 'select' => 'friends_friend_id',
'from' => 'profile_friends',
'where' => 'friends_member_id=' . $author['member_id'],
//'order' => 'friends_added DESC',
'limit' => array( 0, 300 ) ) );
$this->DB->execute();
@@ -350,7 +390,24 @@ class memberStatus
$sort_field = ( isset( $filters['sort_field'] ) ) ? $filters['sort_field'] : 'status_date';
$offset = ( isset( $filters['offset'] ) ) ? intval( $filters['offset'] ) : 0;
$limit = ( isset( $filters['limit'] ) ) ? intval( $filters['limit'] ) : 10;
$member_id = ( isset( $filters['member_id'] ) AND $filters['member_id'] ) ? $filters['member_id'] : 0;
$member_id = !empty( $filters['member_id'] ) ? $filters['member_id'] : 0;
if ( ! empty( $filters['getCount'] ) )
{
$count = $this->DB->buildAndFetch( array( 'select' => 'count(*) as cnt',
'from' => array( 'member_status_updates' => 's' ),
'where' => ( count( $where ) ) ? implode( ' AND ', $where ) : '',
'add_join' => array(array(
'from' => array( 'members' => 'm' ),
'where' => 'm.member_id=s.status_author_id',
'type' => 'left' ),
array(
'from' => array( 'profile_portal' => 'pp' ),
'where' => 'pp.pp_member_id=m.member_id',
'type' => 'left' ) ) ) );
$this->_statusCount = intval( $count['cnt'] );
}
/* Grab them */
$this->DB->build( array( 'select' => 's.*',
@@ -360,7 +417,7 @@ class memberStatus
'limit' => array( $offset, $limit ),
'add_join' => array(array( 'select' => 'm.*',
'from' => array( 'members' => 'm' ),
'where' => 'm.member_id=s.status_member_id',
'where' => 'm.member_id=s.status_author_id',
'type' => 'left' ),
array( 'select' => 'pp.*',
'from' => array( 'profile_portal' => 'pp' ),
@@ -382,8 +439,14 @@ class memberStatus
$row['_creatorImg'] = $this->creatorImage( $row );
$row['_creatorText'] = $this->creatorText( $row );
/* For someone else? */
if ( $row['status_member_id'] != $row['status_author_id'] )
{
$authorIds[ $row['status_id'] ] = $row['status_member_id'];
$mids[$row['status_member_id']] = $row['status_member_id'];
}
/* Format member */
$row = IPSMember::buildDisplayData( $row, array( 'reputation' => 0, 'warn' => 0, 'avatar' => 0 ) );
$row = IPSMember::buildDisplayData( $row, array( 'reputation' => 0, 'warn' => 0 ) );
/* Replies */
if ( $row['status_replies'] AND strstr( $row['status_last_ids'], 'a:' ) )
@@ -419,6 +482,11 @@ class memberStatus
foreach( $statuses as $id => $row )
{
if ( $row['status_member_id'] != $row['status_author_id'] )
{
$statuses[ $id ]['owner'] = IPSMember::buildDisplayData( $members[ $row['status_member_id'] ], array( 'reputation' => 0, 'warn' => 0 ) );
}
if ( is_array( $row['replies'] ) )
{
foreach( $row['replies'] as $rid => $r )
@@ -427,7 +495,7 @@ class memberStatus
{
if ( ! isset( $members[ $r['reply_member_id'] ]['_done'] ) )
{
$members[ $r['reply_member_id'] ] = IPSMember::buildDisplayData( $members[ $r['reply_member_id'] ], array( 'reputation' => 0, 'warn' => 0, 'avatar' => 0 ) );
$members[ $r['reply_member_id'] ] = IPSMember::buildDisplayData( $members[ $r['reply_member_id'] ], array( 'reputation' => 0, 'warn' => 0 ) );
$members[ $r['reply_member_id'] ]['_done'] = 1;
}
@@ -446,7 +514,6 @@ class memberStatus
* Fetch all replies to a status
* Default filters are sorted on reply_date ASC
*
* @access public
* @param mixed [Array of member data OR member ID INT for member updating their status - will use ->getAuthor() if null]
* @param array Array of sort/filter data ( member_id [int], latest_only [0,1], offset [int], limit [int], unix_cutoff [int], sort_dir [asc,desc], sort_field [string] )
*/
@@ -485,7 +552,7 @@ class memberStatus
$row['_canDelete'] = $this->canDeleteReply( $this->getAuthor(), $row, $status );
/* Format member */
$row = IPSMember::buildDisplayData( $row, array( 'reputation' => 0, 'warn' => 0, 'avatar' => 0 ) );
$row = IPSMember::buildDisplayData( $row, array( 'reputation' => 0, 'warn' => 0 ) );
$replies[ $row['reply_id'] ] = $row;
}
@@ -497,23 +564,25 @@ class memberStatus
/**
* Create a status update for a member
*
* @access public
* @param array [Array of member data for member updating their status - will use ->getAuthor() if null]
* @param array [Array of member data for owner of status update. If null and StatusOwner empty, getAuthor will be used]
* @return array Status information
*/
public function create( $author=null )
public function create( $author=null, $owner=null )
{
$author = ( $author === null ) ? $this->getAuthor() : $author;
$_owner = $this->getStatusOwner();
$owner = ( $owner === null ) ? ( ! empty( $_owner['member_id'] ) ? $_owner : $author ) : $owner;
if ( $this->canCreate( $author ) )
{
if ( $this->canCreate( $author, $owner ) )
{
if ( $this->getContent() )
{
$content = $this->_cleanContent( $this->getContent() );
$hash = IPSText::contentToMd5( $content );
/* Check for this status update already created */
$test = $this->fetchByHash( $author['member_id'], $hash );
$test = $this->fetchByHash( $owner['member_id'], $hash );
if ( $test['status_id'] )
{
@@ -521,11 +590,14 @@ class memberStatus
return FALSE;
}
$data = array( 'status_member_id' => $author['member_id'],
$data = array( 'status_member_id' => $owner['member_id'],
'status_author_id' => $author['member_id'],
'status_date' => time(),
'status_content' => $this->_parseContent( $content, $this->_internalData['Creator'] ),
'status_hash' => $hash,
'status_replies' => 0,
'status_author_ip' => $this->member->ip_address,
'status_approved' => $this->getIsApproved(),
'status_imported' => intval( $this->_internalData['IsImport'] ),
'status_creator' => trim( addslashes( $this->_internalData['Creator'] ) ),
'status_last_ids' => '' );
@@ -535,80 +607,88 @@ class memberStatus
$status_id = $this->DB->getInsertId();
$data['status_id'] = $status_id;
$this->_recordAction( 'new', $author, $data );
$this->rebuildOwnerLatest( $author );
/* Fire off external updates */
$eU = $this->getExternalUpdates();
if ( ! $this->_internalData['IsImport'] AND is_array( $eU ) )
if ( $owner['member_id'] != $author['member_id'] )
{
$this->_triggerExternalUpdates( $eU, $status_id, $author, $content );
$this->_sendCommentNotification( $author, $owner, $data );
}
//-----------------------------------------
// Notify owner's friends as configured
//-----------------------------------------
$friends = array();
if ( $this->settings['friends_enabled'] )
else
{
$this->DB->build( array( 'select' => 'friends_member_id', 'from' => 'profile_friends', 'where' => 'friends_friend_id=' . $author['member_id'] ) );
$this->DB->execute();
$this->_recordAction( 'new', $author, $data );
while( $_friend = $this->DB->fetch() )
$this->rebuildOwnerLatest( $owner );
/* Fire off external updates */
$eU = $this->getExternalUpdates();
if ( ! $this->_internalData['IsImport'] AND is_array( $eU ) )
{
$friends[ $_friend['friends_member_id'] ] = $_friend['friends_member_id'];
$this->_triggerExternalUpdates( $eU, $status_id, $owner, $content );
}
}
if( count($friends) )
{
//-----------------------------------------
// Notifications library
//-----------------------------------------
$classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . '/sources/classes/member/notifications.php', 'notifications' );
$notifyLibrary = new $classToLoad( $this->registry );
$friends = IPSMember::load( $friends );
foreach( $friends as $friend )
{
$friend['language'] = $friend['language'] == "" ? IPSLib::getDefaultLanguage() : $friend['language'];
$ndata = array( 'NAME' => $friend['members_display_name'],
'OWNER' => $author['members_display_name'],
'STATUS' => $data['status_content'],
'URL' => $this->settings['base_url'] . 'app=core&amp;module=usercp&amp;tab=core&amp;area=notifications' );
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=' . $author['member_id'], 'public', $author['members_seo_name'], 'showuser' ),
$this->settings['base_url'] . 'app=members&module=profile&section=status&do=list&status_id=' . $status_id
);
$notifyLibrary->setMember( $friend );
$notifyLibrary->setFrom( $author );
$notifyLibrary->setNotificationKey( 'friend_status_update' );
$notifyLibrary->setNotificationUrl( $this->settings['base_url'] . 'app=members&module=profile&section=status&do=list&status_id=' . $status_id );
$notifyLibrary->setNotificationText( IPSText::getTextClass('email')->message );
$notifyLibrary->setNotificationTitle( IPSText::getTextClass('email')->subject );
try
{
$notifyLibrary->sendNotification();
}
catch( Exception $e ){}
//-----------------------------------------
// Notify owner's friends as configured
//-----------------------------------------
$friends = array();
if ( $this->settings['friends_enabled'] AND $author['member_id'] == $owner['member_id'] )
{
$this->DB->build( array( 'select' => 'friends_member_id', 'from' => 'profile_friends', 'where' => 'friends_friend_id=' . $owner['member_id'] ) );
$this->DB->execute();
while( $_friend = $this->DB->fetch() )
{
$friends[ $_friend['friends_member_id'] ] = $_friend['friends_member_id'];
}
}
}
if( count($friends) )
{
//-----------------------------------------
// Notifications library
//-----------------------------------------
$classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . '/sources/classes/member/notifications.php', 'notifications' );
$notifyLibrary = new $classToLoad( $this->registry );
$friends = IPSMember::load( $friends );
foreach( $friends as $friend )
{
$friend['language'] = $friend['language'] == "" ? IPSLib::getDefaultLanguage() : $friend['language'];
$ndata = array( 'NAME' => $friend['members_display_name'],
'OWNER' => $owner['members_display_name'],
'STATUS' => $data['status_content'],
'URL' => $this->settings['base_url'] . 'app=core&amp;module=usercp&amp;tab=core&amp;area=notifications' );
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'],
$this->registry->output->buildSEOUrl( 'app=members&module=profile&section=status&do=list&status_id=' . $status_id, 'publicNoSession' )
);
$notifyLibrary->setMember( $friend );
$notifyLibrary->setFrom( $author );
$notifyLibrary->setNotificationKey( 'friend_status_update' );
$notifyLibrary->setNotificationUrl( $this->registry->output->buildSEOUrl( 'app=members&module=profile&section=status&do=list&status_id=' . $status_id, 'publicNoSession' ) );
$notifyLibrary->setNotificationText( IPSText::getTextClass('email')->message );
$notifyLibrary->setNotificationTitle( IPSText::getTextClass('email')->subject );
try
{
$notifyLibrary->sendNotification();
}
catch( Exception $e ){}
}
}
}
}
return $data;
@@ -620,7 +700,6 @@ class memberStatus
/**
* Create a status update for a member
*
* @access public
* @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 array Reply information
@@ -659,13 +738,12 @@ class memberStatus
/**
* Triggers external postings Twitter, etc
* @todo At some point it could be expanded into a mini framework with plugins
*
* @access protected
* @param array Update to...
* @param int Status ID just posted
* @param array [Array of member data for member updating their status - will use ->getAuthor() if null]
* @param string [Content to update]
* @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 )
{
@@ -685,8 +763,8 @@ class memberStatus
{
$url = $this->settings['base_url'] . 'app=members&module=profile&section=status&do=list&status_id=' . $status_id;
require_once( IPS_ROOT_PATH . 'sources/classes/twitter/connect.php' );
$twitter = new twitter_connect( $this->registry, $author['twitter_token'], $author['twitter_secret'] );
$classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/classes/twitter/connect.php', 'twitter_connect' );
$twitter = new $classToLoad( $this->registry, $author['twitter_token'], $author['twitter_secret'] );
$twitter->updateStatusWithUrl( $content, $url, FALSE );
}
@@ -699,8 +777,8 @@ class memberStatus
{
$url = $this->settings['base_url'] . 'app=members&module=profile&section=status&do=list&status_id=' . $status_id;
require_once( IPS_ROOT_PATH . 'sources/classes/facebook/connect.php' );
$facebook = new facebook_connect( $this->registry );
$classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/classes/facebook/connect.php', 'facebook_connect' );
$facebook = new $classToLoad( $this->registry );
$facebook->updateStatusWithUrl( $content, $url, FALSE );
}
}
@@ -712,7 +790,6 @@ class memberStatus
* Emails users of new status replies
* Emails owner (if selected) and anyone else who replied (if selected)
*
* @access protected
* @param array Author array
* @param array Status array
* @param array Reply array
@@ -891,10 +968,51 @@ class memberStatus
return FALSE;
}
/**
* Send comment notification
*
* Emails users of new status replies
* Emails owner (if selected) and anyone else who replied (if selected)
*
* @param array Author array
* @param array Status array
* @param array Reply array
* @return boolean
*/
protected function _sendCommentNotification( $author, $owner, $status )
{
$classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . '/sources/classes/member/notifications.php', 'notifications' );
$notifyLibrary = new $classToLoad( $this->registry );
IPSText::getTextClass('email')->getTemplate( "new_comment_added", $owner['language'] );
IPSText::getTextClass( 'email' )->buildMessage( array( 'MEMBERS_DISPLAY_NAME' => $owner['members_display_name'],
'COMMENT_NAME' => $author['members_display_name'],
'LINK' => $this->settings['board_url'] . '/index.' . $this->settings['php_ext'] . '?showuser=' . $owner['member_id'] ) );
IPSText::getTextClass('email')->subject = sprintf( IPSText::getTextClass('email')->subject,
$this->registry->output->buildSEOUrl( 'showuser=' . $owner['member_id'] . '&amp;tab=status', 'public', $owner['members_seo_name'], 'showuser' ),
$this->registry->output->buildSEOUrl( 'showuser=' . $author['member_id'], 'public', $author['members_seo_name'], 'showuser' ),
$this->memberData['members_display_name'] );
$notifyLibrary->setMember( $owner );
$notifyLibrary->setFrom( $author );
$notifyLibrary->setNotificationKey( 'profile_comment' );
$notifyLibrary->setNotificationUrl( $this->registry->output->buildSEOUrl( 'showuser=' . $owner['member_id'] . '&amp;tab=status', 'public', $owner['members_seo_name'], 'showuser' ) );
$notifyLibrary->setNotificationText( IPSText::getTextClass('email')->message );
$notifyLibrary->setNotificationTitle( IPSText::getTextClass('email')->subject );
try
{
$notifyLibrary->sendNotification();
}
catch( Exception $e ){}
return FALSE;
}
/**
* Lock status
*
* @access public
* @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
@@ -927,7 +1045,6 @@ class memberStatus
/**
* Unlock status
*
* @access public
* @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
@@ -957,7 +1074,6 @@ class memberStatus
/**
* Delete all user's status'
*
* @access public
* @param array [Array of member data for member updating their status - will use ->getAuthor() if null]
* @return boolean
*/
@@ -999,7 +1115,6 @@ class memberStatus
/**
* Delete all user's replies
*
* @access public
* @param array [Array of member data for member updating their status - will use ->getAuthor() if null]
* @return boolean
*/
@@ -1068,7 +1183,6 @@ class memberStatus
/**
* Delete status
*
* @access public
* @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
@@ -1104,7 +1218,6 @@ class memberStatus
/**
* Delete reply
*
* @access public
* @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]
* @param array [Array of status reply information OR reply ID OR uses $this->_internalData['ReplyData'] if none]
@@ -1142,7 +1255,6 @@ class memberStatus
/**
* Rebuild status data
*
* @access public
* @param array [Array of status information OR status ID OR uses $this->_internalData['StatusData'] if none]
* @return boolean
*/
@@ -1187,7 +1299,6 @@ class memberStatus
/**
* Rebuilds status data such as last status update, etc.
*
* @access public
* @param array [Array of member data for member updating their status - will use ->getAuthor() if null]
* @return boolean
*/
@@ -1235,7 +1346,6 @@ class memberStatus
/**
* Fetch the status update by hash
*
* @access public
* @param int Member ID
*/
public function fetchByHash( $memberId, $hash )
@@ -1264,7 +1374,6 @@ class memberStatus
/**
* Fetch the member's latest status update
*
* @access public
* @param int Member ID
*/
public function fetchMemberLatest( $memberId )
@@ -1274,7 +1383,7 @@ class memberStatus
$this->DB->build( array( 'select' => 's.*',
'from' => array( 'member_status_updates' => 's' ),
'where' => 's.status_member_id=' . intval( $memberId ),
'where' => 's.status_member_id=' . intval( $memberId ) . ' AND s.status_author_id=' . intval( $memberId ),
'order' => 's.status_date DESC',
'limit' => array( 0, 1 ),
'add_join' => array(array( 'select' => 'm.*',
@@ -1312,7 +1421,6 @@ class memberStatus
/**
* Fetch creator image
*
* @access public
* @return string (img URL)
*/
public function creatorImage( $status )
@@ -1326,7 +1434,7 @@ class memberStatus
$creator = IPSText::alphanumericalClean( $status['status_creator'] );
/* Image exists? */
if ( ! file_exists( IPS_PUBLIC_PATH . 'style_status/' . $creator . '.png' ) )
if ( ! is_file( IPS_PUBLIC_PATH . 'style_status/' . $creator . '.png' ) )
{
$creator = 'ipb';
}
@@ -1337,7 +1445,6 @@ class memberStatus
/**
* Fetch creator text
*
* @access public
* @return string
*/
public function creatorText( $status )
@@ -1357,15 +1464,20 @@ class memberStatus
}
/**
* Perm Check: Can post a status update
*
* @access public
* @return bool
*/
public function canCreate( $author=null )
* Perm Check: Can post a status update
*
* @return bool
*/
public function canCreate( $author=null, $owner=null )
{
$author = ( $author === null ) ? $this->getAuthor() : $author;
if ( $owner !== null AND $author['member_id'] != $owner['member_id'] )
{
/* Not a new status by user */
return $this->canComment( $author, $owner );
}
if ( ! $author['member_id'] )
{
return FALSE;
@@ -1385,14 +1497,64 @@ class memberStatus
}
/**
* Perm Check: Can post a status update
*
* @access public
* @param array [Array of author data, uses getAuthor if none]
* @param array [Array of status owner information uses $this->_internalData['StatusOwner'] if none]
* @param array [Array of status data information uses $this->_internalData['StatusData'] if none]
* @return bool
*/
* Perm Check: Can post a comment
*
* @param array [Array of author data, uses getAuthor if none]
* @param array [Array of status owner information uses $this->_internalData['StatusOwner'] if none]
* @return bool
*/
public function canComment( $author=null, $owner=null, $status=null )
{
$author = ( $author === null ) ? $this->getAuthor() : $author;
$owner = ( $owner === null ) ? $this->_internalData['StatusOwner'] : $owner;
/* Are we allowed to comment? */
if ( ! $author['g_reply_other_topics'] )
{
return false;
}
if ( $author['restrict_post'] )
{
if ( $author['restrict_post'] == 1 )
{
return false;
}
$post_arr = IPSMember::processBanEntry( $author['restrict_post'] );
if ( time() >= $post_arr['date_end'] )
{
/* Update this member's profile */
IPSMember::save( $author['member_id'], array( 'core' => array( 'restrict_post' => 0 ) ) );
}
else
{
return false;
}
}
$_you_are_being_ignored = explode( ",", $owner['ignored_users'] );
if ( is_array( $_you_are_being_ignored ) and count( $_you_are_being_ignored ) )
{
if ( in_array( $author['member_id'], $_you_are_being_ignored ) )
{
return false;
}
}
return true;
}
/**
* Perm Check: Can post a status update
*
* @param array [Array of author data, uses getAuthor if none]
* @param array [Array of status owner information uses $this->_internalData['StatusOwner'] if none]
* @param array [Array of status data information uses $this->_internalData['StatusData'] if none]
* @return bool
*/
public function canReply( $author=null, $owner=null, $status=null )
{
$author = ( $author === null ) ? $this->getAuthor() : $author;
@@ -1443,13 +1605,12 @@ class memberStatus
}
/**
* Perm Check: Can delete a status update
*
* @access public
* @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
*/
* Perm Check: Can delete a status update
*
* @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 canDeleteStatus( $author=null, $status=null )
{
$author = ( $author === null ) ? $this->getAuthor() : $author;
@@ -1465,6 +1626,12 @@ class memberStatus
return FALSE;
}
/* is left by someone else */
if ( ( $status['status_member_id'] != $status['status_author_id'] ) && $status['status_author_id'] == $author['member_id'] )
{
return true;
}
if ( ! $author['g_is_supmod'] )
{
if ( $author['gbw_no_status_update'] OR $author['bw_no_status_update'] )
@@ -1482,14 +1649,13 @@ class memberStatus
}
/**
* Perm Check: Can delete a reply
*
* @access public
* @param array [Array of author data, uses getAuthor if none]
* @param array [Array of status reply information OR reply ID OR uses $this->_internalData['ReplyData'] if none]
* @param array [Array of status information OR status ID OR uses $this->_internalData['StatusData'] if none]
* @return bool
*/
* Perm Check: Can delete a reply
*
* @param array [Array of author data, uses getAuthor if none]
* @param array [Array of status reply information OR reply ID OR uses $this->_internalData['ReplyData'] if none]
* @param array [Array of status information OR status ID OR uses $this->_internalData['StatusData'] if none]
* @return bool
*/
public function canDeleteReply( $author=null, $reply=null, $status=null )
{
$author = ( $author === null ) ? $this->getAuthor() : $author;
@@ -1530,14 +1696,13 @@ class memberStatus
}
/**
* Perm Check: Can lock a status
* status_is_locked: 1 means user lock, so owner can unlock, 2 means admin lock, so cannot unlock.
*
* @access public
* @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
*/
* Perm Check: Can lock a status
* status_is_locked: 1 means user lock, so owner can unlock, 2 means admin lock, so cannot unlock.
*
* @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 canLockStatus( $author=null, $status=null )
{
$author = ( $author === null ) ? $this->getAuthor() : $author;
@@ -1562,19 +1727,28 @@ class memberStatus
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.
*
* @access public
* @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
*/
* Perm Check: Can lock a status
* status_is_locked: 1 means user lock, so owner can unlock, 2 means admin lock, so cannot unlock.
*
* @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 canUnlockStatus( $author=null, $status=null )
{
$author = ( $author === null ) ? $this->getAuthor() : $author;
@@ -1606,7 +1780,6 @@ class memberStatus
/**
* Record a custom action
*
* @access public
* @param string Type (new or reply)
* @param array text, url, app
* @param array [Array of author data, uses getAuthor if none]
@@ -1630,7 +1803,6 @@ class memberStatus
/**
* Record an action
*
* @access protected
* @param string Type (new or reply)
* @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]
@@ -1657,7 +1829,6 @@ class memberStatus
/**
* Load a status from the DB
*
* @access protected
* @param int Status ID
* @return array Array OR FALSE
*/
@@ -1706,7 +1877,6 @@ class memberStatus
/**
* Load a reply from the DB
*
* @access protected
* @param int Status ID
* @return array Array OR FALSE
*/
@@ -1755,7 +1925,6 @@ class memberStatus
/**
* Clean up content suitable for posting
*
* @access protected
* @param string In
* @return string Out
*/
@@ -1777,7 +1946,7 @@ class memberStatus
/* Auto parse tags */
if ( $this->settings['su_parse_url'] )
{
$content = preg_replace_callback( "#(^|\s|\(|>|\](?<!\[url\]))((?:http|https|news|ftp)://\w+[^\),\s\<\[]+)#is", array( $this, '_autoParseUrls' ), $content );
$content = preg_replace_callback( '#(^|\s|\(|>|\](?<!\[url\]))((?:http|https|news|ftp)://\w+[^\),\s\<\[]+)#is', array( $this, '_autoParseUrls' ), $content );
}
/* Twittah? */
@@ -1800,7 +1969,6 @@ class memberStatus
/**
* Callback to auto-parse @names
*
* @access protected
* @param array Matches from the regular expression
* @return string Converted text
*/
@@ -1812,7 +1980,6 @@ class memberStatus
/**
* Callback to auto-parse #tags
*
* @access protected
* @param array Matches from the regular expression
* @return string Converted text
*/
@@ -1824,7 +1991,7 @@ class memberStatus
/**
* Callback to auto-parse urls
* I totally stole this from Brandon's code but do NOT tell him.
* @access protected
*
* @param array Matches from the regular expression
* @return string Converted text
*/
@@ -1861,7 +2028,6 @@ class memberStatus
/**
* Check for mod posts or restricted posts or ignored
*
* @access protected
* @param array [Array of author data, uses getAuthor if none]
* @param array [Array of status owner information uses $this->_internalData['StatusOwner'] if none]
* @return bool
@@ -1932,7 +2098,6 @@ class memberStatus
/**
* Various getters and setters
*
* @access public
* @param string
* @param mixed void, or an array of arguments
* @return mixed Data