* set/remove the favorite flag for a report * * @param int $reportId * @param string $favorite * @return bool */
(int $reportId, string $favorite)
| 423 | * @return bool |
| 424 | */ |
| 425 | public function setFavorite(int $reportId, string $favorite) { |
| 426 | $return = true; |
| 427 | if ($favorite === 'true') { |
| 428 | $return = $this->addFavoriteTag('analytics', $reportId); |
| 429 | } else { |
| 430 | $favorites = $this->tagManager->load('analytics')->getFavorites(); |
| 431 | if (is_array($favorites) and in_array($reportId, $favorites)) { |
| 432 | $return = $this->removeFavoriteTag('analytics', $reportId); |
| 433 | } |
| 434 | } |
| 435 | return $return; |
| 436 | } |
| 437 | |
| 438 | private function addFavoriteTag(string $scope, int $objectId): bool { |
| 439 | try { |