* set/remove the favorite flag for a report * * @param int $reportId * @param string $favorite * @return bool */
(int $reportId, string $favorite)
| 393 | * @return bool |
| 394 | */ |
| 395 | public function setFavorite(int $reportId, string $favorite) { |
| 396 | $return = true; |
| 397 | if ($favorite === 'true') { |
| 398 | $return = $this->addFavoriteTag('analytics', $reportId); |
| 399 | } else { |
| 400 | $favorites = $this->tagManager->load('analytics')->getFavorites(); |
| 401 | if (is_array($favorites) and in_array($reportId, $favorites)) { |
| 402 | $return = $this->removeFavoriteTag('analytics', $reportId); |
| 403 | } |
| 404 | } |
| 405 | return $return; |
| 406 | } |
| 407 | |
| 408 | private function addFavoriteTag(string $scope, int $objectId): bool { |
| 409 | try { |