当前位置: 首页>>代码示例>>PHP>>正文


PHP CRM_Core_BAO_ActionSchedule::add方法代码示例

本文整理汇总了PHP中CRM_Core_BAO_ActionSchedule::add方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_BAO_ActionSchedule::add方法的具体用法?PHP CRM_Core_BAO_ActionSchedule::add怎么用?PHP CRM_Core_BAO_ActionSchedule::add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CRM_Core_BAO_ActionSchedule的用法示例。


在下文中一共展示了CRM_Core_BAO_ActionSchedule::add方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: civicrm_api3_action_schedule_create

/**
 * Create a new Action Schedule
 *
 * @param array $params
 *
 * @return array
 *
 * {@getfields action_schedule_create}
 */
function civicrm_api3_action_schedule_create($params)
{
    if (empty($params['id'])) {
        // an update does not require any mandatory parameters
        civicrm_api3_verify_one_mandatory($params, NULL, array('title', 'mapping_id', 'entity_status', 'entity_value'));
    }
    $ids = array();
    if (isset($params['id']) && !CRM_Utils_Rule::integer($params['id'])) {
        return civicrm_api3_create_error('Invalid value for ID');
    }
    if (!array_key_exists('name', $params) && !array_key_exists('id', $params)) {
        $params['name'] = CRM_Utils_String::munge($params['title']);
    }
    $actionSchedule = new CRM_Core_BAO_ActionSchedule();
    $actionSchedule = CRM_Core_BAO_ActionSchedule::add($params, $ids);
    $actSchedule = array();
    _civicrm_api3_object_to_array($actionSchedule, $actSchedule[$actionSchedule->id]);
    return civicrm_api3_create_success($actSchedule, $params, 'action_schedule', 'create', $actionSchedule);
}
开发者ID:archcidburnziso,项目名称:civicrm-core,代码行数:28,代码来源:ActionSchedule.php

示例2: postProcess

 /**
  * Function to process the form
  *
  * @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];
         }
     }
     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);
     }
     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, $ids);
     $status = ts("Your new Reminder titled %1 has been saved.", array(1 => "<strong>{$values['title']}</strong>"));
     CRM_Core_Session::setStatus($status, ts('Saved'), 'success');
     parent::endPostProcess();
 }
开发者ID:archcidburnziso,项目名称:civicrm-core,代码行数:91,代码来源:ScheduleReminders.php

示例3: postProcess

 /**
  * Function to process the form
  *
  * @access public
  *
  * @return None
  */
 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.'));
         if ($this->_context == 'event' && $this->_eventId) {
             $url = CRM_Utils_System::url('civicrm/event/manage/reminder', "reset=1&action=update&id={$this->_eventId}");
             $session = CRM_Core_Session::singleton();
             $session->pushUserContext($url);
         }
         return;
     }
     $values = $this->controller->exportValues($this->getName());
     $keys = array('title', 'subject', 'absolute_date', 'group_id');
     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'] = $values['entity'][0];
     $entity_value = $values['entity'][1];
     $entity_status = $values['entity'][2];
     //force recording activity for membership reminder
     if ($params['mapping_id'] == 4) {
         $params['record_activity'] = 1;
     }
     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);
     $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';
     }
     if ($this->_action & CRM_Core_Action::UPDATE) {
         $params['id'] = $this->_id;
     } elseif ($this->_action & CRM_Core_Action::ADD) {
         // we do this only once, so name never changes
         $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 (CRM_Utils_Array::value($key, $values)) {
             $composeParams[$key] = $values[$key];
         }
     }
     if (CRM_Utils_Array::value('updateTemplate', $composeParams)) {
         $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_MessageTemplates::add($templateParams);
     }
     if (CRM_Utils_Array::value('saveTemplate', $composeParams)) {
         $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_MessageTemplates::add($templateParams);
     }
     if (isset($msgTemplate->id)) {
         $params['msg_template_id'] = $msgTemplate->id;
//.........这里部分代码省略.........
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:101,代码来源:ScheduleReminders.php

示例4: testRepetitionFrequencyUnit

 /**
  * Test that the various repetition units work correctly.
  * CRM-17028
  */
 public function testRepetitionFrequencyUnit()
 {
     $membershipTypeParams = array('duration_interval' => '1', 'duration_unit' => 'year', 'is_active' => 1, 'period_type' => 'rolling');
     $membershipType = $this->createTestObject('CRM_Member_DAO_MembershipType', $membershipTypeParams);
     $interval_units = array('hour', 'day', 'week', 'month', 'year');
     foreach ($interval_units as $interval_unit) {
         $membershipEndDate = DateTime::createFromFormat('Y-m-d H:i:s', "2013-03-15 00:00:00");
         $contactParams = array('contact_type' => 'Individual', 'first_name' => 'Test', 'last_name' => "Interval {$interval_unit}", 'is_deceased' => 0);
         $contact = $this->createTestObject('CRM_Contact_DAO_Contact', $contactParams);
         $this->assertTrue(is_numeric($contact->id));
         $emailParams = array('contact_id' => $contact->id, 'email' => "test-member-{$interval_unit}@example.com", 'location_type_id' => 1);
         $email = $this->createTestObject('CRM_Core_DAO_Email', $emailParams);
         $this->assertTrue(is_numeric($email->id));
         $membershipParams = array('membership_type_id' => $membershipType->id, 'contact_id' => $contact->id, 'join_date' => '20120315', 'start_date' => '20120315', 'end_date' => '20130315', 'is_override' => 0, 'status_id' => 2);
         $membershipParams['status-id'] = 1;
         $membership = $this->createTestObject('CRM_Member_DAO_Membership', $membershipParams);
         $actionScheduleParams = $this->fixtures['sched_on_membership_end_date_repeat_interval'];
         $actionScheduleParams['entity_value'] = $membershipType->id;
         $actionScheduleParams['repetition_frequency_unit'] = $interval_unit;
         $actionScheduleParams['repetition_frequency_interval'] = 2;
         $actionSchedule = CRM_Core_BAO_ActionSchedule::add($actionScheduleParams);
         $this->assertTrue(is_numeric($actionSchedule->id));
         $beforeEndDate = $this->createModifiedDateTime($membershipEndDate, '-1 day');
         $beforeFirstUnit = $this->createModifiedDateTime($membershipEndDate, "+1 {$interval_unit}");
         $afterFirstUnit = $this->createModifiedDateTime($membershipEndDate, "+2 {$interval_unit}");
         $cronRuns = array(array('time' => $beforeEndDate->format('Y-m-d H:i:s'), 'recipients' => array()), array('time' => $membershipEndDate->format('Y-m-d H:i:s'), 'recipients' => array(array("test-member-{$interval_unit}@example.com"))), array('time' => $beforeFirstUnit->format('Y-m-d H:i:s'), 'recipients' => array()), array('time' => $afterFirstUnit->format('Y-m-d H:i:s'), 'recipients' => array(array("test-member-{$interval_unit}@example.com"))));
         $this->assertCronRuns($cronRuns);
         $actionSchedule->delete();
         $membership->delete();
     }
 }
开发者ID:konadave,项目名称:civicrm-core,代码行数:35,代码来源:ActionScheduleTest.php

示例5: postProcess

 /**
  * Process the form submission.
  *
  * @param array $params
  * @param string $type
  * @param array $linkedEntities
  *
  * @throws \CiviCRM_API3_Exception
  */
 public static function postProcess($params = array(), $type, $linkedEntities = array())
 {
     //Check entity_id not present in params take it from class variable
     if (empty($params['entity_id'])) {
         $params['entity_id'] = self::$_entityId;
     }
     //Process this function only when you get this variable
     if ($params['allowRepeatConfigToSubmit'] == 1) {
         if (!empty($params['entity_table']) && !empty($params['entity_id']) && $type) {
             $params['used_for'] = $type;
             if (empty($params['parent_entity_id'])) {
                 $params['parent_entity_id'] = self::$_parentEntityId;
             }
             if (!empty($params['schedule_reminder_id'])) {
                 $params['id'] = $params['schedule_reminder_id'];
             } else {
                 $params['id'] = self::$_scheduleReminderID;
             }
             //Save post params to the schedule reminder table
             $recurobj = new CRM_Core_BAO_RecurringEntity();
             $dbParams = $recurobj->mapFormValuesToDB($params);
             //Delete repeat configuration and rebuild
             if (!empty($params['id'])) {
                 CRM_Core_BAO_ActionSchedule::del($params['id']);
                 unset($params['id']);
             }
             $actionScheduleObj = CRM_Core_BAO_ActionSchedule::add($dbParams);
             //exclude dates
             $excludeDateList = array();
             if (CRM_Utils_Array::value('exclude_date_list', $params) && CRM_Utils_Array::value('parent_entity_id', $params) && $actionScheduleObj->entity_value) {
                 //Since we get comma separated values lets get them in array
                 $excludeDates = explode(",", $params['exclude_date_list']);
                 //Check if there exists any values for this option group
                 $optionGroupIdExists = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup', $type . '_repeat_exclude_dates_' . $params['parent_entity_id'], 'id', 'name');
                 if ($optionGroupIdExists) {
                     CRM_Core_BAO_OptionGroup::del($optionGroupIdExists);
                 }
                 $optionGroupParams = array('name' => $type . '_repeat_exclude_dates_' . $actionScheduleObj->entity_value, 'title' => $type . ' recursion', 'is_reserved' => 0, 'is_active' => 1);
                 $opGroup = CRM_Core_BAO_OptionGroup::add($optionGroupParams);
                 if ($opGroup->id) {
                     $oldWeight = 0;
                     $fieldValues = array('option_group_id' => $opGroup->id);
                     foreach ($excludeDates as $val) {
                         $optionGroupValue = array('option_group_id' => $opGroup->id, 'label' => CRM_Utils_Date::processDate($val), 'value' => CRM_Utils_Date::processDate($val), 'name' => $opGroup->name, 'description' => 'Used for recurring ' . $type, 'weight' => CRM_Utils_Weight::updateOtherWeights('CRM_Core_DAO_OptionValue', $oldWeight, CRM_Utils_Array::value('weight', $params), $fieldValues), 'is_active' => 1);
                         $excludeDateList[] = $optionGroupValue['value'];
                         CRM_Core_BAO_OptionValue::create($optionGroupValue);
                     }
                 }
             }
             //Set type for API
             $apiEntityType = explode("_", $type);
             if (!empty($apiEntityType[1])) {
                 $apiType = $apiEntityType[1];
             }
             //Delete relations if any from recurring entity tables before inserting new relations for this entity id
             if ($params['entity_id']) {
                 //If entity has any pre delete function, consider that first
                 if (CRM_Utils_Array::value('pre_delete_func', CRM_Core_BAO_RecurringEntity::$_recurringEntityHelper[$params['entity_table']]) && CRM_Utils_Array::value('helper_class', CRM_Core_BAO_RecurringEntity::$_recurringEntityHelper[$params['entity_table']])) {
                     $preDeleteResult = call_user_func_array(CRM_Core_BAO_RecurringEntity::$_recurringEntityHelper[$params['entity_table']]['pre_delete_func'], array($params['entity_id']));
                     if (!empty($preDeleteResult)) {
                         call_user_func(array(CRM_Core_BAO_RecurringEntity::$_recurringEntityHelper[$params['entity_table']]['helper_class'], $preDeleteResult));
                     }
                 }
                 //Ready to execute delete on entities if it has delete function set
                 if (CRM_Utils_Array::value('delete_func', CRM_Core_BAO_RecurringEntity::$_recurringEntityHelper[$params['entity_table']]) && CRM_Utils_Array::value('helper_class', CRM_Core_BAO_RecurringEntity::$_recurringEntityHelper[$params['entity_table']])) {
                     //Check if pre delete function has some ids to be deleted
                     if (!empty(CRM_Core_BAO_RecurringEntity::$_entitiesToBeDeleted)) {
                         foreach (CRM_Core_BAO_RecurringEntity::$_entitiesToBeDeleted as $eid) {
                             $result = civicrm_api3(ucfirst(strtolower($apiType)), CRM_Core_BAO_RecurringEntity::$_recurringEntityHelper[$params['entity_table']]['delete_func'], array('sequential' => 1, 'id' => $eid));
                             if ($result['error']) {
                                 CRM_Core_Error::statusBounce('Error creating recurring list');
                             }
                         }
                     } else {
                         $getRelatedEntities = CRM_Core_BAO_RecurringEntity::getEntitiesFor($params['entity_id'], $params['entity_table'], FALSE);
                         foreach ($getRelatedEntities as $key => $value) {
                             $result = civicrm_api3(ucfirst(strtolower($apiType)), CRM_Core_BAO_RecurringEntity::$_recurringEntityHelper[$params['entity_table']]['delete_func'], array('sequential' => 1, 'id' => $value['id']));
                             if ($result['error']) {
                                 CRM_Core_Error::statusBounce('Error creating recurring list');
                             }
                         }
                     }
                 }
                 // find all entities from the recurring set. At this point we 'll get entities which were not deleted
                 // for e.g due to participants being present. We need to delete them from recurring tables anyway.
                 $pRepeatingEntities = CRM_Core_BAO_RecurringEntity::getEntitiesFor($params['entity_id'], $params['entity_table']);
                 foreach ($pRepeatingEntities as $val) {
                     CRM_Core_BAO_RecurringEntity::delEntity($val['id'], $val['table'], TRUE);
                 }
             }
             $recursion = new CRM_Core_BAO_RecurringEntity();
//.........这里部分代码省略.........
开发者ID:FundingWorks,项目名称:civicrm-core,代码行数:101,代码来源:RecurringEntity.php

示例6: testContactCustomDate_Anniv

 public function testContactCustomDate_Anniv()
 {
     $group = array('title' => 'Test_Group now', 'name' => 'test_group_now', 'extends' => array('Individual'), 'style' => 'Inline', 'is_multiple' => FALSE, 'is_active' => 1);
     $createGroup = $this->callAPISuccess('custom_group', 'create', $group);
     $field = array('label' => 'Graduation', 'data_type' => 'Date', 'html_type' => 'Select Date', 'custom_group_id' => $createGroup['id']);
     $createField = $this->callAPISuccess('custom_field', 'create', $field);
     $contactParams = $this->fixtures['contact'];
     $contactParams["custom_{$createField['id']}"] = '2013-12-16';
     $contact = $this->callAPISuccess('Contact', 'create', $contactParams);
     $this->_testObjects['CRM_Contact_DAO_Contact'][] = $contact['id'];
     $actionSchedule = $this->fixtures['sched_contact_grad_anniv'];
     $actionSchedule['entity_value'] = "custom_{$createField['id']}";
     $actionScheduleDao = CRM_Core_BAO_ActionSchedule::add($actionSchedule);
     $this->assertTrue(is_numeric($actionScheduleDao->id));
     $this->assertCronRuns(array(array('time' => '2014-03-07 01:00:00', 'recipients' => array()), array('time' => '2018-12-23 20:00:00', 'recipients' => array(array('test-member@example.com')))));
     $this->callAPISuccess('custom_group', 'delete', array('id' => $createGroup['id']));
 }
开发者ID:FundingWorks,项目名称:civicrm-core,代码行数:17,代码来源:ActionScheduleTest.php

示例7: postProcess


//.........这里部分代码省略.........
     }
     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 ($params['mapping_id'] == 1) {
             $params['limit_to'] = 1;
         }
         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);
     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';
     }
     if ($this->_action & CRM_Core_Action::UPDATE) {
         $params['id'] = $this->_id;
     } elseif ($this->_action & CRM_Core_Action::ADD) {
         // we do this only once, so name never changes
         $params['name'] = CRM_Utils_String::munge($params['title'], '_', 64);
     }
     $modePrefixes = array('Mail' => NULL, 'SMS' => 'SMS');
     if ($params['mode'] == 'Email' || empty($params['sms_provider_id'])) {
         unset($modePrefixes['SMS']);
     } elseif ($params['mode'] == 'SMS') {
         unset($modePrefixes['Mail']);
     }
     //TODO: handle postprocessing of SMS and/or Email info based on $modePrefixes
     $composeFields = array('template', 'saveTemplate', 'updateTemplate', 'saveTemplateName');
     $msgTemplate = NULL;
     //mail template is composed
     foreach ($modePrefixes as $prefix) {
         $composeParams = array();
         foreach ($composeFields as $key) {
             $key = $prefix . $key;
             if (!empty($values[$key])) {
                 $composeParams[$key] = $values[$key];
             }
         }
         if (!empty($composeParams[$prefix . 'updateTemplate'])) {
             $templateParams = array('is_active' => TRUE);
             if ($prefix == 'SMS') {
                 $templateParams += array('msg_text' => $params['sms_body_text'], 'is_sms' => TRUE);
             } else {
                 $templateParams += array('msg_text' => $params['body_text'], 'msg_html' => $params['body_html'], 'msg_subject' => $params['subject']);
             }
             $templateParams['id'] = $values[$prefix . 'template'];
             $msgTemplate = CRM_Core_BAO_MessageTemplate::add($templateParams);
         }
         if (!empty($composeParams[$prefix . 'saveTemplate'])) {
             $templateParams = array('is_active' => TRUE);
             if ($prefix == 'SMS') {
                 $templateParams += array('msg_text' => $params['sms_body_text'], 'is_sms' => TRUE);
             } else {
                 $templateParams += array('msg_text' => $params['body_text'], 'msg_html' => $params['body_html'], 'msg_subject' => $params['subject']);
             }
             $templateParams['msg_title'] = $composeParams[$prefix . 'saveTemplateName'];
             $msgTemplate = CRM_Core_BAO_MessageTemplate::add($templateParams);
         }
         if ($prefix == 'SMS') {
             if (isset($msgTemplate->id)) {
                 $params['sms_template_id'] = $msgTemplate->id;
             } else {
                 $params['sms_template_id'] = CRM_Utils_Array::value('SMStemplate', $values);
             }
         } else {
             if (isset($msgTemplate->id)) {
                 $params['msg_template_id'] = $msgTemplate->id;
             } else {
                 $params['msg_template_id'] = CRM_Utils_Array::value('template', $values);
             }
         }
     }
     $bao = CRM_Core_BAO_ActionSchedule::add($params);
     // we need to set this on the form so that hooks can identify the created entity
     $this->set('id', $bao->id);
     $bao->free();
     $status = ts("Your new Reminder titled %1 has been saved.", array(1 => "<strong>{$values['title']}</strong>"));
     if ($this->_action) {
         if ($this->_action & CRM_Core_Action::UPDATE) {
             $status = ts("Your Reminder titled %1 has been updated.", array(1 => "<strong>{$values['title']}</strong>"));
         }
         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);
         }
     }
     CRM_Core_Session::setStatus($status, ts('Saved'), 'success');
 }
开发者ID:riyadennis,项目名称:my_civicrm,代码行数:101,代码来源:ScheduleReminders.php

示例8: testMembershipEndDate_NoMatch

 /**
  * For contacts/members which match schedule based on end date,
  * an email should be sent.
  */
 function testMembershipEndDate_NoMatch()
 {
     // creates membership with end_date = 20120615
     $membership = $this->createTestObject('CRM_Member_DAO_Membership', array_merge($this->fixtures['rolling_membership_past'], array('status_id' => 3)));
     $this->assertTrue(is_numeric($membership->id));
     $result = civicrm_api('Email', 'create', array('contact_id' => $membership->contact_id, 'email' => 'test-member@example.com', 'version' => 3));
     $contact = civicrm_api('contact', 'create', array_merge($this->fixtures['contact'], array('contact_id' => $membership->contact_id)));
     $this->assertAPISuccess($result);
     $actionSchedule = $this->fixtures['sched_membership_end_2month'];
     $actionSchedule['entity_value'] = $membership->membership_type_id;
     $actionScheduleDao = CRM_Core_BAO_ActionSchedule::add($actionSchedule);
     $this->assertTrue(is_numeric($actionScheduleDao->id));
     // end_date=2012-06-15 ; schedule is 2 weeks before end_date
     $this->assertCronRuns(array(array('time' => '2012-05-31 01:00:00', 'recipients' => array()), array('time' => '2013-05-01 01:00:00', 'recipients' => array())));
 }
开发者ID:archcidburnziso,项目名称:civicrm-core,代码行数:19,代码来源:ActionScheduleTest.php


注:本文中的CRM_Core_BAO_ActionSchedule::add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。