コード例 #1
0
 /**
  * @return array BaseUserWatchesNotifyContent
  */
 public function getUserNotifyContents(SiteModel $site, UserAccountModel $userAccountModel)
 {
     $out = array();
     $userWatchesSiteRepo = new \repositories\UserWatchesSiteRepository();
     $data = $userWatchesSiteRepo->getUserNotifyContentForSiteAndUser($site, $userAccountModel);
     if ($data) {
         // no point carrying on; someone watching a site overrides any data contained within
         return array($data);
     }
     $siteFeatureRepo = new \repositories\SiteFeatureRepository($this->app);
     if ($siteFeatureRepo->doesSiteHaveFeatureByExtensionAndId($site, 'org.openacalendar', 'Group')) {
         $userWatchesGroupRepo = new \repositories\UserWatchesGroupRepository();
         $data = $userWatchesGroupRepo->getUserNotifyContentForSiteAndUser($site, $userAccountModel);
         if ($data) {
             $out = array_merge($out, $data);
         }
     }
     $userWatchesAreaRepo = new \repositories\UserWatchesAreaRepository();
     $data = $userWatchesAreaRepo->getUserNotifyContentForSiteAndUser($site, $userAccountModel);
     if ($data) {
         $out = array_merge($out, $data);
     }
     return $out;
 }
コード例 #2
0
 $site = $siteRepository->loadById($CONFIG->singleSiteID);
 if (!$site) {
     die("404 Not Found");
     // TODO
 }
 $app['twig']->addGlobal('currentSite', $site);
 $app['currentSite'] = $site;
 # ////////////// Site closed
 if ($app['currentSite']->getIsClosedBySysAdmin()) {
     $app['twig']->addGlobal('currentUserInSite', null);
     $app['twig']->addGlobal('currentUserCanAdminSite', false);
     $app['twig']->addGlobal('currentUserCanEditSite', false);
     return new Response($app['twig']->render('site/closed_by_sys_admin.html.twig', array()));
 }
 # ////////////// Features
 $siteFeaturesRepo = new repositories\SiteFeatureRepository($app);
 $app['currentSiteFeatures'] = new SiteFeaturesList($siteFeaturesRepo->getForSiteAsTree($app['currentSite']));
 $app['twig']->addGlobal('currentSiteFeatures', $app['currentSiteFeatures']);
 $app['currentSiteFeatures']->setFeaturesOnSite($app['currentSite']);
 # ////////////// Permissions and Watch
 $userPermissionsRepo = new \repositories\UserPermissionsRepository($app['extensions']);
 // We do not check UserHasNoEditorPermissionsInSiteRepository(); because that is site mode only.
 // In Single Site mode sysadmins can remove this right.
 $app['currentUserPermissions'] = $userPermissionsRepo->getPermissionsForUserInSite($app['currentUser'], $app['currentSite'], false, true);
 # ////////////// User and their watch and perms
 $app['currentUserActions'] = new UserActionsSiteList($app['currentSite'], $app['currentUserPermissions']);
 $app['currentUserWatchesSite'] = false;
 if ($app['currentUser']) {
     $uwsr = new UserWatchesSiteRepository();
     $uws = $uwsr->loadByUserAndSite($app['currentUser'], $app['currentSite']);
     $app['currentUserWatchesSite'] = $uws && $uws->getIsWatching();