diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b697e2e --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +*.DS_Store +*Thumbs.db +_notes/ diff --git a/deleteallentryversions/DeleteAllEntryVersionsPlugin.php b/deleteallentryversions/DeleteAllEntryVersionsPlugin.php new file mode 100644 index 0000000..ef1c482 --- /dev/null +++ b/deleteallentryversions/DeleteAllEntryVersionsPlugin.php @@ -0,0 +1,40 @@ + 'deleteallentryversions/_settings', + ); + } +} diff --git a/deleteallentryversions/controllers/DeleteAllEntryVersionsController.php b/deleteallentryversions/controllers/DeleteAllEntryVersionsController.php new file mode 100644 index 0000000..4204667 --- /dev/null +++ b/deleteallentryversions/controllers/DeleteAllEntryVersionsController.php @@ -0,0 +1,48 @@ +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(); + } + + + +} diff --git a/deleteallentryversions/templates/_settings.html b/deleteallentryversions/templates/_settings.html new file mode 100644 index 0000000..0daa415 --- /dev/null +++ b/deleteallentryversions/templates/_settings.html @@ -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 %} +
+{% endset %} diff --git a/readme.md b/readme.md new file mode 100644 index 0000000..537fdac --- /dev/null +++ b/readme.md @@ -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".