mirror of
https://github.com/silverstripe/silverstripe-cms
synced 2024-10-22 06:05:56 +00:00
ENHANCEMENT Redirecting to new record from LeftAndMain/CMSMain->doAdd() if not called via ajax
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@102784 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
4ce05e4482
commit
47dfe8b2ab
@ -430,9 +430,11 @@ JS;
|
||||
if($page) $parentID = $page->ID;
|
||||
}
|
||||
|
||||
if(is_numeric($parentID)) $parentObj = DataObject::get_by_id("SiteTree", $parentID);
|
||||
if(!$parentObj || !$parentObj->ID) $parentID = 0;
|
||||
if(is_numeric($parentID) && $parentID > 0) $parentObj = DataObject::get_by_id("SiteTree", $parentID);
|
||||
else $parentObj = null;
|
||||
|
||||
if(!$parentObj || !$parentObj->ID) $parentID = 0;
|
||||
|
||||
if($parentObj) {
|
||||
if(!$parentObj->canAddChildren()) return Security::permissionFailure($this);
|
||||
if(!singleton($className)->canCreate()) return Security::permissionFailure($this);
|
||||
@ -441,13 +443,20 @@ JS;
|
||||
return Security::permissionFailure($this);
|
||||
}
|
||||
|
||||
$p = $this->getNewItem("new-$className-$parentID".$suffix, false);
|
||||
$p->Locale = $data['Locale'];
|
||||
$p->write();
|
||||
$record = $this->getNewItem("new-$className-$parentID".$suffix, false);
|
||||
$record->Locale = $data['Locale'];
|
||||
$record->write();
|
||||
|
||||
$form = $this->getEditForm($p->ID);
|
||||
$form = $this->getEditForm($record->ID);
|
||||
|
||||
return $form->formHtmlContent();
|
||||
if(isset($data['returnID'])) {
|
||||
return $record->ID;
|
||||
} else if(Director::is_ajax()) {
|
||||
$form = $this->getEditForm($record->ID);
|
||||
return $form->formHtmlContent();
|
||||
} else {
|
||||
return $this->redirect(Controller::join_links($this->Link('show'), $record->ID));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -883,9 +883,11 @@ class LeftAndMain extends Controller {
|
||||
// Used in TinyMCE inline folder creation
|
||||
if(isset($data['returnID'])) {
|
||||
return $record->ID;
|
||||
} else {
|
||||
} else if(Director::is_ajax()) {
|
||||
$form = $this->getEditForm($record->ID);
|
||||
return $form->formHtmlContent();
|
||||
} else {
|
||||
return $this->redirect(Controller::join_links($this->Link('show'), $record->ID));
|
||||
}
|
||||
}
|
||||
|
||||
@ -971,7 +973,6 @@ class LeftAndMain extends Controller {
|
||||
* @return int
|
||||
*/
|
||||
public function currentPageID() {
|
||||
SS_Backtrace::backtrace();
|
||||
if($this->request->getVar('ID')) {
|
||||
return $this->request->getVar('ID');
|
||||
} elseif ($this->request->param('ID') && is_numeric($this->request->param('ID'))) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user