From 53e6d5fde32a917718a0658fb95f366dc7dfc248 Mon Sep 17 00:00:00 2001 From: vincent-peugnet Date: Sun, 26 Apr 2020 15:41:48 +0200 Subject: user bookmarks use new object + shortcuts visible in backtopbar --- app/class/User.php | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'app/class/User.php') diff --git a/app/class/User.php b/app/class/User.php index a62091f..56e994d 100644 --- a/app/class/User.php +++ b/app/class/User.php @@ -16,6 +16,7 @@ class User extends Item protected $columns = ['title', 'datemodif', 'datecreation', 'secure', 'visitcount']; protected $connectcount = 0; protected $expiredate = false; + /** @var Bookmark[] Associative array as `id => Bookmark`*/ protected $bookmark = []; protected $display = ['bookmark' => false]; @@ -198,7 +199,15 @@ class User extends Item public function setbookmark($bookmark) { if (is_array($bookmark)) { - $this->bookmark = $bookmark; + $bookmark = array_map( + function ($datas) { + if (is_array($datas) && !empty($datas)) { + return new Bookmark($datas); + } + }, + $bookmark + ); + $this->bookmark = array_filter($bookmark); } } @@ -285,12 +294,10 @@ class User extends Item $this->connectcount ++; } - public function addbookmark(string $id, string $query) + public function addbookmark(Bookmark $bookmark) { - if (!empty($id) && !empty($query)) { - $id = idclean($id); - $id = substr($id, 0, 16); - $this->bookmark[$id] = $query; + if (!empty($bookmark->id()) && !empty($bookmark->query()) && !empty($bookmark->route())) { + $this->bookmark[$bookmark->id()] = $bookmark; } } -- cgit v1.2.3