<?php
/*
+--------------------------------------------------------------------+
- | CiviCRM version 4.5 |
+ | CiviCRM version 4.6 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2014 |
+--------------------------------------------------------------------+
class CRM_Core_BAO_Mapping extends CRM_Core_DAO_Mapping {
/**
- * class constructor
+ * Class constructor
*/
- function __construct() {
+ public function __construct() {
parent::__construct();
}
/**
- * Takes a bunch of params that are needed to match certain criteria and
- * retrieves the relevant objects. Typically the valid params are only
- * contact_id. We'll tweak this function to be more full featured over a period
- * of time. This is the inverse function of create. It also stores all the retrieved
- * values in the default array
+ * 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
+ * @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
- * @access public
+ * @return object CRM_Core_DAO_Mapping object on success, otherwise NULL
* @static
*/
- static function retrieve(&$params, &$defaults) {
+ public static function retrieve(&$params, &$defaults) {
$mapping = new CRM_Core_DAO_Mapping();
$mapping->copyValues($params);
if ($mapping->find(TRUE)) {
}
/**
- * Function to delete the mapping
+ * Delete the mapping
*
- * @param int $id mapping id
+ * @param int $id
+ * Mapping id.
*
* @return boolean
- * @access public
* @static
*
*/
- static function del($id) {
+ public static function del($id) {
// delete from mapping_field table
$mappingField = new CRM_Core_DAO_MappingField();
$mappingField->mapping_id = $id;
}
/**
- * 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
* pairs
*
- * @param array $params an array of name/value pairs
+ * @param array $params
+ * An array of name/value pairs.
*
- * @return object CRM_Core_DAO_Mapper object on success, otherwise null
- * @access public
+ * @return object CRM_Core_DAO_Mapper object on success, otherwise NULL
* @static
*/
- static function add($params) {
+ public static function add($params) {
$mapping = new CRM_Core_DAO_Mapping();
$mapping->copyValues($params);
$mapping->save();
}
/**
- * function to get the list of mappings
+ * Get the list of mappings
*
- * @params string $mappingTypeId mapping type id
- *
- * @param $mappingTypeId
+ * @param string $mappingTypeId
+ * Mapping type id.
*
* @return array $mapping array of mapping name
- * @access public
* @static
*/
- static function getMappings($mappingTypeId) {
+ public static function getMappings($mappingTypeId) {
$mapping = array();
$mappingDAO = new CRM_Core_DAO_Mapping();
$mappingDAO->mapping_type_id = $mappingTypeId;
}
/**
- * function to get the mapping fields
- *
- * @params int $mappingId mapping id
+ * Get the mapping fields
*
- * @param $mappingId
+ * @param int $mappingId
+ * Mapping id.
*
* @return array $mappingFields array of mapping fields
- * @access public
* @static
*/
- static function getMappingFields($mappingId) {
+ public static function getMappingFields($mappingId) {
//mapping is to be loaded from database
$mapping = new CRM_Core_DAO_MappingField();
$mapping->mapping_id = $mappingId;
}
/**
- *function to check Duplicate Mapping Name
- *
- * @params $nameField string mapping Name
- *
- * @params $mapTypeId string mapping Type
+ * Check Duplicate Mapping Name
*
- * @param $nameField
- * @param $mapTypeId
+ * @param string $nameField
+ * mapping Name.
+ * @param string $mapTypeId
+ * mapping Type.
*
* @return boolean
*/
- static function checkMapping($nameField, $mapTypeId) {
+ public static function checkMapping($nameField, $mapTypeId) {
$mapping = new CRM_Core_DAO_Mapping();
$mapping->name = $nameField;
$mapping->mapping_type_id = $mapTypeId;
- if ($mapping->find(TRUE)) {
- return TRUE;
- }
- else {
- return FALSE;
- }
+ return (bool) $mapping->find(TRUE);
}
/**
* Function returns associated array of elements, that will be passed for search
*
- * @params int $smartGroupId smart group id
+ * @param int $smartGroupId
+ * Smart group id.
*
- * @param $smartGroupId
- *
- * @return array $returnFields associated array of elements@static
- * @public
+ * @return array $returnFields associated array of elements
+ * @static
*/
- static function getFormattedFields($smartGroupId) {
+ public static function getFormattedFields($smartGroupId) {
$returnFields = array();
//get the fields from mapping table
}
/**
- * Function to build the mapping form
- *
- * @params object $form form object
- * @params string $mappingType mapping type (Export/Import/Search Builder)
- * @params int $mappingId mapping id
- * @params mixed $columnCount column count is int for and array for search builder
- * @params int $blockCount block count (no of blocks shown)
+ * Build the mapping form
*
- * @param $form
+ * @param CRM_Core_Form $form
* @param string $mappingType
- * @param null $mappingId
- * @param $columnNo
+ * (Export/Import/Search Builder).
+ * @param int $mappingId
+ * @param int $columnNo
* @param int $blockCount
- * @param null $exportMode
+ * (no of blocks shown).
+ * @param NULL $exportMode
*
* @return void
- * @access public
* @static
*/
- static function buildMappingForm(&$form, $mappingType = 'Export', $mappingId = NULL, $columnNo, $blockCount = 3, $exportMode = NULL) {
+ public static function buildMappingForm(&$form, $mappingType = 'Export', $mappingId = NULL, $columnNo, $blockCount = 3, $exportMode = NULL) {
if ($mappingType == 'Export') {
$name = "Map";
$columnCount = array('1' => $columnNo);
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 (CRM_Core_Permission::access('CiviGrant')) {
$fields['Grant'] = CRM_Grant_BAO_Grant::exportableFields();
unset($fields['Grant']['grant_contact_id']);
+ if ($mappingType == 'Search Builder') {
+ unset($fields['Grant']['grant_type_id']);
+ }
$compArray['Grant'] = ts('Grant');
}
}
$defaultLocationType = CRM_Core_BAO_LocationType::getDefault();
- /* FIXME: dirty hack to make the default option show up first. This
- * avoids a mozilla browser bug with defaults on dynamically constructed
- * selector widgets. */
-
-
+ // FIXME: dirty hack to make the default option show up first. This
+ // avoids a mozilla browser bug with defaults on dynamically constructed
+ // selector widgets.
if ($defaultLocationType) {
$defaultLocation = $locationTypes[$defaultLocationType->id];
unset($locationTypes[$defaultLocationType->id]);
- $locationTypes = array(
- $defaultLocationType->id => $defaultLocation) + $locationTypes;
+ $locationTypes = array($defaultLocationType->id => $defaultLocation) + $locationTypes;
}
- $locationTypes = array(
- ' ' => ts('Primary')) + $locationTypes;
+ $locationTypes = array(' ' => ts('Primary')) + $locationTypes;
// since we need a hierarchical list to display contact types & subtypes,
// this is what we going to display in first selector
$contactTypes = array('Contact' => ts('Contacts')) + $contactTypes;
}
- $sel1 =
- array('' => ts('- select record type -')) + $contactTypes + $compArray;
+ $sel1 = array('' => ts('- select record type -')) + $contactTypes + $compArray;
foreach ($sel1 as $key => $sel) {
if ($key) {
}
}
- //Array for core fields and relationship custom data
-
+ // Array for core fields and relationship custom data
$relationshipTypes = CRM_Contact_BAO_Relationship::getContactRelationshipType(NULL, NULL, NULL, NULL, TRUE);
if ($mappingType == 'Export') {
// FIX ME: For now let's not expose custom data related to relationship
$relationshipCustomFields = array();
//$relationshipCustomFields = self::getRelationTypeCustomGroupData( $id );
- //asort( $relationshipCustomFields ) ;
+ //asort($relationshipCustomFields);
$relationshipType = new CRM_Contact_BAO_RelationshipType();
$relationshipType->id = $id;
}
//Location Type for relationship fields
-
foreach ($sel5 as $k => $v) {
if ($v) {
foreach ($v as $rel => $fields) {
$js .= implode(', ', $elements);
$js .= "]";
$js .= "
- for(var i=0;i<nullArray.length;i++) {
+ for (var i=0;i<nullArray.length;i++) {
if ( {$formName}['mapper['+nullArray[i][0]+']['+nullArray[i][1]+']['+nullArray[i][2]+']'] ) {
{$formName}['mapper['+nullArray[i][0]+']['+nullArray[i][1]+']['+nullArray[i][2]+']'].style.display = '';
}
$js .= implode(', ', $elements);
$js .= "]";
$js .= "
- for(var i=0;i<noneArray.length;i++) {
+ for (var i=0;i<noneArray.length;i++) {
if ( {$formName}['mapper['+noneArray[i][0]+']['+noneArray[i][1]+']['+noneArray[i][2]+']'] ) {
{$formName}['mapper['+noneArray[i][0]+']['+noneArray[i][1]+']['+noneArray[i][2]+']'].style.display = 'none';
}
$form->setDefaultAction('refresh');
}
- /* Function returns all custom fields with group title and
- * field label
- * @relationshipTypeId related relationship type id
- * @return $groupTitle all custom field titles
- */
/**
- * @param $relationshipTypeId
+ * Function returns all custom fields with group title and
+ * field label
*
- * @return array
+ * @param int $relationshipTypeId
+ * Related relationship type id.
+ *
+ * @return array all custom field titles
*/
- function getRelationTypeCustomGroupData($relationshipTypeId) {
+ public function getRelationTypeCustomGroupData($relationshipTypeId) {
$customFields = CRM_Core_BAO_CustomField::getFields('Relationship', NULL, NULL, $relationshipTypeId, NULL, NULL);
$groupTitle = array();
/**
* Function returns all Custom group Names
*
- * @param related $customfieldId
+ * @param int $customfieldId
+ * Related file id.
*
- * @internal param \related $customfieldId custom field id
- * @return null|string $customGroupName all custom group names@static
+ * @return null|string $customGroupName all custom group names
+ * @static
*/
- static function getCustomGroupName($customfieldId) {
+ public static function getCustomGroupName($customfieldId) {
if ($customFieldId = CRM_Core_BAO_CustomField::getKeyID($customfieldId)) {
$customGroupId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomField', $customFieldId, 'custom_group_id');
$customGroupName = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomGroup', $customGroupId, 'title');
/**
* Function returns associated array of elements, that will be passed for search
*
- * @params array $params associated array of submitted values
- * @params boolean $row row no of the fields
- *
- * @param $params
+ * @param array $params
+ * Associated array of submitted values.
* @param bool $row
+ * Row no of the fields.
*
- * @return array $returnFields formatted associated array of elements@static
- * @public
+ *
+ * @return array $returnFields formatted associated array of elements
+ * @static
*/
- static function formattedFields(&$params, $row = FALSE) {
+ public static function formattedFields(&$params, $row = FALSE) {
$fields = array();
if (empty($params) || !isset($params['mapper'])) {
'Multi-Select',
'AdvMulti-Select',
'Multi-Select State/Province',
- 'Multi-Select Country'
+ 'Multi-Select Country',
);
// override the operator to handle separator ( note: this might have some performance issues )
}
// 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));
}
/**
- * @param $params
+ * @param array $params
*
* @return array
*/
- static function &returnProperties(&$params) {
+ public static function &returnProperties(&$params) {
$fields = array(
'contact_type' => 1,
'contact_sub_type' => 1,
}
/**
- * save the mapping field info for search builder / export given the formvalues
+ * Save the mapping field info for search builder / export given the formvalues
*
- * @param array $params asscociated array of formvalues
- * @param int $mappingId mapping id
+ * @param array $params
+ * Asscociated array of formvalues.
+ * @param int $mappingId
+ * Mapping id.
*
- * @return null
+ * @return NULL
* @static
- * @access public
*/
- static function saveMappingFields(&$params, $mappingId) {
+ public static function saveMappingFields(&$params, $mappingId) {
//delete mapping fields records for exixting mapping
$mappingFields = new CRM_Core_DAO_MappingField();
$mappingFields->mapping_id = $mappingId;
}
}
}
-