コード例 #1
0
 protected function copyElements($elements, $dest_id, $position = null)
 {
     $counter = 0;
     foreach ($elements as $element) {
         if ($position !== null) {
             $dest_position = $position + $counter;
         } else {
             $dest_position = null;
         }
         $result = $this->pages->copy($element['id'], $dest_id, $dest_position);
         if ($result === false) {
             return false;
         }
         $newId = $result;
         $existing_acl_resource = Acl::getResourceData(Acl::RESOURCE_GROUP_PAGES, $element['id']);
         if ($existing_acl_resource !== false) {
             $new_acl_resource_id = Acl::registerResource(Acl::RESOURCE_GROUP_PAGES, $newId, $this->pages->getAnyCaption($result), $existing_acl_resource['user-groups-mode']);
             $user_groups = Acl::getUserGroups(Acl::RESOURCE_GROUP_PAGES, $element['id']);
             if ($user_groups !== false) {
                 Acl::assignUserGroupsById($new_acl_resource_id, $user_groups);
             }
         }
         $children = $this->pages->getChildren($element['id'], false);
         if ($children !== false) {
             if (count($children) > 0) {
                 if ($this->copyElements($children, $newId) === false) {
                     return false;
                 }
             }
         }
         $counter++;
     }
     return true;
 }
コード例 #2
0
 public function editAction()
 {
     $pageId = Request::getParam('pageId', -1);
     if (is_array($pageId)) {
         $containsSubpages = false;
         if (count($pageId) > 0) {
             foreach ($pageId as $id) {
                 $properties = $this->pages->getProperties($id);
                 if ($properties === false) {
                     $this->doesNotExist();
                     return;
                 }
                 if (!$this->helpers->canAccessPage($id, Acl::ACTION_EDIT)) {
                     $this->accessDenied();
                     return;
                 }
                 $children = $this->pages->getChildren($id, false);
                 if ($children !== false) {
                     if (count($children) > 0) {
                         $containsSubpages = true;
                         break;
                     }
                 }
             }
         }
         $this->view->assign('batchEdit', true);
         $this->view->assign('pageIdList', $pageId);
         $caption = array();
         $alias = array();
         $visibility = array();
         $translated_link_urls = array();
         $languages = Config::get()->languages->list;
         foreach ($languages as $key => $language) {
             $caption[$key] = '';
             $alias[$key] = '';
             $visibility[$key] = 0;
             $translated_link_urls[$key] = '';
         }
         $properties = array('visibility' => Pages::VISIBILITY_ALWAYS, 'active' => 1, 'cachable' => 1, 'translated-link-url' => $translated_link_url);
         $aclResource = array('group' => Acl::RESOURCE_GROUP_PAGES, 'resource-id' => null, 'description' => null, 'user-groups-mode' => Acl::RESOURCE_SUPERUSER_ONLY);
         $aclUserGroups = array();
         $this->view->assign('action', 'edit');
         $this->view->assign('caption', $caption);
         $this->view->assign('alias', $alias);
         $this->view->assign('visibility', $visibility);
         $this->view->assign('translatedLinkUrls', $translated_link_urls);
         $this->view->assign('properties', $properties);
         $this->view->assign('inheritAcl', true);
         $this->view->assign('aclResource', $aclResource);
         $this->view->assign('aclUserGroups', $aclUserGroups);
         $this->view->assign('containsSubpages', $containsSubpages);
     } else {
         if ($pageId > -1) {
             $properties = $this->pages->getProperties($pageId);
             if ($properties === false) {
                 $this->doesNotExist();
                 return;
             }
             if (!$this->helpers->canAccessPage($pageId, Acl::ACTION_EDIT)) {
                 $this->accessDenied();
                 return;
             }
             $this->view->assign('action', 'edit');
             $this->view->assign('batchEdit', false);
             $this->view->assign('pageId', $pageId);
             $this->view->assign('caption', $this->pages->getCaption($pageId));
             $this->view->assign('alias', $this->pages->getPageAliases($pageId));
             $this->view->assign('visibility', $this->pages->getVisibility($pageId));
             $this->view->assign('translatedLinkUrls', $this->pages->getTranslatedLinkUrls($pageId));
             $this->view->assign('properties', $properties);
             $aclResource = Acl::getResourceData(Acl::RESOURCE_GROUP_PAGES, $pageId);
             if ($aclResource === false) {
                 $this->view->assign('inheritAcl', true);
                 $aclResource = array('group' => Acl::RESOURCE_GROUP_PAGES, 'resource-id' => null, 'description' => null, 'user-groups-mode' => Acl::RESOURCE_SUPERUSER_ONLY);
                 $aclUserGroups = array();
             } else {
                 $this->view->assign('inheritAcl', false);
                 $aclUserGroups = Acl::getUserGroups(Acl::RESOURCE_GROUP_PAGES, $pageId);
             }
             $this->view->assign('aclResource', $aclResource);
             $this->view->assign('aclUserGroups', $aclUserGroups);
             $containsSubpages = false;
             $children = $this->pages->getChildren($pageId, false);
             if ($children !== false) {
                 if (count($children) > 0) {
                     $containsSubpages = true;
                 }
             }
             $this->view->assign('containsSubpages', $containsSubpages);
         } else {
             $this->createAction();
         }
     }
 }