* set/remove the favorite flag for a report * * @param int $reportId * @param string $favorite * @return bool */
(int $reportId, string $favorite)
| 432 | * @return bool |
| 433 | */ |
| 434 | public function setFavorite(int $reportId, string $favorite) { |
| 435 | $return = true; |
| 436 | if ($favorite === 'true') { |
| 437 | $return = $this->addFavoriteTag('analytics', $reportId); |
| 438 | } else { |
| 439 | $favorites = $this->tagManager->load('analytics')->getFavorites(); |
| 440 | if (is_array($favorites) and in_array($reportId, $favorites)) { |
| 441 | $return = $this->removeFavoriteTag('analytics', $reportId); |
| 442 | } |
| 443 | } |
| 444 | return $return; |
| 445 | } |
| 446 | |
| 447 | private function addFavoriteTag(string $scope, int $objectId): bool { |
| 448 | try { |