| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
-*/
+ */
/**
*
class CRM_Core_BAO_Mapping extends CRM_Core_DAO_Mapping {
/**
- * Class constructor
+ * Class constructor.
*/
public function __construct() {
parent::__construct();
}
/**
- * Fetch object based on array of properties
+ * Fetch object based on array of properties.
*
* @param array $params
* (reference ) an assoc array of name/value pairs.
* @param array $defaults
* (reference ) an assoc array to hold the flattened values.
*
- * @return object CRM_Core_DAO_Mapping object on success, otherwise NULL
- * @static
+ * @return object
+ * CRM_Core_DAO_Mapping object on success, otherwise NULL
*/
public static function retrieve(&$params, &$defaults) {
$mapping = new CRM_Core_DAO_Mapping();
}
/**
- * Delete the mapping
+ * Delete the mapping.
*
* @param int $id
* Mapping id.
*
- * @return boolean
- * @static
- *
+ * @return bool
*/
public static function del($id) {
// delete from mapping_field table
}
/**
- * Takes an associative array and creates a contact object
+ * Takes an associative array and creates a contact object.
*
* The function extract all the params it needs to initialize the create a
* contact object. the params array could contain additional unused name/value
* @param array $params
* An array of name/value pairs.
*
- * @return object CRM_Core_DAO_Mapper object on success, otherwise NULL
- * @static
+ * @return object
+ * CRM_Core_DAO_Mapper object on success, otherwise NULL
*/
public static function add($params) {
$mapping = new CRM_Core_DAO_Mapping();
}
/**
- * Get the list of mappings
+ * Get the list of mappings.
*
* @param string $mappingTypeId
* Mapping type id.
*
- * @return array $mapping array of mapping name
- * @static
+ * @return array
+ * array of mapping name
*/
public static function getMappings($mappingTypeId) {
$mapping = array();
}
/**
- * Get the mapping fields
+ * Get the mapping fields.
*
* @param int $mappingId
* Mapping id.
*
- * @return array $mappingFields array of mapping fields
- * @static
+ * @return array
+ * array of mapping fields
*/
public static function getMappingFields($mappingId) {
//mapping is to be loaded from database
}
return array(
- $mappingName, $mappingContactType, $mappingLocation, $mappingPhoneType,
- $mappingImProvider, $mappingRelation, $mappingOperator, $mappingValue, $mappingWebsiteType,
+ $mappingName,
+ $mappingContactType,
+ $mappingLocation,
+ $mappingPhoneType,
+ $mappingImProvider,
+ $mappingRelation,
+ $mappingOperator,
+ $mappingValue,
+ $mappingWebsiteType,
);
}
/**
- * Check Duplicate Mapping Name
+ * Check Duplicate Mapping Name.
*
- * @param $nameField
- * String mapping Name.
- * @param $mapTypeId
- * String mapping Type.
+ * @param string $nameField
+ * mapping Name.
+ * @param string $mapTypeId
+ * mapping Type.
*
- * @return boolean
+ * @return bool
*/
public static function checkMapping($nameField, $mapTypeId) {
$mapping = new CRM_Core_DAO_Mapping();
* @param int $smartGroupId
* Smart group id.
*
- * @return array $returnFields associated array of elements@static
+ * @return array
+ * associated array of elements
*/
public static function getFormattedFields($smartGroupId) {
$returnFields = array();
}
/**
- * Build the mapping form
+ * Build the mapping form.
*
* @param CRM_Core_Form $form
* @param string $mappingType
* @param NULL $exportMode
*
* @return void
- * @static
*/
public static function buildMappingForm(&$form, $mappingType = 'Export', $mappingId = NULL, $columnNo, $blockCount = 3, $exportMode = NULL) {
if ($mappingType == 'Export') {
else {
$form->assign('loadedMapping', $mappingId);
- $params = array('id' => $mappingId);
- $temp = array();
+ $params = array('id' => $mappingId);
+ $temp = array();
$mappingDetails = CRM_Core_BAO_Mapping::retrieve($params, $temp);
$form->assign('savedName', $mappingDetails->name);
);
}
- $defaults = array();
+ $defaults = array();
$hasLocationTypes = array();
$hasRelationTypes = array();
- $fields = array();
+ $fields = array();
if ($mappingType == 'Export') {
$required = TRUE;
//we need to unset groups, tags, notes for component export
if ($exportMode != CRM_Export_Form_Select::CONTACT_EXPORT) {
foreach (array(
- 'groups', 'tags', 'notes') as $value) {
+ 'groups',
+ 'tags',
+ 'notes',
+ ) as $value) {
unset($fields['Individual'][$value]);
unset($fields['Household'][$value]);
unset($fields['Organization'][$value]);
if (!empty($fields['Household'][$key]) && !empty($fields['Organization'][$key])) {
$fields['Contact'][$key] = $value;
unset($fields['Organization'][$key],
- $fields['Household'][$key],
- $fields['Individual'][$key]);
+ $fields['Household'][$key],
+ $fields['Individual'][$key]);
}
}
if (array_key_exists('note', $fields['Contact'])) {
$noteTitle = $fields['Contact']['note']['title'];
$fields['Contact']['note']['title'] = $noteTitle . ': ' . ts('Body and Subject');
- $fields['Contact']['note_body'] = array('title' => $noteTitle . ': ' . ts('Body Only'), 'name' => 'note_body');
- $fields['Contact']['note_subject'] = array('title' => $noteTitle . ': ' . ts('Subject Only'), 'name' => 'note_subject');
+ $fields['Contact']['note_body'] = array('title' => $noteTitle . ': ' . ts('Body Only'), 'name' => 'note_body');
+ $fields['Contact']['note_subject'] = array(
+ 'title' => $noteTitle . ': ' . ts('Subject Only'),
+ 'name' => 'note_subject',
+ );
}
}
if (($mappingType == 'Search Builder') || ($exportMode == CRM_Export_Form_Select::CONTRIBUTE_EXPORT)) {
if (CRM_Core_Permission::access('CiviContribute')) {
$fields['Contribution'] = CRM_Contribute_BAO_Contribution::exportableFields();
- unset($fields['Contribution']['contribution_contact_id']);
- unset($fields['Contribution']['contribution_status_id']);
+ foreach (array('contribution_contact_id', 'contribution_soft_credit_name', 'contribution_soft_credit_amount', 'contribution_soft_credit_type', 'contribution_soft_credit_contribution_id') as $element) {
+ unset($fields['Contribution'][$element]);
+ }
$compArray['Contribution'] = ts('Contribution');
}
}
$fields['Participant'] = array_merge($fields['Participant'], $componentPaymentFields);
}
- unset($fields['Participant']['participant_contact_id']);
$compArray['Participant'] = ts('Participant');
}
}
$csRelationships = array();
if ($mappingType == 'Export') {
- $subTypeRelationshipTypes =
- CRM_Contact_BAO_Relationship::getContactRelationshipType(NULL, NULL, NULL, $val['parent'],
- FALSE, 'label', TRUE, $subType);
+ $subTypeRelationshipTypes
+ = CRM_Contact_BAO_Relationship::getContactRelationshipType(NULL, NULL, NULL, $val['parent'],
+ FALSE, 'label', TRUE, $subType);
foreach ($subTypeRelationshipTypes as $key => $var) {
if (!array_key_exists($key, $fields[$val['parent']])) {
}
}
- $sel3[''] = NULL;
- $sel5[''] = NULL;
- $phoneTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Phone', 'phone_type_id');
+ $sel3[''] = NULL;
+ $sel5[''] = NULL;
+ $phoneTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Phone', 'phone_type_id');
$imProviders = CRM_Core_PseudoConstant::get('CRM_Core_DAO_IM', 'provider_id');
asort($phoneTypes);
if ($relationshipType->find(TRUE)) {
$direction = "contact_sub_type_$second";
if (isset($relationshipType->$direction)) {
- $relatedFields = array_merge((array)$relatedMapperFields[$relationshipType->$direction], (array)$relationshipCustomFields);
+ $relatedFields = array_merge((array) $relatedMapperFields[$relationshipType->$direction], (array) $relationshipCustomFields);
}
else {
$target_type = 'contact_type_' . $second;
- $relatedFields = array_merge((array)$relatedMapperFields[$relationshipType->$target_type], (array)$relationshipCustomFields);
+ $relatedFields = array_merge((array) $relatedMapperFields[$relationshipType->$target_type], (array) $relationshipCustomFields);
}
}
$relationshipType->free();
//special fields that have location, hack for primary location
$specialFields = array(
- 'street_address', 'supplemental_address_1', 'supplemental_address_2',
- 'city', 'postal_code', 'postal_code_suffix', 'geo_code_1', 'geo_code_2',
- 'state_province', 'country', 'phone', 'email', 'im',
+ 'street_address',
+ 'supplemental_address_1',
+ 'supplemental_address_2',
+ 'city',
+ 'postal_code',
+ 'postal_code_suffix',
+ 'geo_code_1',
+ 'geo_code_2',
+ 'state_province',
+ 'country',
+ 'phone',
+ 'email',
+ 'im',
);
if (isset($mappingId)) {
list($mappingName, $mappingContactType, $mappingLocation, $mappingPhoneType, $mappingImProvider,
$mappingRelation, $mappingOperator, $mappingValue
- ) = CRM_Core_BAO_Mapping::getMappingFields($mappingId);
+ ) = CRM_Core_BAO_Mapping::getMappingFields($mappingId);
$blkCnt = count($mappingName);
if ($blkCnt >= $blockCount) {
$js = "<script type='text/javascript'>\n";
$formName = "document.{$name}";
if (!empty($nullArray)) {
- $js .= "var nullArray = [";
+ $js .= "var nullArray = [";
$elements = array();
- $seen = array();
+ $seen = array();
foreach ($nullArray as $element) {
$key = "{$element[0]}, {$element[1]}, {$element[2]}";
if (!isset($seen[$key])) {
";
}
if (!empty($noneArray)) {
- $js .= "var noneArray = [";
+ $js .= "var noneArray = [";
$elements = array();
- $seen = array();
+ $seen = array();
foreach ($noneArray as $element) {
$key = "{$element[0]}, {$element[1]}, {$element[2]}";
if (!isset($seen[$key])) {
* @param int $relationshipTypeId
* Related relationship type id.
*
- * @return array all custom field titles
+ * @return array
+ * all custom field titles
*/
public function getRelationTypeCustomGroupData($relationshipTypeId) {
/**
- * Function returns all Custom group Names
+ * Function returns all Custom group Names.
*
* @param int $customfieldId
* Related file id.
*
- * @return null|string $customGroupName all custom group names@static
+ * @return null|string
+ * $customGroupName all custom group names
*/
public static function getCustomGroupName($customfieldId) {
if ($customFieldId = CRM_Core_BAO_CustomField::getKeyID($customfieldId)) {
* Row no of the fields.
*
*
- * @return array $returnFields formatted associated array of elements@static
+ * @return array
+ * formatted associated array of elements
*/
public static function formattedFields(&$params, $row = FALSE) {
$fields = array();
if (in_array($v[0], $types)) {
if ($contactType && $contactType != $v[0]) {
CRM_Core_Error::fatal(ts("Cannot have two clauses with different types: %1, %2",
- array(1 => $contactType, 2 => $v[0])
- ));
+ array(1 => $contactType, 2 => $v[0])
+ ));
}
$contactType = $v[0];
}
}
if ($v[0] == 'Contribution' && substr($fldName, 0, 7) != 'custom_'
- && substr($fldName, 0, 10) != 'financial_') {
+ && substr($fldName, 0, 10) != 'financial_'
+ && substr($fldName, 0, 8) != 'payment_') {
if (substr($fldName, 0, 13) != 'contribution_') {
$fldName = 'contribution_' . $fldName;
}
}
// CRM-14983: verify if values are comma separated convert to array
- if (!is_array($value) && (strpos($value,',') !== FALSE || strstr($value, '(')) && empty($isCustomField) && $params['operator'][$key][$k] == 'IN') {
+ if (!is_array($value) && (strpos($value, ',') !== FALSE || strstr($value, '(')) && empty($isCustomField) && $params['operator'][$key][$k] == 'IN') {
preg_match('#\((.*?)\)#', $value, $match);
$tmpArray = explode(',', $match[1]);
- $value = array_combine(array_values($tmpArray),array_values($tmpArray));
+ $value = array_combine(array_values($tmpArray), array_values($tmpArray));
}
if ($row) {
0,
);
}
-
-
return $fields;
}
* Mapping id.
*
* @return NULL
- * @static
*/
public static function saveMappingFields(&$params, $mappingId) {
//delete mapping fields records for exixting mapping
$mappingFields->delete();
if (empty($params['mapper'])) {
- return;
+ return NULL;
}
//save record in mapping field table
}
}
}
+
}