INFRA-132 - Fix missing newlines in comments
[civicrm-core.git] / CRM / Core / BAO / Mapping.php
index af69c07c0856ffe8a078f0ab2f7fc00119d364d0..3b5d659e4a5e2213ce2e13d88deb15a7e5fea4a8 100644 (file)
@@ -1,7 +1,7 @@
 <?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();
   }
 
   /**
    * 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)) {
@@ -62,16 +63,16 @@ class CRM_Core_BAO_Mapping extends CRM_Core_DAO_Mapping {
   }
 
   /**
-   * 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;
@@ -90,19 +91,19 @@ class CRM_Core_BAO_Mapping extends CRM_Core_DAO_Mapping {
   }
 
   /**
-   * 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();
@@ -111,15 +112,15 @@ class CRM_Core_BAO_Mapping extends CRM_Core_DAO_Mapping {
   }
 
   /**
-   * get the list of mappings
+   * Get the list of mappings
    *
-   * @param string  $mappingTypeId  mapping type id
+   * @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;
@@ -133,15 +134,15 @@ class CRM_Core_BAO_Mapping extends CRM_Core_DAO_Mapping {
   }
 
   /**
-   * get the mapping fields
+   * Get the mapping fields
    *
-   * @param int $mappingId  mapping id
+   * @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;
@@ -193,12 +194,14 @@ class CRM_Core_BAO_Mapping extends CRM_Core_DAO_Mapping {
   /**
    * 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
    */
-  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;
@@ -208,12 +211,13 @@ class CRM_Core_BAO_Mapping extends CRM_Core_DAO_Mapping {
   /**
    * Function returns associated array of elements, that will be passed for search
    *
-   * @param int $smartGroupId smart group id
+   * @param int $smartGroupId
+   *   Smart group id.
    *
-   * @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
@@ -236,20 +240,21 @@ class CRM_Core_BAO_Mapping extends CRM_Core_DAO_Mapping {
   }
 
   /**
-   * Function to build the mapping form
+   * Build the mapping form
    *
    * @param CRM_Core_Form $form
-   * @param string $mappingType (Export/Import/Search Builder)
+   * @param string $mappingType
+   *   (Export/Import/Search Builder).
    * @param int $mappingId
    * @param int $columnNo
-   * @param int $blockCount (no of blocks shown)
-   * @param null $exportMode
+   * @param int $blockCount
+   *   (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);
@@ -373,8 +378,8 @@ class CRM_Core_BAO_Mapping extends CRM_Core_DAO_Mapping {
       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');
       }
     }
 
@@ -594,7 +599,7 @@ class CRM_Core_BAO_Mapping extends CRM_Core_DAO_Mapping {
               // 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;
@@ -867,7 +872,7 @@ class CRM_Core_BAO_Mapping extends CRM_Core_DAO_Mapping {
       $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 = '';
                     }
@@ -888,7 +893,7 @@ class CRM_Core_BAO_Mapping extends CRM_Core_DAO_Mapping {
       $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';
                     }
@@ -909,11 +914,12 @@ class CRM_Core_BAO_Mapping extends CRM_Core_DAO_Mapping {
    * Function returns all custom fields with group title and
    * field label
    *
-   * @param int $relationshipTypeId related relationship type id
+   * @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();
@@ -927,11 +933,13 @@ class CRM_Core_BAO_Mapping extends CRM_Core_DAO_Mapping {
   /**
    * Function returns all  Custom group Names
    *
-   * @param int $customfieldId related file id
+   * @param int $customfieldId
+   *   Related file 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');
@@ -947,14 +955,16 @@ class CRM_Core_BAO_Mapping extends CRM_Core_DAO_Mapping {
   /**
    * Function returns associated array of elements, that will be passed for search
    *
-   * @param array $params associated array of submitted values
-   * @param bool $row  row no of the fields
+   * @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'])) {
@@ -1015,7 +1025,7 @@ class CRM_Core_BAO_Mapping extends CRM_Core_DAO_Mapping {
               '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 )
@@ -1030,7 +1040,7 @@ class CRM_Core_BAO_Mapping extends CRM_Core_DAO_Mapping {
           }
 
           // 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));
@@ -1087,7 +1097,7 @@ class CRM_Core_BAO_Mapping extends CRM_Core_DAO_Mapping {
    *
    * @return array
    */
-  static function &returnProperties(&$params) {
+  public static function &returnProperties(&$params) {
     $fields = array(
       'contact_type' => 1,
       'contact_sub_type' => 1,
@@ -1142,16 +1152,17 @@ class CRM_Core_BAO_Mapping extends CRM_Core_DAO_Mapping {
   }
 
   /**
-   * 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;
@@ -1231,4 +1242,3 @@ class CRM_Core_BAO_Mapping extends CRM_Core_DAO_Mapping {
     }
   }
 }
-