本文整理汇总了PHP中CRM_Member_DAO_Membership::import方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Member_DAO_Membership::import方法的具体用法?PHP CRM_Member_DAO_Membership::import怎么用?PHP CRM_Member_DAO_Membership::import使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Member_DAO_Membership
的用法示例。
在下文中一共展示了CRM_Member_DAO_Membership::import方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: array
/**
* Combine all the importable fields from the lower levels object.
*
* @param string $contactType
* Contact type.
* @param bool $status
*
* @return array
* array of importable Fields
*/
public static function &importableFields($contactType = 'Individual', $status = TRUE)
{
if (!self::$_importableFields) {
if (!self::$_importableFields) {
self::$_importableFields = array();
}
if (!$status) {
$fields = array('' => array('title' => '- ' . ts('do not import') . ' -'));
} else {
$fields = array('' => array('title' => '- ' . ts('Membership Fields') . ' -'));
}
$tmpFields = CRM_Member_DAO_Membership::import();
$contactFields = CRM_Contact_BAO_Contact::importableFields($contactType, NULL);
// Using new Dedupe rule.
$ruleParams = array('contact_type' => $contactType, 'used' => 'Unsupervised');
$fieldsArray = CRM_Dedupe_BAO_Rule::dedupeRuleFields($ruleParams);
$tmpContactField = array();
if (is_array($fieldsArray)) {
foreach ($fieldsArray as $value) {
$customFieldId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomField', $value, 'id', 'column_name');
$value = $customFieldId ? 'custom_' . $customFieldId : $value;
$tmpContactField[trim($value)] = CRM_Utils_Array::value(trim($value), $contactFields);
if (!$status) {
$title = $tmpContactField[trim($value)]['title'] . " " . ts('(match to contact)');
} else {
$title = $tmpContactField[trim($value)]['title'];
}
$tmpContactField[trim($value)]['title'] = $title;
}
}
$tmpContactField['external_identifier'] = $contactFields['external_identifier'];
$tmpContactField['external_identifier']['title'] = $contactFields['external_identifier']['title'] . " " . ts('(match to contact)');
$tmpFields['membership_contact_id']['title'] = $tmpFields['membership_contact_id']['title'] . " " . ts('(match to contact)');
$fields = array_merge($fields, $tmpContactField);
$fields = array_merge($fields, $tmpFields);
$fields = array_merge($fields, CRM_Core_BAO_CustomField::getFieldsForImport('Membership'));
self::$_importableFields = $fields;
}
return self::$_importableFields;
}
示例2: import
/**
* handle the values in import mode
*
* @param int $onDuplicate the code for what action to take on duplicates
* @param array $values the array of values belonging to this line
*
* @return boolean the result of this processing
* @access public
*/
function import($onDuplicate, &$values)
{
// first make sure this is a valid line
$response = $this->summary($values);
if ($response != CRM_Member_Import_Parser::VALID) {
return $response;
}
$params =& $this->getActiveFieldParams();
//assign join date equal to start date if join date is not provided
if (!$params['join_date'] && $params['membership_start_date']) {
$params['join_date'] = $params['membership_start_date'];
}
$session =& CRM_Core_Session::singleton();
$dateType = $session->get("dateTypes");
$formatted = array();
$customFields = CRM_Core_BAO_CustomField::getFields(CRM_Utils_Array::value('contact_type', $params));
// don't add to recent items, CRM-4399
$formatted['skipRecentView'] = true;
foreach ($params as $key => $val) {
if ($val) {
switch ($key) {
case 'join_date':
if (CRM_Utils_Date::convertToDefaultDate($params, $dateType, $key)) {
if (!CRM_Utils_Rule::date($params[$key])) {
CRM_Import_Parser_Contact::addToErrorMsg('Join Date', $errorMessage);
}
} else {
CRM_Import_Parser_Contact::addToErrorMsg('Join Date', $errorMessage);
}
break;
case 'membership_start_date':
if (CRM_Utils_Date::convertToDefaultDate($params, $dateType, $key)) {
if (!CRM_Utils_Rule::date($params[$key])) {
CRM_Import_Parser_Contact::addToErrorMsg('Start Date', $errorMessage);
}
} else {
CRM_Import_Parser_Contact::addToErrorMsg('Start Date', $errorMessage);
}
break;
case 'membership_end_date':
if (CRM_Utils_Date::convertToDefaultDate($params, $dateType, $key)) {
if (!CRM_Utils_Rule::date($params[$key])) {
CRM_Import_Parser_Contact::addToErrorMsg('End Date', $errorMessage);
}
} else {
CRM_Import_Parser_Contact::addToErrorMsg('End Date', $errorMessage);
}
break;
case 'is_override':
$params[$key] = CRM_Utils_String::strtobool($val);
break;
}
if ($customFieldID = CRM_Core_BAO_CustomField::getKeyID($key)) {
if ($customFields[$customFieldID][2] == 'Date') {
CRM_Import_Parser_Contact::formatCustomDate($params, $formatted, $dateType, $key);
unset($params[$key]);
} else {
if ($customFields[$customFieldID][2] == 'Boolean') {
$params[$key] = CRM_Utils_String::strtoboolstr($val);
}
}
}
}
}
//date-Format part ends
static $indieFields = null;
if ($indieFields == null) {
require_once 'CRM/Member/DAO/Membership.php';
$tempIndieFields =& CRM_Member_DAO_Membership::import();
$indieFields = $tempIndieFields;
}
$formatValues = array();
foreach ($params as $key => $field) {
if ($field == null || $field === '') {
continue;
}
$formatValues[$key] = $field;
}
$formatError = _civicrm_membership_formatted_param($formatValues, $formatted, true);
if ($formatError) {
array_unshift($values, $formatError['error_message']);
return CRM_Member_Import_Parser::ERROR;
}
if ($onDuplicate != CRM_Member_Import_Parser::DUPLICATE_UPDATE) {
$formatted['custom'] = CRM_Core_BAO_CustomField::postProcess($formatted, CRM_Core_DAO::$_nullObject, null, 'Membership');
} else {
//fix for CRM-2219 Update Membership
// onDuplicate == CRM_Member_Import_Parser::DUPLICATE_UPDATE
if (CRM_Utils_Array::value('is_override', $formatted) && !CRM_Utils_Array::value('status_id', $formatted)) {
array_unshift($values, "Required parameter missing: Status");
return CRM_Member_Import_Parser::ERROR;
//.........这里部分代码省略.........
示例3: import
/**
* handle the values in import mode
*
* @param int $onDuplicate the code for what action to take on duplicates
* @param array $values the array of values belonging to this line
*
* @return boolean the result of this processing
* @access public
*/
function import($onDuplicate, &$values)
{
try {
// first make sure this is a valid line
$response = $this->summary($values);
if ($response != CRM_Import_Parser::VALID) {
return $response;
}
$params =& $this->getActiveFieldParams();
//assign join date equal to start date if join date is not provided
if (!CRM_Utils_Array::value('join_date', $params) && CRM_Utils_Array::value('membership_start_date', $params)) {
$params['join_date'] = $params['membership_start_date'];
}
$session = CRM_Core_Session::singleton();
$dateType = $session->get('dateTypes');
$formatted = array();
$customFields = CRM_Core_BAO_CustomField::getFields(CRM_Utils_Array::value('contact_type', $params));
// don't add to recent items, CRM-4399
$formatted['skipRecentView'] = TRUE;
$dateLabels = array('join_date' => ts('Member Since'), 'membership_start_date' => ts('Start Date'), 'membership_end_date' => ts('End Date'));
foreach ($params as $key => $val) {
if ($val) {
switch ($key) {
case 'join_date':
case 'membership_start_date':
case 'membership_end_date':
if (CRM_Utils_Date::convertToDefaultDate($params, $dateType, $key)) {
if (!CRM_Utils_Rule::date($params[$key])) {
CRM_Contact_Import_Parser_Contact::addToErrorMsg($dateLabels[$key], $errorMessage);
}
} else {
CRM_Contact_Import_Parser_Contact::addToErrorMsg($dateLabels[$key], $errorMessage);
}
break;
case 'membership_type_id':
if (!is_numeric($val)) {
unset($params['membership_type_id']);
$params['membership_type'] = $val;
}
break;
case 'status_id':
if (!is_numeric($val)) {
unset($params['status_id']);
$params['membership_status'] = $val;
}
break;
case 'is_override':
$params[$key] = CRM_Utils_String::strtobool($val);
break;
}
if ($customFieldID = CRM_Core_BAO_CustomField::getKeyID($key)) {
if ($customFields[$customFieldID]['data_type'] == 'Date') {
CRM_Contact_Import_Parser_Contact::formatCustomDate($params, $formatted, $dateType, $key);
unset($params[$key]);
} else {
if ($customFields[$customFieldID]['data_type'] == 'Boolean') {
$params[$key] = CRM_Utils_String::strtoboolstr($val);
}
}
}
}
}
//date-Format part ends
static $indieFields = NULL;
if ($indieFields == NULL) {
$tempIndieFields = CRM_Member_DAO_Membership::import();
$indieFields = $tempIndieFields;
}
$formatValues = array();
foreach ($params as $key => $field) {
if ($field == NULL || $field === '') {
continue;
}
$formatValues[$key] = $field;
}
//format params to meet api v2 requirements.
//@todo find a way to test removing this formatting
$formatError = $this->membership_format_params($formatValues, $formatted, TRUE);
if ($onDuplicate != CRM_Import_Parser::DUPLICATE_UPDATE) {
$formatted['custom'] = CRM_Core_BAO_CustomField::postProcess($formatted, CRM_Core_DAO::$_nullObject, NULL, 'Membership');
} else {
//fix for CRM-2219 Update Membership
// onDuplicate == CRM_Import_Parser::DUPLICATE_UPDATE
if (CRM_Utils_Array::value('is_override', $formatted) && !CRM_Utils_Array::value('status_id', $formatted)) {
array_unshift($values, 'Required parameter missing: Status');
return CRM_Import_Parser::ERROR;
}
if (!empty($formatValues['membership_id'])) {
$dao = new CRM_Member_BAO_Membership();
$dao->id = $formatValues['membership_id'];
$dates = array('join_date', 'start_date', 'end_date');
//.........这里部分代码省略.........
示例4: array
/**
* Combine all the importable fields from the lower levels object
*
* @param string $contactType contact type
* @param boolean $status
*
* @return array array of importable Fields
* @access public
*/
function &importableFields($contactType = 'Individual', $status = true)
{
if (!self::$_importableFields) {
if (!self::$_importableFields) {
self::$_importableFields = array();
}
if (!$status) {
$fields = array('' => array('title' => '- ' . ts('do not import') . ' -'));
} else {
$fields = array('' => array('title' => '- ' . ts('Membership Fields') . ' -'));
}
$tmpFields = CRM_Member_DAO_Membership::import();
require_once 'CRM/Contact/BAO/Contact.php';
$contactFields = CRM_Contact_BAO_Contact::importableFields($contactType, null);
// Using new Dedupe rule.
$ruleParams = array('contact_type' => $contactType, 'level' => 'Strict');
require_once 'CRM/Dedupe/BAO/Rule.php';
$fieldsArray = CRM_Dedupe_BAO_Rule::dedupeRuleFields($ruleParams);
$tmpContactField = array();
if (is_array($fieldsArray)) {
foreach ($fieldsArray as $value) {
$tmpContactField[trim($value)] = CRM_Utils_Array::value(trim($value), $contactFields);
if (!$status) {
$title = $tmpContactField[trim($value)]['title'] . " " . ts("(match to contact)");
} else {
$title = $tmpContactField[trim($value)]['title'];
}
$tmpContactField[trim($value)]['title'] = $title;
}
}
$tmpContactField['external_identifier'] = $contactFields['external_identifier'];
$tmpContactField['external_identifier']['title'] = $contactFields['external_identifier']['title'] . " " . ts("(match to contact)");
$tmpFields['membership_contact_id']['title'] = $tmpFields['membership_contact_id']['title'] . " " . ts("(match to contact)");
$fields = array_merge($fields, $tmpContactField);
$fields = array_merge($fields, $tmpFields);
$fields = array_merge($fields, CRM_Core_BAO_CustomField::getFieldsForImport('Membership'));
self::$_importableFields = $fields;
}
return self::$_importableFields;
}