mirror of
https://github.com/silverstripe/silverstripe-cms
synced 2024-10-22 08:05:56 +02:00
Merge pull request #1556 from open-sausages/pulls/4.0/remove-obsolete-actions
API Remove obsolete API
This commit is contained in:
commit
75d72285c7
@ -53,7 +53,6 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
|||||||
|
|
||||||
private static $allowed_actions = array(
|
private static $allowed_actions = array(
|
||||||
'archive',
|
'archive',
|
||||||
'buildbrokenlinks',
|
|
||||||
'deleteitems',
|
'deleteitems',
|
||||||
'DeleteItemsForm',
|
'DeleteItemsForm',
|
||||||
'dialog',
|
'dialog',
|
||||||
@ -1269,42 +1268,6 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
|||||||
return $this->batchactions()->batchActionList();
|
return $this->batchactions()->batchActionList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function buildbrokenlinks($request) {
|
|
||||||
// Protect against CSRF on destructive action
|
|
||||||
if(!SecurityToken::inst()->checkRequest($request)) return $this->httpError(400);
|
|
||||||
|
|
||||||
increase_time_limit_to();
|
|
||||||
increase_memory_limit_to();
|
|
||||||
|
|
||||||
if($this->urlParams['ID']) {
|
|
||||||
$newPageSet[] = DataObject::get_by_id("Page", $this->urlParams['ID']);
|
|
||||||
} else {
|
|
||||||
$pages = DataObject::get("Page");
|
|
||||||
foreach($pages as $page) $newPageSet[] = $page;
|
|
||||||
$pages = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
$content = new HTMLEditorField('Content');
|
|
||||||
$download = new HTMLEditorField('Download');
|
|
||||||
|
|
||||||
foreach($newPageSet as $i => $page) {
|
|
||||||
$page->HasBrokenLink = 0;
|
|
||||||
$page->HasBrokenFile = 0;
|
|
||||||
|
|
||||||
$content->setValue($page->Content);
|
|
||||||
$content->saveInto($page);
|
|
||||||
|
|
||||||
$download->setValue($page->Download);
|
|
||||||
$download->saveInto($page);
|
|
||||||
|
|
||||||
echo "<li>$page->Title (link:$page->HasBrokenLink, file:$page->HasBrokenFile)";
|
|
||||||
|
|
||||||
$page->writeWithoutVersion();
|
|
||||||
$page->destroy();
|
|
||||||
$newPageSet[$i] = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function publishall($request) {
|
public function publishall($request) {
|
||||||
if(!Permission::check('ADMIN')) return Security::permissionFailure($this);
|
if(!Permission::check('ADMIN')) return Security::permissionFailure($this);
|
||||||
|
|
||||||
|
@ -1,56 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* @package cms
|
|
||||||
* @subpackage filesystem
|
|
||||||
*/
|
|
||||||
class Folder_UnusedAssetsField extends CompositeField {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var Folder
|
|
||||||
*/
|
|
||||||
protected $folder;
|
|
||||||
|
|
||||||
public function __construct($folder) {
|
|
||||||
$this->folder = $folder;
|
|
||||||
parent::__construct(new FieldList());
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getChildren() {
|
|
||||||
if($this->children->Count() == 0) {
|
|
||||||
$inlineFormAction = new InlineFormAction("delete_unused_thumbnails", _t('Folder.DELETEUNUSEDTHUMBNAILS', 'Delete unused thumbnails'));
|
|
||||||
$inlineFormAction->includeDefaultJS(false) ;
|
|
||||||
|
|
||||||
$this->children = new FieldList(
|
|
||||||
new LiteralField( "UnusedAssets", "<h2>"._t('Folder.UNUSEDFILESTITLE', 'Unused files')."</h2>" ),
|
|
||||||
$this->getAssetList(),
|
|
||||||
new FieldGroup(
|
|
||||||
new LiteralField( "UnusedThumbnails", "<h2>"._t('Folder.UNUSEDTHUMBNAILSTITLE', 'Unused thumbnails')."</h2>"),
|
|
||||||
$inlineFormAction
|
|
||||||
)
|
|
||||||
);
|
|
||||||
$this->children->setForm($this->form);
|
|
||||||
}
|
|
||||||
return $this->children;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function FieldHolder($properties = array()) {
|
|
||||||
$output = "";
|
|
||||||
foreach($this->getChildren() as $child) {
|
|
||||||
$output .= $child->FieldHolder();
|
|
||||||
}
|
|
||||||
return $output;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates table for displaying unused files.
|
|
||||||
*
|
|
||||||
* @return GridField
|
|
||||||
*/
|
|
||||||
protected function getAssetList() {
|
|
||||||
$where = $this->folder->getUnusedFilesListFilter();
|
|
||||||
$files = File::get()->where($where);
|
|
||||||
$field = new GridField('AssetList', false, $files);
|
|
||||||
return $field;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1464,17 +1464,6 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
DB::alteration_message('Contact Us page created', 'created');
|
DB::alteration_message('Contact Us page created', 'created');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// schema migration
|
|
||||||
// @todo Move to migration task once infrastructure is implemented
|
|
||||||
if($this->class == 'SiteTree') {
|
|
||||||
$conn = DB::get_schema();
|
|
||||||
// only execute command if fields haven't been renamed to _obsolete_<fieldname> already by the task
|
|
||||||
if($conn->hasField('SiteTree' ,'Viewers')) {
|
|
||||||
$task = new UpgradeSiteTreePermissionSchemaTask();
|
|
||||||
$task->run(new SS_HTTPRequest('GET','/'));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function onBeforeWrite() {
|
protected function onBeforeWrite() {
|
||||||
|
@ -1,55 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
use SilverStripe\ORM\DB;
|
|
||||||
use SilverStripe\ORM\DataObject;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @package cms
|
|
||||||
* @subpackage tasks
|
|
||||||
*/
|
|
||||||
class UpgradeSiteTreePermissionSchemaTask extends BuildTask {
|
|
||||||
|
|
||||||
private static $allowed_actions = array(
|
|
||||||
'*' => 'ADMIN'
|
|
||||||
);
|
|
||||||
|
|
||||||
protected $title = 'Upgrade SiteTree Permissions Schema';
|
|
||||||
|
|
||||||
protected $description = "Move data from legacy columns to new schema introduced in SilverStripe 2.1.<br />
|
|
||||||
SiteTree->Viewers to SiteTree->CanViewType<br />
|
|
||||||
SiteTree->Editors to SiteTree->CanEditType<br />
|
|
||||||
SiteTree->ViewersGroup to SiteTree->ViewerGroups (has_one to many_many)<br />
|
|
||||||
SiteTree->Editorsroup to SiteTree->EditorGroups (has_one to many_many)<br />
|
|
||||||
See http://open.silverstripe.com/ticket/2847
|
|
||||||
";
|
|
||||||
|
|
||||||
public function run($request) {
|
|
||||||
// transfer values for changed column name
|
|
||||||
foreach(array('SiteTree','SiteTree_Live','SiteTree_versions') as $table) {
|
|
||||||
DB::prepared_query("UPDATE \"{$table}\" SET \"CanViewType\" = ?", array('Viewers'));
|
|
||||||
DB::prepared_query("UPDATE \"{$table}\" SET \"CanEditType\" = ?", array('Editors'));
|
|
||||||
}
|
|
||||||
//Debug::message('Moved SiteTree->Viewers to SiteTree->CanViewType');
|
|
||||||
//Debug::message('Moved SiteTree->Editors to SiteTree->CanEditType');
|
|
||||||
|
|
||||||
// convert has_many to many_many
|
|
||||||
$pageIDs = DB::query("SELECT ID FROM SiteTree")->column('ID');
|
|
||||||
foreach($pageIDs as $pageID) {
|
|
||||||
$page = DataObject::get_by_id('SiteTree', $pageID);
|
|
||||||
if($page->ViewersGroup && DataObject::get_by_id("SilverStripe\\Security\\Group", $page->ViewersGroup)) $page->ViewerGroups()->add($page->ViewersGroup);
|
|
||||||
if($page->EditorsGroup && DataObject::get_by_id("SilverStripe\\Security\\Group", $page->EditorsGroup)) $page->EditorGroups()->add($page->EditorsGroup);
|
|
||||||
|
|
||||||
$page->destroy();
|
|
||||||
unset($page);
|
|
||||||
}
|
|
||||||
//Debug::message('SiteTree->ViewersGroup to SiteTree->ViewerGroups (has_one to many_many)');
|
|
||||||
//Debug::message('SiteTree->EditorsGroup to SiteTree->EditorGroups (has_one to many_many)');
|
|
||||||
|
|
||||||
// rename legacy columns
|
|
||||||
foreach(array('SiteTree','SiteTree_Live','SiteTree_versions') as $table) {
|
|
||||||
foreach(array('Viewers','Editors','ViewersGroup','EditorsGroup') as $field) {
|
|
||||||
DB::get_conn()->dontRequireField($table, $field);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user