本文整理汇总了PHP中CRM_Campaign_BAO_Survey::del方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Campaign_BAO_Survey::del方法的具体用法?PHP CRM_Campaign_BAO_Survey::del怎么用?PHP CRM_Campaign_BAO_Survey::del使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Campaign_BAO_Survey
的用法示例。
在下文中一共展示了CRM_Campaign_BAO_Survey::del方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: postProcess
/**
* Process the form when submitted.
*/
public function postProcess()
{
if ($this->_surveyId) {
CRM_Campaign_BAO_Survey::del($this->_surveyId);
CRM_Core_Session::setStatus('', ts("'%1' survey has been deleted.", array(1 => $this->_surveyTitle)), 'success');
CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/campaign', 'reset=1&subPage=survey'));
} else {
CRM_Core_Error::fatal(ts('Delete action is missing expected survey ID.'));
}
}
示例2: 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();
}
//.........这里部分代码省略.........
示例3: 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'));
}
}