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


PHP CRM_Utils_array类代码示例

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


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

示例1: civicrm_api3_domain_get

/**
 * Get CiviCRM domain details
 * {@getfields domain_create}
 * @example DomainGet.php
 */
function civicrm_api3_domain_get($params)
{
    $params['version'] = CRM_Utils_array::value('domain_version', $params);
    unset($params['version']);
    $bao = new CRM_Core_BAO_Domain();
    if (CRM_Utils_Array::value('current_domain', $params)) {
        $domainBAO = CRM_Core_Config::domainID();
        $params['id'] = $domainBAO;
    }
    _civicrm_api3_dao_set_filter($bao, $params, true, 'domain');
    $domains = _civicrm_api3_dao_to_array($bao, $params, true, 'domain');
    foreach ($domains as $domain) {
        $values = array();
        $locparams = array('entity_id' => $domain['id'], 'entity_table' => 'civicrm_domain');
        require_once 'CRM/Core/BAO/Location.php';
        $values['location'] = CRM_Core_BAO_Location::getValues($locparams, TRUE);
        $address_array = array('street_address', 'supplemental_address_1', 'supplemental_address_2', 'city', 'state_province_id', 'postal_code', 'country_id', 'geo_code_1', 'geo_code_2');
        require_once 'CRM/Core/OptionGroup.php';
        if (!empty($values['location']['email'])) {
            $domain['domain_email'] = CRM_Utils_Array::value('email', $values['location']['email'][1]);
        }
        if (!empty($values['location']['phone'])) {
            $domain['domain_phone'] = array('phone_type' => CRM_Core_OptionGroup::getLabel('phone_type', CRM_Utils_Array::value('phone_type_id', $values['location']['phone'][1])), 'phone' => CRM_Utils_Array::value('phone', $values['location']['phone'][1]));
        }
        if (!empty($values['location']['address'])) {
            foreach ($address_array as $value) {
                $domain['domain_address'][$value] = CRM_Utils_Array::value($value, $values['location']['address'][1]);
            }
        }
        list($domain['from_name'], $domain['from_email']) = CRM_Core_BAO_Domain::getNameAndEmail(TRUE);
        $domains[$domain['id']] = array_merge($domains[$domain['id']], $domain);
    }
    return civicrm_api3_create_success($domains, $params, 'domain', 'get', $bao);
}
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:39,代码来源:Domain.php

示例2: create


//.........这里部分代码省略.........
                 }
             }
         } else {
             $targetParams['target_contact_id'] = $params['target_contact_id'];
             if (CRM_Utils_Array::value('id', $params)) {
                 $target = new CRM_Activity_BAO_ActivityTarget();
                 $target->activity_id = $activityId;
                 $target->find(true);
                 if ($target->target_contact_id != $params['target_contact_id']) {
                     $targetParams['id'] = $target->id;
                     $resultTarget = CRM_Activity_BAO_ActivityTarget::create($targetParams);
                 }
             } else {
                 $resultTarget = CRM_Activity_BAO_ActivityTarget::create($targetParams);
             }
         }
     } else {
         if (CRM_Utils_Array::value('deleteActivityTarget', $params, true)) {
             self::deleteActivityTarget($activityId);
         }
     }
     // write to changelog before transation is committed/rolled
     // back (and prepare status to display)
     if (CRM_Utils_Array::value('id', $params)) {
         $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 (CRM_Utils_Array::value('target_contact_id', $params)) {
         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];
         } else {
             if (isset($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 = $params['source_contact_id'];
     }
     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 (CRM_Utils_Array::value('custom', $params) && is_array($params['custom'])) {
         require_once 'CRM/Core/BAO/CustomValueTable.php';
         CRM_Core_BAO_CustomValueTable::store($params['custom'], 'civicrm_activity', $result->id);
     }
     $transaction->commit();
     if (!CRM_Utils_Array::value('skipRecentView', $params)) {
         $recentOther = array();
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:67,代码来源:Activity.php

示例3: assignToTemplate

 /**
  * assign the minimal set of variables to the template
  *
  * @return void
  * @access public
  */
 function assignToTemplate()
 {
     $name = CRM_Utils_Array::value('billing_first_name', $this->_params);
     if (CRM_Utils_Array::value('billing_middle_name', $this->_params)) {
         $name .= " {$this->_params['billing_middle_name']}";
     }
     $name .= ' ' . CRM_Utils_Array::value('billing_last_name', $this->_params);
     $name = trim($name);
     $this->assign('billingName', $name);
     $this->set('name', $name);
     $this->assign('paymentProcessor', $this->_paymentProcessor);
     $vars = array('amount', 'currencyID', 'credit_card_type', 'trxn_id', 'amount_level');
     $config = CRM_Core_Config::singleton();
     if (isset($this->_values['is_recur']) && CRM_Utils_Array::value('is_recur', $this->_paymentProcessor)) {
         $this->assign('is_recur_enabled', 1);
         $vars = array_merge($vars, array('is_recur', 'frequency_interval', 'frequency_unit', 'installments'));
     }
     if (in_array('CiviPledge', $config->enableComponents) && CRM_Utils_Array::value('is_pledge', $this->_params) == 1) {
         $this->assign('pledge_enabled', 1);
         $vars = array_merge($vars, array('is_pledge', 'pledge_frequency_interval', 'pledge_frequency_unit', 'pledge_installments'));
     }
     if (isset($this->_params['amount_other']) || isset($this->_params['selectMembership'])) {
         $this->_params['amount_level'] = '';
     }
     foreach ($vars as $v) {
         if (isset($this->_params[$v])) {
             if ($v == 'frequency_unit' || $v == 'pledge_frequency_unit') {
                 $frequencyUnits = CRM_Core_OptionGroup::values('recur_frequency_units');
                 if (array_key_exists($this->_params[$v], $frequencyUnits)) {
                     $this->_params[$v] = $frequencyUnits[$this->_params[$v]];
                 }
             }
             if ($v == "amount" && $this->_params[$v] === 0) {
                 $this->_params[$v] = CRM_Utils_Money::format($this->_params[$v], NULL, NULL, TRUE);
             }
             $this->assign($v, $this->_params[$v]);
         }
     }
     // assign the address formatted up for display
     $addressParts = array("street_address-{$this->_bltID}", "city-{$this->_bltID}", "postal_code-{$this->_bltID}", "state_province-{$this->_bltID}", "country-{$this->_bltID}");
     $addressFields = array();
     foreach ($addressParts as $part) {
         list($n, $id) = explode('-', $part);
         $addressFields[$n] = CRM_Utils_Array::value('billing_' . $part, $this->_params);
     }
     $this->assign('address', CRM_Utils_Address::format($addressFields));
     if (CRM_Utils_Array::value('hidden_onbehalf_profile', $this->_params)) {
         $this->assign('onBehalfName', $this->_params['organization_name']);
         $locTypeId = array_keys($this->_params['onbehalf_location']['email']);
         $this->assign('onBehalfEmail', $this->_params['onbehalf_location']['email'][$locTypeId[0]]['email']);
     }
     //fix for CRM-3767
     $assignCCInfo = FALSE;
     if ($this->_amount > 0.0) {
         $assignCCInfo = TRUE;
     } elseif (CRM_Utils_array::value('selectMembership', $this->_params)) {
         $memFee = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipType', $this->_params['selectMembership'], 'minimum_fee');
         if ($memFee > 0.0) {
             $assignCCInfo = TRUE;
         }
     }
     if ($this->_contributeMode == 'direct' && $assignCCInfo) {
         if ($this->_paymentProcessor && $this->_paymentProcessor['payment_type'] & CRM_Core_Payment::PAYMENT_TYPE_DIRECT_DEBIT) {
             $this->assign('payment_type', $this->_paymentProcessor['payment_type']);
             $this->assign('account_holder', $this->_params['account_holder']);
             $this->assign('bank_identification_number', $this->_params['bank_identification_number']);
             $this->assign('bank_name', $this->_params['bank_name']);
             $this->assign('bank_account_number', $this->_params['bank_account_number']);
         } else {
             $date = CRM_Utils_Date::format(CRM_Utils_array::value('credit_card_exp_date', $this->_params));
             $date = CRM_Utils_Date::mysqlToIso($date);
             $this->assign('credit_card_exp_date', $date);
             $this->assign('credit_card_number', CRM_Utils_System::mungeCreditCard(CRM_Utils_array::value('credit_card_number', $this->_params)));
         }
     }
     $this->assign('email', $this->controller->exportValue('Main', "email-{$this->_bltID}"));
     // also assign the receipt_text
     if (isset($this->_values['receipt_text'])) {
         $this->assign('receipt_text', $this->_values['receipt_text']);
     }
 }
开发者ID:hguru,项目名称:224Civi,代码行数:87,代码来源:ContributionBase.php

示例4: loadCMSBootstrap

 /**
  * @return array|NULL
  *   NULL if execution should proceed; array if the response is already known
  */
 public function loadCMSBootstrap()
 {
     $requestParams = CRM_Utils_Request::exportValues();
     $q = CRM_Utils_array::value('q', $requestParams);
     $args = explode('/', $q);
     // Proceed with bootstrap for "?entity=X&action=Y"
     // Proceed with bootstrap for "?q=civicrm/X/Y" but not "?q=civicrm/ping"
     if (!empty($q)) {
         if (count($args) == 2 && $args[1] == 'ping') {
             return NULL;
             // this is pretty wonky but maybe there's some reason I can't see
         }
         if (count($args) != 3) {
             return self::error('ERROR: Malformed REST path');
         }
         if ($args[0] != 'civicrm') {
             return self::error('ERROR: Malformed REST path');
         }
         // Therefore we have reasonably well-formed "?q=civicrm/X/Y"
     }
     if (!CRM_Utils_System::authenticateKey(FALSE)) {
         // FIXME: At time of writing, this doesn't actually do anything because
         // authenticateKey abends, but that's a bad behavior which sends a
         // malformed response.
         return self::error('Failed to authenticate key');
     }
     $uid = NULL;
     if (!$uid) {
         $store = NULL;
         $api_key = CRM_Utils_Request::retrieve('api_key', 'String', $store, FALSE, NULL, 'REQUEST');
         if (empty($api_key)) {
             return self::error("FATAL: mandatory param 'api_key' (user key) missing");
         }
         $contact_id = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $api_key, 'id', 'api_key');
         if ($contact_id) {
             $uid = CRM_Core_BAO_UFMatch::getUFId($contact_id);
         }
     }
     if ($uid) {
         CRM_Utils_System::loadBootStrap(array('uid' => $uid), TRUE, FALSE);
         return NULL;
     } else {
         return self::error('ERROR: No CMS user associated with given api-key');
     }
 }
开发者ID:kidaa30,项目名称:yes,代码行数:49,代码来源:REST.php

示例5: assignAddressField

 /**
  * Add fields to $profileAddressFields as appropriate.
  * profileAddressFields is assigned to the template to tell it
  * what fields are in the profile address
  * that potentially should be copied to the Billing fields
  * we want to give precedence to
  *   1) Billing &
  *   2) then Primary designated as 'Primary
  *   3) location_type is primary
  *   4) if none of these apply then it just uses the first one
  *
  *   as this will be used to
  * transfer profile address data to billing fields
  * http://issues.civicrm.org/jira/browse/CRM-5869
  *
  * @param string $key
  *   Field key - e.g. street_address-Primary, first_name.
  * @param array $profileAddressFields
  *   Array of profile fields that relate to address fields.
  * @param array $profileFilter
  *   Filter to apply to profile fields - expected usage is to only fill based on.
  *   the bottom profile per CRM-13726
  *
  * @return bool
  *   Can the address block be hidden safe in the knowledge all fields are elsewhere collected (see CRM-15118)
  */
 public static function assignAddressField($key, &$profileAddressFields, $profileFilter)
 {
     $billing_id = CRM_Core_BAO_LocationType::getBilling();
     list($prefixName, $index) = CRM_Utils_System::explode('-', $key, 2);
     $profileFields = civicrm_api3('uf_field', 'get', array_merge($profileFilter, array('is_active' => 1, 'return' => 'field_name, is_required', 'options' => array('limit' => 0))));
     //check for valid fields ( fields that are present in billing block )
     $validBillingFields = array('first_name', 'middle_name', 'last_name', 'street_address', 'supplemental_address_1', 'city', 'state_province', 'postal_code', 'country');
     $requiredBillingFields = array_diff($validBillingFields, array('middle_name', 'supplemental_address_1'));
     $validProfileFields = array();
     $requiredProfileFields = array();
     foreach ($profileFields['values'] as $field) {
         if (in_array($field['field_name'], $validBillingFields)) {
             $validProfileFields[] = $field['field_name'];
         }
         if ($field['is_required']) {
             $requiredProfileFields[] = $field['field_name'];
         }
     }
     if (!in_array($prefixName, $validProfileFields)) {
         return FALSE;
     }
     if (!empty($index) && (!CRM_Utils_array::value($prefixName, $profileAddressFields) || $index == $billing_id || $index == 'Primary' && $profileAddressFields[$prefixName] != $billing_id || $index == CRM_Core_BAO_LocationType::getDefault()->id && $profileAddressFields[$prefixName] != $billing_id && $profileAddressFields[$prefixName] != 'Primary')) {
         $profileAddressFields[$prefixName] = $index;
     }
     $potentiallyMissingRequiredFields = array_diff($requiredBillingFields, $requiredProfileFields);
     CRM_Core_Resources::singleton()->addSetting(array('billing' => array('billingProfileIsHideable' => empty($potentiallyMissingRequiredFields))));
 }
开发者ID:kidaa30,项目名称:yes,代码行数:53,代码来源:UFField.php

示例6: postProcess


//.........这里部分代码省略.........
             $this->endPostProcess($newActParams, $activity);
         }
         // copy files attached to old activity if any, to new one,
         // as long as users have not selected the 'delete attachment' option.
         if (empty($newActParams['is_delete_attachment'])) {
             CRM_Core_BAO_File::copyEntityFile('civicrm_activity', $this->_activityId, 'civicrm_activity', $activity->id);
         }
         // copy back params to original var
         $params = $newActParams;
     }
     foreach ($vvalue as $vkey => $vval) {
         if ($vval['actId']) {
             // add tags if exists
             $tagParams = array();
             if (!empty($params['tag'])) {
                 foreach ($params['tag'] as $tag) {
                     $tagParams[$tag] = 1;
                 }
             }
             //save static tags
             CRM_Core_BAO_EntityTag::create($tagParams, 'civicrm_activity', $vval['actId']);
             //save free tags
             if (isset($params['taglist']) && !empty($params['taglist'])) {
                 CRM_Core_Form_Tag::postProcess($params['taglist'], $vval['actId'], 'civicrm_activity', $this);
             }
         }
         // update existing case record if needed
         $caseParams = $params;
         $caseParams['id'] = $vval['case_id'];
         if (!empty($caseParams['case_status_id'])) {
             $caseParams['status_id'] = $caseParams['case_status_id'];
         }
         // unset params intended for activities only
         unset($caseParams['subject'], $caseParams['details'], $caseParams['status_id'], $caseParams['custom']);
         $case = CRM_Case_BAO_Case::create($caseParams);
         // create case activity record
         $caseParams = array('activity_id' => $vval['actId'], 'case_id' => $vval['case_id']);
         CRM_Case_BAO_Case::processCaseActivity($caseParams);
     }
     // Insert civicrm_log record for the activity (e.g. store the
     // created / edited by contact id and date for the activity)
     // Note - civicrm_log is already created by CRM_Activity_BAO_Activity::create()
     // send copy to selected contacts.
     $mailStatus = '';
     $mailToContacts = array();
     //CRM-5695
     //check for notification settings for assignee contacts
     $selectedContacts = array('contact_check');
     $activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name');
     $assigneeID = CRM_Utils_Array::key('Activity Assignees', $activityContacts);
     if (CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'activity_assignee_notification')) {
         $selectedContacts[] = 'assignee_contact_id';
     }
     foreach ($vvalue as $vkey => $vval) {
         foreach ($selectedContacts as $dnt => $val) {
             if (array_key_exists($val, $params) && !CRM_Utils_array::crmIsEmptyArray($params[$val])) {
                 if ($val == 'contact_check') {
                     $mailStatus = ts("A copy of the activity has also been sent to selected contacts(s).");
                 } else {
                     $this->_relatedContacts = CRM_Activity_BAO_ActivityAssignment::getAssigneeNames(array($vval['actId']), TRUE, FALSE);
                     $mailStatus .= ' ' . ts("A copy of the activity has also been sent to assignee contacts(s).");
                 }
                 //build an associative array with unique email addresses.
                 foreach ($params[$val] as $key => $value) {
                     if ($val == 'contact_check') {
                         $id = $key;
                     } else {
                         $id = $value;
                     }
                     if (isset($id) && array_key_exists($id, $this->_relatedContacts) && isset($this->_relatedContacts[$id]['email'])) {
                         //if email already exists in array then append with ', ' another role only otherwise add it to array.
                         if ($contactDetails = CRM_Utils_Array::value($this->_relatedContacts[$id]['email'], $mailToContacts)) {
                             $caseRole = CRM_Utils_Array::value('role', $this->_relatedContacts[$id]);
                             $mailToContacts[$this->_relatedContacts[$id]['email']]['role'] = $contactDetails['role'] . ', ' . $caseRole;
                         } else {
                             $mailToContacts[$this->_relatedContacts[$id]['email']] = $this->_relatedContacts[$id];
                         }
                     }
                 }
             }
         }
         $extraParams = array('case_id' => $vval['case_id'], 'client_id' => $this->_currentlyViewedContactId);
         $result = CRM_Activity_BAO_Activity::sendToAssignee($activity, $mailToContacts, $extraParams);
         if (empty($result)) {
             $mailStatus = '';
         }
         // create follow up activity if needed
         $followupStatus = '';
         if (!empty($params['followup_activity_type_id'])) {
             $followupActivity = CRM_Activity_BAO_Activity::createFollowupActivity($vval['actId'], $params);
             if ($followupActivity) {
                 $caseParams = array('activity_id' => $followupActivity->id, 'case_id' => $vval['case_id']);
                 CRM_Case_BAO_Case::processCaseActivity($caseParams);
                 $followupStatus = ts("A followup activity has been scheduled.") . '<br /><br />';
             }
         }
         $title = ts("%1 Saved", array(1 => $this->_activityTypeName));
         CRM_Core_Session::setStatus($followupStatus . $mailStatus, $title, 'success');
     }
 }
开发者ID:rajeshrhino,项目名称:civicrm-core,代码行数:101,代码来源:Activity.php

示例7: moveAllBelongings


//.........这里部分代码省略.........
             }
         }
     }
     // **** Do file custom fields related migrations
     // FIXME: move this someplace else (one of the BAOs) after discussing
     // where to, and whether CRM_Core_BAO_File::deleteFileReferences() shouldn't actually,
     // like, delete a file...
     if (!isset($customFiles)) {
         $customFiles = array();
     }
     foreach ($customFiles as $customId) {
         list($tableName, $columnName, $groupID) = CRM_Core_BAO_CustomField::getTableColumnGroup($customId);
         // get the contact_id -> file_id mapping
         $fileIds = array();
         $sql = "SELECT entity_id, {$columnName} AS file_id FROM {$tableName} WHERE entity_id IN ({$mainId}, {$otherId})";
         $dao = CRM_Core_DAO::executeQuery($sql, CRM_Core_DAO::$_nullArray);
         while ($dao->fetch()) {
             $fileIds[$dao->entity_id] = $dao->file_id;
         }
         $dao->free();
         // delete the main contact's file
         if (!empty($fileIds[$mainId])) {
             CRM_Core_BAO_File::deleteFileReferences($fileIds[$mainId], $mainId, $customId);
         }
         // move the other contact's file to main contact
         //NYSS need to INSERT or UPDATE depending on whether main contact has an existing record
         if (CRM_Core_DAO::singleValueQuery("SELECT id FROM {$tableName} WHERE entity_id = {$mainId}")) {
             $sql = "UPDATE {$tableName} SET {$columnName} = {$fileIds[$otherId]} WHERE entity_id = {$mainId}";
         } else {
             $sql = "INSERT INTO {$tableName} ( entity_id, {$columnName} ) VALUES ( {$mainId}, {$fileIds[$otherId]} )";
         }
         CRM_Core_DAO::executeQuery($sql, CRM_Core_DAO::$_nullArray);
         if (CRM_Core_DAO::singleValueQuery("\n        SELECT id\n        FROM civicrm_entity_file\n        WHERE entity_table = '{$tableName}' AND file_id = {$fileIds[$otherId]}")) {
             $sql = "\n          UPDATE civicrm_entity_file\n          SET entity_id = {$mainId}\n          WHERE entity_table = '{$tableName}' AND file_id = {$fileIds[$otherId]}";
         } else {
             $sql = "\n          INSERT INTO civicrm_entity_file ( entity_table, entity_id, file_id )\n          VALUES ( '{$tableName}', {$mainId}, {$fileIds[$otherId]} )";
         }
         CRM_Core_DAO::executeQuery($sql, CRM_Core_DAO::$_nullArray);
     }
     // move view only custom fields CRM-5362
     $viewOnlyCustomFields = array();
     foreach ($submitted as $key => $value) {
         $fid = (int) substr($key, 7);
         if (array_key_exists($fid, $cFields) && !empty($cFields[$fid]['attributes']['is_view'])) {
             $viewOnlyCustomFields[$key] = $value;
         }
     }
     // special case to set values for view only, CRM-5362
     if (!empty($viewOnlyCustomFields)) {
         $viewOnlyCustomFields['entityID'] = $mainId;
         CRM_Core_BAO_CustomValueTable::setValues($viewOnlyCustomFields);
     }
     // **** Delete other contact & update prev-next caching
     $otherParams = array('contact_id' => $otherId, 'id' => $otherId, 'version' => 3);
     if (CRM_Core_Permission::check('merge duplicate contacts') && CRM_Core_Permission::check('delete contacts')) {
         // if ext id is submitted then set it null for contact to be deleted
         if (!empty($submitted['external_identifier'])) {
             $query = "UPDATE civicrm_contact SET external_identifier = null WHERE id = {$otherId}";
             CRM_Core_DAO::executeQuery($query);
         }
         civicrm_api('contact', 'delete', $otherParams);
         CRM_Core_BAO_PrevNextCache::deleteItem($otherId);
     }
     // FIXME: else part
     /*         else { */
     /*             CRM_Core_Session::setStatus( ts('Do not have sufficient permission to delete duplicate contact.') ); */
     /*         } */
     // CRM-15681 merge sub_types
     if ($other_sub_types = CRM_Utils_array::value('contact_sub_type', $migrationInfo['other_details'])) {
         if ($main_sub_types = CRM_Utils_array::value('contact_sub_type', $migrationInfo['main_details'])) {
             $submitted['contact_sub_type'] = array_unique(array_merge($main_sub_types, $other_sub_types));
         } else {
             $submitted['contact_sub_type'] = $other_sub_types;
         }
     }
     // **** Update contact related info for the main contact
     if (!empty($submitted)) {
         $submitted['contact_id'] = $mainId;
         //update current employer field
         if ($currentEmloyerId = CRM_Utils_Array::value('current_employer_id', $submitted)) {
             if (!CRM_Utils_System::isNull($currentEmloyerId)) {
                 $submitted['current_employer'] = $submitted['current_employer_id'];
             } else {
                 $submitted['current_employer'] = '';
             }
             unset($submitted['current_employer_id']);
         }
         //CRM-14312 include prefix/suffix from mainId if not overridden for proper construction of display/sort name
         if (!isset($submitted['prefix_id']) && !empty($migrationInfo['main_details']['prefix_id'])) {
             $submitted['prefix_id'] = $migrationInfo['main_details']['prefix_id'];
         }
         if (!isset($submitted['suffix_id']) && !empty($migrationInfo['main_details']['suffix_id'])) {
             $submitted['suffix_id'] = $migrationInfo['main_details']['suffix_id'];
         }
         CRM_Contact_BAO_Contact::createProfileContact($submitted, CRM_Core_DAO::$_nullArray, $mainId);
         unset($submitted);
     }
     CRM_Utils_Hook::post('merge', 'Contact', $mainId, CRM_Core_DAO::$_nullObject);
     return TRUE;
 }
开发者ID:BorislavZlatanov,项目名称:civicrm-core,代码行数:101,代码来源:Merger.php

示例8: processActivity

 /**
  * Process activity creation.
  *
  * @param array $params
  *   Associated array of submitted values.
  *
  * @return self|null|object
  */
 protected function processActivity(&$params)
 {
     $activityAssigned = array();
     $activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name');
     $assigneeID = CRM_Utils_Array::key('Activity Assignees', $activityContacts);
     // format assignee params
     if (!CRM_Utils_Array::crmIsEmptyArray($params['assignee_contact_id'])) {
         //skip those assignee contacts which are already assigned
         //while sending a copy.CRM-4509.
         $activityAssigned = array_flip($params['assignee_contact_id']);
         if ($this->_activityId) {
             $assigneeContacts = CRM_Activity_BAO_ActivityContact::getNames($this->_activityId, $assigneeID);
             $activityAssigned = array_diff_key($activityAssigned, $assigneeContacts);
         }
     }
     // call begin post process. Idea is to let injecting file do
     // any processing before the activity is added/updated.
     $this->beginPostProcess($params);
     $activity = CRM_Activity_BAO_Activity::create($params);
     // add tags if exists
     $tagParams = array();
     if (!empty($params['tag'])) {
         foreach ($params['tag'] as $tag) {
             $tagParams[$tag] = 1;
         }
     }
     //save static tags
     CRM_Core_BAO_EntityTag::create($tagParams, 'civicrm_activity', $activity->id);
     //save free tags
     if (isset($params['activity_taglist']) && !empty($params['activity_taglist'])) {
         CRM_Core_Form_Tag::postProcess($params['activity_taglist'], $activity->id, 'civicrm_activity', $this);
     }
     // call end post process. Idea is to let injecting file do any
     // processing needed, after the activity has been added/updated.
     $this->endPostProcess($params, $activity);
     // CRM-9590
     if (!empty($params['is_multi_activity'])) {
         $this->_activityIds[] = $activity->id;
     } else {
         $this->_activityId = $activity->id;
     }
     // create follow up activity if needed
     $followupStatus = '';
     $followupActivity = NULL;
     if (!empty($params['followup_activity_type_id'])) {
         $followupActivity = CRM_Activity_BAO_Activity::createFollowupActivity($activity->id, $params);
         $followupStatus = ts('A followup activity has been scheduled.');
     }
     // send copy to assignee contacts.CRM-4509
     $mailStatus = '';
     if (CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'activity_assignee_notification')) {
         $activityIDs = array($activity->id);
         if ($followupActivity) {
             $activityIDs = array_merge($activityIDs, array($followupActivity->id));
         }
         $assigneeContacts = CRM_Activity_BAO_ActivityAssignment::getAssigneeNames($activityIDs, TRUE, FALSE);
         if (!CRM_Utils_Array::crmIsEmptyArray($params['assignee_contact_id'])) {
             $mailToContacts = array();
             //build an associative array with unique email addresses.
             foreach ($activityAssigned as $id => $dnc) {
                 if (isset($id) && array_key_exists($id, $assigneeContacts)) {
                     $mailToContacts[$assigneeContacts[$id]['email']] = $assigneeContacts[$id];
                 }
             }
             if (!CRM_Utils_array::crmIsEmptyArray($mailToContacts)) {
                 //include attachments while sending a copy of activity.
                 $attachments = CRM_Core_BAO_File::getEntityFile('civicrm_activity', $activity->id);
                 $ics = new CRM_Activity_BAO_ICalendar($activity);
                 $ics->addAttachment($attachments, $mailToContacts);
                 // CRM-8400 add param with _currentlyViewedContactId for URL link in mail
                 CRM_Case_BAO_Case::sendActivityCopy(NULL, $activity->id, $mailToContacts, $attachments, NULL);
                 $ics->cleanup();
                 $mailStatus .= ts("A copy of the activity has also been sent to assignee contacts(s).");
             }
         }
         // Also send email to follow-up activity assignees if set
         if ($followupActivity) {
             $mailToFollowupContacts = array();
             foreach ($assigneeContacts as $values) {
                 if ($values['activity_id'] == $followupActivity->id) {
                     $mailToFollowupContacts[$values['email']] = $values;
                 }
             }
             if (!CRM_Utils_array::crmIsEmptyArray($mailToFollowupContacts)) {
                 $ics = new CRM_Activity_BAO_ICalendar($followupActivity);
                 $attachments = CRM_Core_BAO_File::getEntityFile('civicrm_activity', $followupActivity->id);
                 $ics->addAttachment($attachments, $mailToFollowupContacts);
                 CRM_Case_BAO_Case::sendActivityCopy(NULL, $followupActivity->id, $mailToFollowupContacts, $attachments, NULL);
                 $ics->cleanup();
                 $mailStatus .= '<br />' . ts("A copy of the follow-up activity has also been sent to follow-up assignee contacts(s).");
             }
         }
//.........这里部分代码省略.........
开发者ID:riyadennis,项目名称:my_civicrm,代码行数:101,代码来源:Activity.php

示例9: mte_checkSettings

function mte_checkSettings($context)
{
    $usedFor = 1;
    if ($context == 'civimail') {
        $usedFor = 2;
    }
    $mailingBackend = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME, 'mandrill_smtp_settings');
    if (CRM_Utils_array::value('is_active', $mailingBackend) && array_key_exists('used_for', $mailingBackend) && !empty($mailingBackend['used_for'][$usedFor])) {
        return TRUE;
    }
    return FALSE;
}
开发者ID:vakeesan26,项目名称:biz.jmaconsulting.mte,代码行数:12,代码来源:mte.php

示例10: postProcess


//.........这里部分代码省略.........
         $params['activity_type_id'] = $this->_activityTypeId;
     }
     if (CRM_Utils_Array::value('hidden_custom', $params) && !isset($params['custom'])) {
         $customFields = CRM_Core_BAO_CustomField::getFields('Activity', FALSE, FALSE, $this->_activityTypeId);
         $customFields = CRM_Utils_Array::crmArrayMerge($customFields, CRM_Core_BAO_CustomField::getFields('Activity', FALSE, FALSE, NULL, NULL, TRUE));
         $params['custom'] = CRM_Core_BAO_CustomField::postProcess($params, $customFields, $this->_activityId, 'Activity');
     }
     // store the date with proper format
     $params['activity_date_time'] = CRM_Utils_Date::processDate($params['activity_date_time'], $params['activity_date_time_time']);
     // assigning formated value to related variable
     if (CRM_Utils_Array::value('target_contact_id', $params)) {
         $params['target_contact_id'] = explode(',', $params['target_contact_id']);
     } else {
         $params['target_contact_id'] = array();
     }
     if (CRM_Utils_Array::value('assignee_contact_id', $params)) {
         $params['assignee_contact_id'] = explode(',', $params['assignee_contact_id']);
     } else {
         $params['assignee_contact_id'] = array();
     }
     // get ids for associated contacts
     if (!$params['source_contact_id']) {
         $params['source_contact_id'] = $this->_currentUserId;
     } else {
         $params['source_contact_id'] = $this->_submitValues['source_contact_qid'];
     }
     if (isset($this->_activityId)) {
         $params['id'] = $this->_activityId;
     }
     // add attachments as needed
     CRM_Core_BAO_File::formatAttachment($params, $params, 'civicrm_activity', $this->_activityId);
     // format target params
     if (!$this->_single) {
         $params['target_contact_id'] = $this->_contactIds;
     }
     $activityAssigned = array();
     // format assignee params
     if (!CRM_Utils_Array::crmIsEmptyArray($params['assignee_contact_id'])) {
         //skip those assignee contacts which are already assigned
         //while sending a copy.CRM-4509.
         $activityAssigned = array_flip($params['assignee_contact_id']);
         if ($this->_activityId) {
             $assigneeContacts = CRM_Activity_BAO_ActivityAssignment::getAssigneeNames($this->_activityId);
             $activityAssigned = array_diff_key($activityAssigned, $assigneeContacts);
         }
     }
     // call begin post process. Idea is to let injecting file do
     // any processing before the activity is added/updated.
     $this->beginPostProcess($params);
     $activity = CRM_Activity_BAO_Activity::create($params);
     // add tags if exists
     $tagParams = array();
     if (!empty($params['tag'])) {
         foreach ($params['tag'] as $tag) {
             $tagParams[$tag] = 1;
         }
     }
     //save static tags
     CRM_Core_BAO_EntityTag::create($tagParams, 'civicrm_activity', $activity->id);
     //save free tags
     if (isset($params['activity_taglist']) && !empty($params['activity_taglist'])) {
         CRM_Core_Form_Tag::postProcess($params['activity_taglist'], $activity->id, 'civicrm_activity', $this);
     }
     // call end post process. Idea is to let injecting file do any
     // processing needed, after the activity has been added/updated.
     $this->endPostProcess($params, $activity);
     // CRM-9590
     $this->_activityId = $activity->id;
     // create follow up activity if needed
     $followupStatus = '';
     if (CRM_Utils_Array::value('followup_activity_type_id', $params)) {
         $followupActivity = CRM_Activity_BAO_Activity::createFollowupActivity($activity->id, $params);
         $followupStatus = ts('A followup activity has been scheduled.');
     }
     // send copy to assignee contacts.CRM-4509
     $mailStatus = '';
     if (!CRM_Utils_Array::crmIsEmptyArray($params['assignee_contact_id']) && CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'activity_assignee_notification')) {
         $mailToContacts = array();
         $assigneeContacts = CRM_Activity_BAO_ActivityAssignment::getAssigneeNames($activity->id, TRUE, FALSE);
         //build an associative array with unique email addresses.
         foreach ($activityAssigned as $id => $dnc) {
             if (isset($id) && array_key_exists($id, $assigneeContacts)) {
                 $mailToContacts[$assigneeContacts[$id]['email']] = $assigneeContacts[$id];
             }
         }
         if (!CRM_Utils_array::crmIsEmptyArray($mailToContacts)) {
             //include attachments while sendig a copy of activity.
             $attachments = CRM_Core_BAO_File::getEntityFile('civicrm_activity', $activity->id);
             // CRM-8400 add param with _currentlyViewedContactId for URL link in mail
             $result = CRM_Case_BAO_Case::sendActivityCopy(NULL, $activity->id, $mailToContacts, $attachments, NULL);
             $mailStatus .= ts("A copy of the activity has also been sent to assignee contacts(s).");
         }
     }
     // set status message
     if (CRM_Utils_Array::value('subject', $params)) {
         $params['subject'] = "'" . $params['subject'] . "'";
     }
     CRM_Core_Session::setStatus(ts('Activity %1 has been saved. %2. %3', array(1 => $params['subject'], 2 => $followupStatus, 3 => $mailStatus)));
     return array('activity' => $activity);
 }
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:101,代码来源:Activity.php

示例11: assignAddressField

 /**
  * Add fields to $profileAddressFields as appropriate.
  * profileAddressFields is assigned to the template to tell it
  * what fields are in the profile address
  * that potentially should be copied to the Billing fields
  * we want to give precedence to 
  *   1) Billing & 
  *   2) then Primary designated as 'Primary
  *   3) location_type is primary
  *   4) if none of these apply then it just uses the first one
  *   
  *   as this will be used to
  * transfer profile address data to billing fields
  * http://issues.civicrm.org/jira/browse/CRM-5869
  * @param string $key Field key - e.g. street_address-Primary, first_name
  * @params array $profileAddressFields array of profile fields that relate to address fields
  */
 static function assignAddressField($key, &$profileAddressFields)
 {
     $billing_id = CRM_Core_BAO_LocationType::getBilling();
     list($prefixName, $index) = CRM_Utils_System::explode('-', $key, 2);
     //check for valid fields ( fields that are present in billing block )
     $validBillingFields = array('first_name', 'middle_name', 'last_name', 'street_address', 'supplemental_address_1', 'city', 'state_province', 'postal_code', 'country');
     if (!in_array($prefixName, $validBillingFields)) {
         return;
     }
     if (!empty($index) && (!CRM_Utils_array::value($prefixName, $profileAddressFields) || $index == $billing_id || $index == 'Primary' && $profileAddressFields[$prefixName] != $billing_id || $index == CRM_Core_BAO_LocationType::getDefault()->id && $profileAddressFields[$prefixName] != $billing_id && $profileAddressFields[$prefixName] != 'Primary')) {
         $profileAddressFields[$prefixName] = $index;
     }
 }
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:30,代码来源:UFField.php

示例12: formRule


//.........这里部分代码省略.........
             }
             //validate for min and max.
             if ($otherAmountVal) {
                 $min = CRM_Utils_Array::value('min_amount', $self->_values);
                 $max = CRM_Utils_Array::value('max_amount', $self->_values);
                 if ($min && $otherAmountVal < $min) {
                     $errors['amount_other'] = ts('Contribution amount must be at least %1', array(1 => $min));
                 }
                 if ($max && $otherAmountVal > $max) {
                     $errors['amount_other'] = ts('Contribution amount cannot be more than %1.', array(1 => $max));
                 }
             }
         }
     }
     // validate PCP fields - if not anonymous, we need a nick name value
     if ($self->_pcpId && CRM_Utils_Array::value('pcp_display_in_roll', $fields) && CRM_Utils_Array::value('pcp_is_anonymous', $fields) == 0 && CRM_Utils_Array::value('pcp_roll_nickname', $fields) == '') {
         $errors['pcp_roll_nickname'] = ts('Please enter a name to include in the Honor Roll, or select \'contribute anonymously\'.');
     }
     // return if this is express mode
     $config = CRM_Core_Config::singleton();
     if ($self->_paymentProcessor['billing_mode'] & CRM_Core_Payment::BILLING_MODE_BUTTON) {
         if (CRM_Utils_Array::value($self->_expressButtonName . '_x', $fields) || CRM_Utils_Array::value($self->_expressButtonName . '_y', $fields) || CRM_Utils_Array::value($self->_expressButtonName, $fields)) {
             return $errors;
         }
     }
     //validate the pledge fields.
     if (CRM_Utils_Array::value('pledge_block_id', $self->_values)) {
         //validation for pledge payment.
         if (CRM_Utils_Array::value('pledge_id', $self->_values)) {
             if (empty($fields['pledge_amount'])) {
                 $errors['pledge_amount'] = ts('At least one payment option needs to be checked.');
             }
         } else {
             if (CRM_Utils_Array::value('is_pledge', $fields)) {
                 if (CRM_Utils_Rule::positiveInteger(CRM_Utils_Array::value('pledge_installments', $fields)) == false) {
                     $errors['pledge_installments'] = ts('Please enter a valid pledge installment.');
                 } else {
                     if (CRM_Utils_Array::value('pledge_installments', $fields) == null) {
                         $errors['pledge_installments'] = ts('Pledge Installments is required field.');
                     } else {
                         if (CRM_Utils_array::value('pledge_installments', $fields) == 1) {
                             $errors['pledge_installments'] = ts('Pledges consist of multiple scheduled payments. Select one-time contribution if you want to make your gift in a single payment.');
                         } else {
                             if (CRM_Utils_array::value('pledge_installments', $fields) == 0) {
                                 $errors['pledge_installments'] = ts('Pledge Installments field must be > 1.');
                             }
                         }
                     }
                 }
                 //validation for Pledge Frequency Interval.
                 if (CRM_Utils_Rule::positiveInteger(CRM_Utils_Array::value('pledge_frequency_interval', $fields)) == false) {
                     $errors['pledge_frequency_interval'] = ts('Please enter a valid Pledge Frequency Interval.');
                 } else {
                     if (CRM_Utils_Array::value('pledge_frequency_interval', $fields) == null) {
                         $errors['pledge_frequency_interval'] = ts('Pledge Frequency Interval. is required field.');
                     } else {
                         if (CRM_Utils_array::value('pledge_frequency_interval', $fields) == 0) {
                             $errors['pledge_frequency_interval'] = ts('Pledge frequency interval field must be > 0');
                         }
                     }
                 }
             }
         }
     }
     // also return if paylater mode
     if (CRM_Utils_Array::value('is_pay_later', $fields)) {
         return empty($errors) ? true : $errors;
     }
     // if the user has chosen a free membership or the amount is less than zero
     // i.e. we skip calling the payment processor and hence dont need credit card
     // info
     if ((double) $amount <= 0.0) {
         return $errors;
     }
     foreach ($self->_fields as $name => $fld) {
         if ($fld['is_required'] && CRM_Utils_System::isNull(CRM_Utils_Array::value($name, $fields))) {
             $errors[$name] = ts('%1 is a required field.', array(1 => $fld['title']));
         }
     }
     // make sure that credit card number and cvv are valid
     require_once 'CRM/Utils/Rule.php';
     if (CRM_Utils_Array::value('credit_card_type', $fields)) {
         if (CRM_Utils_Array::value('credit_card_number', $fields) && !CRM_Utils_Rule::creditCardNumber($fields['credit_card_number'], $fields['credit_card_type'])) {
             $errors['credit_card_number'] = ts('Please enter a valid Credit Card Number');
         }
         if (CRM_Utils_Array::value('cvv2', $fields) && !CRM_Utils_Rule::cvv($fields['cvv2'], $fields['credit_card_type'])) {
             $errors['cvv2'] = ts('Please enter a valid Credit Card Verification Number');
         }
     }
     $elements = array('email_greeting' => 'email_greeting_custom', 'postal_greeting' => 'postal_greeting_custom', 'addressee' => 'addressee_custom');
     foreach ($elements as $greeting => $customizedGreeting) {
         if ($greetingType = CRM_Utils_Array::value($greeting, $fields)) {
             $customizedValue = CRM_Core_OptionGroup::getValue($greeting, 'Customized', 'name');
             if ($customizedValue == $greetingType && !CRM_Utils_Array::value($customizedGreeting, $fields)) {
                 $errors[$customizedGreeting] = ts('Custom %1 is a required field if %1 is of type Customized.', array(1 => ucwords(str_replace('_', " ", $greeting))));
             }
         }
     }
     return empty($errors) ? true : $errors;
 }
开发者ID:rajeshrhino,项目名称:Civicrm-Direct-Debit-Integration,代码行数:101,代码来源:Main.php

示例13: CRM_Member_DAO_Membership

 /**
  * takes an associative array and creates a membership object
  *
  * the function extracts all the params it needs to initialize the created
  * 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)
 {
     // get activity types for use in activity record creation
     $activityTypes = CRM_Core_PseudoConstant::activityType(TRUE, FALSE, FALSE, 'name');
     if (CRM_Utils_Array::value('membership', $ids)) {
         CRM_Utils_Hook::pre('edit', 'Membership', $ids['membership'], $params);
         $oldStatus = NULL;
         $oldType = NULL;
         $membershipObj = new CRM_Member_DAO_Membership();
         $membershipObj->id = $ids['membership'];
         $membershipObj->find();
         while ($membershipObj->fetch()) {
             $oldStatus = $membershipObj->status_id;
             $oldType = $membershipObj->membership_type_id;
         }
     } else {
         CRM_Utils_Hook::pre('create', 'Membership', NULL, $params);
     }
     if (array_key_exists('reminder_date', $params) && !$params['reminder_date']) {
         $params['reminder_date'] = 'null';
     }
     if (array_key_exists('is_override', $params) && !$params['is_override']) {
         $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();
     if (empty($membership->contact_id) || empty($membership->status_id)) {
         // this means we are in renewal mode and are just updating the membership
         // record or this is an API update call and all fields are not present in the update record
         // however the hooks dont care and want all data CRM-7784
         $tempMembership = new CRM_Member_DAO_Membership();
         $tempMembership->id = $membership->id;
         $tempMembership->find(TRUE);
         $membership = $tempMembership;
     }
     //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) : CRM_Utils_Date::isoToMysql($membership->start_date);
     $values = self::getStatusANDTypeValues($membership->id);
     $membershipLog = array('membership_id' => $membership->id, 'status_id' => $membership->status_id, 'start_date' => $logStartDate, 'end_date' => CRM_Utils_Date::isoToMysql($membership->end_date), 'renewal_reminder_date' => CRM_Utils_Date::isoToMysql($membership->reminder_date), 'modified_date' => date('Ymd'), 'membership_type_id' => $values[$membership->id]['membership_type_id']);
     $session = CRM_Core_Session::singleton();
     // If we have an authenticated session, set modified_id to that user's contact_id, else set to membership.contact_id
     if ($session->get('userID')) {
         $membershipLog['modified_id'] = $session->get('userID');
     } elseif (!empty($ids['userId'])) {
         $membershipLog['modified_id'] = $ids['userId'];
     } else {
         $membershipLog['modified_id'] = $membership->contact_id;
     }
     CRM_Member_BAO_MembershipLog::add($membershipLog, CRM_Core_DAO::$_nullArray);
     // reset the group contact cache since smart groups might be affected due to this
     CRM_Contact_BAO_GroupContactCache::remove();
     if (CRM_Utils_Array::value('membership', $ids)) {
         if ($membership->status_id != $oldStatus) {
             $allStatus = CRM_Member_PseudoConstant::membershipStatus();
             $activityParam = array('subject' => "Status changed from {$allStatus[$oldStatus]} to {$allStatus[$membership->status_id]}", 'source_contact_id' => $membershipLog['modified_id'], 'target_contact_id' => $membership->contact_id, 'source_record_id' => $membership->id, 'activity_type_id' => array_search('Change Membership Status', $activityTypes), 'status_id' => 2, 'version' => 3, 'priority_id' => 2, 'activity_date_time' => date('Y-m-d H:i:s'), 'is_auto' => 0, 'is_current_revision' => 1, 'is_deleted' => 0);
             $activityResult = civicrm_api('activity', 'create', $activityParam);
         }
         if (isset($membership->membership_type_id) && $membership->membership_type_id != $oldType) {
             $membershipTypes = CRM_Member_PseudoConstant::membershipType();
             $activityParam = array('subject' => "Type changed from {$membershipTypes[$oldType]} to {$membershipTypes[$membership->membership_type_id]}", 'source_contact_id' => $membershipLog['modified_id'], 'target_contact_id' => $membership->contact_id, 'source_record_id' => $membership->id, 'activity_type_id' => array_search('Change Membership Type', $activityTypes), 'status_id' => 2, 'version' => 3, 'priority_id' => 2, 'activity_date_time' => date('Y-m-d H:i:s'), 'is_auto' => 0, 'is_current_revision' => 1, 'is_deleted' => 0);
             $activityResult = civicrm_api('activity', 'create', $activityParam);
         }
         CRM_Utils_Hook::post('edit', 'Membership', $membership->id, $membership);
     } else {
         CRM_Utils_Hook::post('create', 'Membership', $membership->id, $membership);
     }
     return $membership;
 }
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:88,代码来源:Membership.php

示例14: postProcess


//.........这里部分代码省略.........
             }
         }
         //save static tags
         require_once 'CRM/Core/BAO/EntityTag.php';
         CRM_Core_BAO_EntityTag::create($tagParams, 'civicrm_activity', $activity->id);
         //save free tags
         if (isset($params['taglist']) && !empty($params['taglist'])) {
             require_once 'CRM/Core/Form/Tag.php';
             CRM_Core_Form_Tag::postProcess($params['taglist'], $activity->id, 'civicrm_activity', $this);
         }
     }
     $params['assignee_contact_id'] = $assineeContacts;
     // update existing case record if needed
     $caseParams = $params;
     $caseParams['id'] = $this->_caseId;
     if (CRM_Utils_Array::value('case_type_id', $caseParams)) {
         $caseParams['case_type_id'] = CRM_Case_BAO_Case::VALUE_SEPERATOR . $caseParams['case_type_id'] . CRM_Case_BAO_Case::VALUE_SEPERATOR;
     }
     if (CRM_Utils_Array::value('case_status_id', $caseParams)) {
         $caseParams['status_id'] = $caseParams['case_status_id'];
     }
     // unset params intended for activities only
     unset($caseParams['subject'], $caseParams['details'], $caseParams['status_id'], $caseParams['custom']);
     $case = CRM_Case_BAO_Case::create($caseParams);
     // create case activity record
     $caseParams = array('activity_id' => $activity->id, 'case_id' => $this->_caseId);
     CRM_Case_BAO_Case::processCaseActivity($caseParams);
     // create activity assignee records
     $assigneeParams = array('activity_id' => $activity->id);
     if (!CRM_Utils_Array::crmIsEmptyArray($params['assignee_contact_id'])) {
         //skip those assignee contacts which are already assigned
         //while sending a copy.CRM-4509.
         $activityAssigned = array_flip($params['assignee_contact_id']);
         $activityId = isset($this->_activityId) ? $this->_activityId : $activity->id;
         $assigneeContacts = CRM_Activity_BAO_ActivityAssignment::getAssigneeNames($activityId);
         $activityAssigned = array_diff_key($activityAssigned, $assigneeContacts);
         foreach ($params['assignee_contact_id'] as $key => $id) {
             $assigneeParams['assignee_contact_id'] = $id;
             CRM_Activity_BAO_Activity::createActivityAssignment($assigneeParams);
         }
         //modify assigne_contact as per newly assigned contact before sending copy. CRM-4509.
         $params['assignee_contact_id'] = $activityAssigned;
     }
     // Insert civicrm_log record for the activity (e.g. store the
     // created / edited by contact id and date for the activity)
     // Note - civicrm_log is already created by CRM_Activity_BAO_Activity::create()
     // send copy to selected contacts.
     $mailStatus = '';
     $mailToContacts = array();
     //CRM-5695
     //check for notification settings for assignee contacts
     $selectedContacts = array('contact_check');
     $config =& CRM_Core_Config::singleton();
     if ($config->activityAssigneeNotification) {
         $selectedContacts[] = 'assignee_contact_id';
     }
     foreach ($selectedContacts as $dnt => $val) {
         if (array_key_exists($val, $params) && !CRM_Utils_array::crmIsEmptyArray($params[$val])) {
             if ($val == 'contact_check') {
                 $mailStatus = ts("A copy of the activity has also been sent to selected contacts(s).");
             } else {
                 $this->_relatedContacts = CRM_Activity_BAO_ActivityAssignment::getAssigneeNames($activity->id, true, false);
                 $mailStatus .= ' ' . ts("A copy of the activity has also been sent to assignee contacts(s).");
             }
             //build an associative array with unique email addresses.
             foreach ($params[$val] as $id => $dnc) {
                 if (isset($id) && array_key_exists($id, $this->_relatedContacts)) {
                     //if email already exists in array then append with ', ' another role only otherwise add it to array.
                     if ($contactDetails = CRM_Utils_Array::value($this->_relatedContacts[$id]['email'], $mailToContacts)) {
                         $caseRole = CRM_Utils_Array::value('role', $this->_relatedContacts[$id]);
                         $mailToContacts[$this->_relatedContacts[$id]['email']]['role'] = $contactDetails['role'] . ', ' . $caseRole;
                     } else {
                         $mailToContacts[$this->_relatedContacts[$id]['email']] = $this->_relatedContacts[$id];
                     }
                 }
             }
         }
     }
     if (!CRM_Utils_array::crmIsEmptyArray($mailToContacts)) {
         //include attachments while sendig a copy of activity.
         $attachments =& CRM_Core_BAO_File::getEntityFile('civicrm_activity', $activity->id);
         $result = CRM_Case_BAO_Case::sendActivityCopy($this->_currentlyViewedContactId, $activity->id, $mailToContacts, $attachments, $this->_caseId);
         if (empty($result)) {
             $mailStatus = '';
         }
     } else {
         $mailStatus = '';
     }
     // create follow up activity if needed
     $followupStatus = '';
     if (CRM_Utils_Array::value('followup_activity_type_id', $params)) {
         $followupActivity = CRM_Activity_BAO_Activity::createFollowupActivity($activity->id, $params);
         if ($followupActivity) {
             $caseParams = array('activity_id' => $followupActivity->id, 'case_id' => $this->_caseId);
             CRM_Case_BAO_Case::processCaseActivity($caseParams);
             $followupStatus = ts("A followup activity has been scheduled.");
         }
     }
     CRM_Core_Session::setStatus(ts("'%1' activity has been %2. %3 %4", array(1 => $this->_activityTypeName, 2 => $recordStatus, 3 => $followupStatus, 4 => $mailStatus)));
 }
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:101,代码来源:Activity.php

示例15: getRowsElementsAndInfo

 /**
  * A function to build an array of information required by merge function and the merge UI.
  *
  * @param  int     $mainId         main contact with whom merge has to happen
  * @param  int     $otherId        duplicate contact which would be deleted after merge operation
  *
  * @static
  * @access public
  */
 static function getRowsElementsAndInfo($mainId, $otherId)
 {
     $qfZeroBug = 'e8cddb72-a257-11dc-b9cc-0016d3330ee9';
     // Fetch contacts
     foreach (array('main' => $mainId, 'other' => $otherId) as $moniker => $cid) {
         $params = array('contact_id' => $cid, 'version' => 3, 'return' => array_merge(array('display_name'), self::getContactFields()));
         $result = civicrm_api('contact', 'get', $params);
         if (empty($result['values'][$cid]['contact_type'])) {
             return FALSE;
         }
         ${$moniker} = $result['values'][$cid];
     }
     static $fields = array();
     if (empty($fields)) {
         $fields = CRM_Contact_DAO_Contact::fields();
         CRM_Core_DAO::freeResult();
     }
     // FIXME: there must be a better way
     foreach (array('main', 'other') as $moniker) {
         $contact =& ${$moniker};
         $preferred_communication_method = CRM_Utils_array::value('preferred_communication_method', $contact);
         $value = empty($preferred_communication_method) ? array() : $preferred_communication_method;
         $specialValues[$moniker] = array('preferred_communication_method' => $value);
         if (!empty($contact['preferred_communication_method'])) {
             // api 3 returns pref_comm_method as an array, which breaks the lookup; so we reconstruct
             $prefCommList = is_array($specialValues[$moniker]['preferred_communication_method']) ? implode(CRM_Core_DAO::VALUE_SEPARATOR, $specialValues[$moniker]['preferred_communication_method']) : $specialValues[$moniker]['preferred_communication_method'];
             $specialValues[$moniker]['preferred_communication_method'] = CRM_Core_DAO::VALUE_SEPARATOR . $prefCommList . CRM_Core_DAO::VALUE_SEPARATOR;
         }
         $names = array('preferred_communication_method' => array('newName' => 'preferred_communication_method_display', 'groupName' => 'preferred_communication_method'));
         CRM_Core_OptionGroup::lookupValues($specialValues[$moniker], $names);
     }
     static $optionValueFields = array();
     if (empty($optionValueFields)) {
         $optionValueFields = CRM_Core_OptionValue::getFields();
     }
     foreach ($optionValueFields as $field => $params) {
         $fields[$field]['title'] = $params['title'];
     }
     $diffs = self::findDifferences($main, $other);
     $rows = $elements = $relTableElements = $migrationInfo = array();
     foreach ($diffs['contact'] as $field) {
         foreach (array('main', 'other') as $moniker) {
             $contact =& ${$moniker};
             $value = CRM_Utils_Array::value($field, $contact);
             if (isset($specialValues[$moniker][$field]) && is_string($specialValues[$moniker][$field])) {
                 $value = CRM_Core_DAO::VALUE_SEPARATOR . trim($specialValues[$moniker][$field], CRM_Core_DAO::VALUE_SEPARATOR) . CRM_Core_DAO::VALUE_SEPARATOR;
             }
             $label = isset($specialValues[$moniker]["{$field}_display"]) ? $specialValues[$moniker]["{$field}_display"] : $value;
             if (!empty($fields[$field]['type']) && $fields[$field]['type'] == CRM_Utils_Type::T_DATE) {
                 if ($value) {
                     $value = str_replace('-', '', $value);
                     $label = CRM_Utils_Date::customFormat($label);
                 } else {
                     $value = "null";
                 }
             } elseif (!empty($fields[$field]['type']) && $fields[$field]['type'] == CRM_Utils_Type::T_BOOLEAN) {
                 if ($label === '0') {
                     $label = ts('[ ]');
                 }
                 if ($label === '1') {
                     $label = ts('[x]');
                 }
             } elseif ($field == 'individual_prefix' || $field == 'prefix_id') {
                 $label = CRM_Utils_Array::value('prefix', $contact);
                 $value = CRM_Utils_Array::value('prefix_id', $contact);
                 $field = 'prefix_id';
             } elseif ($field == 'individual_suffix' || $field == 'suffix_id') {
                 $label = CRM_Utils_Array::value('suffix', $contact);
                 $value = CRM_Utils_Array::value('suffix_id', $contact);
                 $field = 'suffix_id';
             }
             $rows["move_{$field}"][$moniker] = $label;
             if ($moniker == 'other') {
                 if ($value === NULL) {
                     $value = 'null';
                 }
                 if ($value === 0 or $value === '0') {
                     $value = $qfZeroBug;
                 }
                 if (is_array($value) && empty($value[1])) {
                     $value[1] = NULL;
                 }
                 $elements[] = array('advcheckbox', "move_{$field}", NULL, NULL, NULL, $value);
                 $migrationInfo["move_{$field}"] = $value;
             }
         }
         $rows["move_{$field}"]['title'] = $fields[$field]['title'];
     }
     // handle location blocks.
     $locationBlocks = array('email', 'phone', 'address');
     $locations = array();
//.........这里部分代码省略.........
开发者ID:archcidburnziso,项目名称:civicrm-core,代码行数:101,代码来源:Merger.php


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