public function submit($arLayoutID) { if ($this->validateAction()) { $arLayout = AreaLayout::getByID($arLayoutID); if (!is_object($arLayout)) { throw new Exception(t('Invalid layout object.')); } if ($_POST['arLayoutPresetID'] == '-1') { UserPreset::add($arLayout, $_POST['arLayoutPresetName']); } else { $existingPreset = UserPreset::getByID($_POST['arLayoutPresetID']); if (is_object($existingPreset)) { $existingPreset->updateName($_POST['arLayoutPresetName']); $existingPreset->updateAreaLayoutObject($arLayout); } } $pr = new EditResponse(); if ($existingPreset) { $pr->setMessage(t('Area layout preset updated successfully.')); } else { $pr->setMessage(t('Area layout preset saved successfully.')); } $pr->outputJSON(); } }
public function submit() { if ($this->validateAction() && $this->canAccess()) { $a = $this->area; $oldStyle = $this->page->getAreaCustomStyle($a); if (is_object($oldStyle)) { $oldStyleSet = $oldStyle->getStyleSet(); } $nvc = $this->page->getVersionToModify(); $r = $this->request->request->all(); $set = new StyleSet(); $set->setBackgroundColor($r['backgroundColor']); $set->setBackgroundImageFileID(intval($r['backgroundImageFileID'])); $set->setBackgroundRepeat($r['backgroundRepeat']); $set->setLinkColor($r['linkColor']); $set->setTextColor($r['textColor']); $set->setBaseFontSize($r['baseFontSize']); $set->setMarginTop($r['marginTop']); $set->setMarginRight($r['marginRight']); $set->setMarginBottom($r['marginBottom']); $set->setMarginLeft($r['marginLeft']); $set->setPaddingTop($r['paddingTop']); $set->setPaddingRight($r['paddingRight']); $set->setPaddingBottom($r['paddingBottom']); $set->setPaddingLeft($r['paddingLeft']); $set->setBorderWidth($r['borderWidth']); $set->setBorderStyle($r['borderStyle']); $set->setBorderColor($r['borderColor']); $set->setBorderRadius($r['borderRadius']); $set->setAlignment($r['alignment']); $set->setRotate($r['rotate']); $set->setBoxShadowBlur($r['boxShadowBlur']); $set->setBoxShadowColor($r['boxShadowColor']); $set->setBoxShadowHorizontal($r['boxShadowHorizontal']); $set->setBoxShadowVertical($r['boxShadowVertical']); $set->setBoxShadowSpread($r['boxShadowSpread']); $set->setCustomClass($r['customClass']); $set->save(); $nvc->setCustomStyleSet($a, $set); $pr = new EditResponse(); $pr->setPage($this->page); $pr->setAdditionalDataAttribute('aID', $this->area->getAreaID()); $pr->setAdditionalDataAttribute('arHandle', $this->area->getAreaHandle()); $pr->setAdditionalDataAttribute('issID', $set->getID()); if (is_object($oldStyleSet)) { $pr->setAdditionalDataAttribute('oldIssID', $oldStyleSet->getID()); } $style = new CustomStyle($set, $this->area->getAreaHandle()); $pr->setAdditionalDataAttribute('css', $style->getCSS()); $pr->setAdditionalDataAttribute('containerClass', $style->getContainerClass()); $pr->setMessage(t('Design updated.')); $pr->outputJSON(); } }
public function submit() { if ($this->validateAction()) { $request = \Request::getInstance(); $this->page->addCollectionAliasExternal($request->request->get('name'), $request->request->get('link'), $request->request->get('openInNewWindow')); $r = new EditResponse(); $r->setPage($this->page); $r->setRedirectURL(URL::to('/dashboard/sitemap')); $r->outputJSON(); } }
public function submit() { if ($this->validateAction()) { $c = $this->page; $request = \Request::getInstance(); $this->page->updateCollectionAliasExternal($request->request->get('name'), $request->request->get('link'), $request->request->get('openInNewWindow')); $pr = new EditResponse(); $pr->setMessage(t('External Link updated.')); $pr->setPage($c); $pr->outputJSON(); } }
public function getJSON() { $h = \Core::make('helper/concrete/dashboard/sitemap'); if ($h->canRead()) { $c = ConcretePage::getByID(intval($_POST['cID'])); $cp = new Permissions($c); if ($cp->canViewPage()) { $r = new PageEditResponse(); $r->setPage($c); $r->outputJSON(); } } }
public function delete() { if ($this->validateAction()) { $preset = Preset::getByID($this->request->request('arLayoutPresetID')); if (!is_object($preset)) { throw new Exception(t('Invalid layout preset object.')); } $preset->delete(); $pr = new EditResponse(); $pr->setAdditionalDataAttribute('arLayoutPresetID', $preset->getAreaLayoutPresetID()); $pr->outputJSON(); } }
public function submit() { $e = $this->app->make('error'); $pagetype = Type::getByID($this->request->request->get('ptID')); if (is_object($pagetype)) { $configuredTarget = $pagetype->getPageTypePublishTargetObject(); $cParentID = $configuredTarget->getPageTypePublishTargetConfiguredTargetParentPageID(); if (!$cParentID) { $cParentID = $this->request->request->get('cParentID'); } } $parent = Page::getByID($cParentID); $template = null; if ($this->request->request->get('ptComposerPageTemplateID')) { $template = Template::getByID($this->request->request->get('ptComposerPageTemplateID')); } if (!is_object($template)) { $template = $pagetype->getPageTypeDefaultPageTemplateObject(); } if (is_object($pagetype)) { $validator = $pagetype->getPageTypeValidatorObject(); $e->add($validator->validateCreateDraftRequest($template)); $e->add($validator->validatePublishLocationRequest($parent)); if ($this->request->request('addPageComposeAction') == 'publish') { $e->add($validator->validatePublishDraftRequest()); } } $pr = new EditResponse(); $pr->setError($e); if (!$e->has()) { $d = $pagetype->createDraft($template); $d->setPageDraftTargetParentPageID($cParentID); $saver = $pagetype->getPageTypeSaverObject(); $saver->saveForm($d); if ($this->request->request('addPageComposeAction') == 'publish' || $this->request->request('addPageComposeAction') == 'schedule') { $publishDateTime = false; if ($this->request->request->get('addPageComposeAction') == 'schedule') { $dateTime = new DateTime(); $publishDateTime = $dateTime->translate('check-in-scheduler'); } $pagetype->publish($d, $publishDateTime); $pr->setAdditionalDataAttribute('cParentID', $cParentID); $pr->setMessage(t('Page Added Successfully.')); } else { $pr->setRedirectURL($d->getCollectionLink(true)); } } $pr->outputJSON(); }
public function submit() { if ($this->validateAction()) { $c = $this->page; $pr = new EditResponse(); if ($c->isExternalLink()) { $pr->setMessage(t('External Link deleted.')); } else { $pr->setMessage(t("Alias deleted.")); } $c->removeThisAlias(); $pr->setPage($c); $pr->outputJSON(); } }
public function submit() { $pagetype = Type::getByID($this->request->request->get('ptID')); if (is_object($pagetype)) { $configuredTarget = $pagetype->getPageTypePublishTargetObject(); $cParentID = $configuredTarget->getPageTypePublishTargetConfiguredTargetParentPageID(); if (!$cParentID) { $cParentID = $this->request->request->get('cParentID'); } } list($e, $pagetype, $parent) = $this->checkPermissions( $this->request->request->get('ptID'), $cParentID ); if ($this->request->request->get('ptComposerPageTemplateID')) { $template = Template::getByID($this->request->request->get('ptComposerPageTemplateID')); } if (!is_object($template)) { $template = $pagetype->getPageTypeDefaultPageTemplateObject(); } if (is_object($pagetype)) { $validator = $pagetype->getPageTypeValidatorObject(); $e->add($validator->validateCreateDraftRequest($template)); if ($this->request->request('addPageComposeAction') == 'publish') { $e->add($validator->validatePublishDraftRequest()); } } $pr = new EditResponse(); $pr->setError($e); if (!$e->has()) { $d = $pagetype->createDraft($template); $d->setPageDraftTargetParentPageID($cParentID); $pagetype->savePageTypeComposerForm($d); if ($this->request->request('addPageComposeAction') == 'publish') { $pagetype->publish($d); $pr->setAdditionalDataAttribute('cParentID', $cParentID); $pr->setMessage(t('Page Added Successfully.')); } else { $pr->setRedirectURL($d->getCollectionLink(true)); } } $pr->outputJSON(); }
public function getJSON() { $h = \Core::make('helper/concrete/dashboard/sitemap'); if ($h->canRead()) { $c = ConcretePage::getByID(intval($_POST['cID'])); $cp = new Permissions($c); if ($cp->canViewPage()) { $r = new PageEditResponse(); $r->setPage($c); $r->outputJSON(); } else { Core::make('helper/ajax')->sendError(t('You are not allowed to access this page.')); } } else { Core::make('helper/ajax')->sendError(t('You do not have access to the sitemap.')); } }
public function submit() { if ($this->validateAction() && $this->canAccess()) { $a = $this->area; $oldStyle = $this->page->getAreaCustomStyle($a); if (is_object($oldStyle)) { $oldStyleSet = $oldStyle->getStyleSet(); } $nvc = $this->page->getVersionToModify(); $set = StyleSet::populateFromRequest($this->request); if (is_object($set)) { $set->save(); $nvc->setCustomStyleSet($a, $set); } else if ($oldStyleSet) { $nvc->resetAreaCustomStyle($this->area); } $pr = new EditResponse(); $pr->setPage($this->page); $pr->setAdditionalDataAttribute('aID', $this->area->getAreaID()); $pr->setAdditionalDataAttribute('arHandle', $this->area->getAreaHandle()); if (is_object($oldStyleSet)) { $pr->setAdditionalDataAttribute('oldIssID', $oldStyleSet->getID()); } if (is_object($set)) { $pr->setAdditionalDataAttribute('issID', $set->getID()); $style = new CustomStyle($set, $this->area->getAreaHandle()); $css = $style->getCSS(); if ($css !== '') { $pr->setAdditionalDataAttribute('css', $style->getCSS()); } $pr->setAdditionalDataAttribute('containerClass', $style->getContainerClass()); } $pr->setMessage(t('Design updated.')); $pr->outputJSON(); } }
public function create_new() { $pr = new PageEditResponse(); $ms = Section::getByID($this->request->request->get('section')); // we get the related parent id if ($this->page->isPageDraft()) { $cParentID = $this->page->getPageDraftTargetParentPageID(); } else { $cParentID = $this->page->getCollectionParentID(); } $cParent = \Page::getByID($cParentID); $cParentRelatedID = $ms->getTranslatedPageID($cParent); if ($cParentRelatedID > 0) { // we copy the page underneath it and store it $ct = \PageType::getByID($this->page->getPageTypeID()); if ($this->page->isPageDraft()) { $ptp = new \Permissions($ct); if (!$ptp->canAddPageType()) { throw new \Exception(t('You do not have permission to add a page of this type.')); } } $newParent = \Page::getByID($cParentRelatedID); $cp = new \Permissions($newParent); if ($cp->canAddSubCollection($ct)) { if ($this->page->isPageDraft()) { $targetParent = \Page::getByPath(\Config::get('concrete.paths.drafts')); } else { $targetParent = $newParent; } $newPage = $this->page->duplicate($targetParent); if (is_object($newPage)) { if ($this->page->isPageDraft()) { $newPage->setPageDraftTargetParentPageID($newParent->getCollectionID()); Section::relatePage($this->page, $newPage, $ms->getLocale()); $pr->setMessage(t('New draft created.')); } else { // grab the approved version and unapprove it $v = Version::get($newPage, 'ACTIVE'); if (is_object($v)) { $v->deny(); } $pr->setMessage(t('Unapproved page created. You must publish this page before it is live.')); } $ih = Core::make('multilingual/interface/flag'); $icon = (string) $ih->getSectionFlagIcon($ms); $pr->setAdditionalDataAttribute('name', $newPage->getCollectionName()); $pr->setAdditionalDataAttribute('link', $newPage->getCollectionLink()); $pr->setAdditionalDataAttribute('icon', $icon); } } else { throw new \Exception(t('You do not have permission to add this page to this section of the tree.')); } } $pr->outputJSON(); }
public function submit() { if ($this->validateAction()) { $c = $this->page; $cp = $this->permissions; $u = new User(); if ($cp->canDeletePage() && $c->getCollectionID() != HOME_CID && !$c->isMasterCollection()) { $children = $c->getNumChildren(); if ($children == 0 || $u->isSuperUser()) { if ($c->isExternalLink()) { $c->delete(); } else { $pkr = new DeletePagePageWorkflowRequest(); $pkr->setRequestedPage($c); $pkr->setRequesterUserID($u->getUserID()); $u->unloadCollectionEdit($c); $response = $pkr->trigger(); $pr = new PageEditResponse(); $pr->setPage($c); $parent = Page::getByID($c->getCollectionParentID(), 'ACTIVE'); if ($response instanceof WorkflowProgressResponse) { // we only get this response if we have skipped workflows and jumped straight in to an approve() step. $pr->setMessage(t('Page deleted successfully.')); if (!$this->request->request->get('sitemap')) { $pr->setRedirectURL($parent->getCollectionLink(true)); } } else { $pr->setMessage(t('Page deletion request saved. This action will have to be approved before the page is deleted.')); } $pr->outputJSON(); } } } } }
public function create_new() { $pr = new PageEditResponse(); $ms = Section::getByID($this->request->request->get('section')); // we get the related parent id $cParentID = $this->page->getCollectionParentID(); $cParent = \Page::getByID($cParentID); $cParentRelatedID = $ms->getTranslatedPageID($cParent); if ($cParentRelatedID > 0) { // we copy the page underneath it and store it $newParent = \Page::getByID($cParentRelatedID); $ct = \PageType::getByID($this->page->getPageTypeID()); $cp = new \Permissions($newParent); if ($cp->canAddSubCollection($ct) && $this->page->canMoveCopyTo($newParent)) { $newPage = $this->page->duplicate($newParent); if (is_object($newPage)) { // grab the approved version and unapprove it $v = Version::get($newPage, 'ACTIVE'); if (is_object($v)) { $v->deny(); $pkr = new ApprovePageRequest(); $pkr->setRequestedPage($newPage); $u = new \User(); $pkr->setRequestedVersionID($v->getVersionID()); $pkr->setRequesterUserID($u->getUserID()); $response = $pkr->trigger(); if (!$response instanceof Response) { // we are deferred $pr->setMessage(t('<strong>Request Saved.</strong> You must complete the workflow before this change is active.')); } else { $ih = Core::make('multilingual/interface/flag'); $icon = $ih->getSectionFlagIcon($ms); $pr->setAdditionalDataAttribute('name', $newPage->getCollectionName()); $pr->setAdditionalDataAttribute('link', $newPage->getCollectionLink()); $pr->setAdditionalDataAttribute('icon', $icon); $pr->setMessage(t('Page created.')); } } } } else { throw new \Exception(t('You do not have permission to add this page to this section of the tree.')); } } $pr->outputJSON(); }
public function submit() { if ($this->validateAction() && $this->canAccess()) { $a = \Area::get($this->page, $_GET['arHandle']); $c = $this->page; if (is_object($a)) { $b = \Block::getByID($_GET['bID'], $c, $a); $p = new \Permissions($b); if ($p->canAdminBlock() && $c->isMasterCollection()) { if (is_array($_POST['cIDs'])) { foreach ($_POST['cIDs'] as $cID) { $nc = \Page::getByID($cID); if (!$b->isAlias($nc)) { $bt = $b->getBlockTypeObject(); if ($bt->isCopiedWhenPropagated()) { $b->duplicate($nc, true); } else { $b->alias($nc); } } } } // now remove any items that WERE checked and now aren't if (is_array($_POST['checkedCIDs'])) { foreach ($_POST['checkedCIDs'] as $cID) { if (!is_array($_POST['cIDs']) || !in_array($cID, $_POST['cIDs'])) { $nc = \Page::getByID($cID, 'RECENT'); $nb = \Block::getByID($_GET['bID'], $nc, $a); if (is_object($nb) && !$nb->isError()) { $nb->deleteBlock(); } $nc->rescanDisplayOrder($_REQUEST['arHandle']); } } } $er = new EditResponse(); $er->setPage($this->page); $er->setAdditionalDataAttribute('bID', $b->getBlockID()); $er->setAdditionalDataAttribute('aID', $a->getAreaID()); $er->setAdditionalDataAttribute('arHandle', $a->getAreaHandle()); $er->setMessage(t('Defaults updated.')); $er->outputJSON(); } } } }
public function submit() { if ($this->validateAction()) { $b = $this->getBlockToEdit(); if ($this->permissions->canEditBlockName()) { $b->setName($this->request->request->get('bName')); } if ($this->permissions->canEditBlockCacheSettings()) { $b->resetCustomCacheSettings(); if ($this->request->request->get('cbOverrideBlockTypeCacheSettings')) { $b->setCustomCacheSettings($this->request->request->get('btCacheBlockOutput'), $this->request->request->get('btCacheBlockOutputOnPost'), $this->request->request->get('btCacheBlockOutputForRegisteredUsers'), $this->request->request->get('btCacheBlockOutputLifetime')); } } $pr = new EditResponse(); $pr->setPage($this->page); $pr->setAdditionalDataAttribute('aID', $this->area->getAreaID()); $pr->setAdditionalDataAttribute('arHandle', $this->area->getAreaHandle()); $pr->setAdditionalDataAttribute('bID', $b->getBlockID()); $pr->setMessage(t('Advanced block settings saved successfully.')); $pr->outputJSON(); } }
public function submit() { if ($this->validateAction() && $this->canAccess()) { $b = $this->getBlockToEdit(); $oldStyle = $b->getCustomStyle(); if (is_object($oldStyle)) { $oldStyleSet = $oldStyle->getStyleSet(); } $r = $this->request->request->all(); $set = new StyleSet(); $set->setBackgroundColor($r['backgroundColor']); $set->setBackgroundImageFileID(intval($r['backgroundImageFileID'])); $set->setBackgroundRepeat($r['backgroundRepeat']); $set->setLinkColor($r['linkColor']); $set->setTextColor($r['textColor']); $set->setBaseFontSize($r['baseFontSize']); $set->setMarginTop($r['marginTop']); $set->setMarginRight($r['marginRight']); $set->setMarginBottom($r['marginBottom']); $set->setMarginLeft($r['marginLeft']); $set->setPaddingTop($r['paddingTop']); $set->setPaddingRight($r['paddingRight']); $set->setPaddingBottom($r['paddingBottom']); $set->setPaddingLeft($r['paddingLeft']); $set->setBorderWidth($r['borderWidth']); $set->setBorderStyle($r['borderStyle']); $set->setBorderColor($r['borderColor']); $set->setBorderRadius($r['borderRadius']); $set->setAlignment($r['alignment']); $set->setRotate($r['rotate']); $set->setBoxShadowBlur($r['boxShadowBlur']); $set->setBoxShadowColor($r['boxShadowColor']); $set->setBoxShadowHorizontal($r['boxShadowHorizontal']); $set->setBoxShadowVertical($r['boxShadowVertical']); $set->setBoxShadowSpread($r['boxShadowSpread']); $set->setCustomClass($r['customClass']); $set->save(); $b->setCustomStyleSet($set); if ($this->permissions->canEditBlockCustomTemplate()) { $data = array(); $data['bFilename'] = $r['bFilename']; $data['bName'] = $r['bName']; $b->updateBlockInformation($data); } $pr = new EditResponse(); $pr->setPage($this->page); $pr->setAdditionalDataAttribute('aID', $this->area->getAreaID()); $pr->setAdditionalDataAttribute('arHandle', $this->area->getAreaHandle()); $pr->setAdditionalDataAttribute('originalBlockID', $this->block->getBlockID()); $pr->setAdditionalDataAttribute('issID', $set->getID()); if (is_object($oldStyleSet)) { $pr->setAdditionalDataAttribute('oldIssID', $oldStyleSet->getID()); } $style = new CustomStyle($set, $b->getBlockID(), $this->area->getAreaHandle()); $pr->setAdditionalDataAttribute('css', $style->getCSS()); $pr->setAdditionalDataAttribute('bID', $b->getBlockID()); $pr->setMessage(t('Design updated.')); $pr->outputJSON(); } }
public function outputJSON() { return parent::outputJSON(); }
public function reset_site_customizations($pThemeID) { if ($this->validateAction()) { Page::resetAllCustomStyles(); $pt = PageTheme::getByID($pThemeID); $pt->resetThemeCustomStyles(); $r = new PageEditResponse(); $r->setPage($this->page); $r->setRedirectURL(URL::to($this->page)); $r->outputJSON(); } }
public function submit() { if ($this->validateAction() && $this->canAccess()) { $b = $this->getBlockToEdit(); $oldStyle = $b->getCustomStyle(); if (is_object($oldStyle)) { $oldStyleSet = $oldStyle->getStyleSet(); } $r = $this->request->request->all(); $set = StyleSet::populateFromRequest($this->request); if (is_object($set)) { $set->save(); $b->setCustomStyleSet($set); } else { if ($oldStyleSet) { $b->resetCustomStyle(); } } if (isset($r['enableBlockContainer'])) { if ($r['enableBlockContainer'] === '-1') { $b->resetBlockContainerSettings(); } if ($r['enableBlockContainer'] === '0' || $r['enableBlockContainer'] === '1') { $b->setCustomContainerSettings($r['enableBlockContainer']); } } if ($this->permissions->canEditBlockCustomTemplate()) { $data = array(); $data['bFilename'] = $r['bFilename']; $b->updateBlockInformation($data); } $pr = new EditResponse(); $pr->setPage($this->page); $pr->setAdditionalDataAttribute('aID', $this->area->getAreaID()); $pr->setAdditionalDataAttribute('arHandle', $this->area->getAreaHandle()); $pr->setAdditionalDataAttribute('originalBlockID', $this->block->getBlockID()); if (is_object($oldStyleSet)) { $pr->setAdditionalDataAttribute('oldIssID', $oldStyleSet->getID()); } if (is_object($set)) { $pr->setAdditionalDataAttribute('issID', $set->getID()); $style = new CustomStyle($set, $b, $this->page->getCollectionThemeObject()); $css = $style->getCSS(); if ($css !== '') { $pr->setAdditionalDataAttribute('css', $style->getStyleWrapper($css)); } } $pr->setAdditionalDataAttribute('bID', $b->getBlockID()); $pr->setMessage(t('Design updated.')); $pr->outputJSON(); } }
public function arrange() { $pc = new PageEditResponse(); $pc->setPage($this->page); $e = Loader::helper('validation/error'); $nvc = $this->page->getVersionToModify(); $sourceAreaID = intval($_POST['sourceArea']); $destinationAreaID = intval($_POST['area']); $affectedAreaIDs = array(); $affectedAreaIDs[] = $sourceAreaID; if ($sourceAreaID != $destinationAreaID) { $affectedAreaIDs[] = $destinationAreaID; } if (Config::get('concrete.permissions.model') == 'advanced') { // first, we check to see if we have permissions to edit the area contents for the source area. $arHandle = Area::getAreaHandleFromID($sourceAreaID); $ar = Area::getOrCreate($nvc, $arHandle); $ap = new Permissions($ar); if (!$ap->canEditAreaContents()) { $e->add(t('You may not arrange the contents of area %s.', $arHandle)); } else { // now we get further in. We check to see if we're dealing with both a source AND a destination area. // if so, we check the area permissions for the destination area. if ($sourceAreaID != $destinationAreaID) { $destAreaHandle = Area::getAreaHandleFromID($destinationAreaID); $destArea = Area::getOrCreate($nvc, $destAreaHandle); $destAP = new Permissions($destArea); if (!$destAP->canEditAreaContents()) { $e->add(t('You may not arrange the contents of area %s.', $destAreaHandle)); } else { // we're not done yet. Now we have to check to see whether this user has permission to add // a block of this type to the destination area. if ($ar->isGlobalArea()) { $stack = Stack::getByName($arHandle); $b = Block::getByID($_REQUEST['block'], $stack, STACKS_AREA_NAME); } else { $b = Block::getByID($_REQUEST['block'], $nvc, $arHandle); } $bt = $b->getBlockTypeObject(); if (!$destAP->canAddBlock($bt)) { $e->add(t('You may not add %s to area %s.', t($bt->getBlockTypeName()), $destAreaHandle)); } } } } // now, if we get down here we perform the arrangement // it will be set to true if we're in simple permissions mode, or if we've passed all the checks } $source_area = Area::get($nvc, Area::getAreaHandleFromID($sourceAreaID)); $destination_area = Area::get($this->page, Area::getAreaHandleFromID($destinationAreaID)); if ($sourceAreaID !== $destinationAreaID && ($source_area->isGlobalArea() || $destination_area->isGlobalArea())) { // If the source_area is the only global area if ($source_area->isGlobalArea() && !$destination_area->isGlobalArea()) { $cp = new Permissions($nvc); $stack = Stack::getByName($source_area->getAreaHandle()); $stackToModify = $stack->getVersionToModify(); $nvc->relateVersionEdits($stackToModify); $block = Block::getByID($_POST['block'], $stackToModify, Area::get($stackToModify, STACKS_AREA_NAME)); $block->move($nvc, Area::get($nvc, STACKS_AREA_NAME)); } if ($destination_area->isGlobalArea()) { $cp = new Permissions($nvc); $stack = Stack::getByName($destination_area->getAreaHandle()); $stackToModify = $stack->getVersionToModify(); $nvc->relateVersionEdits($stackToModify); // If the source area is global, we need to get the block from there rather than from the view controller if ($source_area->isGlobalArea()) { $sourceStackToModify = Stack::getByName($source_area->getAreaHandle())->getVersionToModify(); $nvc->relateVersionEdits($sourceStackToModify); $block = Block::getByID($_POST['block'], $sourceStackToModify, Area::get($sourceStackToModify, STACKS_AREA_NAME)); } else { $block = Block::getByID($_POST['block'], $nvc, $source_area); } $block->move($stackToModify, Area::get($stackToModify, STACKS_AREA_NAME)); } } if (!$e->has()) { $request = \Request::getInstance(); $area_id = $request->post('area', 0); $block_id = $request->post('block', 0); $block_ids = $request->post('blocks', array()); if ($destination_area->isGlobalArea()) { $stack = Stack::getByName($destination_area->getAreaHandle()); $stackToModify = $stack->getVersionToModify(); $area = Area::get($stackToModify, STACKS_AREA_NAME); $area_id = $area->getAreaID(); $nvc->relateVersionEdits($stackToModify); $stackToModify->processArrangement($area_id, $block_id, $block_ids); } else { $nvc->processArrangement($area_id, $block_id, $block_ids); } } $pc->setError($e); $pc->outputJSON(); exit; }