Version 4.6.0
This commit is contained in:
1 parent
f79dcf067a
commit
517a5e1f70
2036 files changed
+110041
-26162
No files matched your search
@@ -136,6 +136,7 @@ class _Content extends Table
|
||||
* @param NULL|callable $callback Method to call to prepare the returned rows
|
||||
* @param bool $getFirstComment Get the first comment for this item
|
||||
* @param bool $getFollowerCount Get the follower counts for this item
|
||||
* @param bool $getReactions Get reactions for this item
|
||||
* @return void
|
||||
*/
|
||||
public function __construct( $class, \IPS\Http\Url $baseUrl, $where=NULL, \IPS\Node\Model $container=NULL, $includeHidden=\IPS\Content\Hideable::FILTER_AUTOMATIC, $permCheck='view', $honorPinned=TRUE, $showMovedLinks=FALSE, $callback=NULL, $getFirstComment=FALSE, $getFollowerCount=FALSE, $getReactions=FALSE )
|
||||
@@ -342,7 +343,8 @@ class _Content extends Table
|
||||
$this->pages = ceil( $this->count / $this->limit );
|
||||
$rows = iterator_to_array( $it );
|
||||
$idField = $class::$databaseColumnId;
|
||||
|
||||
$nodeClass = isset( $class::$containerNodeClass ) ? $class::$containerNodeClass : NULL;
|
||||
|
||||
if ( isset( $this->getFirstComment ) and isset( $class::$databaseColumnMap['first_comment_id'] ) and $class::$firstCommentRequired )
|
||||
{
|
||||
$commentIds = array();
|
||||
@@ -433,26 +435,81 @@ class _Content extends Table
|
||||
|
||||
/* Pre load the contentPostedIn data to save separate DISTINCT queries later and a query for each unread item */
|
||||
if ( isset( $class::$databaseColumnMap['container'] ) )
|
||||
{
|
||||
{
|
||||
$containerItemIds = array();
|
||||
foreach( $rows as $item )
|
||||
foreach ( $rows as $item )
|
||||
{
|
||||
$colContainer = $class::$databaseColumnMap['container'];
|
||||
$colPrimary = $class::$databaseColumnId;
|
||||
|
||||
$containerItemIds[ $item->$colContainer ][] = $item->$colPrimary;
|
||||
$colPrimary = $class::$databaseColumnId;
|
||||
|
||||
$containerItemIds[$item->$colContainer][] = $item->$colPrimary;
|
||||
}
|
||||
|
||||
$nodeClass = $class::$containerNodeClass;
|
||||
foreach( $containerItemIds as $container => $ids )
|
||||
$memberIds = array();
|
||||
$memberPostedIn = array();
|
||||
|
||||
foreach ( $containerItemIds as $container => $ids )
|
||||
{
|
||||
try
|
||||
{
|
||||
$node = $nodeClass::load( $container );
|
||||
$this->contentPostedIn = array_merge( $node->contentPostedIn( NULL, $ids ), $this->contentPostedIn );
|
||||
|
||||
|
||||
if ( \IPS\IPS::classUsesTrait( $node, 'IPS\Node\Statistics' ) )
|
||||
{
|
||||
$this->contentPostedIn = array_merge( $node->contentPostedIn( NULL, $ids ), $this->contentPostedIn );
|
||||
|
||||
foreach ( $node->authorsPostedIn( $ids ) as $memberId => $itemIds )
|
||||
{
|
||||
if ( $memberId > 0 )
|
||||
{
|
||||
$memberIds[$memberId] = $memberId;
|
||||
|
||||
foreach ( $itemIds as $id )
|
||||
{
|
||||
$memberPostedIn[$id][] = $memberId;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch ( \OutOfRangeException $ex ) { }
|
||||
}
|
||||
|
||||
if ( \count( $memberIds ) )
|
||||
{
|
||||
/* Get the groups */
|
||||
$groups = array();
|
||||
foreach( \IPS\Db::i()->select( 'member_id, member_group_id, mgroup_others', 'core_members', array( \IPS\Db::i()->in( 'member_id', $memberIds ) ) ) as $row )
|
||||
{
|
||||
$groups[ $row['member_id'] ] = array( 'primary' => $row['member_group_id'], 'secondary' => $row['mgroup_others'] );
|
||||
}
|
||||
|
||||
$thisRow = array();
|
||||
foreach( $memberPostedIn as $itemId => $members )
|
||||
{
|
||||
foreach( $members as $m )
|
||||
{
|
||||
if ( isset( $groups[ $m ]['primary'] ) )
|
||||
{
|
||||
$thisRow[ $itemId ]['primary'][ $groups[ $m ]['primary'] ] = $groups[ $m ]['primary'];
|
||||
}
|
||||
|
||||
if ( isset( $groups[ $m ]['secondary'] ) )
|
||||
{
|
||||
foreach( explode( ',', $groups[ $m ]['secondary'] ) as $secondary )
|
||||
{
|
||||
if ( $secondary )
|
||||
{
|
||||
$thisRow[$itemId]['secondary'][$secondary] = $secondary;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach( $rows as $id => $item )
|
||||
{
|
||||
$rows[$id]->groupsPosted = isset( $thisRow[$item->$idField] ) ? \IPS\Member\Group::postedIn( ( isset( $thisRow[$item->$idField]['primary'] ) ? $thisRow[$item->$idField]['primary'] : array() ), ( isset( $thisRow[$item->$idField]['secondary'] ) ? $thisRow[$item->$idField]['secondary'] : array() ) ) : FALSE;
|
||||
}
|
||||
catch( \OutOfRangeException $ex ) {}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -676,7 +733,7 @@ class _Content extends Table
|
||||
if( $item->$action() )
|
||||
{
|
||||
$options[ $id ] = $item->mapped('title');
|
||||
$descriptions[ $id ] = \IPS\Member::loggedIn()->language()->addToStack( 'byline', FALSE, array( 'sprintf' => array( $item->author()->name ) ) ) . \IPS\DateTime::ts( $item->mapped('date') )->html();
|
||||
$descriptions[ $id ] = \IPS\Member::loggedIn()->language()->addToStack( 'byline_merge', FALSE, array( 'htmlsprintf' => array( $item->author()->name, \IPS\DateTime::ts( $item->mapped('date') )->html() ) ) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -807,6 +864,8 @@ class _Content extends Table
|
||||
/* Everything else: just do it */
|
||||
else
|
||||
{
|
||||
$containers = array();
|
||||
|
||||
foreach ( array_keys( \IPS\Request::i()->moderate ) as $id )
|
||||
{
|
||||
try
|
||||
@@ -819,8 +878,24 @@ class _Content extends Table
|
||||
$unread = $object->unread();
|
||||
}
|
||||
|
||||
/* Turn off updating of containers for each action and get container data */
|
||||
try
|
||||
{
|
||||
$object->skipContainerRebuild = TRUE;
|
||||
$containers[ $object->container()->_id ] = $object->container();
|
||||
}
|
||||
catch( \BadMethodCallException $e ){}
|
||||
|
||||
$object->modAction( \IPS\Request::i()->modaction, \IPS\Member::loggedIn(), $params );
|
||||
|
||||
/* Turn back on updating of container data for each action. Also get container again in the event item was moved and it's new */
|
||||
try
|
||||
{
|
||||
$object->skipContainerRebuild = FALSE;
|
||||
$containers[ $object->container()->_id ] = $object->container();
|
||||
}
|
||||
catch( \BadMethodCallException $e ){}
|
||||
|
||||
/* Mark it as read */
|
||||
if( $object instanceof \IPS\Content\ReadMarkers and \IPS\Request::i()->modaction == 'move' AND $unread == 0 )
|
||||
{
|
||||
@@ -829,6 +904,23 @@ class _Content extends Table
|
||||
}
|
||||
catch ( \Exception $e ) {}
|
||||
}
|
||||
|
||||
/* Now update the containers in one go */
|
||||
foreach( $containers as $container )
|
||||
{
|
||||
if ( $container->_comments !== NULL )
|
||||
{
|
||||
$container->setLastComment();
|
||||
}
|
||||
|
||||
if ( $container->_reviews !== NULL )
|
||||
{
|
||||
$container->setLastReview();
|
||||
}
|
||||
|
||||
$container->resetCommentCounts();
|
||||
$container->save();
|
||||
}
|
||||
}
|
||||
|
||||
\IPS\Output::i()->redirect( $this->baseUrl );
|
||||
|
||||
Reference in new issue
Block a user