From 4d3e4dbe840719446712b7c46392f2e35787fd4d Mon Sep 17 00:00:00 2001 From: monishdeb Date: Tue, 2 Dec 2014 20:23:38 +0530 Subject: [PATCH] CRM-15291 fix - Remove CRM_Event_Form_ManageEvent_ScheduleReminders https://issues.civicrm.org/jira/browse/CRM-15291 --- CRM/Admin/Form/ScheduleReminders.php | 168 +++++--- .../Form/ManageEvent/ScheduleReminders.php | 382 ++---------------- CRM/Event/Form/ManageEvent/TabHeader.php | 10 +- .../CRM/Admin/Form/ScheduleReminders.tpl | 107 ++--- .../CRM/Admin/Page/ScheduleReminders.tpl | 31 +- .../Form/ManageEvent/ScheduleReminders.tpl | 195 --------- templates/CRM/Event/Page/ManageEvent.tpl | 7 +- 7 files changed, 228 insertions(+), 672 deletions(-) mode change 100755 => 100644 CRM/Event/Form/ManageEvent/ScheduleReminders.php delete mode 100755 templates/CRM/Event/Form/ManageEvent/ScheduleReminders.tpl diff --git a/CRM/Admin/Form/ScheduleReminders.php b/CRM/Admin/Form/ScheduleReminders.php index 06451c563d..5eb99bef50 100644 --- a/CRM/Admin/Form/ScheduleReminders.php +++ b/CRM/Admin/Form/ScheduleReminders.php @@ -57,13 +57,12 @@ class CRM_Admin_Form_ScheduleReminders extends CRM_Admin_Form { parent::buildQuickForm(); $this->_mappingID = $mappingID = NULL; $providersCount = CRM_SMS_BAO_Provider::activeProviderCount(); + $this->_context = CRM_Utils_Request::retrieve('context', 'String', $this); if ($this->_action & (CRM_Core_Action::DELETE)) { - $reminderName = - CRM_Core_DAO::getFieldValue('CRM_Core_DAO_ActionSchedule', $this->_id, 'title'); - $this->_context = CRM_Utils_Request::retrieve('context', 'String', $this); + $reminderName = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_ActionSchedule', $this->_id, 'title'); if ($this->_context == 'event') { - $this->_eventId = CRM_Utils_Request::retrieve('eventId', 'Integer', $this); + $this->_compId = CRM_Utils_Request::retrieve('compId', 'Integer', $this); } $this->assign('reminderName', $reminderName); return; @@ -71,19 +70,32 @@ class CRM_Admin_Form_ScheduleReminders extends CRM_Admin_Form { elseif ($this->_action & (CRM_Core_Action::UPDATE)) { $this->_mappingID = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_ActionSchedule', $this->_id, 'mapping_id'); - $this->_context = CRM_Utils_Request::retrieve('context', 'String', $this); if ($this->_context == 'event') { - $this->_eventId = CRM_Utils_Request::retrieve('eventId', 'Integer', $this); + $this->_compId = CRM_Utils_Request::retrieve('compId', 'Integer', $this); } } - - if (!empty($_POST) && !empty($_POST['entity'])) { - $mappingID = $_POST['entity'][0]; - } - elseif ($this->_mappingID) { - $mappingID = $this->_mappingID; + elseif (!empty($this->_context)) { + if ($this->_context == 'event') { + $this->_compId = CRM_Utils_Request::retrieve('compId', 'Integer', $this); + $field = 'civicrm_event'; + $isTemplate = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $this->_compId, 'is_template'); + if ($isTemplate) { + $field = 'event_template'; + } + $this->_mappingID = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_ActionMapping', $field, 'id', 'entity_value'); + if (!$this->_mappingID) { + CRM_Core_Error::fatal('Could not find mapping for event scheduled reminders.'); + } + } } + if (!empty($_POST) && !empty($_POST['entity']) && empty($this->_context)) { + $mappingID = $_POST['entity'][0]; + } + elseif ($this->_mappingID) { + $mappingID = $this->_mappingID; + } + $this->add( 'text', 'title', @@ -94,35 +106,44 @@ class CRM_Admin_Form_ScheduleReminders extends CRM_Admin_Form { $selectionOptions = CRM_Core_BAO_ActionSchedule::getSelection($mappingID); extract($selectionOptions); - - if (empty($sel1)) { - CRM_Core_Error::fatal('Could not find mapping for scheduled reminders.'); - } $this->assign('entityMapping', json_encode($entityMapping)); $this->assign('recipientMapping', json_encode($recipientMapping)); - $sel = & $this->add( - 'hierselect', - 'entity', - ts('Entity'), - array( - 'name' => 'entity[0]', - 'style' => 'vertical-align: top;', - ), - TRUE - ); - $sel->setOptions(array($sel1, $sel2, $sel3)); + if (empty($this->_context)) { + if (empty($sel1)) { + CRM_Core_Error::fatal('Could not find mapping for scheduled reminders.'); + } - if (is_a($sel->_elements[1], 'HTML_QuickForm_select')) { - // make second selector a multi-select - - $sel->_elements[1]->setMultiple(TRUE); - $sel->_elements[1]->setSize(5); - } + $sel = & $this->add( + 'hierselect', + 'entity', + ts('Entity'), + array( + 'name' => 'entity[0]', + 'style' => 'vertical-align: top;', + ), + TRUE + ); + $sel->setOptions(array($sel1, $sel2, $sel3)); - if (is_a($sel->_elements[2], 'HTML_QuickForm_select')) { - // make third selector a multi-select - - $sel->_elements[2]->setMultiple(TRUE); - $sel->_elements[2]->setSize(5); + if (is_a($sel->_elements[1], 'HTML_QuickForm_select')) { + // make second selector a multi-select - + $sel->_elements[1]->setMultiple(TRUE); + $sel->_elements[1]->setSize(5); + } + + if (is_a($sel->_elements[2], 'HTML_QuickForm_select')) { + // make third selector a multi-select - + $sel->_elements[2]->setMultiple(TRUE); + $sel->_elements[2]->setSize(5); + } + } + else { + $options = $sel3[$this->_mappingID][0]; + $attributes = array('multiple' => 'multiple', 'class' => 'crm-select2 huge', 'placeholder' => $options[0]); + unset($options[0]); + $this->add('select', 'entity', ts('Recipient(s)'), $options, TRUE, $attributes); + $this->assign('context', $this->_context); } //get the frequency units. @@ -208,11 +229,17 @@ class CRM_Admin_Form_ScheduleReminders extends CRM_Admin_Form { ); if (!empty($this->_submitValues['recipient_listing'])) { - $recipientListingOptions = CRM_Core_BAO_ActionSchedule::getRecipientListing($_POST['entity'][0], $_POST['recipient']); + if (!empty($this->_context)) { + $recipientListingOptions = CRM_Core_BAO_ActionSchedule::getRecipientListing($this->_mappingID, $this->_submitValues['recipient']); + } + else { + $recipientListingOptions = CRM_Core_BAO_ActionSchedule::getRecipientListing($_POST['entity'][0], $_POST['recipient']); + } } elseif (!empty($this->_values['recipient_listing'])) { $recipientListingOptions = CRM_Core_BAO_ActionSchedule::getRecipientListing($this->_values['mapping_id'], $this->_values['recipient']); } + $this->add('select', 'recipient_listing', ts('Recipient Roles'), $recipientListingOptions, FALSE, array('multiple' => TRUE, 'class' => 'crm-select2 huge', 'placeholder' => TRUE)); @@ -230,7 +257,7 @@ class CRM_Admin_Form_ScheduleReminders extends CRM_Admin_Form { $this->add('checkbox', 'is_active', $isActive); - $this->addFormRule(array('CRM_Admin_Form_ScheduleReminders', 'formRule')); + $this->addFormRule(array('CRM_Admin_Form_ScheduleReminders', 'formRule'), $this); $this->setPageTitle(ts('Scheduled Reminder')); } @@ -243,7 +270,7 @@ class CRM_Admin_Form_ScheduleReminders extends CRM_Admin_Form { * @access public * @static */ - static function formRule($fields) { + static function formRule($fields, $files, $self) { $errors = array(); if ((array_key_exists(1, $fields['entity']) && $fields['entity'][1][0] === 0) || (array_key_exists(2, $fields['entity']) && $fields['entity'][2][0] == 0) @@ -266,7 +293,7 @@ class CRM_Admin_Form_ScheduleReminders extends CRM_Admin_Form { $errors['subject'] = ts('Subject is a required field.'); } - if (CRM_Utils_System::isNull(CRM_Utils_Array::value(1, $fields['entity']))) { + if (empty($self->_context) && CRM_Utils_System::isNull(CRM_Utils_Array::value(1, $fields['entity']))) { $errors['entity'] = ts('Please select entity value'); } @@ -308,15 +335,16 @@ class CRM_Admin_Form_ScheduleReminders extends CRM_Admin_Form { } else { $defaults = $this->_values; - $entityValue = explode(CRM_Core_DAO::VALUE_SEPARATOR, - CRM_Utils_Array::value('entity_value', $defaults) - ); - $entityStatus = explode(CRM_Core_DAO::VALUE_SEPARATOR, - CRM_Utils_Array::value('entity_status', $defaults) - ); - $defaults['entity'][0] = CRM_Utils_Array::value('mapping_id', $defaults); - $defaults['entity'][1] = $entityValue; - $defaults['entity'][2] = $entityStatus; + $entityValue = explode(CRM_Core_DAO::VALUE_SEPARATOR, CRM_Utils_Array::value('entity_value', $defaults)); + $entityStatus = explode(CRM_Core_DAO::VALUE_SEPARATOR, CRM_Utils_Array::value('entity_status', $defaults)); + if (empty($this->_context)) { + $defaults['entity'][0] = CRM_Utils_Array::value('mapping_id', $defaults); + $defaults['entity'][1] = $entityValue; + $defaults['entity'][2] = $entityStatus; + } + else { + $defaults['entity'] = $entityStatus; + } if ($absoluteDate = CRM_Utils_Array::value('absolute_date', $defaults)) { list($date, $time) = CRM_Utils_Date::setDateDefaults($absoluteDate); $defaults['absolute_date'] = $date; @@ -356,9 +384,9 @@ class CRM_Admin_Form_ScheduleReminders extends CRM_Admin_Form { // delete reminder CRM_Core_BAO_ActionSchedule::del($this->_id); CRM_Core_Session::setStatus(ts('Selected Reminder has been deleted.'), ts('Record Deleted'), 'success'); - if ($this->_context == 'event' && $this->_eventId) { + if ($this->_context == 'event' && $this->_compId) { $url = CRM_Utils_System::url('civicrm/event/manage/reminder', - "reset=1&action=update&id={$this->_eventId}" + "reset=1&action=browse&id={$this->_compId}&component={$this->_context}&setTab=1" ); $session = CRM_Core_Session::singleton(); $session->pushUserContext($url); @@ -436,17 +464,22 @@ class CRM_Admin_Form_ScheduleReminders extends CRM_Admin_Form { $params['group_id'] = $params['recipient_manual'] = $params['recipient_listing'] = 'null'; } - $params['mapping_id'] = $values['entity'][0]; - $entity_value = $values['entity'][1]; - $entity_status = $values['entity'][2]; - - if ($entity_value == 1) { - $params['limit_to'] = 1; + if (!empty($this->_mappingID) && !empty($this->_compId)) { + $params['mapping_id'] = $this->_mappingID; + $params['entity_value'] = $this->_compId; + $params['entity_status'] = implode(CRM_Core_DAO::VALUE_SEPARATOR, $values['entity']); } + else { + $params['mapping_id'] = $values['entity'][0]; + $entity_value = $values['entity'][1]; + $entity_status = $values['entity'][2]; + if ($entity_value == 1) { + $params['limit_to'] = 1; + } - foreach (array( - 'entity_value', 'entity_status') as $key) { - $params[$key] = implode(CRM_Core_DAO::VALUE_SEPARATOR, $$key); + foreach (array('entity_value', 'entity_status') as $key) { + $params[$key] = implode(CRM_Core_DAO::VALUE_SEPARATOR, $$key); + } } $params['is_active'] = CRM_Utils_Array::value('is_active', $values, 0); @@ -561,15 +594,16 @@ class CRM_Admin_Form_ScheduleReminders extends CRM_Admin_Form { $status = ts("Your new Reminder titled %1 has been saved.", array(1 => "{$values['title']}") ); - if ($this->_action & CRM_Core_Action::UPDATE) { - $status = ts("Your Reminder titled %1 has been updated.", - array(1 => "{$values['title']}") - ); - if ($this->_context == 'event' && $this->_eventId) { - $url = CRM_Utils_System::url('civicrm/event/manage/reminder', - "reset=1&action=update&id={$this->_eventId}" + if ($this->_action) { + if ($this->_action & CRM_Core_Action::UPDATE) { + $status = ts("Your Reminder titled %1 has been updated.", + array(1 => "{$values['title']}") ); + } + + if ($this->_context == 'event' && $this->_compId) { + $url = CRM_Utils_System::url('civicrm/event/manage/reminder', "reset=1&action=browse&id={$this->_compId}&component={$this->_context}&setTab=1"); $session = CRM_Core_Session::singleton(); $session->pushUserContext($url); } diff --git a/CRM/Event/Form/ManageEvent/ScheduleReminders.php b/CRM/Event/Form/ManageEvent/ScheduleReminders.php old mode 100755 new mode 100644 index 763edabb6e..f0b0f2b4a6 --- a/CRM/Event/Form/ManageEvent/ScheduleReminders.php +++ b/CRM/Event/Form/ManageEvent/ScheduleReminders.php @@ -48,361 +48,51 @@ class CRM_Event_Form_ManageEvent_ScheduleReminders extends CRM_Event_Form_Manage */ function preProcess() { parent::preProcess(); + $setTab = CRM_Utils_Request::retrieve('setTab', 'Int', $this, FALSE, 0); + $component = CRM_Utils_Request::retrieve('component', 'String', $this); - $newReminder = CRM_Utils_Request::retrieve('new', 'Boolean', $this, FALSE, FALSE); - if ($this->_action & CRM_Core_Action::UPDATE && - !$newReminder - ) { - $field = 'civicrm_event'; - if ($this->_isTemplate) { - $field = 'event_template'; - } - $reminderList = CRM_Core_BAO_ActionSchedule::getList(FALSE, $field, $this->_id ); - if ($reminderList && is_array($reminderList)) { - // Add action links to each of the reminders - foreach ($reminderList as & $format) { - $action = CRM_Core_Action::UPDATE + CRM_Core_Action::DELETE; - if ($format['is_active']) { - $action += CRM_Core_Action::DISABLE; - } - else { - $action += CRM_Core_Action::ENABLE; - } - $scheduleReminder = new CRM_Admin_Page_ScheduleReminders; - $links = $scheduleReminder->links(); - $links[CRM_Core_Action::DELETE]['qs'] .= "&context=event&eventId={$this->_id}"; - $links[CRM_Core_Action::UPDATE]['qs'] .= "&context=event&eventId={$this->_id}"; - $format['action'] = CRM_Core_Action::formLink( - $links, - $action, - array('id' => $format['id']), - ts('more'), - FALSE, - 'event.reminder.list', - 'Event', - $this->_id - ); - } - } - else { - $reminderList = TRUE; - } - $this->assign('rows', $reminderList); - - // Update tab "disabled" css class - $this->ajaxResponse['tabValid'] = !empty($reminderList) && is_array($reminderList); - } - $this->setPageTitle(ts('Scheduled Reminder')); - } - - /** - * Set default values for the form. For edit/view mode - * the default values are retrieved from the database - * - * @access public - * - * @return void - */ - function setDefaultValues() { - $defaults = array(); - $defaults['is_active'] = 1; - $defaults['record_activity'] = 1; - return $defaults; - } - - /** - * Build the form object - * - * @return void - * @access public - */ - public function buildQuickForm() { $field = 'civicrm_event'; if ($this->_isTemplate) { $field = 'event_template'; } - $this->_mappingID = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_ActionMapping', $field, 'id', 'entity_value'); - if (!$this->_mappingID) { - CRM_Core_Error::fatal('Could not find mapping for event scheduled reminders.'); - } - - parent::buildQuickForm(); - $this->add('text', 'title', ts('Reminder Name'), - array( - 'size' => 45, - 'maxlength' => 128 - ), TRUE - ); - - $selectionOptions = CRM_Core_BAO_ActionSchedule::getSelection($this->_mappingID); - extract($selectionOptions); - - $this->assign('recipientMapping', json_encode($recipientMapping)); - - // Fixme: hack to adjust the output of CRM_Core_BAO_ActionSchedule::getSelection so it looks nice with the jQuery.select2 plugin - // TODO: fix this upstream - $options = $sel3[$this->_mappingID][0]; - $attributes = array('multiple' => 'multiple', 'class' => 'crm-select2 huge', 'placeholder' => $options[0]); - unset($options[0]); - $entity = $this->add('select', 'entity', ts('Recipient(s)'), $options, TRUE, $attributes); - - //get the frequency units. - $this->_freqUnits = array('hour' => 'hour') + CRM_Core_OptionGroup::values('recur_frequency_units'); - - $numericOptions = CRM_Core_SelectValues::getNumericOptions(0, 30); - - //reminder_interval - $this->add('select', 'start_action_offset', ts('When'), $numericOptions); - - foreach ($this->_freqUnits as $val => $label) { - $freqUnitsDisplay[$val] = ts('%1(s)', array(1 => $label)); - } - - $this->addDate('absolute_date', ts('Start Date'), FALSE, - array('formatType' => 'mailing') - ); - - //reminder_frequency - $this->add('select', 'start_action_unit', ts('Frequency'), $freqUnitsDisplay, TRUE); - - $condition = array('before' => ts('before'), - 'after' => ts('after'), - ); - //reminder_action - $this->add('select', 'start_action_condition', ts('Action Condition'), $condition); - - $this->add('select', 'start_action_date', ts('Date Field'), $sel4, TRUE); - - $this->addElement('checkbox', 'record_activity', ts('Record activity for automated email')); - - $this->addElement('checkbox', 'is_repeat', ts('Repeat'), - NULL, array('onclick' => "return showHideByValue('is_repeat',true,'repeatFields','table-row','radio',false);") - ); - - $this->add('select', 'repetition_frequency_unit', ts('every'), $freqUnitsDisplay); - $this->add('select', 'repetition_frequency_interval', ts('every'), $numericOptions); - $this->add('select', 'end_frequency_unit', ts('until'), $freqUnitsDisplay); - $this->add('select', 'end_frequency_interval', ts('until'), $numericOptions); - $this->add('select', 'end_action', ts('Repetition Condition'), $condition, TRUE); - $this->add('select', 'end_date', ts('Date Field'), $sel4, TRUE); - - $recipient = 'event_contacts'; - $limitOptions = array(1 => ts('Limit to'), 0 => ts('Addition to')); - $this->add('select', 'limit_to', ts('Limit Options'), $limitOptions); - - $this->add('select', 'recipient', ts('Recipients'), $sel5[$recipient], - FALSE, array('onchange' => "showHideByValue('recipient','manual','recipientManual','table-row','select',false); showHideByValue('recipient','group','recipientGroup','table-row','select',false);") - ); - $recipientListing = $this->add('select', 'recipient_listing', ts('Recipient Roles'), - $sel3[$this->_mappingID][0], FALSE, array('multiple' => TRUE, 'class' => 'crm-select2 huge', 'placeholder' => TRUE) - ); - - $this->addEntityRef('recipient_manual_id', ts('Manual Recipients'), array('multiple' => true)); - - $this->add('select', 'group_id', ts('Group'), - CRM_Core_PseudoConstant::nestedGroup(), FALSE, array('class' => 'crm-select2 huge') - ); - - CRM_Mailing_BAO_Mailing::commonCompose($this); - - $this->add('text', 'subject', ts('Subject'), - CRM_Core_DAO::getAttribute('CRM_Core_DAO_ActionSchedule', 'subject') - ); - - $this->add('checkbox', 'is_active', ts('Send email')); - - $this->addFormRule(array('CRM_Event_Form_ManageEvent_ScheduleReminders', 'formRule')); - } - - /** - * Global validation rules for the form - * - * @param array $fields posted values of the form - * - * @return array list of errors to be posted back to the form - * @static - * @access public - */ - static function formRule($fields) { - $errors = array(); - if (!empty($fields['is_active']) && - CRM_Utils_System::isNull($fields['subject']) - ) { - $errors['subject'] = ts('Subject is a required field.'); - } - - if (!CRM_Utils_System::isNull($fields['absolute_date'])) { - if (CRM_Utils_Date::format(CRM_Utils_Date::processDate($fields['absolute_date'], NULL)) < CRM_Utils_Date::format(date('YmdHi00'))) { - $errors['absolute_date'] = ts('Absolute date cannot be earlier than the current time.'); - } - } - - if (!empty($errors)) { - return $errors; - } - - return empty($errors) ? TRUE : $errors; - } - - /** - * Process the form submission - * - * @access public - * - * @return void - */ - public function postProcess() { - if ($this->_action & CRM_Core_Action::DELETE) { - // delete reminder - CRM_Core_BAO_ActionSchedule::del($this->_id); - CRM_Core_Session::setStatus(ts('Selected Reminder has been deleted.'), ts('Record Deleted'), 'success'); - return; - } - - $values = $this->controller->exportValues($this->getName()); - $keys = array( - 'title', - 'subject', - 'absolute_date', - 'group_id', - 'record_activity', - 'limit_to' - ); - foreach ($keys as $key) { - $params[$key] = CRM_Utils_Array::value($key, $values); - } - - $moreKeys = array( - 'start_action_offset', - 'start_action_unit', - 'start_action_condition', - 'start_action_date', - 'repetition_frequency_unit', - 'repetition_frequency_interval', - 'end_frequency_unit', - 'end_frequency_interval', - 'end_action', - 'end_date', - ); - - if ($absoluteDate = CRM_Utils_Array::value('absolute_date', $params)) { - $params['absolute_date'] = CRM_Utils_Date::processDate($absoluteDate); - foreach ($moreKeys as $mkey) { - $params[$mkey] = 'null'; - } - } - else { - $params['absolute_date'] = 'null'; - foreach ($moreKeys as $mkey) { - $params[$mkey] = CRM_Utils_Array::value($mkey, $values); - } - } - - $params['body_text'] = CRM_Utils_Array::value('text_message', $values); - $params['body_html'] = CRM_Utils_Array::value('html_message', $values); - - if (CRM_Utils_Array::value('recipient', $values) == 'manual') { - $params['recipient_manual'] = CRM_Utils_Array::value('recipient_manual_id', $values); - $params['group_id'] = $params['recipient'] = $params['recipient_listing'] = 'null'; - } - elseif (CRM_Utils_Array::value('recipient', $values) == 'group') { - $params['group_id'] = $values['group_id']; - $params['recipient_manual'] = $params['recipient'] = $params['recipient_listing'] = 'null'; - } - elseif (!CRM_Utils_System::isNull($values['recipient_listing'])) { - $params['recipient'] = CRM_Utils_Array::value('recipient', $values); - $params['recipient_listing'] = implode(CRM_Core_DAO::VALUE_SEPARATOR, - CRM_Utils_Array::value('recipient_listing', $values) - ); - $params['group_id'] = $params['recipient_manual'] = 'null'; - } - else { - $params['recipient'] = CRM_Utils_Array::value('recipient', $values); - $params['group_id'] = $params['recipient_manual'] = $params['recipient_listing'] = 'null'; - } - - $params['mapping_id'] = $this->_mappingID; - - $params['entity_value'] = $this->_id; - $params['entity_status'] = implode(CRM_Core_DAO::VALUE_SEPARATOR, $values['entity']); - $params['is_active'] = CRM_Utils_Array::value('is_active', $values, 0); - $params['is_repeat'] = CRM_Utils_Array::value('is_repeat', $values, 0); - - if (CRM_Utils_Array::value('is_repeat', $values) == 0) { - $params['repetition_frequency_unit'] = 'null'; - $params['repetition_frequency_interval'] = 'null'; - $params['end_frequency_unit'] = 'null'; - $params['end_frequency_interval'] = 'null'; - $params['end_action'] = 'null'; - $params['end_date'] = 'null'; - } - $params['name'] = CRM_Utils_String::munge($params['title'], '_', 64); - - $composeFields = array( - 'template', 'saveTemplate', - 'updateTemplate', 'saveTemplateName', - ); - $msgTemplate = NULL; - //mail template is composed - $composeParams = array(); - foreach ($composeFields as $key) { - if (!empty($values[$key])) { - $composeParams[$key] = $values[$key]; + $reminderList = CRM_Core_BAO_ActionSchedule::getList(FALSE, $field, $this->_id); + if ($reminderList && is_array($reminderList)) { + // Add action links to each of the reminders + foreach ($reminderList as & $format) { + $action = CRM_Core_Action::UPDATE + CRM_Core_Action::DELETE; + if ($format['is_active']) { + $action += CRM_Core_Action::DISABLE; + } + else { + $action += CRM_Core_Action::ENABLE; + } + $scheduleReminder = new CRM_Admin_Page_ScheduleReminders; + $links = $scheduleReminder->links(); + $links[CRM_Core_Action::DELETE]['qs'] .= "&context=event&compId={$this->_id}"; + $links[CRM_Core_Action::UPDATE]['qs'] .= "&context=event&compId={$this->_id}"; + $format['action'] = CRM_Core_Action::formLink( + $links, + $action, + array('id' => $format['id']), + ts('more'), + FALSE, + 'actionSchedule.manage.action', + 'ActionSchedule', + $this->_id + ); } } - if (!empty($composeParams['updateTemplate'])) { - $templateParams = array( - 'msg_text' => $params['body_text'], - 'msg_html' => $params['body_html'], - 'msg_subject' => $params['subject'], - 'is_active' => TRUE, - ); - - $templateParams['id'] = $values['template']; - - $msgTemplate = CRM_Core_BAO_MessageTemplate::add($templateParams); - } + $this->assign('rows', $reminderList); + $this->assign('setTab' , $setTab); + $this->assign('component' , $component); - if (!empty($composeParams['saveTemplate'])) { - $templateParams = array( - 'msg_text' => $params['body_text'], - 'msg_html' => $params['body_html'], - 'msg_subject' => $params['subject'], - 'is_active' => TRUE, - ); - - $templateParams['msg_title'] = $composeParams['saveTemplateName']; - - $msgTemplate = CRM_Core_BAO_MessageTemplate::add($templateParams); - } - - if (isset($msgTemplate->id)) { - $params['msg_template_id'] = $msgTemplate->id; - } - else { - $params['msg_template_id'] = CRM_Utils_Array::value('template', $values); - } - - CRM_Core_BAO_ActionSchedule::add($params); - - $status = ts("Your new Reminder titled %1 has been saved.", - array(1 => "{$values['title']}") - ); - - CRM_Core_Session::setStatus($status, ts('Saved'), 'success'); - - parent::endPostProcess(); + // Update tab "disabled" css class + $this->ajaxResponse['tabValid'] = is_array($reminderList) && (count($reminderList) > 0); + $this->setPageTitle(ts('Scheduled Reminder')); } - /** - * Return a descriptive name for the page, used in wizard header - * - * @return string - * @access public - */ - public function getTitle() { - return ts('Event Schedule Reminder'); + function getTemplateFileName() { + return 'CRM/Admin/Page/ScheduleReminders.tpl'; } -} - +} \ No newline at end of file diff --git a/CRM/Event/Form/ManageEvent/TabHeader.php b/CRM/Event/Form/ManageEvent/TabHeader.php index 893df6fce6..7beb7deaa7 100644 --- a/CRM/Event/Form/ManageEvent/TabHeader.php +++ b/CRM/Event/Form/ManageEvent/TabHeader.php @@ -151,6 +151,8 @@ WHERE e.id = %1 $fullName = $form->getVar('_name'); $className = CRM_Utils_String::getClassName($fullName); $new = ''; + $action = 'update'; + // hack for special cases. switch ($className) { case 'Event': @@ -164,7 +166,6 @@ WHERE e.id = %1 case 'ScheduleReminders': $class = 'reminder'; - $new = !empty($_GET['new']) ? '&new=1' : ''; break; default: @@ -188,8 +189,12 @@ WHERE e.id = %1 $tabs[$key]['qfKey'] = NULL; } + if ($key == 'reminder') { + $action = 'browse'; + } + $tabs[$key]['link'] = CRM_Utils_System::url("civicrm/event/manage/{$key}", - "{$reset}action=update&id={$eventID}&component=event{$new}{$tabs[$key]['qfKey']}" + "{$reset}action={$action}&id={$eventID}&component=event{$tabs[$key]['qfKey']}" ); } } @@ -230,4 +235,3 @@ WHERE e.id = %1 return $current; } } - diff --git a/templates/CRM/Admin/Form/ScheduleReminders.tpl b/templates/CRM/Admin/Form/ScheduleReminders.tpl index 70750f2262..4637412cca 100644 --- a/templates/CRM/Admin/Form/ScheduleReminders.tpl +++ b/templates/CRM/Admin/Form/ScheduleReminders.tpl @@ -165,7 +165,7 @@ } {literal} - - {/literal} + }); + +{/literal} {/if} diff --git a/templates/CRM/Admin/Page/ScheduleReminders.tpl b/templates/CRM/Admin/Page/ScheduleReminders.tpl index 40ecbf322c..a992cd96a9 100644 --- a/templates/CRM/Admin/Page/ScheduleReminders.tpl +++ b/templates/CRM/Admin/Page/ScheduleReminders.tpl @@ -25,16 +25,22 @@ +--------------------------------------------------------------------+ *} {* this template is for configuring Scheduled Reminders *} - +{if $setTab eq 1} + {if $component eq 'event'} + {include file="CRM/Event/Form/ManageEvent/Tab.tpl"} + {/if} +{else} {if $action eq 1 or $action eq 2 or $action eq 8 or $action eq 16384} {include file="CRM/Admin/Form/ScheduleReminders.tpl"} {else} {* include wysiwyg related files*} {include file="CRM/common/wysiwyg.tpl" includeWysiwygEditor=true} - {capture assign=schedRemindersDocLink}{docURL page="user/current/email/scheduled-reminders/"}{/capture} -
- {ts}Scheduled reminders allow you to automatically send messages to contacts regarding their memberships, participation in events, or other activities.{/ts} {$schedRemindersDocLink} -
+ {if !$component} + {capture assign=schedRemindersDocLink}{docURL page="user/current/email/scheduled-reminders/"}{/capture} +
+ {ts}Scheduled reminders allow you to automatically send messages to contacts regarding their memberships, participation in events, or other activities.{/ts} {$schedRemindersDocLink} +
+ {/if} {if $rows}
{include file="CRM/Admin/Page/Reminders.tpl"} @@ -42,10 +48,21 @@ {else}
- {ts}None found.{/ts} + {if $component} + {ts}No Scheduled Reminders have been created for this {$component}.{/ts} + {else} + {ts}None found.{/ts} + {/if}
{/if} {/if} +{/if} diff --git a/templates/CRM/Event/Form/ManageEvent/ScheduleReminders.tpl b/templates/CRM/Event/Form/ManageEvent/ScheduleReminders.tpl deleted file mode 100755 index 6095070c6a..0000000000 --- a/templates/CRM/Event/Form/ManageEvent/ScheduleReminders.tpl +++ /dev/null @@ -1,195 +0,0 @@ -{* - +--------------------------------------------------------------------+ - | CiviCRM version 4.5 | - +--------------------------------------------------------------------+ - | Copyright (C) 2011 Marty Wright | - | Licensed to CiviCRM under the Academic Free License version 3.0. | - +--------------------------------------------------------------------+ - | This file is a part of CiviCRM. | - | | - | CiviCRM is free software; you can copy, modify, and distribute it | - | under the terms of the GNU Affero General Public License | - | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. | - | | - | CiviCRM is distributed in the hope that it will be useful, but | - | WITHOUT ANY WARRANTY; without even the implied warranty of | - | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | - | See the GNU Affero General Public License for more details. | - | | - | You should have received a copy of the GNU Affero General Public | - | License and the CiviCRM Licensing Exception along | - | with this program; if not, contact CiviCRM LLC | - | at info[AT]civicrm[DOT]org. If you have questions about the | - | GNU Affero General Public License or the licensing of CiviCRM, | - | see the CiviCRM license FAQ at http://civicrm.org/licensing | - +--------------------------------------------------------------------+ -*} -{* This template is used for adding/scheduling reminders. *} -
- - {if $rows} -
- {include file="CRM/Admin/Page/Reminders.tpl"} - - -
- - {else} - -
- {include file="CRM/common/formButtons.tpl" location="top"} -
- {if $action eq 8} -
-
- {ts 1=$reminderName}WARNING: You are about to delete the Reminder titled %1.{/ts} {ts}Do you want to continue?{/ts} -
- {else} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
{$form.title.label}{$form.title.html}
{$form.entity.label}{$form.entity.html}
{$form.start_action_offset.label}{include file="CRM/common/jcalendar.tpl" elementName=absolute_date} {ts}OR{/ts}
{$form.start_action_offset.html}   {$form.start_action_unit.html}   {$form.start_action_condition.html}   {$form.start_action_date.html}
{$form.record_activity.label}{$form.record_activity.html}
{$form.is_repeat.label}{$form.is_repeat.html}  {ts}Enable repetition.{/ts}
- - - - - - - - -
{$form.repetition_frequency_interval.label}   {$form.repetition_frequency_interval.html}{$form.repetition_frequency_unit.html}
{$form.end_frequency_interval.label}   {$form.end_frequency_interval.html} - {$form.end_frequency_unit.html}   {$form.end_action.html}   {$form.end_date.html}
-
{$form.recipient.label}{$form.limit_to.html}  {$form.recipient.html}  {help id="recipient" file="CRM/Admin/Page/ScheduleReminders.hlp" title=$form.recipient.label}
{$form.recipient_listing.label}{$form.recipient_listing.html}
{$form.recipient_manual_id.label}{$form.recipient_manual_id.html}{edit}
{ts}You can manually send out the reminders to these recipients.{/ts}
{/edit}
{$form.group_id.label}{$form.group_id.html}
-
{ts}Email{/ts} - - - - - - - - - - - - - -
{$form.is_active.html} {$form.is_active.label}
{$form.template.label}{$form.template.html}
{$form.subject.label}{$form.subject.html}
- {include file="CRM/Contact/Form/Task/EmailCommon.tpl" upload=1 noAttach=1} -
- - {include file="CRM/common/showHideByFieldValue.tpl" - trigger_field_id = "is_repeat" - trigger_value = "true" - target_element_id = "repeatFields" - target_element_type = "table-row" - field_type = "radio" - invert = "false" - } - - {include file="CRM/common/showHideByFieldValue.tpl" - trigger_field_id ="recipient" - trigger_value = 'manual' - target_element_id ="recipientManual" - target_element_type ="table-row" - field_type ="select" - invert = 0 - } - - {include file="CRM/common/showHideByFieldValue.tpl" - trigger_field_id ="recipient" - trigger_value = 'group' - target_element_id ="recipientGroup" - target_element_type ="table-row" - field_type ="select" - invert = 0 - } - - {literal} - - {/literal} - {/if} -
- {include file="CRM/common/formButtons.tpl" location="bottom"} -
-
-{/if} diff --git a/templates/CRM/Event/Page/ManageEvent.tpl b/templates/CRM/Event/Page/ManageEvent.tpl index 58492647a1..06db993866 100644 --- a/templates/CRM/Event/Page/ManageEvent.tpl +++ b/templates/CRM/Event/Page/ManageEvent.tpl @@ -109,8 +109,13 @@ {foreach from=$rows.tab key=k item=v} {assign var="fld" value=$v.field} {if NOT $row.$fld}{assign var="status" value="disabled"}{else}{assign var="status" value="enabled"}{/if} -
  • {$v.title} + {else} +
  • {$v.title}
  • + {/if} {/foreach} -- 2.25.1