diff options
Diffstat (limited to 'application/front/controller/admin/ManageShaareController.php')
-rw-r--r-- | application/front/controller/admin/ManageShaareController.php | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/application/front/controller/admin/ManageShaareController.php b/application/front/controller/admin/ManageShaareController.php index ff330a99..bdfc5ca7 100644 --- a/application/front/controller/admin/ManageShaareController.php +++ b/application/front/controller/admin/ManageShaareController.php | |||
@@ -297,6 +297,42 @@ class ManageShaareController extends ShaarliAdminController | |||
297 | } | 297 | } |
298 | 298 | ||
299 | /** | 299 | /** |
300 | * GET /admin/shaare/{id}/pin - Pin or unpin a bookmark. | ||
301 | */ | ||
302 | public function pinBookmark(Request $request, Response $response, array $args): Response | ||
303 | { | ||
304 | $this->checkToken($request); | ||
305 | |||
306 | $id = $args['id'] ?? ''; | ||
307 | try { | ||
308 | if (false === ctype_digit($id)) { | ||
309 | throw new BookmarkNotFoundException(); | ||
310 | } | ||
311 | $bookmark = $this->container->bookmarkService->get((int) $id); // Read database | ||
312 | } catch (BookmarkNotFoundException $e) { | ||
313 | $this->saveErrorMessage(sprintf( | ||
314 | t('Bookmark with identifier %s could not be found.'), | ||
315 | $id | ||
316 | )); | ||
317 | |||
318 | return $this->redirectFromReferer($request, $response, ['/pin'], ['pin']); | ||
319 | } | ||
320 | |||
321 | $formatter = $this->container->formatterFactory->getFormatter('raw'); | ||
322 | |||
323 | $bookmark->setSticky(!$bookmark->isSticky()); | ||
324 | |||
325 | // To preserve backward compatibility with 3rd parties, plugins still use arrays | ||
326 | $data = $formatter->format($bookmark); | ||
327 | $this->container->pluginManager->executeHooks('save_link', $data); | ||
328 | $bookmark->fromArray($data); | ||
329 | |||
330 | $this->container->bookmarkService->set($bookmark); | ||
331 | |||
332 | return $this->redirectFromReferer($request, $response, ['/pin'], ['pin']); | ||
333 | } | ||
334 | |||
335 | /** | ||
300 | * Helper function used to display the shaare form whether it's a new or existing bookmark. | 336 | * Helper function used to display the shaare form whether it's a new or existing bookmark. |
301 | * | 337 | * |
302 | * @param array $link data used in template, either from parameters or from the data store | 338 | * @param array $link data used in template, either from parameters or from the data store |