Version 5.0.0 beta 5
This commit is contained in:
1 parent
2f24f9de48
commit
57d9db6ce2
218 files changed
+5331
-7416
No files matched your search
@@ -347,6 +347,9 @@ trait Assignable
|
||||
*/
|
||||
public static function assignmentFormField( Item $item, ?Model $container=null, ?string $fieldName=null ) : FormAbstract
|
||||
{
|
||||
/* Preload some language strings */
|
||||
Member::loggedIn()->language()->get( ['assignment_team', 'assign_to'] );
|
||||
|
||||
$prefix = Member::loggedIn()->language()->get( 'assignment_team' );
|
||||
$currentValue = null;
|
||||
if( $currentAssignment = $item->assignment )
|
||||
|
||||
+10
-4
@@ -2833,12 +2833,15 @@ abstract class Item extends Content
|
||||
/* Work out the order */
|
||||
if ( $order === NULL )
|
||||
{
|
||||
$dateColumn = static::$databaseColumnMap['date'];
|
||||
if ( is_array( $dateColumn ) )
|
||||
if( isset( static::$databaseColumnMap[ 'date' ] ) )
|
||||
{
|
||||
$dateColumn = array_pop( $dateColumn );
|
||||
$dateColumn = static::$databaseColumnMap['date'];
|
||||
if ( is_array( $dateColumn ) )
|
||||
{
|
||||
$dateColumn = array_pop( $dateColumn );
|
||||
}
|
||||
$order = static::$databaseTable . '.' . static::$databasePrefix . $dateColumn . ' DESC';
|
||||
}
|
||||
$order = static::$databaseTable . '.' . static::$databasePrefix . $dateColumn . ' DESC';
|
||||
}
|
||||
|
||||
$containerWhere = array();
|
||||
@@ -6340,6 +6343,9 @@ abstract class Item extends Content
|
||||
{
|
||||
$blurb = NULL;
|
||||
|
||||
/* Preload some language strings */
|
||||
Member::loggedIn()->language()->get( ['comment_meta_date_weeks_later', 'comment_meta_date_months_later', 'comment_meta_date_years_later'] );
|
||||
|
||||
/* Years? */
|
||||
if ( $nextDate->diff( $date )->y > 0 )
|
||||
{
|
||||
|
||||
@@ -575,8 +575,9 @@ trait Reactable
|
||||
$this->hasReacted[ $member->member_id ] = Content\Reaction::load( $this->reputation[ $member->member_id ] );
|
||||
}
|
||||
}
|
||||
else
|
||||
elseif ( ! is_array( $this->reputation ) )
|
||||
{
|
||||
/* $this->reputation is not set, so we need to query the database */
|
||||
$where = $this->getReactionWhereClause( NULL, FALSE );
|
||||
$where[] = array( 'member_id=?', $member->member_id );
|
||||
$this->hasReacted[ $member->member_id ] = Content\Reaction::load( Db::i()->select( 'reaction', 'core_reputation_index', $where )->first() );
|
||||
|
||||
@@ -397,16 +397,7 @@ trait Statistics
|
||||
return array();
|
||||
}
|
||||
|
||||
$return = array();
|
||||
foreach( new ActiveRecordIterator( Db::i()->select( '*', $commentClass::$databaseTable, array( Db::i()->in( $commentIdField, $postIds ) ), "FIND_IN_SET( {$commentIdField}, '" . implode( ",", $postIds ) . "' )", array( 0, $count ) ), $commentClass ) as $comment )
|
||||
{
|
||||
if ( $comment->canView() and $comment->mapped('item') == $this->$idField and isset( $counts[ $comment->$commentIdField ] ) )
|
||||
{
|
||||
$return[] = array( 'comment' => $comment, 'count' => $counts[ $comment->$commentIdField ] );
|
||||
}
|
||||
}
|
||||
|
||||
return $return;
|
||||
return $this->getComments( $commentClass, $commentIdField, $idField, $postIds, $count, $counts );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -469,18 +460,40 @@ trait Statistics
|
||||
return array();
|
||||
}
|
||||
|
||||
$return = array();
|
||||
foreach( new ActiveRecordIterator( Db::i()->select( '*', $commentClass::$databaseTable, array( Db::i()->in( $commentIdField, $postIds ) ), "FIND_IN_SET( {$commentIdField}, '" . implode( ",", $postIds ) . "' )", array( 0, $count ) ), $commentClass ) as $comment )
|
||||
return $this->getComments( $commentClass, $commentIdField, $idField, $postIds, $count, $counts );
|
||||
}
|
||||
|
||||
protected $commentCache = array();
|
||||
|
||||
/**
|
||||
* Get the comments, storing them for later use in the same request
|
||||
*
|
||||
* @param string $commentClass
|
||||
* @param string $commentIdField
|
||||
* @param string $idField
|
||||
* @param array $postIds
|
||||
* @param int $count
|
||||
* @param array $counts
|
||||
* @return array
|
||||
*/
|
||||
protected function getComments( string $commentClass, string $commentIdField, string $idField, array $postIds, int $count, array $counts ): array
|
||||
{
|
||||
$key = md5( $commentClass . $commentIdField . $idField . implode( ',', $postIds ) . $count . json_encode( $counts ) );
|
||||
|
||||
if ( ! isset( $this->commentCache[ $key ] ) )
|
||||
{
|
||||
if ( $comment->canView() and $comment->mapped('item') == $this->$idField and isset( $counts[ $comment->$commentIdField ] ) )
|
||||
$this->commentCache[ $key ] = [];
|
||||
foreach ( new ActiveRecordIterator( Db::i()->select( '*', $commentClass::$databaseTable, [Db::i()->in( $commentIdField, $postIds )], "FIND_IN_SET( {$commentIdField}, '" . implode( ",", $postIds ) . "' )", [0, $count] ), $commentClass ) as $comment )
|
||||
{
|
||||
$return[] = array( 'comment' => $comment, 'count' => $counts[ $comment->$commentIdField ] );
|
||||
if ( $comment->canView() and $comment->mapped( 'item' ) == $this->$idField and isset( $counts[$comment->$commentIdField] ) )
|
||||
{
|
||||
$this->commentCache[ $key ][] = ['comment' => $comment, 'count' => $counts[$comment->$commentIdField]];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $return;
|
||||
return $this->commentCache[ $key ];
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the top 10 popular days for posts
|
||||
*
|
||||
|
||||
Reference in new issue
Block a user