本文整理汇总了PHP中CRM_Member_BAO_Membership::del方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Member_BAO_Membership::del方法的具体用法?PHP CRM_Member_BAO_Membership::del怎么用?PHP CRM_Member_BAO_Membership::del使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Member_BAO_Membership
的用法示例。
在下文中一共展示了CRM_Member_BAO_Membership::del方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: postProcess
/**
* process the form after the input has been submitted and validated
*
* @access public
*
* @return None
*/
public function postProcess()
{
$deletedMembers = 0;
foreach ($this->_memberIds as $memberId) {
if (CRM_Member_BAO_Membership::del($memberId)) {
$deletedMembers++;
}
}
CRM_Core_Session::setStatus($deletedMembers, ts('Deleted Member(s)'), 'success');
CRM_Core_Session::setStatus(ts('Total Selected Membership(s): %1', array(1 => count($this->_memberIds))), '', 'info');
}
示例2: civicrm_api3_membership_delete
/**
* Deletes an existing contact Membership.
*
* @param array $params
* Array array holding id - Id of the contact membership to be deleted.
*
* @return array
* API result array.
*/
function civicrm_api3_membership_delete($params)
{
if (isset($params['preserve_contribution'])) {
if (CRM_Member_BAO_Membership::del($params['id'], $params['preserve_contribution'])) {
return civicrm_api3_create_success(TRUE, $params);
} else {
throw new API_Exception(ts('Could not delete membership'));
}
} else {
return _civicrm_api3_basic_delete(_civicrm_api3_get_BAO(__FUNCTION__), $params);
}
}
示例3: postProcess
/**
* Process the form after the input has been submitted and validated.
*
*
* @return void
*/
public function postProcess()
{
$deleted = $failed = 0;
foreach ($this->_memberIds as $memberId) {
if (CRM_Member_BAO_Membership::del($memberId)) {
$deleted++;
} else {
$failed++;
}
}
if ($deleted) {
$msg = ts('%count membership deleted.', array('plural' => '%count memberships deleted.', 'count' => $deleted));
CRM_Core_Session::setStatus($msg, ts('Removed'), 'success');
}
if ($failed) {
CRM_Core_Session::setStatus(ts('1 could not be deleted.', array('plural' => '%count could not be deleted.', 'count' => $failed)), ts('Error'), 'error');
}
}
示例4: postProcess
/**
* Process the form submission.
*
*
* @return void
*/
public function postProcess()
{
if ($this->_action & CRM_Core_Action::DELETE) {
CRM_Member_BAO_Membership::del($this->_id);
return;
}
$allMemberStatus = CRM_Member_PseudoConstant::membershipStatus();
$allContributionStatus = CRM_Contribute_PseudoConstant::contributionStatus();
$isTest = $this->_mode == 'test' ? 1 : 0;
$lineItems = NULL;
if (!empty($this->_lineItem)) {
$lineItems = $this->_lineItem;
}
$config = CRM_Core_Config::singleton();
// get the submitted form values.
$this->_params = $formValues = $this->controller->exportValues($this->_name);
$this->convertDateFieldsToMySQL($formValues);
$params = $softParams = $ids = array();
$membershipTypeValues = array();
foreach ($this->_memTypeSelected as $memType) {
$membershipTypeValues[$memType]['membership_type_id'] = $memType;
}
//take the required membership recur values.
if ($this->_mode && !empty($this->_params['auto_renew'])) {
$params['is_recur'] = $this->_params['is_recur'] = $formValues['is_recur'] = TRUE;
$mapping = array('frequency_interval' => 'duration_interval', 'frequency_unit' => 'duration_unit');
$count = 0;
foreach ($this->_memTypeSelected as $memType) {
$recurMembershipTypeValues = CRM_Utils_Array::value($memType, $this->_recurMembershipTypes, array());
foreach ($mapping as $mapVal => $mapParam) {
$membershipTypeValues[$memType][$mapVal] = CRM_Utils_Array::value($mapParam, $recurMembershipTypeValues);
if (!$count) {
$this->_params[$mapVal] = $formValues[$mapVal] = CRM_Utils_Array::value($mapParam, $recurMembershipTypeValues);
}
}
$count++;
}
}
// process price set and get total amount and line items.
$lineItem = array();
$priceSetId = NULL;
if (!($priceSetId = CRM_Utils_Array::value('price_set_id', $formValues))) {
CRM_Member_BAO_Membership::createLineItems($this, $formValues['membership_type_id'], $priceSetId);
}
$isQuickConfig = 0;
if ($this->_priceSetId && CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $this->_priceSetId, 'is_quick_config')) {
$isQuickConfig = 1;
}
$termsByType = array();
if ($priceSetId) {
CRM_Price_BAO_PriceSet::processAmount($this->_priceSet['fields'], $this->_params, $lineItem[$priceSetId]);
if (CRM_Utils_Array::value('tax_amount', $this->_params)) {
$params['tax_amount'] = $this->_params['tax_amount'];
}
$params['total_amount'] = CRM_Utils_Array::value('amount', $this->_params);
$submittedFinancialType = CRM_Utils_Array::value('financial_type_id', $formValues);
if (!empty($lineItem[$priceSetId])) {
foreach ($lineItem[$priceSetId] as &$li) {
if (!empty($li['membership_type_id'])) {
if (!empty($li['membership_num_terms'])) {
$termsByType[$li['membership_type_id']] = $li['membership_num_terms'];
}
}
///CRM-11529 for quick config backoffice transactions
//when financial_type_id is passed in form, update the
//lineitems with the financial type selected in form
if ($isQuickConfig && $submittedFinancialType) {
$li['financial_type_id'] = $submittedFinancialType;
}
}
}
}
$this->storeContactFields($formValues);
$params['contact_id'] = $this->_contactID;
$fields = array('status_id', 'source', 'is_override', 'campaign_id');
foreach ($fields as $f) {
$params[$f] = CRM_Utils_Array::value($f, $formValues);
}
// fix for CRM-3724
// when is_override false ignore is_admin statuses during membership
// status calculation. similarly we did fix for import in CRM-3570.
if (empty($params['is_override'])) {
$params['exclude_is_admin'] = TRUE;
}
// process date params to mysql date format.
$dateTypes = array('join_date' => 'joinDate', 'start_date' => 'startDate', 'end_date' => 'endDate');
foreach ($dateTypes as $dateField => $dateVariable) {
${$dateVariable} = CRM_Utils_Date::processDate($formValues[$dateField]);
}
$memTypeNumTerms = empty($termsByType) ? CRM_Utils_Array::value('num_terms', $formValues) : NULL;
$calcDates = array();
foreach ($this->_memTypeSelected as $memType) {
if (empty($memTypeNumTerms)) {
$memTypeNumTerms = CRM_Utils_Array::value($memType, $termsByType, 1);
//.........这里部分代码省略.........
示例5: relAction
/**
* Perform create or delete action on related memberships.
*
* @param string $action
* Create or delete.
* @param array $owner
* Primary membership info (membership_id, contact_id, membership_type ...).
*/
public function relAction($action, $owner)
{
switch ($action) {
case 'delete':
$id = CRM_Utils_Request::retrieve('mid', 'Positive', $this);
$relatedContactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this);
$relatedDisplayName = CRM_Contact_BAO_Contact::displayName($relatedContactId);
CRM_Member_BAO_Membership::del($id);
CRM_Core_Session::setStatus(ts('Related membership for %1 has been deleted.', array(1 => $relatedDisplayName)), ts('Membership Deleted'), 'success');
break;
case 'create':
$ids = array();
$params = array('contact_id' => CRM_Utils_Request::retrieve('rid', 'Positive', $this), 'membership_type_id' => $owner['membership_type_id'], 'owner_membership_id' => $owner['id'], 'join_date' => CRM_Utils_Date::processDate($owner['join_date'], NULL, TRUE, 'Ymd'), 'start_date' => CRM_Utils_Date::processDate($owner['start_date'], NULL, TRUE, 'Ymd'), 'end_date' => CRM_Utils_Date::processDate($owner['end_date'], NULL, TRUE, 'Ymd'), 'source' => ts('Manual Assignment of Related Membership'), 'is_test' => $owner['is_test'], 'campaign_id' => CRM_Utils_Array::value('campaign_id', $owner), 'status_id' => $owner['status_id'], 'skipStatusCal' => TRUE, 'createActivity' => TRUE);
CRM_Member_BAO_Membership::create($params, $ids);
$relatedDisplayName = CRM_Contact_BAO_Contact::displayName($params['contact_id']);
CRM_Core_Session::setStatus(ts('Related membership for %1 has been created.', array(1 => $relatedDisplayName)), ts('Membership Added'), 'success');
break;
default:
CRM_Core_Error::fatal(ts("Invalid action specified in URL"));
}
// Redirect back to membership view page for the owner, without the relAction parameters
CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/contact/view/membership', "action=view&reset=1&id={$owner['membership_id']}&cid={$owner['contact_id']}" . $this->addContext()));
}
示例6: postProcess
/**
* Process the form submission.
*/
public function postProcess()
{
if ($this->_action & CRM_Core_Action::DELETE) {
CRM_Member_BAO_Membership::del($this->_id);
return;
}
// get the submitted form values.
$this->_params = $this->controller->exportValues($this->_name);
$this->submit($this->_params);
$this->setUserContext();
}
示例7: testDeleteMembership
public function testDeleteMembership()
{
$contactId = Contact::createIndividual();
$params = array('contact_id' => $contactId, 'membership_type_id' => $this->_membershipTypeID, 'join_date' => date('Ymd', strtotime('2006-01-21')), 'start_date' => date('Ymd', strtotime('2006-01-21')), 'end_date' => date('Ymd', strtotime('2006-12-21')), 'source' => 'Payment', 'is_override' => 1, 'status_id' => $this->_membershipStatusID);
$ids = array();
CRM_Member_BAO_Membership::create($params, $ids);
$membershipId = $this->assertDBNotNull('CRM_Member_BAO_Membership', $contactId, 'id', 'contact_id', 'Database check for created membership.');
CRM_Member_BAO_Membership::del($membershipId);
$membershipId = $this->assertDBNull('CRM_Member_BAO_Membership', $contactId, 'id', 'contact_id', 'Database check for deleted membership.');
Contact::delete($contactId);
}