/** * @return array */ public function getUserNotifyContentForSiteAndUser(SiteModel $siteModel, UserAccountModel $userAccountModel) { global $CONFIG; $out = array(); $grb = new AreaRepositoryBuilder(); $grb->setSite($siteModel); $grb->setLimit(0); // all! No limit // TODO don't we still want to do this? How will user A get a notification if user B deletes area? but then so far most area deletetions are by admins. $grb->setIncludeDeleted(false); foreach ($grb->fetchAll() as $area) { $uwg = $this->loadByUserAndArea($userAccountModel, $area); if ($uwg && $uwg->getIsWatching()) { $dateSince = $uwg->getSinceDateForNotifyChecking(); $historyRepositoryBuilder = new HistoryRepositoryBuilder(); $historyRepositoryBuilder->getHistoryRepositoryBuilderConfig()->setArea($area); $historyRepositoryBuilder->setSince($dateSince); $historyRepositoryBuilder->setNotUser($userAccountModel); // Only admins can change tags at the moment so don't include $historyRepositoryBuilder->setIncludeTagHistory(false); $histories = $historyRepositoryBuilder->fetchAll(); if ($histories) { $content = new UserWatchesAreaNotifyContent(); $content->setHistories($histories); $userWatchesAreaStopRepository = new UserWatchesAreaStopRepository(); $userWatchesAreaStop = $userWatchesAreaStopRepository->getForUserAndArea($userAccountModel, $area); $content->setUnwatchURL($CONFIG->getWebSiteDomainSecure($siteModel->getSlug()) . '/area/' . $area->getSlugForURL() . '/stopWatchingFromEmail/' . $userAccountModel->getId() . '/' . $userWatchesAreaStop->getAccessKey()); $content->setUserAccount($userAccountModel); $content->setSite($siteModel); $content->setArea($area); $content->setWatchedThingTitle($area->getTitle()); $content->setWatchedThingURL($CONFIG->getWebSiteDomainSecure($siteModel->getSlug()) . '/area/' . $area->getSlugForURL() . '/history'); $out[] = $content; } } } return $out; }