Version 4.1.19
This commit is contained in:
1 parent
28bd025b35
commit
2bd5025018
2674 files changed
+233518
-77766
No files matched your search
@@ -2,9 +2,9 @@
|
||||
/**
|
||||
* @brief Status Update Model
|
||||
* @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 10 Feb 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
@@ -21,7 +21,7 @@ if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
/**
|
||||
* Status Update Model
|
||||
*/
|
||||
class _Status extends \IPS\Content\Item implements \IPS\Content\ReportCenter, \IPS\Content\Reputation, \IPS\Content\Lockable, \IPS\Content\Hideable, \IPS\Content\Searchable
|
||||
class _Status extends \IPS\Content\Item implements \IPS\Content\ReportCenter, \IPS\Content\Reputation, \IPS\Content\Lockable, \IPS\Content\Hideable, \IPS\Content\Searchable, \IPS\Content\Shareable
|
||||
{
|
||||
/* !\IPS\Patterns\ActiveRecord */
|
||||
|
||||
@@ -45,11 +45,6 @@ class _Status extends \IPS\Content\Item implements \IPS\Content\ReportCenter, \I
|
||||
*/
|
||||
public static $commentsPerPage = 3;
|
||||
|
||||
/**
|
||||
* @brief Number of comments per page when requesting previous replies (ajax)
|
||||
*/
|
||||
public static $commentsPerPageAjax = 25;
|
||||
|
||||
/**
|
||||
* @brief Multiton Store
|
||||
*/
|
||||
@@ -189,6 +184,19 @@ class _Status extends \IPS\Content\Item implements \IPS\Content\ReportCenter, \I
|
||||
return $this->member_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Search Index Permissions
|
||||
*
|
||||
* @return string Comma-delimited values or '*'
|
||||
* @li Number indicates a group
|
||||
* @li Number prepended by "m" indicates a member
|
||||
* @li Number prepended by "s" indicates a social group
|
||||
*/
|
||||
public function searchIndexPermissions()
|
||||
{
|
||||
return \IPS\Application\Module::get( 'core', 'status', 'front' )->permissions()['perm_view'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get mapped value
|
||||
*
|
||||
@@ -231,7 +239,14 @@ class _Status extends \IPS\Content\Item implements \IPS\Content\ReportCenter, \I
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if ( $member->pp_setting_count_comments === 0 or !\IPS\Settings::i()->profile_comments )
|
||||
/* Member has statuses disabled or statuses are completely disabled */
|
||||
if ( !$member->pp_setting_count_comments or !\IPS\Settings::i()->profile_comments )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Are we restricted? */
|
||||
if ( $member->members_bitoptions['bw_no_status_update'] OR $member->group['gbw_no_status_update'] )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
@@ -275,37 +290,49 @@ class _Status extends \IPS\Content\Item implements \IPS\Content\ReportCenter, \I
|
||||
public static function canCreate( \IPS\Member $member, \IPS\Node\Model $container=NULL, $showError=FALSE )
|
||||
{
|
||||
$profileOwner = isset( \IPS\Request::i()->id ) ? \IPS\Member::load( \IPS\Request::i()->id ) : \IPS\Member::loggedIn();
|
||||
|
||||
$error = 'no_module_permission';
|
||||
$return = TRUE;
|
||||
|
||||
/* Can we access the module? */
|
||||
if ( !parent::canCreate( $member, $container, $showError ) )
|
||||
{
|
||||
return FALSE;
|
||||
$return = FALSE;
|
||||
}
|
||||
|
||||
/* We have to be logged in */
|
||||
if ( !$member->member_id )
|
||||
{
|
||||
return FALSE;
|
||||
$return = FALSE;
|
||||
}
|
||||
|
||||
/* And not restricted */
|
||||
if ( $member->members_bitoptions['bw_no_status_update'] )
|
||||
if ( $member->members_bitoptions['bw_no_status_update'] or $member->group['gbw_no_status_update'] )
|
||||
{
|
||||
return FALSE;
|
||||
$return = FALSE;
|
||||
}
|
||||
|
||||
/* Is the user being ignored */
|
||||
if ( $profileOwner->isIgnoring( $member, 'messages' ) )
|
||||
{
|
||||
return FALSE;
|
||||
$return = FALSE;
|
||||
}
|
||||
|
||||
if ( $profileOwner->pp_setting_count_comments === 0 )
|
||||
if ( !$profileOwner->pp_setting_count_comments )
|
||||
{
|
||||
return FALSE;
|
||||
$return = FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
if ( !\IPS\Settings::i()->profile_comments )
|
||||
{
|
||||
$return = FALSE;
|
||||
}
|
||||
|
||||
/* Return */
|
||||
if ( $showError and !$return )
|
||||
{
|
||||
\IPS\Output::i()->error( $error, '2C322/1', 403 );
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -341,7 +368,7 @@ class _Status extends \IPS\Content\Item implements \IPS\Content\ReportCenter, \I
|
||||
'autoSaveKey' => 'status',
|
||||
'minimize' => $minimize,
|
||||
), '\IPS\Helpers\Form::floodCheck' );
|
||||
|
||||
|
||||
return $formElements;
|
||||
}
|
||||
|
||||
@@ -358,27 +385,6 @@ class _Status extends \IPS\Content\Item implements \IPS\Content\ReportCenter, \I
|
||||
/* Create */
|
||||
$status = parent::createFromForm( $values, $container, $sendNotification );
|
||||
\IPS\File::claimAttachments( 'status', $status->id );
|
||||
|
||||
/* Sync */
|
||||
if ( $status->member_id == $status->author_id and $syncSettings = json_decode( \IPS\Member::loggedIn()->profilesync, TRUE ) )
|
||||
{
|
||||
foreach ( $syncSettings as $provider => $settings )
|
||||
{
|
||||
if ( isset( $settings['status'] ) and $settings['status'] === 'export' )
|
||||
{
|
||||
$class= 'IPS\core\ProfileSync\\' . ucfirst( $provider );
|
||||
$sync = new $class( \IPS\Member::loggedIn() );
|
||||
if ( method_exists( $sync, 'exportStatus' ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
$sync->exportStatus( $status );
|
||||
}
|
||||
catch ( \Exception $e ) { }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Return */
|
||||
return $status;
|
||||
@@ -393,8 +399,10 @@ class _Status extends \IPS\Content\Item implements \IPS\Content\ReportCenter, \I
|
||||
public function processForm( $values )
|
||||
{
|
||||
parent::processForm( $values );
|
||||
|
||||
$this->member_id = isset( \IPS\Request::i()->id ) ? \IPS\Request::i()->id : \IPS\Member::loggedIn()->member_id;
|
||||
|
||||
/* Work out which profile we are posting too, but only if we are NOT coming from the Create menu or the status updates widget (neither of which allow posting to another profile */
|
||||
/* @todo The dependency on \IPS\Request here needs to be moved to the controller */
|
||||
$this->member_id = ( isset( \IPS\Request::i()->id ) AND ( isset( \IPS\Request::i()->controller ) AND \IPS\Request::i()->controller != 'ajaxcreate' ) ) ? \IPS\Request::i()->id : \IPS\Member::loggedIn()->member_id;
|
||||
|
||||
if ( !$this->_new )
|
||||
{
|
||||
@@ -447,6 +455,18 @@ class _Status extends \IPS\Content\Item implements \IPS\Content\ReportCenter, \I
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get URL from index data
|
||||
*
|
||||
* @param array $indexData Data from the search index
|
||||
* @param array $itemData Basic data about the item. Only includes columns returned by item::basicDataColumns()
|
||||
* @return \IPS\Http\Url
|
||||
*/
|
||||
public static function urlFromIndexData( $indexData, $itemData )
|
||||
{
|
||||
return \IPS\Http\Url::internal( "app=core&module=members&controller=profile&id={$indexData['index_author']}&status={$indexData['index_item_id']}&type=status", 'front', 'profile', array( $itemData['author']['members_seo_name'] ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Send notifications
|
||||
*
|
||||
@@ -472,7 +492,7 @@ class _Status extends \IPS\Content\Item implements \IPS\Content\ReportCenter, \I
|
||||
$notification = new \IPS\Notification( \IPS\Application::load( 'core' ), 'new_status', $this, array( $this ) );
|
||||
$followers = \IPS\Member::load( $this->member_id )->followers( 3, array( 'immediate' ), $this->mapped('date'), NULL );
|
||||
|
||||
if( is_array( $followers ) )
|
||||
if( count( $followers ) )
|
||||
{
|
||||
foreach( $followers AS $follower )
|
||||
{
|
||||
@@ -530,6 +550,64 @@ class _Status extends \IPS\Content\Item implements \IPS\Content\ReportCenter, \I
|
||||
|
||||
return parent::canDelete( $member );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get comment count
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function commentCount()
|
||||
{
|
||||
$count = parent::commentCount();
|
||||
|
||||
if( $this->canViewHiddenComments() )
|
||||
{
|
||||
$idColumn = static::$databaseColumnId;
|
||||
$class = static::$commentClass;
|
||||
$authorCol = $class::$databasePrefix . $class::$databaseColumnMap['author'];
|
||||
$where = array( array( $class::$databasePrefix . $class::$databaseColumnMap['item'] . '=?', $this->$idColumn ) );
|
||||
|
||||
if ( isset( static::$databaseColumnMap['hidden_comments'] ) )
|
||||
{
|
||||
$count += $this->mapped('hidden_comments');
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( isset( $class::$databaseColumnMap['approved'] ) )
|
||||
{
|
||||
$col = $class::$databasePrefix . $class::$databaseColumnMap['approved'];
|
||||
$where[] = array( "{$col}=-1" );
|
||||
}
|
||||
elseif( isset( $class::$databaseColumnMap['hidden'] ) )
|
||||
{
|
||||
$col = $class::$databasePrefix . $class::$databaseColumnMap['hidden'];
|
||||
$where[] = array( "{$col}=-1" );
|
||||
}
|
||||
$count += \IPS\Db::i()->select( 'COUNT(*)', $class::$databaseTable, $where )->first();
|
||||
}
|
||||
|
||||
if ( isset( static::$databaseColumnMap['unapproved_comments'] ) )
|
||||
{
|
||||
$count += $this->mapped('unapproved_comments');
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( isset( $class::$databaseColumnMap['approved'] ) )
|
||||
{
|
||||
$col = $class::$databasePrefix . $class::$databaseColumnMap['approved'];
|
||||
$where[] = array( "{$col}=0" );
|
||||
}
|
||||
elseif( isset( $class::$databaseColumnMap['hidden'] ) )
|
||||
{
|
||||
$col = $class::$databasePrefix . $class::$databaseColumnMap['hidden'];
|
||||
$where[] = array( "{$col}=1" );
|
||||
}
|
||||
$count += \IPS\Db::i()->select( 'COUNT(*)', $class::$databaseTable, $where )->first();
|
||||
}
|
||||
}
|
||||
|
||||
return $count;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get comments to display
|
||||
@@ -539,11 +617,11 @@ class _Status extends \IPS\Content\Item implements \IPS\Content\ReportCenter, \I
|
||||
public function commentsForDisplay()
|
||||
{
|
||||
/* Init */
|
||||
$limit = static::$commentsPerPage;
|
||||
$limit = static::getCommentsPerPage();
|
||||
$numberOfComments = $this->commentCount();
|
||||
|
||||
/* If there is more than 3 comments, we want to display the LAST 3 on page 1, the 3 before that on page 2, etc */
|
||||
if ( $numberOfComments >= static::$commentsPerPage )
|
||||
if ( $numberOfComments >= $limit )
|
||||
{
|
||||
/* Work out what page we're looking at, but only if we are actually paginating through comments */
|
||||
/* @future we should probably remove the dependancy on \IPS\Request::i()->page here, as the status may be display on a page that isn't necessarily the profile (ex: My Activity) */
|
||||
@@ -555,7 +633,7 @@ class _Status extends \IPS\Content\Item implements \IPS\Content\ReportCenter, \I
|
||||
|
||||
/* Start by making the offset to be the $numberOfComments - ( 3 * $page )
|
||||
For example, if there's 5 comments, and we're on page 1, the offset will be 2 */
|
||||
$offset = $numberOfComments - ( static::$commentsPerPage * $page );
|
||||
$offset = $numberOfComments - ( $limit * $page );
|
||||
|
||||
/* However, if we've got to the start, set teh offset to 0 and adjust the limit to get whatever is left */
|
||||
if ( $offset < 0 )
|
||||
@@ -563,6 +641,12 @@ class _Status extends \IPS\Content\Item implements \IPS\Content\ReportCenter, \I
|
||||
$limit += $offset;
|
||||
$offset = 0;
|
||||
}
|
||||
|
||||
/* Is limit still in the negatives? Just reset it. */
|
||||
if ( $limit < 0 )
|
||||
{
|
||||
$limit = static::getCommentsPerPage();
|
||||
}
|
||||
}
|
||||
|
||||
/* If there's less than 3 comments, just display those */
|
||||
@@ -594,16 +678,23 @@ class _Status extends \IPS\Content\Item implements \IPS\Content\ReportCenter, \I
|
||||
* @param array $indexData Data from the search index
|
||||
* @param array $authorData Basic data about the author. Only includes columns returned by \IPS\Member::columnsForPhoto()
|
||||
* @param array $itemData Basic data about the item. Only includes columns returned by item::basicDataColumns()
|
||||
* @param array|NULL $containerData Basic data about the author. Only includes columns returned by container::basicDataColumns()
|
||||
* @param array|NULL $containerData Basic data about the container. Only includes columns returned by container::basicDataColumns()
|
||||
* @param array $reputationData Array of people who have given reputation and the reputation they gave
|
||||
* @param int|NULL $reviewRating If this is a review, the rating
|
||||
* @param bool $iPostedIn If the user has posted in the item
|
||||
* @param string $view 'expanded' or 'condensed'
|
||||
* @param bool $asItem Displaying results as items?
|
||||
* @param bool $canIgnoreComments Can ignore comments in the result stream? Activity stream can, but search results cannot.
|
||||
* @param array $template Optional custom template
|
||||
* @return string
|
||||
*/
|
||||
public static function searchResult( array $indexData, array $authorData, array $itemData, array $containerData = NULL, array $reputationData, $reviewRating, $iPostedIn, $view, $asItem )
|
||||
{
|
||||
public static function searchResult( array $indexData, array $authorData, array $itemData, array $containerData = NULL, array $reputationData, $reviewRating, $iPostedIn, $view, $asItem, $canIgnoreComments=FALSE, $template=NULL )
|
||||
{
|
||||
if ( $template !== NULL )
|
||||
{
|
||||
return parent::searchResult( $indexData, $authorData, $itemData, $containerData, $reputationData, $reviewRating, $iPostedIn, $view, $asItem, $canIgnoreComments, $template );
|
||||
}
|
||||
|
||||
$status = static::constructFromData( $itemData );
|
||||
$status->reputation = $reputationData;
|
||||
|
||||
@@ -623,4 +714,16 @@ class _Status extends \IPS\Content\Item implements \IPS\Content\ReportCenter, \I
|
||||
{
|
||||
return static::$commentsPerPage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Share this content using a share service
|
||||
*
|
||||
* @param string $className The share service classname
|
||||
* @return void
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
protected function autoShare( $className )
|
||||
{
|
||||
$className::publish( html_entity_decode( trim( strip_tags( $this->content ) ), ENT_QUOTES | \IPS\HTMLENTITIES, 'UTF-8' ) );
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user