mirror of
https://github.com/flarum/core.git
synced 2025-08-13 11:54:32 +02:00
Compare commits
12 Commits
as/better-
...
dk/2022032
Author | SHA1 | Date | |
---|---|---|---|
|
88b5918e3a | ||
|
d0119e7634 | ||
|
726c8f3a9a | ||
|
8fe1d1cabc | ||
|
d0b4e74b1f | ||
|
65c861ab7b | ||
|
cb9fe6930f | ||
|
b64003cba5 | ||
|
46f8cf4628 | ||
|
3343fde5f2 | ||
|
907b1f10aa | ||
|
ae7d31ec16 |
2
extensions/lock/js/dist/forum.js.map
generated
vendored
2
extensions/lock/js/dist/forum.js.map
generated
vendored
File diff suppressed because one or more lines are too long
@@ -55,23 +55,23 @@ class TagFilterGambit extends AbstractRegexGambit implements FilterInterface
|
||||
{
|
||||
$slugs = explode(',', trim($rawSlugs, '"'));
|
||||
|
||||
$query->where(function (Builder $query) use ($slugs, $negate) {
|
||||
foreach ($slugs as $slug) {
|
||||
if ($slug === 'untagged') {
|
||||
$query->whereIn('discussions.id', function (Builder $query) {
|
||||
$query->select('discussion_id')
|
||||
->from('discussion_tag');
|
||||
}, 'or', ! $negate);
|
||||
} else {
|
||||
$id = $this->tags->getIdForSlug($slug);
|
||||
|
||||
$query->whereIn('discussions.id', function (Builder $query) use ($id) {
|
||||
$query->select('discussion_id')
|
||||
->from('discussion_tag')
|
||||
->where('tag_id', $id);
|
||||
}, 'or', $negate);
|
||||
$query
|
||||
->distinct()
|
||||
->leftJoin('discussion_tag', 'discussions.id', '=', 'discussion_tag.discussion_id')
|
||||
->where(function (Builder $query) use ($slugs, $negate) {
|
||||
foreach ($slugs as $slug) {
|
||||
if ($slug === 'untagged' && ! $negate) {
|
||||
$query->orWhereNull('discussion_tag.tag_id');
|
||||
} elseif ($slug === 'untagged' && $negate) {
|
||||
$query->orWhereNotNull('discussion_tag.tag_id');
|
||||
} elseif ($id = $this->tags->getIdForSlug($slug)) {
|
||||
$query->orWhere(
|
||||
'discussion_tag.tag_id',
|
||||
$negate ? '!=' : '=',
|
||||
$id
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@@ -132,7 +132,7 @@ export default abstract class Post<CustomAttrs extends IPostAttrs = IPostAttrs>
|
||||
classes.push('Post--by-actor');
|
||||
}
|
||||
|
||||
if (user && user?.id() === discussion.attribute('startUserId')) {
|
||||
if (user && user === discussion.user()) {
|
||||
classes.push('Post--by-start-user');
|
||||
}
|
||||
|
||||
|
@@ -48,6 +48,7 @@ class ShowDiscussionController extends AbstractShowController
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public $include = [
|
||||
'user',
|
||||
'posts',
|
||||
'posts.discussion',
|
||||
'posts.user',
|
||||
|
@@ -16,7 +16,9 @@ use Flarum\Foundation\EventGeneratorTrait;
|
||||
use Flarum\Notification\Notification;
|
||||
use Flarum\Post\Event\Deleted;
|
||||
use Flarum\User\User;
|
||||
use Illuminate\Database\ConnectionInterface;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Query\Expression;
|
||||
|
||||
/**
|
||||
* @property int $id
|
||||
@@ -91,7 +93,19 @@ class Post extends AbstractModel
|
||||
// discussion.
|
||||
static::creating(function (self $post) {
|
||||
$post->type = $post::$type;
|
||||
$post->number = ++$post->discussion->post_number_index;
|
||||
|
||||
/** @var ConnectionInterface $db */
|
||||
$db = static::getConnectionResolver();
|
||||
$post->number = new Expression('('.$db
|
||||
->table('posts', 'pn')
|
||||
->whereRaw($db->getTablePrefix().'pn.discussion_id = '.intval($post->discussion_id))
|
||||
->select($db->raw('max('.$db->getTablePrefix().'pn.number) + 1'))
|
||||
->toSql()
|
||||
.')');
|
||||
});
|
||||
|
||||
static::created(function (self $post) {
|
||||
$post->refresh();
|
||||
$post->discussion->save();
|
||||
});
|
||||
|
||||
|
Reference in New Issue
Block a user