diff --git a/README.md b/README.md
index 24884f5..6984f69 100644
--- a/README.md
+++ b/README.md
@@ -21,3 +21,8 @@ new to have the DailyTask cron job set up. See ScheduledTask.php
## Usage
When you open a page in the CMS, there will now be a Review tab.
+
+## Migration
+When migrating from an older version of this module to the current version,
+you might need to run: /dev/tasks/ContentReviewOwnerMigrationTask
+
diff --git a/code/ContentReviewEmails.php b/code/ContentReviewEmails.php
index 86fd790..71792d2 100644
--- a/code/ContentReviewEmails.php
+++ b/code/ContentReviewEmails.php
@@ -15,10 +15,10 @@ class ContentReviewEmails extends DailyTask {
Subsite::$disable_subsite_filter = true;
}
- $pages = DataObject::get('Page', "\"SiteTree\".\"NextReviewDate\" = '".(class_exists('SS_Datetime') ? SS_Datetime::now()->URLDate() : SSDatetime::now()->URLDate())."' AND \"SiteTree\".\"OwnerID\" != 0");
+ $pages = DataObject::get('Page', "\"SiteTree\".\"NextReviewDate\" = '".(class_exists('SS_Datetime') ? SS_Datetime::now()->URLDate() : SSDatetime::now()->URLDate())."' AND \"SiteTree\".\"ContentReviewOwnerID\" != 0");
if ($pages && $pages->Count()) {
foreach($pages as $page) {
- $owner = $page->Owner();
+ $owner = $page->ContentReviewOwner();
if ($owner) {
$sender = Security::findAnAdministrator();
$recipient = $owner;
diff --git a/code/ContentReviewOwnerMigrationTask.php b/code/ContentReviewOwnerMigrationTask.php
new file mode 100644
index 0000000..82177d5
--- /dev/null
+++ b/code/ContentReviewOwnerMigrationTask.php
@@ -0,0 +1,20 @@
+OwnerID column to a new column name
+ */
+class ContentReviewOwnerMigrationTask extends BuildTask {
+ public function run($request) {
+ $results = DB::query('SHOW columns from "SiteTree" WHERE "field" = \'OwnerID\'');
+ if ($results->numRecords() == 0) {
+ echo "
No need to run task. SiteTree->OwnerID doesn't exist
";
+ } else {
+ DB::query('UPDATE "SiteTree" SET "ContentReviewOwnerID" = "OwnerID"');
+ DB::query('UPDATE "SiteTree_Live" SET "ContentReviewOwnerID" = "OwnerID"');
+ DB::query('UPDATE "SiteTree_versions" SET "ContentReviewOwnerID" = "OwnerID"');
+ DB::query('ALTER TABLE "SiteTree" DROP COLUMN "OwnerID"');
+ DB::query('ALTER TABLE "SiteTree_Live" DROP COLUMN "OwnerID"');
+ DB::query('ALTER TABLE "SiteTree_versions" DROP COLUMN "OwnerID"');
+ echo "Migrated 3 tables. Dropped obsolete OwnerID column
";
+ }
+ }
+}
\ No newline at end of file
diff --git a/code/PagesDueForReviewReport.php b/code/PagesDueForReviewReport.php
index aa30d85..1a664fe 100644
--- a/code/PagesDueForReviewReport.php
+++ b/code/PagesDueForReviewReport.php
@@ -40,7 +40,7 @@ class PagesDueForReviewReport extends SS_Report {
$map = $map + array('' => 'Any', '-1' => '(no owner)');
- $params->push(new DropdownField("OwnerID", 'Page owner', $map));
+ $params->push(new DropdownField("ContentReviewOwnerID", 'Page owner', $map));
// Restore current subsite
Subsite::changeSubsite($existingSubsite);
@@ -49,7 +49,7 @@ class PagesDueForReviewReport extends SS_Report {
$map = $cmsUsers->map('ID', 'Title', '(no owner)')->toArray();
unset($map['']);
$map = array('' => 'Any', '-1' => '(no owner)') + $map;
- $params->push(new DropdownField("OwnerID", 'Page owner', $map));
+ $params->push(new DropdownField("ContentReviewOwnerID", 'Page owner', $map));
}
$params->push(
@@ -135,11 +135,11 @@ class PagesDueForReviewReport extends SS_Report {
}
// Owner dropdown
- if(!empty($params['OwnerID'])) {
- $ownerID = (int)$params['OwnerID'];
+ if(!empty($params['ContentReviewOwnerID'])) {
+ $ownerID = (int)$params['ContentReviewOwnerID'];
// We use -1 here to distinguish between No Owner and Any
if($ownerID == -1) $ownerID = 0;
- $records->addFilter(array('OwnerID' => $ownerID));
+ $records->addFilter(array('ContentReviewOwnerID' => $ownerID));
}
// Turn a query into records
diff --git a/code/SiteTreeContentReview.php b/code/SiteTreeContentReview.php
index 528ef02..dca395c 100644
--- a/code/SiteTreeContentReview.php
+++ b/code/SiteTreeContentReview.php
@@ -16,11 +16,11 @@ class SiteTreeContentReview extends DataExtension implements PermissionProvider
);
static $has_one = array(
- 'Owner' => 'Member',
+ 'ContentReviewOwner' => 'Member',
);
function getOwnerName() {
- if($this->owner->OwnerID && $this->owner->Owner()) return $this->owner->Owner()->FirstName . ' ' . $this->owner->Owner()->Surname;
+ if($this->owner->ContentReviewOwnerID && $this->owner->ContentReviewOwner()) return $this->owner->ContentReviewOwner()->FirstName . ' ' . $this->owner->ContentReviewOwner()->Surname;
}
function getEditorName() {
@@ -37,7 +37,7 @@ class SiteTreeContentReview extends DataExtension implements PermissionProvider
$fields->addFieldsToTab("Root.Review", array(
new HeaderField(_t('SiteTreeCMSWorkflow.REVIEWHEADER', "Content review"), 2),
- new DropdownField("OwnerID", _t("SiteTreeCMSWorkflow.PAGEOWNER",
+ new DropdownField("ContentReviewOwnerID", _t("SiteTreeCMSWorkflow.PAGEOWNER",
"Page owner (will be responsible for reviews)"), $cmsUsers->map('ID', 'Title', '(no owner)')),
DateField::create(
"NextReviewDate",
diff --git a/javascript/PagesDueForReview.js b/javascript/PagesDueForReview.js
index 61ec88c..c23301d 100644
--- a/javascript/PagesDueForReview.js
+++ b/javascript/PagesDueForReview.js
@@ -2,7 +2,7 @@
// Hide all owner dropdowns except the one for the current subsite
function showCorrectSubsiteIDDropdown(value) {
- var domid = 'OwnerID' + value;
+ var domid = 'ContentReviewOwnerID' + value;
var ownerIDDropdowns = $('div.subsiteSpecificOwnerID');
for(var i = 0; i < ownerIDDropdowns.length; i++) {
diff --git a/tests/ContentReviewTest.php b/tests/ContentReviewTest.php
index f5c1468..f8be5ca 100644
--- a/tests/ContentReviewTest.php
+++ b/tests/ContentReviewTest.php
@@ -84,14 +84,14 @@ class ContentReviewTest extends FunctionalTest {
$page = new Page();
$page->ReviewPeriodDays = 10;
- $page->OwnerID = $editor->ID;
+ $page->ContentReviewOwnerID = $editor->ID;
$page->write();
$this->assertTrue($page->doPublish());
$this->assertEquals($page->OwnerName, "Test Editor");
$page = $this->objFromFixture('Page', 'about');
- $page->OwnerID = 0;
+ $page->ContentReviewOwnerID = 0;
$page->write();
$this->assertTrue($page->doPublish());
diff --git a/tests/ContentReviewTest.yml b/tests/ContentReviewTest.yml
index 5a6d80c..9d0e471 100644
--- a/tests/ContentReviewTest.yml
+++ b/tests/ContentReviewTest.yml
@@ -42,7 +42,7 @@ Page:
staff:
Title: Staff
NextReviewDate: 2010-02-14
- Owner: =>Member.author
+ ContentReviewOwner: =>Member.author
contact:
Title: Contact Us
NextReviewDate: 2010-02-21
\ No newline at end of file