From 60b36f60f9a9073aa58faaea7a1017d7d4cdf323 Mon Sep 17 00:00:00 2001 From: priyankakaran26 Date: Sun, 7 Sep 2014 16:32:41 +0100 Subject: [PATCH] 1. dao generations fixes 2. cascade-type to mode --- CRM/Core/BAO/RecurringEntity.php | 11 +++++++++- CRM/Core/DAO/RecurringEntity.php | 16 ++++++++++++++- CRM/Core/Page/AJAX/RecurringEntity.php | 20 +++++++++---------- CRM/Core/xml/Menu/Misc.xml | 6 +++--- templates/CRM/Core/Form/RecurringEntity.tpl | 4 ++-- .../Form/ManageEvent/ConfirmRepeatMode.tpl | 4 ++-- xml/schema/Core/RecurringEntity.xml | 7 +++---- 7 files changed, 45 insertions(+), 23 deletions(-) diff --git a/CRM/Core/BAO/RecurringEntity.php b/CRM/Core/BAO/RecurringEntity.php index d6edd05280..92d5b2fe81 100644 --- a/CRM/Core/BAO/RecurringEntity.php +++ b/CRM/Core/BAO/RecurringEntity.php @@ -92,7 +92,7 @@ class CRM_Core_BAO_RecurringEntity extends CRM_Core_DAO_RecurringEntity { ); if (!$mode) { - $mode = CRM_Core_DAO::singleValueQuery("SELECT cascade_type FROM civicrm_recurring_entity WHERE entity_id = %3 AND entity_table = %2", $queryParams); + $mode = CRM_Core_DAO::singleValueQuery("SELECT mode FROM civicrm_recurring_entity WHERE entity_id = %3 AND entity_table = %2", $queryParams); } $query = "SELECT * @@ -168,6 +168,15 @@ class CRM_Core_BAO_RecurringEntity extends CRM_Core_DAO_RecurringEntity { } static public function triggerUpdate($obj) { + // if DB version is earlier than 4.6 skip any processing + static $currentVer = NULL; + if (!$currentVer) { + $currentVer = CRM_Core_BAO_Domain::version(); + } + if (version_compare($currentVer, '4.6.alpha1') < 0) { + return; + } + static $processedEntities = array(); if (empty($obj->id) || empty($obj->__table)) { return FALSE; diff --git a/CRM/Core/DAO/RecurringEntity.php b/CRM/Core/DAO/RecurringEntity.php index bd19e139c4..812464bba3 100644 --- a/CRM/Core/DAO/RecurringEntity.php +++ b/CRM/Core/DAO/RecurringEntity.php @@ -108,6 +108,11 @@ class CRM_Core_DAO_RecurringEntity extends CRM_Core_DAO * @var string */ public $entity_table; + /** + * + * @var boolean + */ + public $mode; /** * class constructor * @@ -151,7 +156,15 @@ class CRM_Core_DAO_RecurringEntity extends CRM_Core_DAO 'type' => CRM_Utils_Type::T_STRING, 'title' => ts('Entity Table') , 'required' => true, - 'size' => CRM_Utils_Type::TWO, + 'maxlength' => 64, + 'size' => CRM_Utils_Type::BIG, + ) , + 'mode' => array( + 'name' => 'mode', + 'type' => CRM_Utils_Type::T_BOOLEAN, + 'title' => ts('Cascade Type') , + 'required' => true, + 'default' => '1', ) , ); } @@ -172,6 +185,7 @@ class CRM_Core_DAO_RecurringEntity extends CRM_Core_DAO 'parent_id' => 'parent_id', 'entity_id' => 'entity_id', 'entity_table' => 'entity_table', + 'mode' => 'mode', ); } return self::$_fieldKeys; diff --git a/CRM/Core/Page/AJAX/RecurringEntity.php b/CRM/Core/Page/AJAX/RecurringEntity.php index 0c3061008c..30fd29dd2d 100644 --- a/CRM/Core/Page/AJAX/RecurringEntity.php +++ b/CRM/Core/Page/AJAX/RecurringEntity.php @@ -14,20 +14,20 @@ class CRM_Core_Page_AJAX_RecurringEntity { - public static function updateCascadeType(){ - if(CRM_Utils_Array::value('cascadeType', $_REQUEST) && CRM_Utils_Array::value('entityId', $_REQUEST)){ + public static function updateMode() { + if(CRM_Utils_Array::value('mode', $_REQUEST) && CRM_Utils_Array::value('entityId', $_REQUEST)){ $finalResult = array(); - $cascadeType = CRM_Utils_Type::escape($_REQUEST['cascadeType'], 'Integer'); + $mode = CRM_Utils_Type::escape($_REQUEST['mode'], 'Integer'); $entityId = CRM_Utils_Type::escape($_REQUEST['entityId'], 'Integer'); - + $sql = "UPDATE - civicrm_recurring_entity - SET cascade_type = (%1) - WHERE entity_id = (%2) AND entity_table = 'civicrm_event'"; + civicrm_recurring_entity + SET mode = %1 + WHERE entity_id = %2 AND entity_table = 'civicrm_event'"; $params = array( - 1 => array($cascadeType, 'Integer'), - 2 => array($entityId, 'Integer') - ); + 1 => array($mode, 'Integer'), + 2 => array($entityId, 'Integer') + ); CRM_Core_DAO::executeQuery($sql, $params); $finalResult['status'] = 'Done'; } diff --git a/CRM/Core/xml/Menu/Misc.xml b/CRM/Core/xml/Menu/Misc.xml index bd681ea47b..670660f0b3 100644 --- a/CRM/Core/xml/Menu/Misc.xml +++ b/CRM/Core/xml/Menu/Misc.xml @@ -176,12 +176,12 @@ access CiviCRM - civicrm/ajax/recurringEntity/update_cascade_type - CRM_Core_Page_AJAX_RecurringEntity::updateCascadeType + civicrm/ajax/recurringentity/update-mode + CRM_Core_Page_AJAX_RecurringEntity::updateMode access CiviCRM,access CiviEvent - civicrm/ajax/recurringEntity/generate_preview + civicrm/ajax/recurringentity/generate-preview CRM_Core_Page_AJAX_RecurringEntity::generatePreview access CiviCRM,access CiviEvent diff --git a/templates/CRM/Core/Form/RecurringEntity.tpl b/templates/CRM/Core/Form/RecurringEntity.tpl index a471e81d0a..793a9d78d0 100644 --- a/templates/CRM/Core/Form/RecurringEntity.tpl +++ b/templates/CRM/Core/Form/RecurringEntity.tpl @@ -262,7 +262,7 @@ } } }); - var ajaxurl = CRM.url("civicrm/ajax/recurringEntity/generate_preview"); + var ajaxurl = CRM.url("civicrm/ajax/recurringentity/generate-preview"); var eventID = {/literal}{$currentEntityId}{literal}; if(eventID != ""){ ajaxurl += "?event_id="+eventID; @@ -400,4 +400,4 @@ } } -{/literal} \ No newline at end of file +{/literal} diff --git a/templates/CRM/Event/Form/ManageEvent/ConfirmRepeatMode.tpl b/templates/CRM/Event/Form/ManageEvent/ConfirmRepeatMode.tpl index 22bb92ff37..dd2fe864fd 100644 --- a/templates/CRM/Event/Form/ManageEvent/ConfirmRepeatMode.tpl +++ b/templates/CRM/Event/Form/ManageEvent/ConfirmRepeatMode.tpl @@ -97,8 +97,8 @@ function updateMode(mode) { var eventID = {/literal}{$id}{literal}; if (eventID != "" && mode) { - var ajaxurl = CRM.url("civicrm/ajax/recurringEntity/update_cascade_type"); - var data = {cascadeType: mode, entityId: eventID}; + var ajaxurl = CRM.url("civicrm/ajax/recurringentity/update-mode"); + var data = {mode: mode, entityId: eventID}; $.ajax({ dataType: "json", data: data, diff --git a/xml/schema/Core/RecurringEntity.xml b/xml/schema/Core/RecurringEntity.xml index 1448925a3a..6d6b460af6 100644 --- a/xml/schema/Core/RecurringEntity.xml +++ b/xml/schema/Core/RecurringEntity.xml @@ -42,12 +42,11 @@ 4.6 - cascade_type - tinyint unsigned + mode + boolean 1 - 4 Cascade Type true 4.6 - \ No newline at end of file + -- 2.25.1