From 619d3303262cc7b0aadd5c27dec9ad4e630644eb Mon Sep 17 00:00:00 2001 From: Seamus Lee Date: Thu, 7 Sep 2017 07:04:38 +1000 Subject: [PATCH] CRM-20892 Add in modified_date column to civicrm_mailing to assist in preventing cross edit of mailings --- CRM/Mailing/DAO/Mailing.php | 24 ++++++++++++++++++++++- CRM/Upgrade/Incremental/php/FourSeven.php | 10 ++++++++++ xml/schema/Mailing/Mailing.xml | 10 ++++++++++ 3 files changed, 43 insertions(+), 1 deletion(-) diff --git a/CRM/Mailing/DAO/Mailing.php b/CRM/Mailing/DAO/Mailing.php index d9c55517f29d..2d0f8756ff32 100644 --- a/CRM/Mailing/DAO/Mailing.php +++ b/CRM/Mailing/DAO/Mailing.php @@ -30,7 +30,7 @@ * * Generated from xml/schema/CRM/Mailing/Mailing.xml * DO NOT EDIT. Generated by CRM_Core_CodeGen - * (GenCodeChecksum:9a7cf33adcdee2e83d5fe1b5a28186cb) + * (GenCodeChecksum:7f90165e5c470ceb7e4644a5ab0660d1) */ require_once 'CRM/Core/DAO.php'; require_once 'CRM/Utils/Type.php'; @@ -299,6 +299,12 @@ class CRM_Mailing_DAO_Mailing extends CRM_Core_DAO { * @var string */ public $language; + /** + * When was the mailing (or closely related entity) was created or modified or deleted. + * + * @var timestamp + */ + public $modified_date; /** * Class constructor. */ @@ -908,6 +914,22 @@ static function &fields() { 'optionEditPath' => 'civicrm/admin/options/languages', ) ) , + 'mailing_modified_date' => array( + 'name' => 'modified_date', + 'type' => CRM_Utils_Type::T_TIMESTAMP, + 'title' => ts('Modified Date') , + 'description' => 'When was the mailing (or closely related entity) was created or modified or deleted.', + 'required' => false, + 'export' => true, + 'where' => 'civicrm_mailing.modified_date', + 'headerPattern' => '', + 'dataPattern' => '', + 'default' => 'CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP', + 'table_name' => 'civicrm_mailing', + 'entity' => 'Mailing', + 'bao' => 'CRM_Mailing_BAO_Mailing', + 'localizable' => 0, + ) , ); CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']); } diff --git a/CRM/Upgrade/Incremental/php/FourSeven.php b/CRM/Upgrade/Incremental/php/FourSeven.php index 500da9045d49..c00f3f8e15c9 100644 --- a/CRM/Upgrade/Incremental/php/FourSeven.php +++ b/CRM/Upgrade/Incremental/php/FourSeven.php @@ -429,6 +429,16 @@ public function upgrade_4_7_25($rev) { 'civicrm_case', 'modified_date', "timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'When was the case (or closely related entity) was created or modified or deleted.'"); } + /** + * Upgrade function. + * + * @param string $rev + */ + public function upgrade_4_7_26($rev) { + $this->addTask('CRM-20892 - Add modified_date to civicrm_mailing', 'addColumn', + 'civicrm_mailing', 'modified_date', "timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'When was the mailing (or closely related entity) was created or modified or deleted.'"); + $this->addTask(ts('Upgrade DB to %1: SQL', array(1 => $rev)), 'runSql', $rev); + } /* * Important! All upgrade functions MUST add a 'runSql' task. diff --git a/xml/schema/Mailing/Mailing.xml b/xml/schema/Mailing/Mailing.xml index 25d2488079bc..7b8880a06e24 100644 --- a/xml/schema/Mailing/Mailing.xml +++ b/xml/schema/Mailing/Mailing.xml @@ -487,4 +487,14 @@ Select + + modified_date + mailing_modified_date + timestamp + When was the mailing (or closely related entity) was created or modified or deleted. + false + true + CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP + 4.7 +