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


PHP CRM_Contact_BAO_GroupContactCache::remove方法代码示例

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


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

示例1: postProcess

 /**
  * process the form
  *
  * @return void
  * @access public
  */
 public function postProcess()
 {
     // Process / save custom data
     // Get the form values and groupTree
     $params = $this->controller->exportValues($this->_name);
     CRM_Core_BAO_CustomValueTable::postProcess($params, $this->_groupTree[$this->_groupID]['fields'], 'civicrm_contact', $this->_contactId, $this->_entityType);
     // reset the group contact cache for this group
     CRM_Contact_BAO_GroupContactCache::remove();
     $customGroupResult = civicrm_api3('CustomGroup', 'get', array('id' => $this->_groupID, 'sequential' => 1));
     if ($customGroupResult['count']) {
         $customGroup = CRM_Utils_Array::first($customGroupResult['values']);
         if ($customGroup['name'] === 'HRJobContract_Summary') {
             $jobContractsResult = civicrm_api3('HRJobContract', 'get', array('sequential' => 1, 'contact_id' => $this->_contactId, 'return' => "period_start_date,period_end_date"));
             foreach ($jobContractsResult['values'] as $jobContract) {
                 if ($jobContract['is_current'] && !$jobContract['deleted']) {
                     $jobContractSummaryDates = $this->_getJobContractSummaryDates($this->_groupTree[$this->_groupID]['fields'], $params);
                     $createParams = array('sequential' => 1, 'jobcontract_id' => $jobContract['id']);
                     if (empty($jobContract['period_start_date']) && !empty($jobContractSummaryDates['startDate'])) {
                         $createParams['period_start_date'] = $jobContractSummaryDates['startDate'];
                     }
                     if ((empty($jobContract['period_end_date']) || $jobContract['period_end_date'] > $jobContractSummaryDates['endDate']) && !empty($jobContractSummaryDates['endDate'])) {
                         $createParams['period_end_date'] = $jobContractSummaryDates['endDate'];
                     }
                     $result = civicrm_api3('HRJobDetails', 'create', $createParams);
                 }
             }
         }
     }
     $this->response();
 }
开发者ID:JoeMurray,项目名称:civihr,代码行数:36,代码来源:CustomData.php

示例2: create


//.........这里部分代码省略.........
     if (!empty($params['id'])) {
         $logMsg = "Activity (id: {$result->id} ) updated with ";
     } else {
         $logMsg = "Activity created for ";
     }
     $msgs = array();
     if (isset($params['source_contact_id'])) {
         $msgs[] = "source={$params['source_contact_id']}";
     }
     if (!empty($params['target_contact_id'])) {
         if (is_array($params['target_contact_id']) && !CRM_Utils_array::crmIsEmptyArray($params['target_contact_id'])) {
             $msgs[] = "target=" . implode(',', $params['target_contact_id']);
             // take only first target
             // will be used for recently viewed display
             $t = array_slice($params['target_contact_id'], 0, 1);
             $recentContactId = $t[0];
         } elseif (isset($params['target_contact_id']) && !is_array($params['target_contact_id'])) {
             $msgs[] = "target={$params['target_contact_id']}";
             // will be used for recently viewed display
             $recentContactId = $params['target_contact_id'];
         }
     } else {
         // at worst, take source for recently viewed display
         $recentContactId = CRM_Utils_Array::value('source_contact_id', $params);
     }
     if (isset($params['assignee_contact_id'])) {
         if (is_array($params['assignee_contact_id'])) {
             $msgs[] = "assignee=" . implode(',', $params['assignee_contact_id']);
         } else {
             $msgs[] = "assignee={$params['assignee_contact_id']}";
         }
     }
     $logMsg .= implode(', ', $msgs);
     self::logActivityAction($result, $logMsg);
     if (!empty($params['custom']) && is_array($params['custom'])) {
         CRM_Core_BAO_CustomValueTable::store($params['custom'], 'civicrm_activity', $result->id);
     }
     $transaction->commit();
     if (empty($params['skipRecentView'])) {
         $recentOther = array();
         if (!empty($params['case_id'])) {
             $caseContactID = CRM_Core_DAO::getFieldValue('CRM_Case_DAO_CaseContact', $params['case_id'], 'contact_id', 'case_id');
             $url = CRM_Utils_System::url('civicrm/case/activity/view', "reset=1&aid={$activity->id}&cid={$caseContactID}&caseID={$params['case_id']}&context=home");
         } else {
             $q = "action=view&reset=1&id={$activity->id}&atype={$activity->activity_type_id}&cid=" . CRM_Utils_Array::value('source_contact_id', $params) . "&context=home";
             if ($activity->activity_type_id != CRM_Core_OptionGroup::getValue('activity_type', 'Email', 'name')) {
                 $url = CRM_Utils_System::url('civicrm/activity', $q);
                 if ($activity->activity_type_id == CRM_Core_OptionGroup::getValue('activity_type', 'Print PDF Letter', 'name')) {
                     $recentOther['editUrl'] = CRM_Utils_System::url('civicrm/activity/pdf/add', "action=update&reset=1&id={$activity->id}&atype={$activity->activity_type_id}&cid={$params['source_contact_id']}&context=home");
                 } else {
                     $recentOther['editUrl'] = CRM_Utils_System::url('civicrm/activity/add', "action=update&reset=1&id={$activity->id}&atype={$activity->activity_type_id}&cid=" . CRM_Utils_Array::value('source_contact_id', $params) . "&context=home");
                 }
                 if (CRM_Core_Permission::check("delete activities")) {
                     $recentOther['deleteUrl'] = CRM_Utils_System::url('civicrm/activity', "action=delete&reset=1&id={$activity->id}&atype={$activity->activity_type_id}&cid=" . CRM_Utils_Array::value('source_contact_id', $params) . "&context=home");
                 }
             } else {
                 $url = CRM_Utils_System::url('civicrm/activity/view', $q);
                 if (CRM_Core_Permission::check('delete activities')) {
                     $recentOther['deleteUrl'] = CRM_Utils_System::url('civicrm/activity', "action=delete&reset=1&id={$activity->id}&atype={$activity->activity_type_id}&cid=" . CRM_Utils_Array::value('source_contact_id', $params) . "&context=home");
                 }
             }
         }
         if (!isset($activity->parent_id)) {
             $recentContactDisplay = CRM_Contact_BAO_Contact::displayName($recentContactId);
             // add the recently created Activity
             $activityTypes = CRM_Core_PseudoConstant::activityType(TRUE, TRUE);
             $activitySubject = CRM_Core_DAO::getFieldValue('CRM_Activity_DAO_Activity', $activity->id, 'subject');
             $title = "";
             if (isset($activitySubject)) {
                 $title = $activitySubject . ' - ';
             }
             $title = $title . $recentContactDisplay;
             if (!empty($activityTypes[$activity->activity_type_id])) {
                 $title .= ' (' . $activityTypes[$activity->activity_type_id] . ')';
             }
             CRM_Utils_Recent::add($title, $url, $activity->id, 'Activity', $recentContactId, $recentContactDisplay, $recentOther);
         }
     }
     // reset the group contact cache since smart groups might be affected due to this
     CRM_Contact_BAO_GroupContactCache::remove();
     if (!empty($params['id'])) {
         CRM_Utils_Hook::post('edit', 'Activity', $activity->id, $activity);
     } else {
         CRM_Utils_Hook::post('create', 'Activity', $activity->id, $activity);
     }
     // if the subject contains a ‘[case #…]’ string, file that activity on the related case (CRM-5916)
     $matches = array();
     if (preg_match('/\\[case #([0-9a-h]{7})\\]/', CRM_Utils_Array::value('subject', $params), $matches)) {
         $key = CRM_Core_DAO::escapeString(CIVICRM_SITE_KEY);
         $hash = $matches[1];
         $query = "SELECT id FROM civicrm_case WHERE SUBSTR(SHA1(CONCAT('{$key}', id)), 1, 7) = '{$hash}'";
         $caseParams = array('activity_id' => $activity->id, 'case_id' => CRM_Core_DAO::singleValueQuery($query));
         if ($caseParams['case_id']) {
             CRM_Case_BAO_Case::processCaseActivity($caseParams);
         } else {
             self::logActivityAction($activity, "unknown case hash encountered: {$hash}");
         }
     }
     return $result;
 }
开发者ID:saurabhbatra96,项目名称:civicrm-core,代码行数:101,代码来源:Activity.php

示例3: add

 /**
  * takes an associative array and creates a contribution object
  *
  * the function extract all the params it needs to initialize the create a
  * contribution object. the params array could contain additional unused name/value
  * pairs
  *
  * @param array  $params (reference ) an assoc array of name/value pairs
  * @param array $ids    the array that holds all the db ids
  *
  * @return object CRM_Contribute_BAO_Contribution object
  * @access public
  * @static
  */
 static function add(&$params, &$ids)
 {
     if (empty($params)) {
         return;
     }
     $duplicates = array();
     if (self::checkDuplicate($params, $duplicates, CRM_Utils_Array::value('contribution', $ids))) {
         $error =& CRM_Core_Error::singleton();
         $d = implode(', ', $duplicates);
         $error->push(CRM_Core_Error::DUPLICATE_CONTRIBUTION, 'Fatal', array($d), "Duplicate error - existing contribution record(s) have a matching Transaction ID or Invoice ID. Contribution record ID(s) are: {$d}");
         return $error;
     }
     // first clean up all the money fields
     $moneyFields = array('total_amount', 'net_amount', 'fee_amount', 'non_deductible_amount');
     //if priceset is used, no need to cleanup money
     if (CRM_UTils_Array::value('skipCleanMoney', $params)) {
         unset($moneyFields[0]);
     }
     foreach ($moneyFields as $field) {
         if (isset($params[$field])) {
             $params[$field] = CRM_Utils_Rule::cleanMoney($params[$field]);
         }
     }
     if (CRM_Utils_Array::value('payment_instrument_id', $params)) {
         require_once 'CRM/Contribute/PseudoConstant.php';
         $paymentInstruments = CRM_Contribute_PseudoConstant::paymentInstrument('name');
         if ($params['payment_instrument_id'] != array_search('Check', $paymentInstruments)) {
             $params['check_number'] = 'null';
         }
     }
     require_once 'CRM/Utils/Hook.php';
     if (CRM_Utils_Array::value('contribution', $ids)) {
         CRM_Utils_Hook::pre('edit', 'Contribution', $ids['contribution'], $params);
     } else {
         CRM_Utils_Hook::pre('create', 'Contribution', null, $params);
     }
     $contribution = new CRM_Contribute_BAO_Contribution();
     $contribution->copyValues($params);
     $contribution->id = CRM_Utils_Array::value('contribution', $ids);
     // also add financial_trxn details as part of fix for CRM-4724
     $contribution->trxn_result_code = CRM_Utils_Array::value('trxn_result_code', $params);
     $contribution->payment_processor = CRM_Utils_Array::value('payment_processor', $params);
     require_once 'CRM/Utils/Rule.php';
     if (!CRM_Utils_Rule::currencyCode($contribution->currency)) {
         require_once 'CRM/Core/Config.php';
         $config = CRM_Core_Config::singleton();
         $contribution->currency = $config->defaultCurrency;
     }
     $result = $contribution->save();
     // reset the group contact cache for this group
     require_once 'CRM/Contact/BAO/GroupContactCache.php';
     CRM_Contact_BAO_GroupContactCache::remove();
     if (CRM_Utils_Array::value('contribution', $ids)) {
         CRM_Utils_Hook::post('edit', 'Contribution', $contribution->id, $contribution);
     } else {
         CRM_Utils_Hook::post('create', 'Contribution', $contribution->id, $contribution);
     }
     return $result;
 }
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:73,代码来源:Contribution.php

示例4: clearContactCaches

 /**
  * Clear the contact cache so things are kosher. We started off being super aggressive with clearing
  * caches, but are backing off from this with every release. Compromise between ease of coding versus
  * performance versus being accurate at that very instant
  *
  * @param $contactID
  *   The contactID that was edited / deleted.
  */
 public static function clearContactCaches($contactID = NULL)
 {
     // clear acl cache if any.
     CRM_ACL_BAO_Cache::resetCache();
     if (empty($contactID)) {
         // also clear prev/next dedupe cache - if no contactID passed in
         CRM_Core_BAO_PrevNextCache::deleteItem();
     }
     // reset the group contact cache for this group
     CRM_Contact_BAO_GroupContactCache::remove();
 }
开发者ID:FundingWorks,项目名称:civicrm-core,代码行数:19,代码来源:Utils.php

示例5: key

 /**
  * Takes an associative array and creates a participant object.
  *
  * the function extract all the params it needs to initialize the create a
  * participant object. the params array could contain additional unused name/value
  * pairs
  *
  * @param array $params
  *   (reference ) an assoc array of name/value pairs.
  *
  * @return CRM_Event_BAO_Participant
  */
 public static function &add(&$params)
 {
     if (!empty($params['id'])) {
         CRM_Utils_Hook::pre('edit', 'Participant', $params['id'], $params);
     } else {
         CRM_Utils_Hook::pre('create', 'Participant', NULL, $params);
     }
     // converting dates to mysql format
     if (!empty($params['register_date'])) {
         $params['register_date'] = CRM_Utils_Date::isoToMysql($params['register_date']);
     }
     if (!empty($params['participant_fee_amount'])) {
         $params['participant_fee_amount'] = CRM_Utils_Rule::cleanMoney($params['participant_fee_amount']);
     }
     if (!empty($params['fee_amount'])) {
         $params['fee_amount'] = CRM_Utils_Rule::cleanMoney($params['fee_amount']);
     }
     // ensure that role ids are encoded as a string
     if (isset($params['role_id']) && is_array($params['role_id'])) {
         if (in_array(key($params['role_id']), CRM_Core_DAO::acceptedSQLOperators(), TRUE)) {
             $op = key($params['role_id']);
             $params['role_id'] = $params['role_id'][$op];
         } else {
             $params['role_id'] = implode(CRM_Core_DAO::VALUE_SEPARATOR, $params['role_id']);
         }
     }
     $participantBAO = new CRM_Event_BAO_Participant();
     if (!empty($params['id'])) {
         $participantBAO->id = CRM_Utils_Array::value('id', $params);
         $participantBAO->find(TRUE);
         $participantBAO->register_date = CRM_Utils_Date::isoToMysql($participantBAO->register_date);
     }
     $participantBAO->copyValues($params);
     //CRM-6910
     //1. If currency present, it should be valid one.
     //2. We should have currency when amount is not null.
     $currency = $participantBAO->fee_currency;
     if ($currency || !CRM_Utils_System::isNull($participantBAO->fee_amount)) {
         if (!CRM_Utils_Rule::currencyCode($currency)) {
             $config = CRM_Core_Config::singleton();
             $currency = $config->defaultCurrency;
         }
     }
     $participantBAO->fee_currency = $currency;
     $participantBAO->save();
     $session = CRM_Core_Session::singleton();
     // reset the group contact cache for this group
     CRM_Contact_BAO_GroupContactCache::remove();
     if (!empty($params['id'])) {
         CRM_Utils_Hook::post('edit', 'Participant', $participantBAO->id, $participantBAO);
     } else {
         CRM_Utils_Hook::post('create', 'Participant', $participantBAO->id, $participantBAO);
     }
     return $participantBAO;
 }
开发者ID:BorislavZlatanov,项目名称:civicrm-core,代码行数:67,代码来源:Participant.php

示例6: CRM_Member_BAO_Membership

 /**
  * takes an associative array and creates a membership object
  *
  * the function extract all the params it needs to initialize the create a
  * membership object. the params array could contain additional unused name/value
  * pairs
  *
  * @param array  $params (reference ) an assoc array of name/value pairs
  * @param array $ids    the array that holds all the db ids
  *
  * @return object CRM_Member_BAO_Membership object
  * @access public
  * @static
  */
 static function &add(&$params, &$ids)
 {
     require_once 'CRM/Utils/Hook.php';
     if (CRM_Utils_Array::value('membership', $ids)) {
         CRM_Utils_Hook::pre('edit', 'Membership', $ids['membership'], $params);
     } else {
         CRM_Utils_Hook::pre('create', 'Membership', null, $params);
     }
     // converting dates to mysql format
     if (isset($params['join_date'])) {
         $params['join_date'] = CRM_Utils_Date::isoToMysql($params['join_date']);
     }
     if (isset($params['start_date'])) {
         $params['start_date'] = CRM_Utils_Date::isoToMysql($params['start_date']);
     }
     if (CRM_Utils_Array::value('end_date', $params)) {
         $params['end_date'] = CRM_Utils_Date::isoToMysql($params['end_date']);
     } else {
         $params['end_date'] = 'null';
     }
     if (CRM_Utils_Array::value('reminder_date', $params)) {
         $params['reminder_date'] = CRM_Utils_Date::isoToMysql($params['reminder_date']);
     } else {
         $params['reminder_date'] = 'null';
     }
     if (!CRM_Utils_Array::value('is_override', $params)) {
         $params['is_override'] = 'null';
     }
     $membership = new CRM_Member_BAO_Membership();
     $membership->copyValues($params);
     $membership->id = CRM_Utils_Array::value('membership', $ids);
     $membership->save();
     $membership->free();
     $session =& CRM_Core_Session::singleton();
     //get the log start date.
     //it is set during renewal of membership.
     $logStartDate = CRM_Utils_array::value('log_start_date', $params);
     $logStartDate = $logStartDate ? CRM_Utils_Date::isoToMysql($logStartDate) : $membership->start_date;
     $membershipLog = array('membership_id' => $membership->id, 'status_id' => $membership->status_id, 'start_date' => $logStartDate, 'end_date' => $membership->end_date, 'renewal_reminder_date' => $membership->reminder_date, 'modified_id' => CRM_Utils_Array::value('userId', $ids), 'modified_date' => date('Ymd'));
     require_once 'CRM/Member/BAO/MembershipLog.php';
     CRM_Member_BAO_MembershipLog::add($membershipLog, CRM_Core_DAO::$_nullArray);
     // reset the group contact cache since smart groups might be affected due to this
     require_once 'CRM/Contact/BAO/GroupContactCache.php';
     CRM_Contact_BAO_GroupContactCache::remove();
     if (CRM_Utils_Array::value('membership', $ids)) {
         CRM_Utils_Hook::post('edit', 'Membership', $membership->id, $membership);
     } else {
         CRM_Utils_Hook::post('create', 'Membership', $membership->id, $membership);
     }
     return $membership;
 }
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:65,代码来源:Membership.php

示例7: deleteCustomValue

 /**
  * Function to delete custom value
  *
  */
 function deleteCustomValue(&$config)
 {
     $customValueID = CRM_Utils_Type::escape($_POST['valueID'], 'Positive');
     $customGroupID = CRM_Utils_Type::escape($_POST['groupID'], 'Positive');
     require_once "CRM/Core/BAO/CustomValue.php";
     CRM_Core_BAO_CustomValue::deleteCustomValue($customValueID, $customGroupID);
     if ($contactId = CRM_Utils_Array::value('contactId', $_POST)) {
         require_once 'CRM/Contact/BAO/Contact.php';
         echo CRM_Contact_BAO_Contact::getCountComponent('custom_' . $_POST['groupID'], $contactId);
     }
     // reset the group contact cache for this group
     require_once 'CRM/Contact/BAO/GroupContactCache.php';
     CRM_Contact_BAO_GroupContactCache::remove();
 }
开发者ID:ksecor,项目名称:civicrm,代码行数:18,代码来源:AJAX.php

示例8: createProfileContact


//.........这里部分代码省略.........
             require_once 'CRM/Quest/BAO/Student.php';
             if (!$studentFieldPresent && array_key_exists($name, CRM_Quest_BAO_Student::exportableFields())) {
                 $studentFieldPresent = 1;
             }
         }
     }
     //set the values for checkboxes (do_not_email, do_not_mail, do_not_trade, do_not_phone)
     $privacy = CRM_Core_SelectValues::privacy();
     foreach ($privacy as $key => $value) {
         if (array_key_exists($key, $fields)) {
             if ($params[$key]) {
                 $data[$key] = $params[$key];
             } else {
                 $data[$key] = 0;
             }
         }
     }
     // manage is_opt_out
     if (array_key_exists('is_opt_out', $fields)) {
         $wasOptOut = CRM_Utils_Array::value('is_opt_out', $contactDetails, false);
         $isOptOut = CRM_Utils_Array::value('is_opt_out', $params, false);
         $data['is_opt_out'] = $isOptOut;
         // on change, create new civicrm_subscription_history entry
         if ($wasOptOut != $isOptOut && CRM_Utils_Array::value('contact_id', $contactDetails)) {
             $shParams = array('contact_id' => $contactDetails['contact_id'], 'status' => $isOptOut ? 'Removed' : 'Added', 'method' => 'Web');
             CRM_Contact_BAO_SubscriptionHistory::create($shParams);
         }
     }
     require_once 'CRM/Contact/BAO/Contact.php';
     if ($data['contact_type'] != 'Student') {
         $contact =& self::create($data);
     }
     // contact is null if the profile does not have any contact fields
     if ($contact) {
         $contactID = $contact->id;
     }
     if (!$contactID) {
         CRM_Core_Error::fatal('Cannot proceed without a valid contact id');
     }
     // Process group and tag
     if (CRM_Utils_Array::value('group', $fields)) {
         $method = 'Admin';
         // this for sure means we are coming in via profile since i added it to fix
         // removing contacts from user groups -- lobo
         if ($visibility) {
             $method = 'Web';
         }
         CRM_Contact_BAO_GroupContact::create($params['group'], $contactID, $visibility, $method);
     }
     if (CRM_Utils_Array::value('tag', $fields)) {
         require_once 'CRM/Core/BAO/EntityTag.php';
         CRM_Core_BAO_EntityTag::create($params['tag'], $contactID);
     }
     //to add profile in default group
     if (is_array($addToGroupID)) {
         $contactIds = array($contactID);
         foreach ($addToGroupID as $groupId) {
             CRM_Contact_BAO_GroupContact::addContactsToGroup($contactIds, $groupId);
         }
     } else {
         if ($addToGroupID) {
             $contactIds = array($contactID);
             CRM_Contact_BAO_GroupContact::addContactsToGroup($contactIds, $addToGroupID);
         }
     }
     //to update student record
     if (CRM_Core_Permission::access('Quest') && $studentFieldPresent) {
         $ids = array();
         $dao =& new CRM_Quest_DAO_Student();
         $dao->contact_id = $contactID;
         if ($dao->find(true)) {
             $ids['id'] = $dao->id;
         }
         $ssids = array();
         $studentSummary =& new CRM_Quest_DAO_StudentSummary();
         $studentSummary->contact_id = $contactID;
         if ($studentSummary->find(true)) {
             $ssids['id'] = $studentSummary->id;
         }
         $params['contact_id'] = $contactID;
         //fixed for check boxes
         $specialFields = array('educational_interest', 'college_type', 'college_interest', 'test_tutoring');
         foreach ($specialFields as $field) {
             if ($params[$field]) {
                 $params[$field] = implode(CRM_Core_BAO_CustomOption::VALUE_SEPERATOR, array_keys($params[$field]));
             }
         }
         CRM_Quest_BAO_Student::create($params, $ids);
         CRM_Quest_BAO_Student::createStudentSummary($params, $ssids);
     }
     // reset the group contact cache for this group
     require_once 'CRM/Contact/BAO/GroupContactCache.php';
     CRM_Contact_BAO_GroupContactCache::remove();
     if ($editHook) {
         CRM_Utils_Hook::post('edit', 'Profile', $contactID, $params);
     } else {
         CRM_Utils_Hook::post('create', 'Profile', $contactID, $params);
     }
     return $contactID;
 }
开发者ID:ksecor,项目名称:civicrm,代码行数:101,代码来源:Contact.php

示例9: removeContactsFromGroup

 /**
  * Given an array of contact ids, remove all the contacts from the group
  *
  * @param array $contactIds
  *   (reference ) the array of contact ids to be removed.
  * @param int $groupId
  *   The id of the group.
  *
  * @param string $method
  * @param string $status
  * @param NULL $tracking
  *
  * @return array
  *   (total, removed, notRemoved) count of contacts removed to group
  */
 public static function removeContactsFromGroup(&$contactIds, $groupId, $method = 'Admin', $status = 'Removed', $tracking = NULL)
 {
     if (!is_array($contactIds)) {
         return array(0, 0, 0);
     }
     if ($status == 'Removed' || $status == 'Deleted') {
         $op = 'delete';
     } else {
         $op = 'edit';
     }
     CRM_Utils_Hook::pre($op, 'GroupContact', $groupId, $contactIds);
     $date = date('YmdHis');
     $numContactsRemoved = 0;
     $numContactsNotRemoved = 0;
     $group = new CRM_Contact_DAO_Group();
     $group->id = $groupId;
     $group->find(TRUE);
     foreach ($contactIds as $contactId) {
         if ($status == 'Deleted') {
             $query = "DELETE FROM civicrm_group_contact WHERE contact_id={$contactId} AND group_id={$groupId}";
             $dao = CRM_Core_DAO::executeQuery($query);
             $historyParams = array('group_id' => $groupId, 'contact_id' => $contactId, 'status' => $status, 'method' => $method, 'date' => $date, 'tracking' => $tracking);
             CRM_Contact_BAO_SubscriptionHistory::create($historyParams);
         } else {
             $groupContact = new CRM_Contact_DAO_GroupContact();
             $groupContact->group_id = $groupId;
             $groupContact->contact_id = $contactId;
             // check if the selected contact id already a member, or if this is
             // an opt-out of a smart group.
             // if not a member remove to groupContact else keep the count of contacts that are not removed
             if ($groupContact->find(TRUE) || $group->saved_search_id) {
                 // remove the contact from the group
                 $numContactsRemoved++;
             } else {
                 $numContactsNotRemoved++;
             }
             //now we grant the negative membership to contact if not member. CRM-3711
             $historyParams = array('group_id' => $groupId, 'contact_id' => $contactId, 'status' => $status, 'method' => $method, 'date' => $date, 'tracking' => $tracking);
             CRM_Contact_BAO_SubscriptionHistory::create($historyParams);
             $groupContact->status = $status;
             $groupContact->save();
         }
     }
     // also reset the acl cache
     $config = CRM_Core_Config::singleton();
     if (!$config->doNotResetCache) {
         CRM_ACL_BAO_Cache::resetCache();
     }
     // reset the group contact cache for all group(s)
     // if this group is being used as a smart group
     // @todo consider what to do here - it feels like we should either
     // 1) just invalidate the specific group's cache(& perhaps any parents) & let cron do it's thing or
     // possibly clear this specific groups cache, or just call opportunisticCacheFlush() - which would have the
     // same effect as the remove call. The reservation about that is that it is no more aggressive for the group that
     // we know is altered than for all the others, or perhaps, more the point with it's parents & groups that use it in
     // their criteria.
     CRM_Contact_BAO_GroupContactCache::remove();
     CRM_Utils_Hook::post($op, 'GroupContact', $groupId, $contactIds);
     return array(count($contactIds), $numContactsRemoved, $numContactsNotRemoved);
 }
开发者ID:nielosz,项目名称:civicrm-core,代码行数:75,代码来源:GroupContact.php

示例10: testGroupClause

 /**
  * Test the group contact clause does not contain an OR.
  *
  * The search should return 3 contacts - 2 households in the smart group of
  * Contact Type = Household and one Individual hard-added to it. The
  * Household that meets both criteria should be returned once.
  */
 public function testGroupClause()
 {
     $this->householdCreate();
     $householdID = $this->householdCreate();
     $individualID = $this->individualCreate();
     $groupID = $this->smartGroupCreate();
     $this->callAPISuccess('GroupContact', 'create', array('group_id' => $groupID, 'contact_id' => $individualID, 'status' => 'Added'));
     $this->callAPISuccess('GroupContact', 'create', array('group_id' => $groupID, 'contact_id' => $householdID, 'status' => 'Added'));
     // Refresh the cache for test purposes. It would be better to alter to alter the GroupContact add function to add contacts to the cache.
     CRM_Contact_BAO_GroupContactCache::remove($groupID, FALSE);
     $sql = CRM_Contact_BAO_Query::getQuery(array(array('group', 'IN', array($groupID), 0, 0)), array('contact_id'));
     $dao = CRM_Core_DAO::executeQuery($sql);
     $this->assertEquals(3, $dao->N);
     $this->assertFalse(strstr($sql, ' OR '));
     $sql = CRM_Contact_BAO_Query::getQuery(array(array('group', 'IN', array($groupID), 0, 0)), array('contact_id' => 1, 'group' => 1));
     $dao = CRM_Core_DAO::executeQuery($sql);
     $this->assertEquals(3, $dao->N);
     $this->assertFalse(strstr($sql, ' OR '), 'Query does not include or');
     while ($dao->fetch()) {
         $this->assertTrue($dao->groups == $groupID || $dao->groups == ',' . $groupID, $dao->groups . ' includes ' . $groupID);
     }
 }
开发者ID:nielosz,项目名称:civicrm-core,代码行数:29,代码来源:QueryTest.php

示例11: removeContactsFromTag

 /**
  * Given an array of contact ids, remove contact(s) tags 
  *
  * @param array  $contactIds (reference ) the array of contact ids to be added
  * @param int    $tagId the id of the tag
  *
  * @return array             (total, removed, notRemoved) count of contacts removed from tags
  * @access public
  * @static
  */
 static function removeContactsFromTag(&$contactIds, $tagId)
 {
     $numContactsRemoved = 0;
     $numContactsNotRemoved = 0;
     foreach ($contactIds as $contactId) {
         $tag =& new CRM_Core_DAO_EntityTag();
         $tag->contact_id = $contactId;
         $tag->tag_id = $tagId;
         if ($tag->find()) {
             $tag->delete();
             $numContactsRemoved++;
         } else {
             $numContactsNotRemoved++;
         }
     }
     // reset the group contact cache for all groups
     // if tags are being used in a smart group
     require_once 'CRM/Contact/BAO/GroupContactCache.php';
     CRM_Contact_BAO_GroupContactCache::remove();
     return array(count($contactIds), $numContactsRemoved, $numContactsNotRemoved);
 }
开发者ID:ksecor,项目名称:civicrm,代码行数:31,代码来源:EntityTag.php

示例12: postProcess

 /**
  * process the form
  *
  * @return void
  * @access public
  */
 public function postProcess()
 {
     // need to process / save custom data
     // Get the form values and groupTree
     $params = $this->controller->exportValues($this->_name);
     CRM_Core_BAO_CustomValueTable::postProcess($params, $this->_groupTree[$this->_groupID]['fields'], 'civicrm_contact', $this->_contactId, $this->_entityType);
     // reset the group contact cache for this group
     CRM_Contact_BAO_GroupContactCache::remove();
     $response = array('status' => 'save');
     $this->postProcessHook();
     echo json_encode($response);
     CRM_Utils_System::civiExit();
 }
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:19,代码来源:CustomData.php

示例13: setUpPopulatedGroup

 /**
  * Set up a smart group for testing.
  *
  * The smart group includes all Households by filter. In addition an individual
  * is created and hard-added and an individual is created that is not added.
  *
  * One household is hard-added as well as being in the filter.
  *
  * This gives us a range of scenarios for testing contacts are included only once
  * whenever they are hard-added or in the criteria.
  *
  * @return int
  */
 public function setUpPopulatedGroup()
 {
     $individual1ID = $this->individualCreate();
     $individualID = $this->individualCreate();
     $individualIDRemoved = $this->individualCreate();
     $groupID = $this->groupCreate(array('name' => uniqid(), 'title' => uniqid()));
     $this->callAPISuccess('GroupContact', 'create', array('group_id' => $groupID, 'contact_id' => $individualIDRemoved, 'status' => 'Removed'));
     $this->callAPISuccess('GroupContact', 'create', array('group_id' => $groupID, 'contact_id' => $individualID, 'status' => 'Added'));
     foreach (array($individual1ID, $individualID, $individualIDRemoved) as $contactID) {
         $this->contributionCreate(array('contact_id' => $contactID, 'invoice_id' => '', 'trxn_id' => ''));
     }
     // Refresh the cache for test purposes. It would be better to alter to alter the GroupContact add function to add contacts to the cache.
     CRM_Contact_BAO_GroupContactCache::remove($groupID, FALSE);
     return $groupID;
 }
开发者ID:nielosz,项目名称:civicrm-core,代码行数:28,代码来源:ReportTemplateTest.php

示例14: clearContactCaches

 static function clearContactCaches()
 {
     // clear acl cache if any.
     CRM_ACL_BAO_Cache::resetCache();
     // also clear prev/next dedupe cache
     CRM_Core_BAO_PrevNextCache::deleteItem();
     // reset the group contact cache for this group
     CRM_Contact_BAO_GroupContactCache::remove();
 }
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:9,代码来源:Utils.php

示例15: CRM_Event_BAO_Participant

 /**
  * takes an associative array and creates a participant object
  *
  * the function extract all the params it needs to initialize the create a
  * participant object. the params array could contain additional unused name/value
  * pairs
  *
  * @param array  $params (reference ) an assoc array of name/value pairs
  * @param array $ids    the array that holds all the db ids
  *
  * @return object CRM_Event_BAO_Participant object
  * @access public
  * @static
  */
 static function &add(&$params)
 {
     require_once 'CRM/Utils/Hook.php';
     if (CRM_Utils_Array::value('id', $params)) {
         CRM_Utils_Hook::pre('edit', 'Participant', $params['id'], $params);
     } else {
         CRM_Utils_Hook::pre('create', 'Participant', null, $params);
     }
     // converting dates to mysql format
     if (CRM_Utils_Array::value('register_date', $params)) {
         $params['register_date'] = CRM_Utils_Date::isoToMysql($params['register_date']);
     }
     if (CRM_Utils_Array::value('participant_fee_amount', $params)) {
         $params['participant_fee_amount'] = CRM_Utils_Rule::cleanMoney($params['participant_fee_amount']);
     }
     if (CRM_Utils_Array::value('participant_fee_amount', $params)) {
         $params['fee_amount'] = CRM_Utils_Rule::cleanMoney($params['fee_amount']);
     }
     $participantBAO = new CRM_Event_BAO_Participant();
     if (CRM_Utils_Array::value('id', $params)) {
         $participantBAO->id = CRM_Utils_Array::value('id', $params);
         $participantBAO->find(true);
         $participantBAO->register_date = CRM_Utils_Date::isoToMysql($participantBAO->register_date);
     }
     $participantBAO->copyValues($params);
     //CRM-6910
     //1. If currency present, it should be valid one.
     //2. We should have currency when amount is not null.
     require_once 'CRM/Utils/Rule.php';
     $currency = $participantBAO->fee_currency;
     if ($currency || !CRM_Utils_System::isNull($participantBAO->fee_amount)) {
         if (!CRM_Utils_Rule::currencyCode($currency)) {
             $config = CRM_Core_Config::singleton();
             $currency = $config->defaultCurrency;
         }
     }
     $participantBAO->fee_currency = $currency;
     $participantBAO->save();
     $session =& CRM_Core_Session::singleton();
     // reset the group contact cache for this group
     require_once 'CRM/Contact/BAO/GroupContactCache.php';
     CRM_Contact_BAO_GroupContactCache::remove();
     if (CRM_Utils_Array::value('id', $params)) {
         CRM_Utils_Hook::post('edit', 'Participant', $participantBAO->id, $participantBAO);
     } else {
         CRM_Utils_Hook::post('create', 'Participant', $participantBAO->id, $participantBAO);
     }
     return $participantBAO;
 }
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:63,代码来源:Participant.php


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