MINOR Merged r69410 from trunk

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/branches/2.3@69839 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Ingo Schommer 2009-01-07 06:03:23 +00:00 committed by Sam Minnee
parent 1e4083c290
commit 3351aef184

View File

@ -370,11 +370,7 @@ JS;
Versioned::reading_stage('Live');
singleton($treeClass)->flushCache();
$record = DataObject::get_one( $treeClass, "`$treeClass`.ID = $id");
if($record) {
$record->DeletedFromStage = true;
} else {
Versioned::reading_stage(null);
}
if($record) Versioned::reading_stage(null);
}
return $record;
@ -387,7 +383,7 @@ JS;
$record = $this->getRecord($id);
if($record) {
if($record->DeletedFromStage) $record->Status = _t('CMSMain.REMOVEDFD',"Removed from the draft site");
if($record->IsDeletedFromStage) $record->Status = _t('CMSMain.REMOVEDFD',"Removed from the draft site");
$fields = $record->getCMSFields($this);
if ($fields == null) {
@ -407,7 +403,7 @@ JS;
if($liveRecord) $liveURLField->setValue($liveRecord->AbsoluteLink());
}
if(!$record->DeletedFromStage) {
if(!$record->IsDeletedFromStage) {
$stageURLField->setValue($record->AbsoluteLink());
}
@ -430,7 +426,7 @@ JS;
$form->loadDataFrom($record);
$form->disableDefaultAction();
if(!$record->canEdit() || $record->DeletedFromStage) {
if(!$record->canEdit() || $record->IsDeletedFromStage) {
$readonlyFields = $form->Fields()->makeReadonly();
$form->setFields($readonlyFields);
}
@ -464,7 +460,6 @@ JS;
$p = $this->getNewItem("new-$className-$parent".$suffix, false);
$p->write();
$p->CheckedPublicationDifferences = $p->AddedToStage = true;
return $this->returnItemToUser($p);
}
@ -520,6 +515,11 @@ JS;
return $newItem;
}
/**
* Delete the page from live. This means a page in draft mode might still exist.
*
* @see delete()
*/
public function deletefromlive($urlParams, $form) {
$id = $_REQUEST['ID'];
Versioned::reading_stage('Live');
@ -577,9 +577,8 @@ JS;
* @uses SiteTree->doRevertToLive()
*/
public function revert($urlParams, $form) {
$id = $_REQUEST['ID'];
$record = DataObject::get_by_id("SiteTree", $id);
$id = (int)$_REQUEST['ID'];
$record = Versioned::get_one_by_stage('SiteTree', 'Live', "\"SiteTree_Live\".\"ID\" = {$id}");
// a user can restore a page without publication rights, as it just adds a new draft state
// (this action should just be available when page has been "deleted from draft")
if($record && !$record->canEdit()) return Security::permissionFailure($this);
@ -595,19 +594,32 @@ JS;
}
/**
* Delete the current page
* Delete the current page from draft stage.
* @see deletefromlive()
*/
public function delete($urlParams, $form) {
$id = $_REQUEST['ID'];
$record = DataObject::get_one("SiteTree", "SiteTree.ID = $id");
if($record && !$record->canDelete()) return Security::permissionFailure();
// save ID and delete record
$recordID = $record->ID;
$record->delete();
$record->ID = $recordID;
if(Director::is_ajax()) {
return $this->tellBrowserAboutPublicationChange($record, sprintf(_t('CMSMain.REMOVEDPAGEFROMDRAFT',"Removed '%s' from the draft site"),$record->Title));
// need a valid ID value even if the record doesn't have one in the database
// (its still present in the live tables)
$liveRecord = Versioned::get_one_by_stage('SiteTree', 'Live', "\"SiteTree_Live\".\"ID\" = $recordID");
// if the page has never been published to live, we need to act the same way as in deletefromlive()
if($liveRecord) {
// the form is readonly now, so we need to refresh the representation
FormResponse::get_page($recordID);
return $this->tellBrowserAboutPublicationChange($liveRecord, sprintf(_t('CMSMain.REMOVEDPAGEFROMDRAFT',"Removed '%s' from the draft site"),$record->Title));
} else {
FormResponse::add($this->deleteTreeNodeJS($record));
FormResponse::status_message(sprintf(_t('CMSMain.REMOVEDPAGEFROMDRAFT',"Removed '%s' from the draft site"),$record->Title), 'good');
return FormResponse::respond();
}
} else {
Director::redirectBack();
}
@ -683,7 +695,7 @@ JS;
function tellBrowserAboutPublicationChange($page, $statusMessage) {
$JS_title = Convert::raw2js($page->TreeTitle());
$JS_stageURL = $page->DeletedFromStage ? '' : Convert::raw2js($page->AbsoluteLink());
$JS_stageURL = $page->IsDeletedFromStage ? '' : Convert::raw2js($page->AbsoluteLink());
$liveRecord = Versioned::get_one_by_stage('SiteTree', 'Live', "`SiteTree`.ID = $page->ID");
$JS_liveURL = $liveRecord ? Convert::raw2js($liveRecord->AbsoluteLink()) : '';
@ -1010,10 +1022,8 @@ JS;
$record->destroy();
// DataObject::delete_by_id($this->stat('tree_class'), $id);
$record->CheckedPublicationDifferences = $record->DeletedFromStage = true;
// check to see if the record exists on the live site, if it doesn't remove the tree node
// $_REQUEST['showqueries'] = 1 ;
$liveRecord = Versioned::get_one_by_stage( $this->stat('tree_class'), 'Live', "`{$this->stat('tree_class')}`.`ID`={$id}");
if($liveRecord) {
@ -1328,7 +1338,6 @@ JS
$newrecord = clone $record;
$newrecord->ID = $temporalID;
$newrecord->CheckedPublicationDifferences = $newrecord->AddedToStage = true;
return $this->returnItemToUser($newrecord);
}