' . ts('Default versions of the following System Workflow Message Templates have been modified to handle new functionality: If you have modified these templates, please review the new default versions and implement updates as needed to your copies (Administer > Communications > Message Templates > System Workflow Messages).'); } if ($rev == '4.6.alpha3') { $postUpgradeMessage .= '

' . ts('A new permission has been added for editing message templates. Previously, users needed the "administer CiviCRM" permission. Now, users need the new permission called "edit message templates." Please check your CMS permissions to ensure that users who should be able to edit message templates are assigned this new permission.'); } } /** * (Queue Task Callback) */ public static function task_4_6_x_runSql(CRM_Queue_TaskContext $ctx, $rev) { $upgrade = new CRM_Upgrade_Form(); $upgrade->processSQL($rev); return TRUE; } /** * Syntactic sugar for adding a task which (a) is in this class and (b) has * a high priority. * * After passing the $funcName, you can also pass parameters that will go to * the function. Note that all params must be serializable. */ protected function addTask($title, $funcName) { $queue = CRM_Queue_Service::singleton()->load(array( 'type' => 'Sql', 'name' => CRM_Upgrade_Form::QUEUE_NAME, )); $args = func_get_args(); $title = array_shift($args); $funcName = array_shift($args); $task = new CRM_Queue_Task( array(get_class($this), $funcName), $args, $title ); $queue->createItem($task, array('weight' => -1)); } /** * Upgrade function. * * @param string $rev */ public function upgrade_4_6_alpha3($rev) { // Task to process sql. $this->addTask(ts('Add and update reference_date column for Schedule Reminders'), 'updateReferenceDate'); } /** * Add new column reference_date to civicrm_action_log in order to track. * * CRM-15728, actual action_start_date for membership entity for only those schedule reminders which are not repeatable * * @param \CRM_Queue_TaskContext $ctx * * @return bool */ public static function updateReferenceDate(CRM_Queue_TaskContext $ctx) { //Add column civicrm_action_log.reference_date if not exists. $sql = "SELECT count(*) FROM information_schema.columns WHERE table_schema = database() AND table_name = 'civicrm_action_log' AND COLUMN_NAME = 'reference_date' "; $res = CRM_Core_DAO::singleValueQuery($sql); if ($res <= 0) { $query = "ALTER TABLE `civicrm_action_log` ADD COLUMN `reference_date` date COMMENT 'Stores the date from the entity which triggered this reminder action (e.g. membership.end_date for most membership renewal reminders)'"; CRM_Core_DAO::executeQuery($query); } //Retrieve schedule reminders for membership entity and is not repeatable and no absolute date chosen. $query = "SELECT schedule.* FROM civicrm_action_schedule schedule LEFT JOIN civicrm_action_mapping mapper ON mapper.id = schedule.mapping_id AND mapper.entity = 'civicrm_membership' AND schedule.is_repeat = 0 AND schedule.start_action_date IS NOT NULL"; // construct basic where clauses $where = array( 'reminder.action_date_time >= DATE_SUB(reminder.action_date_time, INTERVAL 9 MONTH)', ); //choose reminder older then 9 months $dao = CRM_Core_DAO::executeQuery($query); while ($dao->fetch()) { $referenceColumn = str_replace('membership_', "m.", $dao->start_action_date); $value = implode(', ', explode(CRM_Core_DAO::VALUE_SEPARATOR, trim($dao->entity_value, CRM_Core_DAO::VALUE_SEPARATOR))); if (!empty($value)) { $where[] = "m.membership_type_id IN ({$value})"; } else { $where[] = "m.membership_type_id IS NULL"; } //Create new action_log records where action_start_date changes and exclude reminders for additional contacts //and select contacts are active $sql = "UPDATE civicrm_action_log reminder LEFT JOIN civicrm_membership m ON reminder.entity_id = m.id AND reminder.entity_table = 'civicrm_membership' AND ( m.is_override IS NULL OR m.is_override = 0 ) INNER JOIN civicrm_contact c ON c.id = e.contact_id AND c.is_deleted = 0 AND c.is_deceased = 0 SET reminder.reference_date = {$referenceColumn} WHERE " . implode(" AND ", $where); CRM_Core_DAO::executeQuery($sql); } return TRUE; } }