本文整理汇总了PHP中CRM_Core_BAO_UFJoin::deleteAll方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_BAO_UFJoin::deleteAll方法的具体用法?PHP CRM_Core_BAO_UFJoin::deleteAll怎么用?PHP CRM_Core_BAO_UFJoin::deleteAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Core_BAO_UFJoin
的用法示例。
在下文中一共展示了CRM_Core_BAO_UFJoin::deleteAll方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: postProcess
/**
* Process the form.
*/
public function postProcess()
{
// store the submitted values in an array
$params = $this->controller->exportValues($this->_name);
// also update the ProfileModule tables
$ufJoinParams = array('is_active' => 1, 'module' => 'CiviCampaign', 'entity_table' => 'civicrm_survey', 'entity_id' => $this->_surveyId);
// first delete all past entries
CRM_Core_BAO_UFJoin::deleteAll($ufJoinParams);
$uf = array();
$wt = 2;
if (!empty($params['contact_profile_id'])) {
$uf[1] = $params['contact_profile_id'];
$wt = 1;
}
if (!empty($params['activity_profile_id'])) {
$uf[2] = $params['activity_profile_id'];
}
$uf = array_values($uf);
if (!empty($uf)) {
foreach ($uf as $weight => $ufGroupId) {
$ufJoinParams['weight'] = $weight + $wt;
$ufJoinParams['uf_group_id'] = $ufGroupId;
CRM_Core_BAO_UFJoin::create($ufJoinParams);
unset($ufJoinParams['id']);
}
}
parent::endPostProcess();
}
示例2: postProcess
/**
* Process the form submission.
*
*
* @return void
*/
public function postProcess()
{
$params = $this->exportValues();
$params['id'] = $this->_id;
// format params
$params['is_online_registration'] = CRM_Utils_Array::value('is_online_registration', $params, FALSE);
$params['is_confirm_enabled'] = CRM_Utils_Array::value('is_confirm_enabled', $params, FALSE);
// CRM-11182
$params['is_multiple_registrations'] = CRM_Utils_Array::value('is_multiple_registrations', $params, FALSE);
$params['allow_same_participant_emails'] = CRM_Utils_Array::value('allow_same_participant_emails', $params, FALSE);
$params['requires_approval'] = CRM_Utils_Array::value('requires_approval', $params, FALSE);
// reset is_email confirm if not online reg
if (!$params['is_online_registration']) {
$params['is_email_confirm'] = FALSE;
}
if (!$this->_isTemplate) {
$params['registration_start_date'] = CRM_Utils_Date::processDate($params['registration_start_date'], $params['registration_start_date_time'], TRUE);
$params['registration_end_date'] = CRM_Utils_Date::processDate($params['registration_end_date'], $params['registration_end_date_time'], TRUE);
}
CRM_Event_BAO_Event::add($params);
// also update the ProfileModule tables
$ufJoinParams = array('is_active' => 1, 'module' => 'CiviEvent', 'entity_table' => 'civicrm_event', 'entity_id' => $this->_id);
// first delete all past entries
CRM_Core_BAO_UFJoin::deleteAll($ufJoinParams);
$uf = array();
$wt = 2;
if (!empty($params['custom_pre_id'])) {
$uf[1] = $params['custom_pre_id'];
$wt = 1;
}
if (!empty($params['custom_post_id'])) {
$uf[2] = $params['custom_post_id'];
}
if (!empty($params['custom_post_id_multiple'])) {
$uf = array_merge($uf, $params['custom_post_id_multiple']);
}
$uf = array_values($uf);
if (!empty($uf)) {
foreach ($uf as $weight => $ufGroupId) {
$ufJoinParams['weight'] = $weight + $wt;
$ufJoinParams['uf_group_id'] = $ufGroupId;
CRM_Core_BAO_UFJoin::create($ufJoinParams);
unset($ufJoinParams['id']);
}
}
// also update the ProfileModule tables
$ufJoinParamsAdd = array('is_active' => 1, 'module' => 'CiviEvent_Additional', 'entity_table' => 'civicrm_event', 'entity_id' => $this->_id);
// first delete all past entries
CRM_Core_BAO_UFJoin::deleteAll($ufJoinParamsAdd);
if (!empty($params['is_multiple_registrations'])) {
$ufAdd = array();
$wtAdd = 2;
if (array_key_exists('additional_custom_pre_id', $params)) {
if (empty($params['additional_custom_pre_id'])) {
$ufAdd[1] = $params['custom_pre_id'];
$wtAdd = 1;
} elseif (CRM_Utils_Array::value('additional_custom_pre_id', $params) == 'none') {
} else {
$ufAdd[1] = $params['additional_custom_pre_id'];
$wtAdd = 1;
}
}
if (array_key_exists('additional_custom_post_id', $params)) {
if (empty($params['additional_custom_post_id'])) {
$ufAdd[2] = $params['custom_post_id'];
} elseif (CRM_Utils_Array::value('additional_custom_post_id', $params) == 'none') {
} else {
$ufAdd[2] = $params['additional_custom_post_id'];
}
}
if (!empty($params['additional_custom_post_id_multiple'])) {
$additionalPostMultiple = array();
foreach ($params['additional_custom_post_id_multiple'] as $key => $value) {
if (is_null($value) && !empty($params['custom_post_id'])) {
$additionalPostMultiple[$key] = $params['custom_post_id'];
} elseif ($value == 'none') {
continue;
} elseif ($value) {
$additionalPostMultiple[$key] = $value;
}
}
$ufAdd = array_merge($ufAdd, $additionalPostMultiple);
}
$ufAdd = array_values($ufAdd);
if (!empty($ufAdd)) {
foreach ($ufAdd as $weightAdd => $ufGroupIdAdd) {
$ufJoinParamsAdd['weight'] = $weightAdd + $wtAdd;
$ufJoinParamsAdd['uf_group_id'] = $ufGroupIdAdd;
CRM_Core_BAO_UFJoin::create($ufJoinParamsAdd);
unset($ufJoinParamsAdd['id']);
}
}
}
// get the profiles to evaluate what they collect
//.........这里部分代码省略.........
示例3: postProcess
/**
* Process the form.
*/
public function postProcess()
{
// get the submitted form values.
$params = $this->controller->exportValues($this->_name);
// we do this in case the user has hit the forward/back button
if ($this->_id) {
$params['id'] = $this->_id;
} else {
$session = CRM_Core_Session::singleton();
$params['created_id'] = $session->get('userID');
$params['created_date'] = date('YmdHis');
$config = CRM_Core_Config::singleton();
$params['currency'] = $config->defaultCurrency;
}
$params['is_confirm_enabled'] = CRM_Utils_Array::value('is_confirm_enabled', $params, FALSE);
$params['is_share'] = CRM_Utils_Array::value('is_share', $params, FALSE);
$params['is_active'] = CRM_Utils_Array::value('is_active', $params, FALSE);
$params['is_credit_card_only'] = CRM_Utils_Array::value('is_credit_card_only', $params, FALSE);
$params['honor_block_is_active'] = CRM_Utils_Array::value('honor_block_is_active', $params, FALSE);
$params['is_for_organization'] = !empty($params['is_organization']) ? CRM_Utils_Array::value('is_for_organization', $params, FALSE) : 0;
$params['start_date'] = CRM_Utils_Date::processDate($params['start_date'], $params['start_date_time'], TRUE);
$params['end_date'] = CRM_Utils_Date::processDate($params['end_date'], $params['end_date_time'], TRUE);
$params['goal_amount'] = CRM_Utils_Rule::cleanMoney($params['goal_amount']);
if (!$params['honor_block_is_active']) {
$params['honor_block_title'] = NULL;
$params['honor_block_text'] = NULL;
}
$dao = CRM_Contribute_BAO_ContributionPage::create($params);
$ufJoinParams = array('is_organization' => array('module' => 'on_behalf', 'entity_table' => 'civicrm_contribution_page', 'entity_id' => $dao->id), 'honor_block_is_active' => array('module' => 'soft_credit', 'entity_table' => 'civicrm_contribution_page', 'entity_id' => $dao->id));
foreach ($ufJoinParams as $index => $ufJoinParam) {
if (!empty($params[$index])) {
// first delete all past entries
CRM_Core_BAO_UFJoin::deleteAll($ufJoinParam);
$ufJoinParam['uf_group_id'] = $params[$index];
$ufJoinParam['weight'] = 1;
$ufJoinParam['is_active'] = 1;
if ($index == 'honor_block_is_active') {
$ufJoinParam['uf_group_id'] = $params['honoree_profile'];
$ufJoinParam['module_data'] = CRM_Contribute_BAO_ContributionPage::formatModuleData($params, FALSE, 'soft_credit');
} else {
$ufJoinParam['uf_group_id'] = $params['onbehalf_profile_id'];
$ufJoinParam['module_data'] = CRM_Contribute_BAO_ContributionPage::formatModuleData($params, FALSE, 'on_behalf');
}
CRM_Core_BAO_UFJoin::create($ufJoinParam);
} else {
if ($index == 'honor_block_is_active') {
$params['honor_block_title'] = NULL;
$params['honor_block_text'] = NULL;
} else {
$params['for_organization'] = NULL;
}
//On subsequent honor_block_is_active uncheck, disable(don't delete)
//that particular honoree profile entry in UFjoin table, CRM-13981
$ufId = CRM_Core_BAO_UFJoin::findJoinEntryId($ufJoinParam);
if ($ufId) {
$ufJoinParam['uf_group_id'] = CRM_Core_BAO_UFJoin::findUFGroupId($ufJoinParam);
$ufJoinParam['is_active'] = 0;
CRM_Core_BAO_UFJoin::create($ufJoinParam);
}
}
}
$this->set('id', $dao->id);
if ($this->_action & CRM_Core_Action::ADD) {
$url = 'civicrm/admin/contribute/amount';
$urlParams = "action=update&reset=1&id={$dao->id}";
// special case for 'Save and Done' consistency.
if ($this->controller->getButtonName('submit') == '_qf_Amount_upload_done') {
$url = 'civicrm/admin/contribute';
$urlParams = 'reset=1';
CRM_Core_Session::setStatus(ts("'%1' information has been saved.", array(1 => $this->getTitle())), ts('Saved'), 'success');
}
CRM_Utils_System::redirect(CRM_Utils_System::url($url, $urlParams));
}
parent::endPostProcess();
}
示例4: postProcess
/**
* Process the form.
*
* @return void
*/
public function postProcess()
{
// get the submitted form values.
$params = $this->controller->exportValues($this->_name);
if ($this->_action & CRM_Core_Action::UPDATE) {
$params['id'] = $this->_id;
}
$transaction = new CRM_Core_Transaction();
// also update uf join table
$ufJoinParams = array('is_active' => 1, 'module' => 'CiviContribute', 'entity_table' => 'civicrm_contribution_page', 'entity_id' => $this->_id);
// first delete all past entries
CRM_Core_BAO_UFJoin::deleteAll($ufJoinParams);
if (!empty($params['custom_pre_id'])) {
$ufJoinParams['weight'] = 1;
$ufJoinParams['uf_group_id'] = $params['custom_pre_id'];
CRM_Core_BAO_UFJoin::create($ufJoinParams);
}
unset($ufJoinParams['id']);
if (!empty($params['custom_post_id'])) {
$ufJoinParams['weight'] = 2;
$ufJoinParams['uf_group_id'] = $params['custom_post_id'];
CRM_Core_BAO_UFJoin::create($ufJoinParams);
}
$transaction->commit();
parent::endPostProcess();
}
示例5: postProcess
/**
* Function to process the form
*
* @access public
* @return None
*/
public function postProcess()
{
$params = array();
$params = $this->exportValues();
$params['id'] = $this->_id;
//format params
$params['is_online_registration'] = CRM_Utils_Array::value('is_online_registration', $params, false);
$params['is_multiple_registrations'] = CRM_Utils_Array::value('is_multiple_registrations', $params, false);
$params['allow_same_participant_emails'] = CRM_Utils_Array::value('allow_same_participant_emails', $params, false);
$params['requires_approval'] = CRM_Utils_Array::value('requires_approval', $params, false);
// reset is_email confirm if not online reg
if (!$params['is_online_registration']) {
$params['is_email_confirm'] = false;
}
if (!$this->_isTemplate) {
$params['registration_start_date'] = CRM_Utils_Date::processDate($params['registration_start_date'], $params['registration_start_date_time'], true);
$params['registration_end_date'] = CRM_Utils_Date::processDate($params['registration_end_date'], $params['registration_end_date_time'], true);
}
require_once 'CRM/Event/BAO/Event.php';
CRM_Event_BAO_Event::add($params);
// also update the ProfileModule tables
$ufJoinParams = array('is_active' => 1, 'module' => 'CiviEvent', 'entity_table' => 'civicrm_event', 'entity_id' => $this->_id);
require_once 'CRM/Core/BAO/UFJoin.php';
// first delete all past entries
CRM_Core_BAO_UFJoin::deleteAll($ufJoinParams);
if (!empty($params['custom_pre_id'])) {
$ufJoinParams['weight'] = 1;
$ufJoinParams['uf_group_id'] = $params['custom_pre_id'];
CRM_Core_BAO_UFJoin::create($ufJoinParams);
}
unset($ufJoinParams['id']);
if (!empty($params['custom_post_id'])) {
$ufJoinParams['weight'] = 2;
$ufJoinParams['uf_group_id'] = $params['custom_post_id'];
CRM_Core_BAO_UFJoin::create($ufJoinParams);
}
// CRM-4377: also update the profiles for additional participants
$ufJoinParams['module'] = 'CiviEvent_Additional';
$ufJoinParams['weight'] = 1;
$ufJoinParams['uf_group_id'] = $params['custom_pre_id'];
if ($params['additional_custom_pre_id'] == 'none') {
$ufJoinParams['is_active'] = 0;
} elseif ($params['additional_custom_pre_id']) {
$ufJoinParams['uf_group_id'] = $params['additional_custom_pre_id'];
}
CRM_Core_BAO_UFJoin::create($ufJoinParams);
$ufJoinParams['weight'] = 2;
$ufJoinParams['uf_group_id'] = $params['custom_post_id'];
if ($params['additional_custom_post_id'] == 'none') {
$ufJoinParams['is_active'] = 0;
} elseif ($params['additional_custom_post_id']) {
//minor fix for CRM-4377
$ufJoinParams['is_active'] = 1;
$ufJoinParams['uf_group_id'] = $params['additional_custom_post_id'];
}
CRM_Core_BAO_UFJoin::create($ufJoinParams);
parent::endPostProcess();
}
示例6: postProcess
/**
* Process the form
*
* @param null
*
* @return void
* @access public
*/
public function postProcess()
{
// store the submitted values in an array
$params = $this->controller->exportValues($this->_name);
$session = CRM_Core_Session::singleton();
$params['last_modified_id'] = $session->get('userID');
$params['last_modified_date'] = date('YmdHis');
require_once 'CRM/Core/BAO/OptionValue.php';
require_once 'CRM/Core/BAO/OptionGroup.php';
$updateResultSet = false;
if (CRM_Utils_Array::value('option_type', $params) == 2 && CRM_Utils_Array::value('option_group_id', $params)) {
if ($params['option_group_id'] == CRM_Utils_Array::value('result_id', $this->_values)) {
$updateResultSet = true;
}
}
if ($this->_surveyId) {
if ($this->_action & CRM_Core_Action::DELETE) {
CRM_Campaign_BAO_Survey::del($this->_surveyId);
CRM_Core_Session::setStatus(ts(' Survey has been deleted.'));
$session->replaceUserContext(CRM_Utils_System::url('civicrm/campaign', 'reset=1&subPage=survey'));
return;
}
$params['id'] = $this->_surveyId;
} else {
$params['created_id'] = $session->get('userID');
$params['created_date'] = date('YmdHis');
}
$params['is_active'] = CRM_Utils_Array::value('is_active', $params, 0);
$params['is_default'] = CRM_Utils_Array::value('is_default', $params, 0);
$recontactInterval = array();
if ($updateResultSet) {
$optionValue = new CRM_Core_DAO_OptionValue();
$optionValue->option_group_id = $this->_values['result_id'];
$optionValue->delete();
$params['result_id'] = $this->_values['result_id'];
} else {
$opGroupName = 'civicrm_survey_' . rand(10, 1000) . '_' . date('YmdHis');
$optionGroup = new CRM_Core_DAO_OptionGroup();
$optionGroup->name = $opGroupName;
$optionGroup->label = $params['title'] . ' Response Set';
$optionGroup->is_active = 1;
$optionGroup->save();
$params['result_id'] = $optionGroup->id;
}
foreach ($params['option_value'] as $k => $v) {
if (strlen(trim($v))) {
$optionValue = new CRM_Core_DAO_OptionValue();
$optionValue->option_group_id = $params['result_id'];
$optionValue->label = $params['option_label'][$k];
$optionValue->name = CRM_Utils_String::titleToVar($params['option_label'][$k]);
$optionValue->value = trim($v);
$optionValue->weight = $params['option_weight'][$k];
$optionValue->is_active = 1;
if (CRM_Utils_Array::value('default_option', $params) && $params['default_option'] == $k) {
$optionValue->is_default = 1;
}
$optionValue->save();
if (CRM_Utils_Array::value($k, $params['option_interval'])) {
$recontactInterval[$optionValue->label] = $params['option_interval'][$k];
}
}
}
$params['recontact_interval'] = serialize($recontactInterval);
$surveyId = CRM_Campaign_BAO_Survey::create($params);
if (CRM_Utils_Array::value('result_id', $this->_values) && !$updateResultSet) {
$query = "SELECT COUNT(*) FROM civicrm_survey WHERE result_id = %1";
$countSurvey = CRM_Core_DAO::singleValueQuery($query, array(1 => array($this->_values['result_id'], 'Integer')));
// delete option group if no any survey is using it.
if (!($countSurvey >= 1)) {
CRM_Core_BAO_OptionGroup::del($this->_values['result_id']);
}
}
require_once 'CRM/Core/BAO/UFJoin.php';
// also update the ProfileModule tables
$ufJoinParams = array('is_active' => 1, 'module' => 'CiviCampaign', 'entity_table' => 'civicrm_survey', 'entity_id' => $surveyId->id);
// first delete all past entries
if ($this->_surveyId) {
CRM_Core_BAO_UFJoin::deleteAll($ufJoinParams);
}
if (CRM_Utils_Array::value('profile_id', $params)) {
$ufJoinParams['weight'] = 1;
$ufJoinParams['uf_group_id'] = $params['profile_id'];
CRM_Core_BAO_UFJoin::create($ufJoinParams);
}
if (!is_a($surveyId, 'CRM_Core_Error')) {
CRM_Core_Session::setStatus(ts('Survey %1 has been saved.', array(1 => $params['title'])));
}
if ($this->_context == 'dialog') {
$returnArray = array('returnSuccess' => true);
echo json_encode($returnArray);
CRM_Utils_System::civiExit();
}
//.........这里部分代码省略.........
示例7: postProcess
public function postProcess()
{
// store the submitted values in an array
$params = $this->controller->exportValues($this->_name);
$session = CRM_Core_Session::singleton();
$params['last_modified_id'] = $session->get('userID');
$params['last_modified_date'] = date('YmdHis');
$params['is_share'] = CRM_Utils_Array::value('is_share', $params, FALSE);
if ($this->_surveyId) {
if ($this->_action & CRM_Core_Action::DELETE) {
CRM_Campaign_BAO_Survey::del($this->_surveyId);
CRM_Core_Session::setStatus(ts(' Petition has been deleted.'), ts('Record Deleted'), 'success');
$session->replaceUserContext(CRM_Utils_System::url('civicrm/campaign', 'reset=1&subPage=petition'));
return;
}
$params['id'] = $this->_surveyId;
} else {
$params['created_id'] = $session->get('userID');
$params['created_date'] = date('YmdHis');
}
$params['bypass_confirm'] = CRM_Utils_Array::value('bypass_confirm', $params, 0);
$params['is_active'] = CRM_Utils_Array::value('is_active', $params, 0);
$params['is_default'] = CRM_Utils_Array::value('is_default', $params, 0);
$surveyId = CRM_Campaign_BAO_Survey::create($params);
// also update the ProfileModule tables
$ufJoinParams = array('is_active' => 1, 'module' => 'CiviCampaign', 'entity_table' => 'civicrm_survey', 'entity_id' => $surveyId->id);
// first delete all past entries
if ($this->_surveyId) {
CRM_Core_BAO_UFJoin::deleteAll($ufJoinParams);
}
if (!empty($params['profile_id'])) {
$ufJoinParams['weight'] = 1;
$ufJoinParams['uf_group_id'] = $params['profile_id'];
CRM_Core_BAO_UFJoin::create($ufJoinParams);
}
if (!empty($params['contact_profile_id'])) {
$ufJoinParams['weight'] = 2;
$ufJoinParams['uf_group_id'] = $params['contact_profile_id'];
CRM_Core_BAO_UFJoin::create($ufJoinParams);
}
if (!is_a($surveyId, 'CRM_Core_Error')) {
CRM_Core_Session::setStatus(ts('Petition has been saved.'), ts('Saved'), 'success');
}
$buttonName = $this->controller->getButtonName();
if ($buttonName == $this->getButtonName('next', 'new')) {
CRM_Core_Session::setStatus(ts(' You can add another Petition.'), '', 'info');
$session->replaceUserContext(CRM_Utils_System::url('civicrm/petition/add', 'reset=1&action=add'));
} else {
$session->replaceUserContext(CRM_Utils_System::url('civicrm/campaign', 'reset=1&subPage=petition'));
}
}
示例8: postProcess
/**
* Process the form
*
* @return void
* @access public
*/
public function postProcess()
{
// get the submitted form values.
$params = $this->controller->exportValues($this->_name);
// we do this in case the user has hit the forward/back button
if ($this->_id) {
$params['id'] = $this->_id;
} else {
$session = CRM_Core_Session::singleton();
$params['created_id'] = $session->get('userID');
$params['created_date'] = date('YmdHis');
$config = CRM_Core_Config::singleton();
$params['currency'] = $config->defaultCurrency;
}
$params['is_confirm_enabled'] = CRM_Utils_Array::value('is_confirm_enabled', $params, FALSE);
$params['is_share'] = CRM_Utils_Array::value('is_share', $params, FALSE);
$params['is_active'] = CRM_Utils_Array::value('is_active', $params, FALSE);
$params['is_credit_card_only'] = CRM_Utils_Array::value('is_credit_card_only', $params, FALSE);
$params['honor_block_is_active'] = CRM_Utils_Array::value('honor_block_is_active', $params, FALSE);
$params['is_for_organization'] = CRM_Utils_Array::value('is_organization', $params) ? CRM_Utils_Array::value('is_for_organization', $params, FALSE) : 0;
$params['start_date'] = CRM_Utils_Date::processDate($params['start_date'], $params['start_date_time'], TRUE);
$params['end_date'] = CRM_Utils_Date::processDate($params['end_date'], $params['end_date_time'], TRUE);
$params['goal_amount'] = CRM_Utils_Rule::cleanMoney($params['goal_amount']);
if (!$params['honor_block_is_active']) {
$params['honor_block_title'] = NULL;
$params['honor_block_text'] = NULL;
}
$dao = CRM_Contribute_BAO_ContributionPage::create($params);
// make entry in UF join table for onbehalf of org profile
$ufJoinParams = array('is_active' => 1, 'module' => 'OnBehalf', 'entity_table' => 'civicrm_contribution_page', 'entity_id' => $dao->id);
// first delete all past entries
CRM_Core_BAO_UFJoin::deleteAll($ufJoinParams);
if (CRM_Utils_Array::value('onbehalf_profile_id', $params)) {
$ufJoinParams['weight'] = 1;
$ufJoinParams['uf_group_id'] = $params['onbehalf_profile_id'];
CRM_Core_BAO_UFJoin::create($ufJoinParams);
}
$this->set('id', $dao->id);
if ($this->_action & CRM_Core_Action::ADD) {
$url = 'civicrm/admin/contribute/amount';
$urlParams = "action=update&reset=1&id={$dao->id}";
// special case for 'Save and Done' consistency.
if ($this->controller->getButtonName('submit') == '_qf_Amount_upload_done') {
$url = 'civicrm/admin/contribute';
$urlParams = 'reset=1';
CRM_Core_Session::setStatus(ts("'%1' information has been saved.", array(1 => $this->getTitle())));
}
CRM_Utils_System::redirect(CRM_Utils_System::url($url, $urlParams));
}
parent::endPostProcess();
}
示例9: postProcess
/**
* Function to process the form
*
* @access public
*
* @return None
*/
public function postProcess()
{
$params = array();
$params = $this->exportValues();
$params['id'] = $this->_id;
//format params
$params['is_online_registration'] = CRM_Utils_Array::value('is_online_registration', $params, FALSE);
$params['is_multiple_registrations'] = CRM_Utils_Array::value('is_multiple_registrations', $params, FALSE);
$params['allow_same_participant_emails'] = CRM_Utils_Array::value('allow_same_participant_emails', $params, FALSE);
$params['requires_approval'] = CRM_Utils_Array::value('requires_approval', $params, FALSE);
// reset is_email confirm if not online reg
if (!$params['is_online_registration']) {
$params['is_email_confirm'] = FALSE;
}
if (!$this->_isTemplate) {
$params['registration_start_date'] = CRM_Utils_Date::processDate($params['registration_start_date'], $params['registration_start_date_time'], TRUE);
$params['registration_end_date'] = CRM_Utils_Date::processDate($params['registration_end_date'], $params['registration_end_date_time'], TRUE);
}
CRM_Event_BAO_Event::add($params);
// also update the ProfileModule tables
$ufJoinParams = array('is_active' => 1, 'module' => 'CiviEvent', 'entity_table' => 'civicrm_event', 'entity_id' => $this->_id);
// first delete all past entries
CRM_Core_BAO_UFJoin::deleteAll($ufJoinParams);
$uf = array();
$wt = 2;
if (!empty($params['custom_pre_id'])) {
$uf[1] = $params['custom_pre_id'];
$wt = 1;
}
if (!empty($params['custom_post_id'])) {
$uf[2] = $params['custom_post_id'];
}
if (CRM_Utils_Array::value('custom_post_id_multiple', $params)) {
$uf = array_merge($uf, $params['custom_post_id_multiple']);
}
$uf = array_values($uf);
if (!empty($uf)) {
foreach ($uf as $weight => $ufGroupId) {
$ufJoinParams['weight'] = $weight + $wt;
$ufJoinParams['uf_group_id'] = $ufGroupId;
CRM_Core_BAO_UFJoin::create($ufJoinParams);
unset($ufJoinParams['id']);
}
}
// also update the ProfileModule tables
$ufJoinParamsAdd = array('is_active' => 1, 'module' => 'CiviEvent_Additional', 'entity_table' => 'civicrm_event', 'entity_id' => $this->_id);
// first delete all past entries
CRM_Core_BAO_UFJoin::deleteAll($ufJoinParamsAdd);
if (CRM_Utils_Array::value('is_multiple_registrations', $params)) {
$ufAdd = array();
$wtAdd = 2;
if (array_key_exists('additional_custom_pre_id', $params)) {
if (!CRM_Utils_Array::value('additional_custom_pre_id', $params)) {
$ufAdd[1] = $params['custom_pre_id'];
$wtAdd = 1;
} elseif (CRM_Utils_Array::value('additional_custom_pre_id', $params) == 'none') {
} else {
$ufAdd[1] = $params['additional_custom_pre_id'];
$wtAdd = 1;
}
}
if (array_key_exists('additional_custom_post_id', $params)) {
if (!CRM_Utils_Array::value('additional_custom_post_id', $params)) {
$ufAdd[2] = $params['custom_post_id'];
} elseif (CRM_Utils_Array::value('additional_custom_post_id', $params) == 'none') {
} else {
$ufAdd[2] = $params['additional_custom_post_id'];
}
}
if (CRM_Utils_Array::value('additional_custom_post_id_multiple', $params)) {
$additionalPostMultiple = array();
foreach ($params['additional_custom_post_id_multiple'] as $key => $value) {
if (!$value && CRM_Utils_Array::value('custom_post_id', $params)) {
$additionalPostMultiple[$key] = $params['custom_post_id'];
} elseif ($value == 'none') {
continue;
} elseif ($value) {
$additionalPostMultiple[$key] = $value;
}
}
$ufAdd = array_merge($ufAdd, $additionalPostMultiple);
}
$ufAdd = array_values($ufAdd);
if (!empty($ufAdd)) {
foreach ($ufAdd as $weightAdd => $ufGroupIdAdd) {
$ufJoinParamsAdd['weight'] = $weightAdd + $wtAdd;
$ufJoinParamsAdd['uf_group_id'] = $ufGroupIdAdd;
CRM_Core_BAO_UFJoin::create($ufJoinParamsAdd);
unset($ufJoinParamsAdd['id']);
}
}
}
parent::endPostProcess();
//.........这里部分代码省略.........
示例10: saveProfileSelections
/**
* Associates user-selected profiles with the volunteer project
*
* @param array $profiles
*/
function saveProfileSelections($profiles)
{
// first delete all past entries
$params = array('entity_table' => CRM_Volunteer_BAO_Project::$_tableName, 'entity_id' => $this->_project->id);
CRM_Core_BAO_UFJoin::deleteAll($params);
if (empty($profiles)) {
$profiles[] = civicrm_api3('UFGroup', 'getvalue', array('name' => 'volunteer_sign_up', 'return' => 'id'));
}
// store the new selections
foreach ($profiles as $key => $profile_id) {
CRM_Core_BAO_UFJoin::create(array('entity_id' => $this->_project->id, 'entity_table' => CRM_Volunteer_BAO_Project::$_tableName, 'is_active' => 1, 'module' => 'CiviVolunteer', 'uf_group_id' => $profile_id, 'weight' => $key));
}
}