aboutsummaryrefslogtreecommitdiffhomepage
path: root/application/bookmark
diff options
context:
space:
mode:
authorArthurHoaro <arthur@hoa.ro>2020-09-06 14:11:02 +0200
committerArthurHoaro <arthur@hoa.ro>2020-09-06 14:11:02 +0200
commit27ddfec3c3847f10ab0de246f4a174b751c5f19e (patch)
tree9fb085dd6f83ad73743950ca0de1549f28eeeef5 /application/bookmark
parent21163a3329ef19dc6ebadb75d6452ac02fd59ab3 (diff)
downloadShaarli-27ddfec3c3847f10ab0de246f4a174b751c5f19e.tar.gz
Shaarli-27ddfec3c3847f10ab0de246f4a174b751c5f19e.tar.zst
Shaarli-27ddfec3c3847f10ab0de246f4a174b751c5f19e.zip
Fix visibility issue on daily page
This filter (links by day) didn't apply any visibility parameter. Fixes #1543
Diffstat (limited to 'application/bookmark')
-rw-r--r--application/bookmark/BookmarkFileService.php4
-rw-r--r--application/bookmark/BookmarkFilter.php17
2 files changed, 14 insertions, 7 deletions
diff --git a/application/bookmark/BookmarkFileService.php b/application/bookmark/BookmarkFileService.php
index e3a61146..c9ec2609 100644
--- a/application/bookmark/BookmarkFileService.php
+++ b/application/bookmark/BookmarkFileService.php
@@ -362,7 +362,9 @@ class BookmarkFileService implements BookmarkServiceInterface
362 */ 362 */
363 public function filterDay($request) 363 public function filterDay($request)
364 { 364 {
365 return $this->bookmarkFilter->filter(BookmarkFilter::$FILTER_DAY, $request); 365 $visibility = $this->isLoggedIn ? BookmarkFilter::$ALL : BookmarkFilter::$PUBLIC;
366
367 return $this->bookmarkFilter->filter(BookmarkFilter::$FILTER_DAY, $request, false, $visibility);
366 } 368 }
367 369
368 /** 370 /**
diff --git a/application/bookmark/BookmarkFilter.php b/application/bookmark/BookmarkFilter.php
index 797a36b8..6636bbfe 100644
--- a/application/bookmark/BookmarkFilter.php
+++ b/application/bookmark/BookmarkFilter.php
@@ -115,7 +115,7 @@ class BookmarkFilter
115 return $this->filterTags($request, $casesensitive, $visibility); 115 return $this->filterTags($request, $casesensitive, $visibility);
116 } 116 }
117 case self::$FILTER_DAY: 117 case self::$FILTER_DAY:
118 return $this->filterDay($request); 118 return $this->filterDay($request, $visibility);
119 default: 119 default:
120 return $this->noFilter($visibility); 120 return $this->noFilter($visibility);
121 } 121 }
@@ -425,21 +425,26 @@ class BookmarkFilter
425 * print_r($mydb->filterDay('20120125')); 425 * print_r($mydb->filterDay('20120125'));
426 * 426 *
427 * @param string $day day to filter. 427 * @param string $day day to filter.
428 * 428 * @param string $visibility return only all/private/public bookmarks.
429
429 * @return array all link matching given day. 430 * @return array all link matching given day.
430 * 431 *
431 * @throws Exception if date format is invalid. 432 * @throws Exception if date format is invalid.
432 */ 433 */
433 public function filterDay($day) 434 public function filterDay($day, $visibility)
434 { 435 {
435 if (!checkDateFormat('Ymd', $day)) { 436 if (!checkDateFormat('Ymd', $day)) {
436 throw new Exception('Invalid date format'); 437 throw new Exception('Invalid date format');
437 } 438 }
438 439
439 $filtered = []; 440 $filtered = [];
440 foreach ($this->bookmarks as $key => $l) { 441 foreach ($this->bookmarks as $key => $bookmark) {
441 if ($l->getCreated()->format('Ymd') == $day) { 442 if ($visibility === static::$PUBLIC && $bookmark->isPrivate()) {
442 $filtered[$key] = $l; 443 continue;
444 }
445
446 if ($bookmark->getCreated()->format('Ymd') == $day) {
447 $filtered[$key] = $bookmark;
443 } 448 }
444 } 449 }
445 450