-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 4437f60
Showing
5 changed files
with
119 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
*.DS_Store | ||
*Thumbs.db | ||
_notes/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
namespace Craft; | ||
|
||
/** | ||
* Delete All Entry Versions plugin | ||
*/ | ||
class DeleteAllEntryVersionsPlugin extends BasePlugin | ||
{ | ||
function getName() | ||
{ | ||
return 'Delete All Entry Versions'; | ||
} | ||
|
||
function getVersion() | ||
{ | ||
return '1.0'; | ||
} | ||
|
||
function getDeveloper() | ||
{ | ||
return 'carlcs'; | ||
} | ||
|
||
function getDeveloperUrl() | ||
{ | ||
return 'https://github.com/carlcs/craft-deleteallentryversions'; | ||
} | ||
|
||
public function getSettingsUrl() | ||
{ | ||
return 'settings/plugins/deleteallentryversions/index'; | ||
} | ||
|
||
public function registerCpRoutes() | ||
{ | ||
return array( | ||
'settings/plugins/deleteallentryversions/index' => 'deleteallentryversions/_settings', | ||
); | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
deleteallentryversions/controllers/DeleteAllEntryVersionsController.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?php | ||
namespace Craft; | ||
|
||
class DeleteAllEntryVersionsController extends BaseController | ||
{ | ||
// Public Methods | ||
// ========================================================================= | ||
|
||
/** | ||
* Deletes all entry versions. | ||
* | ||
* @return null | ||
*/ | ||
public function actionDelete() | ||
{ | ||
if (craft()->getEdition() >= Craft::Client) | ||
{ | ||
// Delete them all. | ||
craft()->db->createCommand()->truncateTable('entryversions'); | ||
|
||
// Save a new version for all entries' current content, to make it possible to revert back to it. | ||
$sections = craft()->sections->getAllSections(); | ||
|
||
foreach ($sections as $section) | ||
{ | ||
if ($section->enableVersioning) | ||
{ | ||
$criteria = craft()->elements->getCriteria(ElementType::Entry); | ||
|
||
$criteria->sectionId = $section->id; | ||
$criteria->status = null; | ||
$criteria->localeEnabled = null; | ||
$criteria->limit = null; | ||
|
||
foreach ($criteria as $entry) | ||
{ | ||
craft()->entryRevisions->saveVersion($entry); | ||
} | ||
} | ||
} | ||
} | ||
|
||
$this->redirectToPostedUrl(); | ||
} | ||
|
||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{% extends '_layouts/cp' %} | ||
{% set title = 'Delete All Entry Versions' %} | ||
|
||
{% set crumbs = [ | ||
{ label: 'Settings'|t, url: url('settings') }, | ||
{ label: 'Plugins'|t, url: url('settings/plugins') }, | ||
] %} | ||
|
||
{% import '_includes/forms' as forms %} | ||
|
||
{% set content %} | ||
<form method="post" accept-charset="UTF-8" data-saveshortcut> | ||
<input type="hidden" name="action" value="deleteAllEntryVersions/delete"> | ||
|
||
<p class="first">{{ 'Backup your Database first! This deletes all entry versions, but keeps the current version of each entry, so you can revert back to it.'|t }}</p> | ||
|
||
<div class="buttons"> | ||
<input type="submit" class="btn submit" value="{{ 'Delete Entry Versions'|t }}"> | ||
</div> | ||
</form> | ||
{% endset %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Delete All Entry Versions plugin for Craft | ||
|
||
This deletes all entry versions, but keeps the current version of each entry, so you can revert back to it. | ||
|
||
## Installation | ||
|
||
To install the plugin, copy the deleteallentryversions/ folder into craft/plugins/. Then go to Settings → Plugins and click the "Install" button next to "Delete All Entry Versions". |