本文整理汇总了PHP中CRM_Campaign_BAO_Campaign::del方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Campaign_BAO_Campaign::del方法的具体用法?PHP CRM_Campaign_BAO_Campaign::del怎么用?PHP CRM_Campaign_BAO_Campaign::del使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Campaign_BAO_Campaign
的用法示例。
在下文中一共展示了CRM_Campaign_BAO_Campaign::del方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: postProcess
/**
* Form submission of new/edit campaign is processed.
*
*
* @return void
*/
public function postProcess()
{
// store the submitted values in an array
$params = $this->controller->exportValues($this->_name);
$session = CRM_Core_Session::singleton();
$groups = array();
if (isset($this->_campaignId)) {
if ($this->_action & CRM_Core_Action::DELETE) {
CRM_Campaign_BAO_Campaign::del($this->_campaignId);
CRM_Core_Session::setStatus(ts('Campaign has been deleted.'), ts('Record Deleted'), 'success');
$session->replaceUserContext(CRM_Utils_System::url('civicrm/campaign', 'reset=1&subPage=campaign'));
return;
}
$params['id'] = $this->_campaignId;
} else {
$params['created_id'] = $session->get('userID');
$params['created_date'] = date('YmdHis');
}
// format params
$params['start_date'] = CRM_Utils_Date::processDate($params['start_date'], $params['start_date_time']);
$params['end_date'] = CRM_Utils_Date::processDate($params['end_date'], $params['end_date_time'], TRUE);
$params['is_active'] = CRM_Utils_Array::value('is_active', $params, FALSE);
$params['last_modified_id'] = $session->get('userID');
$params['last_modified_date'] = date('YmdHis');
if (is_array($params['includeGroups'])) {
foreach ($params['includeGroups'] as $key => $id) {
if ($id) {
$groups['include'][] = $id;
}
}
}
$params['groups'] = $groups;
// delete previous includes/excludes, if campaign already existed
$groupTableName = CRM_Contact_BAO_Group::getTableName();
$dao = new CRM_Campaign_DAO_CampaignGroup();
$dao->campaign_id = $this->_campaignId;
$dao->entity_table = $groupTableName;
$dao->find();
while ($dao->fetch()) {
$dao->delete();
}
//process custom data.
$customFields = CRM_Core_BAO_CustomField::getFields('Campaign', FALSE, FALSE, CRM_Utils_Array::value('campaign_type_id', $params));
$params['custom'] = CRM_Core_BAO_CustomField::postProcess($params, $customFields, $this->_campaignId, 'Campaign');
$result = CRM_Campaign_BAO_Campaign::create($params);
if ($result) {
CRM_Core_Session::setStatus(ts('Campaign %1 has been saved.', array(1 => $result->title)), ts('Saved'), 'success');
$session->pushUserContext(CRM_Utils_System::url('civicrm/campaign', 'reset=1&subPage=campaign'));
}
$buttonName = $this->controller->getButtonName();
if ($buttonName == $this->getButtonName('upload', 'new')) {
CRM_Core_Session::setStatus(ts(' You can add another Campaign.'), '', 'info');
$session->replaceUserContext(CRM_Utils_System::url('civicrm/campaign/add', 'reset=1&action=add'));
} else {
$session->replaceUserContext(CRM_Utils_System::url('civicrm/campaign', 'reset=1&subPage=campaign'));
}
}
示例2: postProcess
/**
* Form submission of new/edit campaign is processed.
*
* @access public
* @return None
*/
public function postProcess()
{
// store the submitted values in an array
$params = $this->controller->exportValues($this->_name);
$session = CRM_Core_Session::singleton();
$groups = array();
if (isset($this->_campaignId)) {
if ($this->_action & CRM_Core_Action::DELETE) {
CRM_Campaign_BAO_Campaign::del($this->_campaignId);
CRM_Core_Session::setStatus(ts(' Campaign has been deleted.'));
$session->replaceUserContext(CRM_Utils_System::url('civicrm/campaign', 'reset=1&subPage=campaign'));
return;
}
$params['id'] = $this->_campaignId;
} else {
$params['created_id'] = $session->get('userID');
$params['created_date'] = date('YmdHis');
}
// format params
$params['start_date'] = CRM_Utils_Date::processDate($params['start_date'], $params['start_date_time']);
$params['end_date'] = CRM_Utils_Date::processDate($params['end_date'], $params['end_date_time'], true);
$params['is_active'] = CRM_Utils_Array::value('is_active', $params, false);
$params['last_modified_id'] = $session->get('userID');
$params['last_modified_date'] = date('YmdHis');
if (is_array($params['includeGroups'])) {
foreach ($params['includeGroups'] as $key => $id) {
if ($id) {
$groups['include'][] = $id;
}
}
}
$params['groups'] = $groups;
// delete previous includes/excludes, if campaign already existed
$groupTableName = CRM_Contact_BAO_Group::getTableName();
$dao = new CRM_Campaign_DAO_CampaignGroup();
$dao->campaign_id = $this->_campaignId;
$dao->entity_table = $groupTableName;
$dao->find();
while ($dao->fetch()) {
$dao->delete();
}
require_once 'CRM/Campaign/BAO/Campaign.php';
$result = CRM_Campaign_BAO_Campaign::create($params);
if ($result) {
CRM_Core_Session::setStatus(ts('Campaign %1 has been saved.', array(1 => $result->title)));
$session->pushUserContext(CRM_Utils_System::url('civicrm/campaign', 'reset=1&subPage=campaign'));
}
if ($this->_context == 'dialog') {
$returnArray = array('returnSuccess' => true);
echo json_encode($returnArray);
CRM_Utils_System::civiExit();
}
$buttonName = $this->controller->getButtonName();
if ($buttonName == $this->getButtonName('next', 'new')) {
CRM_Core_Session::setStatus(ts(' You can add another Campaign.'));
$session->replaceUserContext(CRM_Utils_System::url('civicrm/campaign/add', 'reset=1&action=add'));
} else {
$session->replaceUserContext(CRM_Utils_System::url('civicrm/campaign', 'reset=1&subPage=campaign'));
}
}