Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exclude top ordered records(Pin, Draft, Scheduled, Unread News) from bookmarked list #28

Merged
merged 2 commits into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .github/workflows/php-test-v1.14.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: PHP Codeception Tests - v1.14

on:
push:

jobs:
tests:
uses: humhub/actions/.github/workflows/module-tests-v1.14.yml@main
with:
module-id: content-bookmarks
10 changes: 0 additions & 10 deletions .github/workflows/php-test-v1.8.yml

This file was deleted.

3 changes: 2 additions & 1 deletion docs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
Changelog
=========

1.0.2 (Unreleased)
1.1.0 (Unreleased)
---------------------
- Fix: Translation category for 'You didn\'t save any content yet!'
- Enh: Improvement and addition of French translations
- Enh #23: Tests for `next` version
- Fix #24: Fix visibility of the method `Controller::getAccessRules()`
- Enh #27: Use PHP CS Fixer
- Fix #28: Exclude top ordered records(Pin, Draft, Scheduled, Unread News) from bookmarked list


1.0.1 (June 13, 2021)
Expand Down
4 changes: 2 additions & 2 deletions module.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
"keywords": [
"content bookmarks"
],
"version": "1.0.2",
"version": "1.1.0",
"humhub": {
"minVersion": "1.8"
"minVersion": "1.14"
},
"homepage": "https://github.com/humhub/content-bookmarks"
}
26 changes: 26 additions & 0 deletions stream/BookmarkStreamQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

namespace humhub\modules\contentBookmarks\stream;

use humhub\modules\contentBookmarks\models\ContentBookmark;
use humhub\modules\stream\models\ContentContainerStreamQuery;
use humhub\modules\stream\models\filters\ContentContainerStreamFilter;
use humhub\modules\contentBookmarks\stream\filters\BookmarkStreamFilter;
Expand All @@ -27,4 +28,29 @@ public function beforeApplyFilters()
$this->addFilterHandler(new BookmarkStreamFilter(['user' => Yii::$app->user]));
}

/**
* @inheritdoc
*/
protected function postProcessAll(array $result)
{
$result = parent::postProcessAll($result);

if (count($result) > 0 && !Yii::$app->user->isGuest) {
// Keep the top ordered records(Pin, Draft, Scheduled, Unread News) only if they are bookmarked by current user
$bookmarkedContentIds = ContentBookmark::find()
->select('content_id')
->where(['user_id' => Yii::$app->user->id])
->column();

if (count($bookmarkedContentIds) > 0) {
return array_filter($result, function ($content) use ($bookmarkedContentIds) {
return in_array($content->id, $bookmarkedContentIds);
});
}

return [];
}

return $result;
}
}
Loading