Esempio n. 1
0
 public function indexAction(Request $request, SessionInterface $session)
 {
     Util::checkUserIsLoggedInAndRedirect();
     $loggedInUserId = $session->get('user/id');
     $name = $request->request->get('name');
     $description = $request->request->get('description');
     $type = $request->request->get('type');
     $parentId = $request->request->get('parent_id');
     $spaceId = $request->request->get('space_id');
     if ($type == 'file_list') {
         $pageType = EntityType::ENTITY_FILE_LIST;
     } else {
         $pageType = EntityType::ENTITY_BLANK_PAGE;
     }
     if ($parentId == -1) {
         // set the parent to the home page of the space if it exists
         $space = $this->getRepository(Space::class)->getById($spaceId);
         $homeEntityId = $space['home_entity_id'];
         if ($homeEntityId) {
             $parentId = $homeEntityId;
         } else {
             $parentId = null;
         }
     }
     $page = new Entity($pageType, $spaceId, $loggedInUserId, $parentId, $name, $description);
     $currentDate = Util::getServerCurrentDateTime();
     $pageId = $page->save($currentDate);
     // if the page is a file list create the folders
     $baseFilePath = Util::getAssetsFolder(SystemProduct::SYS_PRODUCT_DOCUMENTADOR, 'filelists');
     if ($pageType == EntityType::ENTITY_FILE_LIST) {
         mkdir($baseFilePath . $pageId);
     }
     return new Response($pageId);
 }
Esempio n. 2
0
 public function indexAction(Request $request, SessionInterface $session)
 {
     Util::checkUserIsLoggedInAndRedirect();
     $clientId = $session->get('client/id');
     $loggedInUserId = $session->get('user/id');
     $emptySpaceName = false;
     $emptySpaceCode = false;
     $doubleCode = false;
     $doubleName = false;
     if ($request->request->has('add_space')) {
         $name = Util::cleanRegularInputField($request->request->get('name'));
         $code = Util::cleanRegularInputField($request->request->get('code'));
         $description = Util::cleanRegularInputField($request->request->get('description'));
         $currentDate = Util::getServerCurrentDateTime();
         if (empty($name)) {
             $emptySpaceName = true;
         }
         if (empty($code)) {
             $emptySpaceCode = true;
         }
         if (!$emptySpaceName && !$emptySpaceCode) {
             $doubleSpace = $this->getRepository(Space::class)->getByCodeAndClientId($clientId, $code);
             if ($doubleSpace) {
                 $doubleCode = true;
             }
             $doubleSpace = $this->getRepository(Space::class)->getByNameAndClientId($clientId, $name);
             if ($doubleSpace) {
                 $doubleName = true;
             }
             if (!$doubleCode && !$doubleName) {
                 $date = Util::getServerCurrentDateTime();
                 $space = new Space($clientId, $loggedInUserId, $name, $code, $description);
                 $spaceId = $space->save($currentDate);
                 $this->getLogger()->addInfo('ADD Documentador space ' . $name, $this->getLoggerContext());
                 // set space permission for current user
                 $this->getRepository(Space::class)->addUserAllPermissions($spaceId, $loggedInUserId);
                 // set default home page
                 $content = '<p><span style="font-size:24px"><strong>Welcome to your new space!</strong></span></p><div class="message-content" style="font-family: Arial, sans-serif; font-size: 14px;"><p>Documentador spaces are great for sharing content and news with your team. This is your home page. You can customize this page in anyway you like.</p></div>';
                 $page = new Entity(EntityType::ENTITY_BLANK_PAGE, $spaceId, $loggedInUserId, null, $name . ' Home', $content);
                 $pageId = $page->save($currentDate);
                 $this->getRepository(Space::class)->setHomePageId($spaceId, $pageId);
                 // add space permissions for groups
                 $this->getRepository(Space::class)->setDefaultPermissions($clientId, $spaceId);
                 return new RedirectResponse('/documentador/administration/spaces');
             }
         }
     }
     $menuSelectedCategory = 'doc_spaces';
     return $this->render(__DIR__ . '/../../../Resources/views/administration/space/Add.php', get_defined_vars());
 }
Esempio n. 3
0
 public function indexAction(Request $request, SessionInterface $session)
 {
     $source_application = 'documentator';
     Util::checkUserIsLoggedInAndRedirect();
     $clientId = $session->get('client/id');
     $loggedInUserId = $session->get('user/id');
     $session->set('selected_product_id', SystemProduct::SYS_PRODUCT_DOCUMENTADOR);
     $spaceId = $request->get('space_id');
     $space = $this->getRepository(Space::class)->getById($spaceId);
     if ($space['client_id'] != $clientId) {
         return new RedirectResponse('/general-settings/bad-link-access-denied');
     }
     $parentEntityId = $request->get('entity_id');
     if ($parentEntityId) {
         $parentEntityId = str_replace("/", "", $parentEntityId);
     }
     if (empty($parentEntityId)) {
         // set the parent to the home page of the space if it exists
         $space = $this->getRepository(Space::class)->getById($spaceId);
         $homeEntityId = $space['home_entity_id'];
         if ($homeEntityId) {
             $parentEntityId = $homeEntityId;
         } else {
             $parentEntityId = null;
         }
     }
     $menuSelectedCategory = 'documentator';
     if ($request->request->has('add_page')) {
         $name = Util::cleanRegularInputField($request->request->get('name'));
         $content = $request->request->get('content');
         $page = new Entity(EntityType::ENTITY_BLANK_PAGE, $spaceId, $loggedInUserId, $parentEntityId, $name, $content);
         $currentDate = Util::getServerCurrentDateTime();
         $pageId = $page->save($currentDate);
         $this->getLogger()->addInfo('ADD Documentador Entity ' . $name, $this->getLoggerContext());
         return new RedirectResponse('/documentador/page/view/' . $pageId);
     }
     $sectionPageTitle = $session->get('client/settings/title_name') . ' / ' . SystemProduct::SYS_PRODUCT_DOCUMENTADOR_NAME . ' / Create Page';
     return $this->render(__DIR__ . '/../../Resources/views/page/Add.php', get_defined_vars());
 }