Example #1
0
 public function view($params)
 {
     $groupId = (int) $params['groupId'];
     if (empty($groupId)) {
         throw new Redirect404Exception();
     }
     $groupDto = $this->service->findGroupById($groupId);
     if ($groupDto === null) {
         throw new Redirect404Exception();
     }
     OW::getDocument()->addMetaInfo('og:title', htmlspecialchars($groupDto->title), 'property');
     OW::getDocument()->addMetaInfo('og:description', htmlspecialchars($groupDto->description), 'property');
     OW::getDocument()->addMetaInfo('og:url', OW_URL_HOME . OW::getRequest()->getRequestUri(), 'property');
     OW::getDocument()->addMetaInfo('og:site_name', OW::getConfig()->getValue('base', 'site_name'), 'property');
     $language = OW::getLanguage();
     if (!$this->service->isCurrentUserCanView($groupDto->userId)) {
         $this->assign('permissionMessage', $language->text('groups', 'view_no_permission'));
         return;
     }
     $invite = $this->service->findInvite($groupDto->id, OW::getUser()->getId());
     if ($invite !== null) {
         OW::getRegistry()->set('groups.hide_console_invite_item', true);
         $this->service->markInviteAsViewed($groupDto->id, OW::getUser()->getId());
     }
     if ($groupDto->whoCanView == GROUPS_BOL_Service::WCV_INVITE && !OW::getUser()->isAuthorized('groups')) {
         if (!OW::getUser()->isAuthenticated()) {
             $this->redirect(OW::getRouter()->urlForRoute('groups-private-group', array('groupId' => $groupDto->id)));
         }
         $user = $this->service->findUser($groupDto->id, OW::getUser()->getId());
         if ($groupDto->whoCanView == GROUPS_BOL_Service::WCV_INVITE && $invite === null && $user === null) {
             $this->redirect(OW::getRouter()->urlForRoute('groups-private-group', array('groupId' => $groupDto->id)));
         }
     }
     OW::getDocument()->setTitle($language->text('groups', 'view_page_title', array('group_name' => strip_tags($groupDto->title))));
     OW::getDocument()->setDescription($language->text('groups', 'view_page_description', array('description' => UTIL_String::truncate(strip_tags($groupDto->description), 200))));
     $place = 'group';
     $customizeUrls = array('customize' => OW::getRouter()->urlForRoute('groups-customize', array('mode' => 'customize', 'groupId' => $groupId)), 'normal' => OW::getRouter()->urlForRoute('groups-view', array('groupId' => $groupId)));
     $componentAdminService = BOL_ComponentAdminService::getInstance();
     $componentEntityService = BOL_ComponentEntityService::getInstance();
     $userCustomizeAllowed = $componentAdminService->findPlace($place)->editableByUser;
     $ownerMode = $groupDto->userId == OW::getUser()->getId();
     $customize = !empty($params['mode']) && $params['mode'] == 'customize';
     if (!($userCustomizeAllowed && $ownerMode) && $customize) {
         $this->redirect($customizeUrls['normal']);
     }
     $template = $customize ? 'drag_and_drop_entity_panel_customize' : 'drag_and_drop_entity_panel';
     $schemeList = $componentAdminService->findSchemeList();
     $defaultScheme = $componentAdminService->findSchemeByPlace($place);
     if (empty($defaultScheme) && !empty($schemeList)) {
         $defaultScheme = reset($schemeList);
     }
     if (!$componentAdminService->isCacheExists($place)) {
         $state = array();
         $state['defaultComponents'] = $componentAdminService->findPlaceComponentList($place);
         $state['defaultPositions'] = $componentAdminService->findAllPositionList($place);
         $state['defaultSettings'] = $componentAdminService->findAllSettingList();
         $state['defaultScheme'] = $defaultScheme;
         $componentAdminService->saveCache($place, $state);
     }
     $state = $componentAdminService->findCache($place);
     $defaultComponents = $state['defaultComponents'];
     $defaultPositions = $state['defaultPositions'];
     $defaultSettings = $state['defaultSettings'];
     $defaultScheme = $state['defaultScheme'];
     if ($userCustomizeAllowed) {
         if (!$componentEntityService->isEntityCacheExists($place, $groupId)) {
             $entityCache = array();
             $entityCache['entityComponents'] = $componentEntityService->findPlaceComponentList($place, $groupId);
             $entityCache['entitySettings'] = $componentEntityService->findAllSettingList($groupId);
             $entityCache['entityPositions'] = $componentEntityService->findAllPositionList($place, $groupId);
             $componentEntityService->saveEntityCache($place, $groupId, $entityCache);
         }
         $entityCache = $componentEntityService->findEntityCache($place, $groupId);
         $entityComponents = $entityCache['entityComponents'];
         $entitySettings = $entityCache['entitySettings'];
         $entityPositions = $entityCache['entityPositions'];
     } else {
         $entityComponents = array();
         $entitySettings = array();
         $entityPositions = array();
     }
     $componentPanel = new BASE_CMP_DragAndDropEntityPanel($place, $groupId, $defaultComponents, $customize, $template);
     $componentPanel->setAdditionalSettingList(array('entityId' => $groupId, 'entity' => 'groups'));
     if ($ownerMode) {
         $componentPanel->allowCustomize($userCustomizeAllowed);
         $componentPanel->customizeControlCunfigure($customizeUrls['customize'], $customizeUrls['normal']);
     }
     $componentPanel->setSchemeList($schemeList);
     $componentPanel->setPositionList($defaultPositions);
     $componentPanel->setSettingList($defaultSettings);
     $componentPanel->setScheme($defaultScheme);
     /*
              * This feature was disabled for users
              * if ( !empty($userScheme) )
               {
               $componentPanel->setUserScheme($userScheme);
               } */
     if (!empty($entityComponents)) {
         $componentPanel->setEntityComponentList($entityComponents);
     }
     if (!empty($entityPositions)) {
         $componentPanel->setEntityPositionList($entityPositions);
     }
     if (!empty($entitySettings)) {
         $componentPanel->setEntitySettingList($entitySettings);
     }
     $this->assign('componentPanel', $componentPanel->render());
 }
Example #2
0
 private function action($place, $userId, $customizeMode, $customizeRouts, $componentTemplate, $responderController = null)
 {
     $userCustomizeAllowed = (bool) $this->componentAdminService->findPlace($place)->editableByUser;
     if (!$userCustomizeAllowed && $customizeMode) {
         $this->redirect($customizeRouts['normal']);
     }
     $schemeList = $this->componentAdminService->findSchemeList();
     $state = $this->componentAdminService->findCache($place);
     if (empty($state)) {
         $state = array();
         $state['defaultComponents'] = $this->componentAdminService->findPlaceComponentList($place);
         $state['defaultPositions'] = $this->componentAdminService->findAllPositionList($place);
         $state['defaultSettings'] = $this->componentAdminService->findAllSettingList();
         $state['defaultScheme'] = (array) $this->componentAdminService->findSchemeByPlace($place);
         $this->componentAdminService->saveCache($place, $state);
     }
     $defaultComponents = $state['defaultComponents'];
     $defaultPositions = $state['defaultPositions'];
     $defaultSettings = $state['defaultSettings'];
     $defaultScheme = $state['defaultScheme'];
     if ($userCustomizeAllowed) {
         $userCache = $this->componentEntityService->findEntityCache($place, $userId);
         if (empty($userCache)) {
             $userCache = array();
             $userCache['userComponents'] = $this->componentEntityService->findPlaceComponentList($place, $userId);
             $userCache['userSettings'] = $this->componentEntityService->findAllSettingList($userId);
             $userCache['userPositions'] = $this->componentEntityService->findAllPositionList($place, $userId);
             $this->componentEntityService->saveEntityCache($place, $userId, $userCache);
         }
         $userComponents = $userCache['userComponents'];
         $userSettings = $userCache['userSettings'];
         $userPositions = $userCache['userPositions'];
     } else {
         $userComponents = array();
         $userSettings = array();
         $userPositions = array();
     }
     if (empty($defaultScheme) && !empty($schemeList)) {
         $defaultScheme = reset($schemeList);
     }
     $componentPanel = new BASE_CMP_DragAndDropEntityPanel($place, $userId, $defaultComponents, $customizeMode, $componentTemplate, $responderController);
     $componentPanel->setAdditionalSettingList(array('entityId' => $userId, 'entity' => 'user'));
     if (!empty($customizeRouts)) {
         $componentPanel->allowCustomize($userCustomizeAllowed);
         $componentPanel->customizeControlCunfigure($customizeRouts['customize'], $customizeRouts['normal']);
     }
     $componentPanel->setSchemeList($schemeList);
     $componentPanel->setPositionList($defaultPositions);
     $componentPanel->setSettingList($defaultSettings);
     $componentPanel->setScheme($defaultScheme);
     /*
              * This feature was disabled for users
              * if ( !empty($userScheme) )
               {
               $componentPanel->setEntityScheme($userScheme);
               } */
     if (!empty($userComponents)) {
         $componentPanel->setEntityComponentList($userComponents);
     }
     if (!empty($userPositions)) {
         $componentPanel->setEntityPositionList($userPositions);
     }
     if (!empty($userSettings)) {
         $componentPanel->setEntitySettingList($userSettings);
     }
     $this->assign('componentPanel', $componentPanel->render());
 }