Merge remote-tracking branch 'upstream/4.5' into 4.5-master-2015-02-09-11-44-07
[civicrm-core.git] / CRM / Core / BAO / UFGroup.php
index cb828687c14b822c5653bb6d0c951cd14e76e29e..0264d2f449d4d421f23a8c3f755afd651581d44c 100644 (file)
@@ -23,7 +23,7 @@
  | GNU Affero General Public License or the licensing of CiviCRM,     |
  | see the CiviCRM license FAQ at http://civicrm.org/licensing        |
  +--------------------------------------------------------------------+
-*/
+ */
 
 /**
  *
@@ -42,22 +42,22 @@ class CRM_Core_BAO_UFGroup extends CRM_Core_DAO_UFGroup {
     LISTINGS_VISIBILITY = 4;
 
   /**
-   * Cache the match clause used in this transaction
+   * Cache the match clause used in this transaction.
    *
    * @var string
    */
   static $_matchFields = NULL;
 
   /**
-   * 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_UFGroup object
-   * @static
+   * @return object
+   *   CRM_Core_DAO_UFGroup object
    */
   public static function retrieve(&$params, &$defaults) {
     return CRM_Core_DAO::commonRetrieve('CRM_Core_DAO_UFGroup', $params, $defaults);
@@ -69,7 +69,8 @@ class CRM_Core_BAO_UFGroup extends CRM_Core_DAO_UFGroup {
    * @param int $id
    *   Id of uf_group.
    *
-   * @return string  contact type
+   * @return string
+   *   contact type
    */
   public static function getContactType($id) {
 
@@ -87,8 +88,9 @@ class CRM_Core_BAO_UFGroup extends CRM_Core_DAO_UFGroup {
       elseif (array_key_exists($type, $validSubTypes)) {
         $cType = CRM_Utils_Array::value('parent', $validSubTypes[$type]);
       }
-      if ($cType)
-      break;
+      if ($cType) {
+        break;
+      }
     }
 
     return $cType;
@@ -100,9 +102,8 @@ class CRM_Core_BAO_UFGroup extends CRM_Core_DAO_UFGroup {
    * @param int $id
    *   Id of uf_form.
    *
-   * @return string title
-   *
-   * @static
+   * @return string
+   *   title
    *
    */
   public static function getTitle($id) {
@@ -110,22 +111,22 @@ class CRM_Core_BAO_UFGroup extends CRM_Core_DAO_UFGroup {
   }
 
   /**
-   * Update the is_active flag in the db
+   * Update the is_active flag in the db.
    *
    * @param int $id
    *   Id of the database record.
    * @param bool $is_active
    *   Value we want to set the is_active field.
    *
-   * @return Object             CRM_Core_DAO_UFGroup object on success, null otherwise
-   * @static
+   * @return Object
+   *   CRM_Core_DAO_UFGroup object on success, null otherwise
    */
   public static function setIsActive($id, $is_active) {
     return CRM_Core_DAO::setFieldValue('CRM_Core_DAO_UFGroup', $id, 'is_active', $is_active);
   }
 
   /**
-   * Get all the registration fields
+   * Get all the registration fields.
    *
    * @param int $action
    *   What action are we doing.
@@ -134,8 +135,8 @@ class CRM_Core_BAO_UFGroup extends CRM_Core_DAO_UFGroup {
    *
    * @param null $ctype
    *
-   * @return array the fields that are needed for registration
-   * @static
+   * @return array
+   *   the fields that are needed for registration
    */
   public static function getRegistrationFields($action, $mode, $ctype = NULL) {
     if ($mode & CRM_Profile_Form::MODE_REGISTER) {
@@ -181,7 +182,7 @@ class CRM_Core_BAO_UFGroup extends CRM_Core_DAO_UFGroup {
   }
 
   /**
-   * Get all the listing fields
+   * Get all the listing fields.
    *
    * @param int $action
    *   What action are we doing.
@@ -195,18 +196,18 @@ class CRM_Core_BAO_UFGroup extends CRM_Core_DAO_UFGroup {
    * @param null $restrict
    * @param bool $skipPermission
    * @param int $permissionType
-   * @return array   the fields that are listings related
-   * @static
+   * @return array
+   *   the fields that are listings related
    */
-  static function getListingFields(
+  public static function getListingFields(
     $action,
     $visibility,
     $considerSelector = FALSE,
-    $ufGroupIds       = NULL,
-    $searchable       = NULL,
-    $restrict         = NULL,
-    $skipPermission   = FALSE,
-    $permissionType   = CRM_Core_Permission::SEARCH
+    $ufGroupIds = NULL,
+    $searchable = NULL,
+    $restrict = NULL,
+    $skipPermission = FALSE,
+    $permissionType = CRM_Core_Permission::SEARCH
   ) {
     if ($ufGroupIds) {
       $subset = self::getFields($ufGroupIds, FALSE, $action,
@@ -241,7 +242,9 @@ class CRM_Core_BAO_UFGroup extends CRM_Core_DAO_UFGroup {
         if ($considerSelector) {
           // drop the fields not meant for the selector
           foreach ($subset as $name => $field) {
-            if (!$field['in_selector'])unset($subset[$name]);
+            if (!$field['in_selector']) {
+              unset($subset[$name]);
+            }
           }
         }
         $fields = array_merge($fields, $subset);
@@ -272,21 +275,21 @@ class CRM_Core_BAO_UFGroup extends CRM_Core_DAO_UFGroup {
    * @param string $orderBy
    * @param null $orderProfiles
    *
-   * @return array   the fields that belong to this ufgroup(s)
-   * @static
+   * @return array
+   *   the fields that belong to this ufgroup(s)
    */
-  static function getFields(
+  public static function getFields(
     $id,
     $register = FALSE,
     $action = NULL,
-    $visibility     = NULL,
+    $visibility = NULL,
     $searchable = NULL,
-    $showAll        = FALSE,
+    $showAll = FALSE,
     $restrict = NULL,
     $skipPermission = FALSE,
-    $ctype          = NULL,
+    $ctype = NULL,
     $permissionType = CRM_Core_Permission::CREATE,
-    $orderBy        = 'field_name',
+    $orderBy = 'field_name',
     $orderProfiles = NULL
   ) {
     if (!is_array($id)) {
@@ -324,8 +327,8 @@ class CRM_Core_BAO_UFGroup extends CRM_Core_DAO_UFGroup {
     if ($orderProfiles AND count($profileIds) > 1) {
       $query .= " ORDER BY FIELD(  g.id, {$gids} )";
     }
-    $group      = CRM_Core_DAO::executeQuery($query, $params);
-    $fields     = array();
+    $group = CRM_Core_DAO::executeQuery($query, $params);
+    $fields = array();
     $validGroup = FALSE;
 
     while ($group->fetch()) {
@@ -349,8 +352,8 @@ class CRM_Core_BAO_UFGroup extends CRM_Core_DAO_UFGroup {
 
     if (empty($fields) && !$validGroup) {
       CRM_Core_Error::fatal(ts('The requested Profile (gid=%1) is disabled OR it is not configured to be used for \'Profile\' listings in its Settings OR there is no Profile with that ID OR you do not have permission to access this profile. Please contact the site administrator if you need assistance.',
-          array(1 => implode(',', $profileIds))
-        ));
+        array(1 => implode(',', $profileIds))
+      ));
     }
     else {
       self::reformatProfileFields($fields);
@@ -394,8 +397,8 @@ class CRM_Core_BAO_UFGroup extends CRM_Core_DAO_UFGroup {
     // used by calculateGroupType, but I don't think the missing fields matter, and -- if
     // they did -- the obvious fix would produce mutual recursion.
     $ufGroupType = self::_calculateGroupType($fieldArrs);
-    $profileType = CRM_Core_BAO_UFField::calculateProfileType(implode(',',$ufGroupType));
-    $contactActivityProfile = CRM_Core_BAO_UFField::checkContactActivityProfileTypeByGroupType(implode(',',$ufGroupType));
+    $profileType = CRM_Core_BAO_UFField::calculateProfileType(implode(',', $ufGroupType));
+    $contactActivityProfile = CRM_Core_BAO_UFField::checkContactActivityProfileTypeByGroupType(implode(',', $ufGroupType));
     $importableFields = self::getImportableFields($showAll, $profileType, $contactActivityProfile);
     list($customFields, $addressCustomFields) = self::getCustomFields($ctype);
 
@@ -419,9 +422,9 @@ class CRM_Core_BAO_UFGroup extends CRM_Core_DAO_UFGroup {
    *
    * @param CRM_Core_DAO_UFGroup|CRM_Core_DAO $group
    * @param CRM_Core_DAO_UFField|CRM_Core_DAO $field
+   * @param array $customFields
    * @param array $addressCustomFields
    * @param array $importableFields
-   * @param array $customFields
    * @param int $permissionType
    *   Eg CRM_Core_Permission::CREATE.
    * @return array
@@ -439,9 +442,9 @@ class CRM_Core_BAO_UFGroup extends CRM_Core_DAO_UFGroup {
 
     $addressCustom = FALSE;
     if (in_array($permissionType, array(
-      CRM_Core_Permission::CREATE,
-      CRM_Core_Permission::EDIT,
-    )) &&
+        CRM_Core_Permission::CREATE,
+        CRM_Core_Permission::EDIT,
+      )) &&
       in_array($field->field_name, array_keys($addressCustomFields))
     ) {
       $addressCustom = TRUE;
@@ -469,7 +472,7 @@ class CRM_Core_BAO_UFGroup extends CRM_Core_DAO_UFGroup {
     $formattedField = array(
       'name' => $name,
       'groupTitle' => $group->title,
-      'groupName'  => $group->name,
+      'groupName' => $group->name,
       'groupHelpPre' => empty($group->help_pre) ? '' : $group->help_pre,
       'groupHelpPost' => empty($group->help_post) ? '' : $group->help_post,
       'title' => $title,
@@ -532,7 +535,7 @@ class CRM_Core_BAO_UFGroup extends CRM_Core_DAO_UFGroup {
   }
 
   /**
-   * Create a query to find all visible UFFields in a UFGroup
+   * Create a query to find all visible UFFields in a UFGroup.
    *
    * This is the SQL-variant of checkUFFieldDisplayable().
    *
@@ -580,7 +583,7 @@ class CRM_Core_BAO_UFGroup extends CRM_Core_DAO_UFGroup {
   }
 
   /**
-   * Create a query to find all visible UFFields in a UFGroup
+   * Create a query to find all visible UFFields in a UFGroup.
    *
    * This is the PHP in-memory variant of createUFFieldQuery().
    *
@@ -588,7 +591,8 @@ class CRM_Core_BAO_UFGroup extends CRM_Core_DAO_UFGroup {
    * @param bool $searchable
    * @param bool $showAll
    * @param int $visibility
-   * @return bool TRUE if field is displayable
+   * @return bool
+   *   TRUE if field is displayable
    */
   protected static function filterUFField($field, $searchable, $showAll, $visibility) {
     if ($searchable && $field->is_searchable != 1) {
@@ -696,7 +700,7 @@ class CRM_Core_BAO_UFGroup extends CRM_Core_DAO_UFGroup {
   }
 
   /**
-   * Check the data validity
+   * Check the data validity.
    *
    * @param int $userID
    *   The user id that we are actually editing.
@@ -707,8 +711,8 @@ class CRM_Core_BAO_UFGroup extends CRM_Core_DAO_UFGroup {
    *   The action of the form.
    *
    * @pram  boolean $register is this the registrtion form
-   * @return boolean   true if form is valid
-   * @static
+   * @return bool
+   *   true if form is valid
    */
   public static function isValid($userID, $title, $register = FALSE, $action = NULL) {
     if ($register) {
@@ -740,7 +744,7 @@ class CRM_Core_BAO_UFGroup extends CRM_Core_DAO_UFGroup {
   }
 
   /**
-   * Get the html for the form that represents this particular group
+   * Get the html for the form that represents this particular group.
    *
    * @param int $userID
    *   The user id that we are actually editing.
@@ -758,17 +762,18 @@ class CRM_Core_BAO_UFGroup extends CRM_Core_DAO_UFGroup {
    * @param bool $doNotProcess
    * @param null $ctype
    *
-   * @return string       the html for the form on success, otherwise empty string
-   * @static
+   * @return string
+   *   the html for the form on success, otherwise empty string
    */
-  static function getEditHTML($userID,
+  public static function getEditHTML(
+    $userID,
     $title,
-    $action       = NULL,
-    $register     = FALSE,
-    $reset        = FALSE,
-    $profileID    = NULL,
+    $action = NULL,
+    $register = FALSE,
+    $reset = FALSE,
+    $profileID = NULL,
     $doNotProcess = FALSE,
-    $ctype        = NULL
+    $ctype = NULL
   ) {
 
     if ($register) {
@@ -897,7 +902,7 @@ class CRM_Core_BAO_UFGroup extends CRM_Core_DAO_UFGroup {
   }
 
   /**
-   * Searches for a contact in the db with similar attributes
+   * Searches for a contact in the db with similar attributes.
    *
    * @param array $params
    *   The list of values to be used in the where clause.
@@ -905,8 +910,8 @@ class CRM_Core_BAO_UFGroup extends CRM_Core_DAO_UFGroup {
    *   The current contact id (hence excluded from matching).
    * @param string $contactType
    *
-   * @return int|null contact_id if found, null otherwise
-   * @static
+   * @return int|null
+   *   contact_id if found, null otherwise
    */
   public static function findContact(&$params, $id = NULL, $contactType = 'Individual') {
     $dedupeParams = CRM_Dedupe_Finder::formatParams($params, $contactType);
@@ -938,9 +943,9 @@ class CRM_Core_BAO_UFGroup extends CRM_Core_DAO_UFGroup {
    * @param null $additionalWhereClause
    *
    * @return void
-   * @static
    */
-  public static function getValues($cid, &$fields, &$values,
+  public static function getValues(
+    $cid, &$fields, &$values,
     $searchable = TRUE, $componentWhere = NULL,
     $absolute = FALSE, $additionalWhereClause = NULL
   ) {
@@ -960,7 +965,7 @@ class CRM_Core_BAO_UFGroup extends CRM_Core_DAO_UFGroup {
     $query = new CRM_Contact_BAO_Query($params, $returnProperties, $fields);
     $options = &$query->_options;
 
-    $details = $query->searchQuery( 0, 0, NULL, FALSE, FALSE,
+    $details = $query->searchQuery(0, 0, NULL, FALSE, FALSE,
       FALSE, FALSE, FALSE, $additionalWhereClause);
     if (!$details->fetch()) {
       return;
@@ -969,8 +974,8 @@ class CRM_Core_BAO_UFGroup extends CRM_Core_DAO_UFGroup {
     $config = CRM_Core_Config::singleton();
 
     $locationTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id');
-    $imProviders   = CRM_Core_PseudoConstant::get('CRM_Core_DAO_IM', 'provider_id');
-    $websiteTypes  = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Website', 'website_type_id');
+    $imProviders = CRM_Core_PseudoConstant::get('CRM_Core_DAO_IM', 'provider_id');
+    $websiteTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Website', 'website_type_id');
 
     $multipleFields = array('url');
 
@@ -988,9 +993,12 @@ class CRM_Core_BAO_UFGroup extends CRM_Core_DAO_UFGroup {
 
       // Create a unique, non-empty index for each field.
       $index = $field['title'];
-      if ($index === '') $index = ' ';
-      while (array_key_exists($index, $values))
+      if ($index === '') {
+        $index = ' ';
+      }
+      while (array_key_exists($index, $values)) {
         $index .= ' ';
+      }
 
       $params[$index] = $values[$index] = '';
       $customFieldName = NULL;
@@ -1002,21 +1010,24 @@ class CRM_Core_BAO_UFGroup extends CRM_Core_DAO_UFGroup {
           $values[$index] = $details->$name;
         }
         elseif (in_array($name, CRM_Contact_BAO_Contact::$_greetingTypes)) {
-          $dname          = $name . '_display';
+          $dname = $name . '_display';
           $values[$index] = $details->$dname;
-          $name           = $name . '_id';
+          $name = $name . '_id';
           $params[$index] = $details->$name;
         }
         elseif (in_array($name, array(
-          'state_province', 'country', 'county'))) {
+          'state_province',
+          'country',
+          'county',
+        ))) {
           $values[$index] = $details->$name;
-          $idx            = $name . '_id';
+          $idx = $name . '_id';
           $params[$index] = $details->$idx;
         }
         elseif ($name === 'preferred_communication_method') {
           $communicationFields = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'preferred_communication_method');
           $compref = array();
-          $pref    = explode(CRM_Core_DAO::VALUE_SEPARATOR, $details->$name);
+          $pref = explode(CRM_Core_DAO::VALUE_SEPARATOR, $details->$name);
 
           foreach ($pref as $k) {
             if ($k) {
@@ -1053,8 +1064,8 @@ class CRM_Core_BAO_UFGroup extends CRM_Core_DAO_UFGroup {
         }
         elseif ($name == 'tag') {
           $entityTags = CRM_Core_BAO_EntityTag::getTag($cid);
-          $allTags    = CRM_Core_PseudoConstant::get('CRM_Core_DAO_EntityTag', 'tag_id', array('onlyActive' => FALSE));
-          $title      = array();
+          $allTags = CRM_Core_PseudoConstant::get('CRM_Core_DAO_EntityTag', 'tag_id', array('onlyActive' => FALSE));
+          $title = array();
           foreach ($entityTags as $tagId) {
             $title[] = $allTags[$tagId];
           }
@@ -1077,7 +1088,7 @@ class CRM_Core_BAO_UFGroup extends CRM_Core_DAO_UFGroup {
             // get all contact subtypes
             $allContactSubTypes = CRM_Contact_BAO_ContactType::subTypeInfo();
             // build contact subtype labels array
-            foreach( $contactSubTypeNames as $cstName ) {
+            foreach ($contactSubTypeNames as $cstName) {
               if ($cstName) {
                 $contactSubTypeLabels[] = $allContactSubTypes[$cstName]['label'];
               }
@@ -1105,7 +1116,8 @@ class CRM_Core_BAO_UFGroup extends CRM_Core_DAO_UFGroup {
               if ($htmlType == 'File') {
                 $entityId = $cid;
                 if (!$cid &&
-                  $fieldType == 'Activity' && !empty($componentWhere[0][2])) {
+                  $fieldType == 'Activity' && !empty($componentWhere[0][2])
+                ) {
                   $entityId = $componentWhere[0][2];
                 }
 
@@ -1124,16 +1136,17 @@ class CRM_Core_BAO_UFGroup extends CRM_Core_DAO_UFGroup {
                     $dao->data_type == 'Boolean'
                   )
                 ) {
-                  $customVal = (int )($details->{$name});
+                  $customVal = (int ) ($details->{$name});
                 }
                 elseif (isset($dao) && property_exists($dao, 'data_type')
                   && $dao->data_type == 'Float'
                 ) {
-                  $customVal = (float )($details->{$name});
+                  $customVal = (float ) ($details->{$name});
                 }
                 elseif (!CRM_Utils_System::isNull(explode(CRM_Core_DAO::VALUE_SEPARATOR,
-                      $details->{$name}
-                    ))) {
+                  $details->{$name}
+                ))
+                ) {
                   $customVal = $details->{$name};
                 }
 
@@ -1151,8 +1164,9 @@ class CRM_Core_BAO_UFGroup extends CRM_Core_DAO_UFGroup {
                   $params[$index] = $values[$index];
                 }
                 if (CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomField',
-                    $cfID, 'is_search_range'
-                  )) {
+                  $cfID, 'is_search_range'
+                )
+                ) {
                   $customFieldName = "{$name}_from";
                 }
               }
@@ -1165,7 +1179,12 @@ class CRM_Core_BAO_UFGroup extends CRM_Core_DAO_UFGroup {
               $values[$index] = "<a href='#' onclick='contactImagePopUp(\"{$details->$name}\", {$width}, {$height});'>{$image_URL}</a>";
             }
             elseif (in_array($name, array(
-              'birth_date', 'deceased_date', 'membership_start_date', 'membership_end_date', 'join_date'))) {
+              'birth_date',
+              'deceased_date',
+              'membership_start_date',
+              'membership_end_date',
+              'join_date',
+            ))) {
               $values[$index] = CRM_Utils_Date::customFormat($details->$name);
               $params[$index] = CRM_Utils_Date::isoToMysql($details->$name);
             }
@@ -1211,16 +1230,23 @@ class CRM_Core_BAO_UFGroup extends CRM_Core_DAO_UFGroup {
           $detailName = str_replace(' ', '_', $detailName);
 
           if (in_array($fieldName, array(
-            'phone', 'im', 'email', 'openid'))) {
+            'phone',
+            'im',
+            'email',
+            'openid',
+          ))) {
             if ($type) {
               $detailName .= "-{$type}";
             }
           }
 
           if (in_array($fieldName, array(
-            'state_province', 'country', 'county'))) {
+            'state_province',
+            'country',
+            'county',
+          ))) {
             $values[$index] = $details->$detailName;
-            $idx            = $detailName . '_id';
+            $idx = $detailName . '_id';
             $params[$index] = $details->$idx;
           }
           elseif ($fieldName == 'im') {
@@ -1251,8 +1277,8 @@ class CRM_Core_BAO_UFGroup extends CRM_Core_DAO_UFGroup {
           $detailName = "website-{$id}-{$fieldName}";
           $url = CRM_Utils_System::fixURL($details->$detailName);
           if ($details->$detailName) {
-            $websiteTypeId  = "website-{$id}-website_type_id";
-            $websiteType    = $websiteTypes[$details->$websiteTypeId];
+            $websiteTypeId = "website-{$id}-website_type_id";
+            $websiteType = $websiteTypes[$details->$websiteTypeId];
             $values[$index] = "<a href=\"$url\">{$details->$detailName} ( {$websiteType} )</a>";
           }
           else {
@@ -1285,9 +1311,12 @@ class CRM_Core_BAO_UFGroup extends CRM_Core_DAO_UFGroup {
             $url = $params[$index];
           }
           elseif (in_array($htmlType, array(
-            'CheckBox', 'Multi-Select', 'AdvMulti-Select',
-                'Multi-Select State/Province', 'Multi-Select Country',
-              ))) {
+            'CheckBox',
+            'Multi-Select',
+            'AdvMulti-Select',
+            'Multi-Select State/Province',
+            'Multi-Select Country',
+          ))) {
             $valSeperator = CRM_Core_DAO::VALUE_SEPARATOR;
             $selectedOptions = explode($valSeperator, $params[$index]);
 
@@ -1347,9 +1376,7 @@ class CRM_Core_BAO_UFGroup extends CRM_Core_DAO_UFGroup {
    * @param int $id
    *   Profile Id.
    *
-   * @return boolean
-   *
-   * @static
+   * @return bool
    *
    */
   public static function usedByModule($id) {
@@ -1374,9 +1401,7 @@ class CRM_Core_BAO_UFGroup extends CRM_Core_DAO_UFGroup {
    * @param int $id
    *   Profile Id.
    *
-   * @return boolean
-   *
-   * @static
+   * @return bool
    *
    */
   public static function del($id) {
@@ -1401,19 +1426,26 @@ class CRM_Core_BAO_UFGroup extends CRM_Core_DAO_UFGroup {
   }
 
   /**
-   * Add the UF Group
+   * Add the UF Group.
    *
    * @param array $params
    *   Reference array contains the values submitted by the form.
    * @param array $ids
    *   Reference array contains the id.
    *
-   * @static
    *
    * @return object
    */
   public static function add(&$params, $ids = array()) {
-    $fields = array('is_active', 'add_captcha', 'is_map', 'is_update_dupe', 'is_edit_link', 'is_uf_link', 'is_cms_user');
+    $fields = array(
+      'is_active',
+      'add_captcha',
+      'is_map',
+      'is_update_dupe',
+      'is_edit_link',
+      'is_uf_link',
+      'is_cms_user',
+    );
     foreach ($fields as $field) {
       $params[$field] = CRM_Utils_Array::value($field, $params, FALSE);
     }
@@ -1445,7 +1477,7 @@ class CRM_Core_BAO_UFGroup extends CRM_Core_DAO_UFGroup {
   }
 
   /**
-   * Make uf join entries for an uf group
+   * Make uf join entries for an uf group.
    *
    * @param array $params
    *   (reference) an assoc array of name/value pairs.
@@ -1453,7 +1485,6 @@ class CRM_Core_BAO_UFGroup extends CRM_Core_DAO_UFGroup {
    *   Ufgroup id.
    *
    * @return void
-   * @static
    */
   public static function createUFJoin(&$params, $ufGroupId) {
     $groupTypes = CRM_Utils_Array::value('uf_group_type', $params);
@@ -1500,7 +1531,8 @@ SET    weight = %1
 WHERE  uf_group_id = %2
 AND    ( entity_id IS NULL OR entity_id <= 0 )
 ";
-    $p = array(1 => array($params['weight'], 'Integer'),
+    $p = array(
+      1 => array($params['weight'], 'Integer'),
       2 => array($ufGroupId, 'Integer'),
     );
     CRM_Core_DAO::executeQuery($query, $p);
@@ -1516,7 +1548,7 @@ AND    ( entity_id IS NULL OR entity_id <= 0 )
   }
 
   /**
-   * Get the UF Join records for an ufgroup id
+   * Get the UF Join records for an ufgroup id.
    *
    * @param int $ufGroupId
    *   Uf group id.
@@ -1525,9 +1557,8 @@ AND    ( entity_id IS NULL OR entity_id <= 0 )
    * @param int $status
    *   If set return module other than default modules (User Account/User registration/Profile).
    *
-   * @return array $ufGroupJoinRecords
+   * @return array
    *
-   * @static
    */
   public static function getUFJoinRecord($ufGroupId = NULL, $displayName = NULL, $status = NULL) {
     if ($displayName) {
@@ -1566,13 +1597,12 @@ AND    ( entity_id IS NULL OR entity_id <= 0 )
   }
 
   /**
-   * Function takes an associative array and creates a ufjoin record for ufgroup
+   * Function takes an associative array and creates a ufjoin record for ufgroup.
    *
    * @param array $params
    *   (reference) an assoc array of name/value pairs.
    *
-   * @return CRM_Core_BAO_UFJoin object
-   * @static
+   * @return CRM_Core_BAO_UFJoin
    */
   public static function addUFJoin(&$params) {
     $ufJoin = new CRM_Core_DAO_UFJoin();
@@ -1582,13 +1612,12 @@ AND    ( entity_id IS NULL OR entity_id <= 0 )
   }
 
   /**
-   * Delete the uf join record for an uf group
+   * Delete the uf join record for an uf group.
    *
    * @param array $params
    *   (reference) an assoc array of name/value pairs.
    *
    * @return void
-   * @static
    */
   public static function delUFJoin(&$params) {
     $ufJoin = new CRM_Core_DAO_UFJoin();
@@ -1597,13 +1626,13 @@ AND    ( entity_id IS NULL OR entity_id <= 0 )
   }
 
   /**
-   * Get the weight for ufjoin record
+   * Get the weight for ufjoin record.
    *
    * @param int $ufGroupId
    *   If $ufGroupId get update weight or add weight.
    *
-   * @return int   weight of the UFGroup
-   * @static
+   * @return int
+   *   weight of the UFGroup
    */
   public static function getWeight($ufGroupId = NULL) {
     //calculate the weight
@@ -1627,7 +1656,7 @@ AND    ( entity_id IS NULL OR entity_id <= 0 )
   }
 
   /**
-   * Get the uf group for a module
+   * Get the uf group for a module.
    *
    * @param string $moduleName
    *   Module name.
@@ -1638,8 +1667,8 @@ AND    ( entity_id IS NULL OR entity_id <= 0 )
    *   Which operation (view, edit, create, etc) to check permission for.
    * @param array|NULL $returnFields list of UFGroup fields to return; NULL for default
    *
-   * @return array $ufGroups array of ufgroups for a module
-   * @static
+   * @return array
+   *   array of ufgroups for a module
    */
   public static function getModuleUFGroup($moduleName = NULL, $count = 0, $skipPermission = TRUE, $op = CRM_Core_Permission::VIEW, $returnFields = NULL) {
     $selectFields = array('id', 'title', 'created_id', 'is_active', 'is_reserved', 'group_type');
@@ -1663,7 +1692,6 @@ AND    ( entity_id IS NULL OR entity_id <= 0 )
       $p[2] = array($moduleName, 'String');
     }
 
-
     // add permissioning for profiles only if not registration
     if (!$skipPermission) {
       $permissionClause = CRM_Core_Permission::ufGroupClause($op, 'civicrm_uf_group.');
@@ -1687,11 +1715,7 @@ AND    ( entity_id IS NULL OR entity_id <= 0 )
         continue;
       }
       foreach ($selectFields as $key => $field) {
-        if($field == 'id') {
-          continue;
-        }
-        elseif ($field == 'name') {
-          $ufGroups[$dao->id][$field] = $dao->title;
+        if ($field == 'id') {
           continue;
         }
         $ufGroups[$dao->id][$field] = $dao->$field;
@@ -1705,14 +1729,14 @@ AND    ( entity_id IS NULL OR entity_id <= 0 )
   }
 
   /**
-   * Filter ufgroups based on logged in user contact type
+   * Filter ufgroups based on logged in user contact type.
    *
    * @param int $ufGroupId
    *   Uf group id (profile id).
    * @param int $contactID
    *
-   * @return boolean true or false
-   * @static
+   * @return bool
+   *   true or false
    */
   public static function filterUFGroups($ufGroupId, $contactID = NULL) {
     if (!$contactID) {
@@ -1747,7 +1771,7 @@ AND    ( entity_id IS NULL OR entity_id <= 0 )
   }
 
   /**
-   * Add profile field to a form
+   * Add profile field to a form.
    *
    * @param CRM_Core_Form $form
    * @param array $field
@@ -1762,16 +1786,15 @@ AND    ( entity_id IS NULL OR entity_id <= 0 )
    * @param string $prefix
    *
    * @return null
-   * @static
    */
-  static function buildProfile(
+  public static function buildProfile(
     &$form,
     &$field,
     $mode,
     $contactId = NULL,
     $online = FALSE,
     $usedFor = NULL,
-    $rowNumber = NULL ,
+    $rowNumber = NULL,
     $prefix = ''
   ) {
     $defaultValues = array();
@@ -1787,7 +1810,7 @@ AND    ( entity_id IS NULL OR entity_id <= 0 )
     // do not display view fields in drupal registration form
     // CRM-4632
     if ($view && $mode == CRM_Profile_Form::MODE_REGISTER) {
-      return;
+      return NULL;
     }
 
     if ($usedFor == 'onbehalf') {
@@ -1803,7 +1826,7 @@ AND    ( entity_id IS NULL OR entity_id <= 0 )
       $name = "field[$rowNumber][$fieldName]";
     }
     elseif (!empty($prefix)) {
-      $name = $prefix ."[$fieldName]";
+      $name = $prefix . "[$fieldName]";
     }
     else {
       $name = $fieldName;
@@ -1814,8 +1837,7 @@ AND    ( entity_id IS NULL OR entity_id <= 0 )
     if ($fieldName == 'image_URL' && $mode == CRM_Profile_Form::MODE_EDIT) {
       $deleteExtra = ts('Are you sure you want to delete contact image.');
       $deleteURL = array(
-        CRM_Core_Action::DELETE =>
-        array(
+        CRM_Core_Action::DELETE => array(
           'name' => ts('Delete Contact Image'),
           'url' => 'civicrm/contact/image',
           'qs' => 'reset=1&id=%%id%%&gid=%%gid%%&action=delete',
@@ -1825,7 +1847,8 @@ AND    ( entity_id IS NULL OR entity_id <= 0 )
       );
       $deleteURL = CRM_Core_Action::formLink($deleteURL,
         CRM_Core_Action::DELETE,
-        array('id' => $form->get('id'),
+        array(
+          'id' => $form->get('id'),
           'gid' => $form->get('gid'),
         ),
         ts('more'),
@@ -1844,7 +1867,9 @@ AND    ( entity_id IS NULL OR entity_id <= 0 )
       $form->addChainSelect($name, array('label' => $title, 'required' => $required));
       $config = CRM_Core_Config::singleton();
       if (!in_array($mode, array(
-        CRM_Profile_Form::MODE_EDIT, CRM_Profile_Form::MODE_SEARCH)) &&
+          CRM_Profile_Form::MODE_EDIT,
+          CRM_Profile_Form::MODE_SEARCH,
+        )) &&
         $config->defaultContactStateProvince
       ) {
         $defaultValues[$name] = $config->defaultContactStateProvince;
@@ -1855,7 +1880,9 @@ AND    ( entity_id IS NULL OR entity_id <= 0 )
       $form->add('select', $name, $title, array('' => ts('- select -')) + CRM_Core_PseudoConstant::country(), $required, $selectAttributes);
       $config = CRM_Core_Config::singleton();
       if (!in_array($mode, array(
-        CRM_Profile_Form::MODE_EDIT, CRM_Profile_Form::MODE_SEARCH)) &&
+          CRM_Profile_Form::MODE_EDIT,
+          CRM_Profile_Form::MODE_SEARCH,
+        )) &&
         $config->defaultContactCountry
       ) {
         $defaultValues[$name] = $config->defaultContactCountry;
@@ -1880,13 +1907,15 @@ AND    ( entity_id IS NULL OR entity_id <= 0 )
           }
           $form->add('select', $providerName, NULL,
             array(
-              '' => ts('- select -')) + CRM_Core_PseudoConstant::get('CRM_Core_DAO_IM', 'provider_id'), $required
+              '' => ts('- select -'),
+            ) + CRM_Core_PseudoConstant::get('CRM_Core_DAO_IM', 'provider_id'), $required
           );
         }
         else {
           $form->add('select', $name . '-provider_id', $title,
             array(
-              '' => ts('- select -')) + CRM_Core_PseudoConstant::get('CRM_Core_DAO_IM', 'provider_id'), $required
+              '' => ts('- select -'),
+            ) + CRM_Core_PseudoConstant::get('CRM_Core_DAO_IM', 'provider_id'), $required
           );
         }
 
@@ -1899,18 +1928,21 @@ AND    ( entity_id IS NULL OR entity_id <= 0 )
       $form->addDate($name, $title, $required, array('formatType' => 'birth'));
     }
     elseif (in_array($fieldName, array(
-      'membership_start_date', 'membership_end_date', 'join_date'))) {
+      'membership_start_date',
+      'membership_end_date',
+      'join_date',
+    ))) {
       $form->addDate($name, $title, $required, array('formatType' => 'custom'));
     }
-    elseif (CRM_Utils_Array::value('name',$field) == 'membership_type') {
+    elseif (CRM_Utils_Array::value('name', $field) == 'membership_type') {
       list($orgInfo, $types) = CRM_Member_BAO_MembershipType::getMembershipTypeInfo();
       $sel = &$form->addElement('hierselect', $name, $title);
-      $select = array('' => ts('- select -') );
-      if(count($orgInfo) == 1 && $field['is_required']) {
+      $select = array('' => ts('- select -'));
+      if (count($orgInfo) == 1 && $field['is_required']) {
         // we only have one org - so we should default to it. Not sure about defaulting to first type
         // as it could be missed - so adding a select
         // however, possibly that is more similar to the membership form
-        if(count($types[1]) > 1) {
+        if (count($types[1]) > 1) {
           $types[1] = $select + $types[1];
         }
       }
@@ -1919,10 +1951,11 @@ AND    ( entity_id IS NULL OR entity_id <= 0 )
       }
       $sel->setOptions(array($orgInfo, $types));
     }
-    elseif (CRM_Utils_Array::value('name',$field) == 'membership_status') {
+    elseif (CRM_Utils_Array::value('name', $field) == 'membership_status') {
       $form->add('select', $name, $title,
         array(
-          '' => ts('- select -')) + CRM_Member_PseudoConstant::membershipStatus(NULL, NULL, 'label'), $required
+          '' => ts('- select -'),
+        ) + CRM_Member_PseudoConstant::membershipStatus(NULL, NULL, 'label'), $required
       );
     }
     elseif (in_array($fieldName, array('gender_id', 'communication_style_id'))) {
@@ -1988,7 +2021,12 @@ AND    ( entity_id IS NULL OR entity_id <= 0 )
       $profileType = CRM_Core_BAO_UFField::getProfileType($gId, TRUE, FALSE, TRUE);
 
       if (empty($profileType) || in_array($profileType, array(
-        'Contact', 'Contribution', 'Participant', 'Membership'))) {
+          'Contact',
+          'Contribution',
+          'Participant',
+          'Membership',
+        ))
+      ) {
         $profileType = 'Individual';
       }
       if (CRM_Contact_BAO_ContactType::isaSubType($profileType)) {
@@ -2000,7 +2038,8 @@ AND    ( entity_id IS NULL OR entity_id <= 0 )
       );
       $form->add('select', $name, $title,
         array(
-          '' => ts('- select -')) + CRM_Core_PseudoConstant::greeting($greeting), $required
+          '' => ts('- select -'),
+        ) + CRM_Core_PseudoConstant::greeting($greeting), $required
       );
       // add custom greeting element
       $form->add('text', $fieldName . '_custom', ts('Custom %1', array(1 => ucwords(str_replace('_', ' ', $fieldName)))),
@@ -2056,7 +2095,7 @@ AND    ( entity_id IS NULL OR entity_id <= 0 )
             'onfocus' => "if (!this.value) {  this.value='http://';} else return false",
             'onblur' => "if ( this.value == 'http://') {  this.value='';} else return false",
           )
-       ), $required
+        ), $required
       );
 
       $form->addRule($name, ts('Enter a valid Website.'), 'url');
@@ -2079,7 +2118,11 @@ AND    ( entity_id IS NULL OR entity_id <= 0 )
       }
     }
     elseif (in_array($fieldName, array(
-      'receive_date', 'receipt_date', 'thankyou_date', 'cancel_date'))) {
+      'receive_date',
+      'receipt_date',
+      'thankyou_date',
+      'cancel_date',
+    ))) {
       $form->addDateTime($name, $title, $required, array('formatType' => 'activityDateTime'));
     }
     elseif ($fieldName == 'send_receipt') {
@@ -2093,17 +2136,19 @@ AND    ( entity_id IS NULL OR entity_id <= 0 )
       list($products, $options) = CRM_Contribute_BAO_Premium::getPremiumProductInfo();
       $sel = &$form->addElement('hierselect', $name, $title);
       $products = array(
-        '0' => ts('- select -')) + $products;
+        '0' => ts('- select -'),
+      ) + $products;
       $sel->setOptions(array($products, $options));
     }
     elseif ($fieldName == 'payment_instrument') {
       $form->add('select', $name, $title,
-                       array(''=>ts( '- select -' )) + CRM_Contribute_PseudoConstant::paymentInstrument( ), $required );
+        array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::paymentInstrument(), $required);
     }
-    else if ($fieldName == 'financial_type' ) {
+    elseif ($fieldName == 'financial_type') {
       $form->add('select', $name, $title,
         array(
-          '' => ts('- select -')) + CRM_Contribute_PseudoConstant::financialType(), $required
+          '' => ts('- select -'),
+        ) + CRM_Contribute_PseudoConstant::financialType(), $required
       );
     }
     elseif ($fieldName == 'contribution_status_id') {
@@ -2112,21 +2157,23 @@ AND    ( entity_id IS NULL OR entity_id <= 0 )
       foreach (array(
                  'In Progress',
                  'Overdue',
-                 'Refunded'
+                 'Refunded',
                ) as $suppress) {
         unset($contributionStatuses[CRM_Utils_Array::key($suppress, $statusName)]);
       }
 
       $form->add('select', $name, $title,
         array(
-          '' => ts('- select -')) + $contributionStatuses, $required
+          '' => ts('- select -'),
+        ) + $contributionStatuses, $required
       );
     }
     elseif ($fieldName == 'soft_credit_type') {
       $name = "soft_credit_type[$rowNumber]";
       $form->add('select', $name, $title,
         array(
-          '' => ts('- select -')) + CRM_Core_OptionGroup::values("soft_credit_type")
+          '' => ts('- select -'),
+        ) + CRM_Core_OptionGroup::values("soft_credit_type")
       );
       //CRM-15350: choose SCT field default value as 'Gift' for membership use
       //else (for contribution), use configured SCT default value
@@ -2142,7 +2189,8 @@ AND    ( entity_id IS NULL OR entity_id <= 0 )
     elseif ($fieldName == 'contribution_page_id') {
       $form->add('select', $name, $title,
         array(
-          '' => ts('- select -')) + CRM_Contribute_PseudoConstant::contributionPage(), $required, 'class="big"'
+          '' => ts('- select -'),
+        ) + CRM_Contribute_PseudoConstant::contributionPage(), $required, 'class="big"'
       );
     }
     elseif ($fieldName == 'participant_register_date') {
@@ -2151,13 +2199,15 @@ AND    ( entity_id IS NULL OR entity_id <= 0 )
     elseif ($fieldName == 'activity_status_id') {
       $form->add('select', $name, $title,
         array(
-          '' => ts('- select -')) + CRM_Core_PseudoConstant::activityStatus(), $required
+          '' => ts('- select -'),
+        ) + CRM_Core_PseudoConstant::activityStatus(), $required
       );
     }
     elseif ($fieldName == 'activity_engagement_level') {
       $form->add('select', $name, $title,
         array(
-          '' => ts('- select -')) + CRM_Campaign_PseudoConstant::engagementLevel(), $required
+          '' => ts('- select -'),
+        ) + CRM_Campaign_PseudoConstant::engagementLevel(), $required
       );
     }
     elseif ($fieldName == 'activity_date_time') {
@@ -2170,7 +2220,8 @@ AND    ( entity_id IS NULL OR entity_id <= 0 )
       }
       $form->add('select', $name, $title,
         array(
-          '' => ts('- select -')) + CRM_Event_PseudoConstant::participantStatus(NULL, $cond, 'label'), $required
+          '' => ts('- select -'),
+        ) + CRM_Event_PseudoConstant::participantStatus(NULL, $cond, 'label'), $required
       );
     }
     elseif ($fieldName == 'participant_role') {
@@ -2180,7 +2231,8 @@ AND    ( entity_id IS NULL OR entity_id <= 0 )
       else {
         $form->add('select', $name, $title,
           array(
-            '' => ts('- select -')) + CRM_Event_PseudoConstant::participantRole(), $required
+            '' => ts('- select -'),
+          ) + CRM_Event_PseudoConstant::participantRole(), $required
         );
       }
     }
@@ -2200,7 +2252,8 @@ AND    ( entity_id IS NULL OR entity_id <= 0 )
         ));
         $form->add('select', $name, $title,
           array(
-            '' => ts('- select -')) + $campaigns, $required, 'class="crm-select2 big"'
+            '' => ts('- select -'),
+          ) + $campaigns, $required, 'class="crm-select2 big"'
         );
       }
     }
@@ -2243,7 +2296,11 @@ AND    ( entity_id IS NULL OR entity_id <= 0 )
 
     //add the rules
     if (in_array($fieldName, array(
-      'non_deductible_amount', 'total_amount', 'fee_amount', 'net_amount'))) {
+      'non_deductible_amount',
+      'total_amount',
+      'fee_amount',
+      'net_amount',
+    ))) {
       $form->addRule($name, ts('Please enter a valid amount.'), 'money');
     }
     if ($rule) {
@@ -2254,7 +2311,7 @@ AND    ( entity_id IS NULL OR entity_id <= 0 )
   }
 
   /**
-   * Set profile defaults
+   * Set profile defaults.
    *
    * @param int $contactId
    *   Contact id.
@@ -2267,11 +2324,9 @@ AND    ( entity_id IS NULL OR entity_id <= 0 )
    * @param int $componentId
    *   Id for specific components like contribute, event etc.
    * @param null $component
-   *
-   * @return null
-   * @static
    */
-  static function setProfileDefaults($contactId, &$fields, &$defaults,
+  public static function setProfileDefaults(
+    $contactId, &$fields, &$defaults,
     $singleProfile = TRUE, $componentId = NULL, $component = NULL
   ) {
     if (!$componentId) {
@@ -2404,12 +2459,12 @@ AND    ( entity_id IS NULL OR entity_id <= 0 )
                 // type as per loc field and removed below code.
                 $primaryLocationType = FALSE;
                 if ($locTypeId == 'Primary') {
-                  if (is_array($value) && array_key_exists($fieldName, $value)){
+                  if (is_array($value) && array_key_exists($fieldName, $value)) {
                     $primaryLocationType = TRUE;
-                    if (in_array($fieldName, $blocks)){
+                    if (in_array($fieldName, $blocks)) {
                       $locTypeId = CRM_Contact_BAO_Contact::getPrimaryLocationType($contactId, FALSE, $fieldName);
                     }
-                    else{
+                    else {
                       $locTypeId = CRM_Contact_BAO_Contact::getPrimaryLocationType($contactId, FALSE, 'address');
                     }
                   }
@@ -2481,7 +2536,8 @@ AND    ( entity_id IS NULL OR entity_id <= 0 )
             if (is_array($details)) {
               if ($fieldName === 'url'
                 && !empty($details['website'])
-                && !empty($details['website'][$locTypeId])) {
+                && !empty($details['website'][$locTypeId])
+              ) {
                 $defaults[$fldName] = CRM_Utils_Array::value('url', $details['website'][$locTypeId]);
               }
             }
@@ -2519,8 +2575,8 @@ AND    ( entity_id IS NULL OR entity_id <= 0 )
    * @param bool $onlyPure
    *   True if only pure profiles are required.
    *
-   * @return array  $profiles  associative array of profiles
-   * @static
+   * @return array
+   *   associative array of profiles
    */
   public static function getProfiles($types, $onlyPure = FALSE) {
     $profiles = array();
@@ -2549,12 +2605,12 @@ AND    ( entity_id IS NULL OR entity_id <= 0 )
    * @param array $optional
    *   Array of types those are optional.
    *
-   * @return array  $profiles  associative array of profiles
-   * @static
+   * @return array
+   *   associative array of profiles
    */
   public static function getValidProfiles($required, $optional = NULL) {
     if (!is_array($required) || empty($required)) {
-      return;
+      return NULL;
     }
 
     $profiles = array();
@@ -2581,8 +2637,8 @@ AND    ( entity_id IS NULL OR entity_id <= 0 )
    * @param array $required
    *   Array of fields those are required in the profile.
    *
-   * @return array  $profiles  associative array of profiles
-   * @static
+   * @return array
+   *   associative array of profiles
    */
   public static function checkValidProfile($ufId, $required = NULL) {
     $validProfile = FALSE;
@@ -2619,10 +2675,10 @@ AND    ( entity_id IS NULL OR entity_id <= 0 )
   /**
    * Get default value for Register.
    *
-   * @param $fields
-   * @param $defaults
+   * @param array $fields
+   * @param array $defaults
    *
-   * @return mixed $defaults@static
+   * @return array
    */
   public static function setRegisterDefaults(&$fields, &$defaults) {
     $config = CRM_Core_Config::singleton();
@@ -2642,7 +2698,7 @@ AND    ( entity_id IS NULL OR entity_id <= 0 )
   }
 
   /**
-   * This function is to make a copy of a profile, including
+   * make a copy of a profile, including
    * all the fields in the profile
    *
    * @param int $id
@@ -2685,7 +2741,8 @@ SET    weight = %1
 WHERE  uf_group_id = %2
 AND    ( entity_id IS NULL OR entity_id <= 0 )
 ";
-    $p = array(1 => array($maxWeight + 1, 'Integer'),
+    $p = array(
+      1 => array($maxWeight + 1, 'Integer'),
       2 => array($copy->id, 'Integer'),
     );
     CRM_Core_DAO::executeQuery($query, $p);
@@ -2709,7 +2766,6 @@ AND    ( entity_id IS NULL OR entity_id <= 0 )
    *
    * @return void
    */
-
   public static function commonSendMail($contactID, &$values) {
     if (!$contactID || !$values) {
       return;
@@ -2727,7 +2783,7 @@ AND    ( entity_id IS NULL OR entity_id <= 0 )
 
     $contactLink = CRM_Utils_System::url('civicrm/contact/view',
       "reset=1&cid=$contactID",
-       TRUE, NULL, FALSE, FALSE, TRUE
+      TRUE, NULL, FALSE, FALSE, TRUE
     );
 
     //get the default domain email address.
@@ -2796,7 +2852,7 @@ AND    ( entity_id IS NULL OR entity_id <= 0 )
   }
 
   /**
-   * Assign uf fields to template
+   * Assign uf fields to template.
    *
    * @param int $gid
    *   Group id.
@@ -2814,15 +2870,14 @@ AND    ( entity_id IS NULL OR entity_id <= 0 )
   }
 
   /**
-   * Format fields for dupe Contact Matching
+   * Format fields for dupe Contact Matching.
    *
    * @param array $params
-   *   Associated array.
    *
    * @param int $contactId
    *
-   * @return array $data assoicated formatted array
-   * @static
+   * @return array
+   *   assoicated formatted array
    */
   public static function formatFields($params, $contactId = NULL) {
     if ($contactId) {
@@ -2834,9 +2889,9 @@ AND    ( entity_id IS NULL OR entity_id <= 0 )
       $primaryLocationType = $defaultLocationType->id;
     }
 
-    $data            = array();
-    $locationType    = array();
-    $count           = 1;
+    $data = array();
+    $locationType = array();
+    $count = 1;
     $primaryLocation = 0;
     foreach ($params as $key => $value) {
       list($fieldName, $locTypeId, $phoneTypeId) = explode('-', $key);
@@ -2944,7 +2999,6 @@ AND    ( entity_id IS NULL OR entity_id <= 0 )
       $data['location'][$loc]['email'][$loc]['email'] = $primaryEmail;
     }
 
-
     return $data;
   }
 
@@ -2957,7 +3011,8 @@ AND    ( entity_id IS NULL OR entity_id <= 0 )
    * @param int $ignoreFieldId
    *   Ignore particular profile field.
    *
-   * @return array list of calculated group type
+   * @return array
+   *   list of calculated group type
    */
   public static function calculateGroupType($gId, $includeTypeValues = FALSE, $ignoreFieldId = NULL) {
     //get the profile fields.
@@ -2973,7 +3028,8 @@ AND    ( entity_id IS NULL OR entity_id <= 0 )
    * @param int $ignoreFieldId
    *   Ignore perticular profile field.
    *
-   * @return array list of calculated group type
+   * @return array
+   *   list of calculated group type
    */
   public static function _calculateGroupType($ufFields, $includeTypeValues = FALSE, $ignoreFieldId = NULL) {
     $groupType = $groupTypeValues = $customFieldIds = array();
@@ -3042,7 +3098,7 @@ AND    ( entity_id IS NULL OR entity_id <= 0 )
    * @param array $groupTypes
    *   With key having group type names.
    *
-   * @return Boolean
+   * @return bool
    */
   public static function updateGroupTypes($gId, $groupTypes = array()) {
     if (!is_array($groupTypes) || !$gId) {
@@ -3055,7 +3111,12 @@ AND    ( entity_id IS NULL OR entity_id <= 0 )
     }
 
     $componentGroupTypes = array('Contribution', 'Participant', 'Membership', 'Activity', 'Case');
-    $validGroupTypes = array_merge(array('Contact', 'Individual', 'Organization', 'Household'), $componentGroupTypes, CRM_Contact_BAO_ContactType::subTypes());
+    $validGroupTypes = array_merge(array(
+      'Contact',
+      'Individual',
+      'Organization',
+      'Household',
+    ), $componentGroupTypes, CRM_Contact_BAO_ContactType::subTypes());
 
     $gTypes = $gTypeValues = array();
 
@@ -3101,7 +3162,7 @@ AND    ( entity_id IS NULL OR entity_id <= 0 )
   }
 
   /**
-   * Create a "group_type" string
+   * Create a "group_type" string.
    *
    * @param array $coreTypes
    *   E.g. array('Individual','Contact','Student').
@@ -3120,7 +3181,7 @@ AND    ( entity_id IS NULL OR entity_id <= 0 )
     if ($subTypes) {
       //CRM-15427 Allow Multiple subtype filtering
       //if (count($subTypes) > 1) {
-        //throw new CRM_Core_Exception("Multiple subtype filtering is not currently supported by widget.");
+      //throw new CRM_Core_Exception("Multiple subtype filtering is not currently supported by widget.");
       //}
       foreach ($subTypes as $subType => $subTypeIds) {
         $groupTypeExpr .= $delim . $subType . ':' . implode(':', $subTypeIds);
@@ -3130,7 +3191,7 @@ AND    ( entity_id IS NULL OR entity_id <= 0 )
   }
 
   /**
-   * This function is used to setDefault componet specific profile fields.
+   * setDefault componet specific profile fields.
    *
    * @param array $fields
    *   Profile fields.
@@ -3143,7 +3204,7 @@ AND    ( entity_id IS NULL OR entity_id <= 0 )
    *
    * @param bool $isStandalone
    *
-   * @return void.
+   * @return void
    */
   public static function setComponentDefaults(&$fields, $componentId, $component, &$defaults, $isStandalone = FALSE) {
     if (!$componentId ||
@@ -3155,25 +3216,25 @@ AND    ( entity_id IS NULL OR entity_id <= 0 )
     $componentBAO = $componentSubType = NULL;
     switch ($component) {
       case 'Membership':
-        $componentBAO     = 'CRM_Member_BAO_Membership';
+        $componentBAO = 'CRM_Member_BAO_Membership';
         $componentBAOName = 'Membership';
         $componentSubType = array('membership_type_id');
         break;
 
       case 'Contribute':
-        $componentBAO     = 'CRM_Contribute_BAO_Contribution';
+        $componentBAO = 'CRM_Contribute_BAO_Contribution';
         $componentBAOName = 'Contribution';
-            $componentSubType = array( 'financial_type_id' );
+        $componentSubType = array('financial_type_id');
         break;
 
       case 'Event':
-        $componentBAO     = 'CRM_Event_BAO_Participant';
+        $componentBAO = 'CRM_Event_BAO_Participant';
         $componentBAOName = 'Participant';
         $componentSubType = array('role_id', 'event_id', 'event_type_id');
         break;
 
       case 'Activity':
-        $componentBAO     = 'CRM_Activity_BAO_Activity';
+        $componentBAO = 'CRM_Activity_BAO_Activity';
         $componentBAOName = 'Activity';
         $componentSubType = array('activity_type_id');
         break;
@@ -3189,7 +3250,17 @@ AND    ( entity_id IS NULL OR entity_id <= 0 )
     }
 
     $formattedGroupTree = array();
-    $dateTimeFields = array('participant_register_date', 'activity_date_time', 'receive_date', 'receipt_date', 'cancel_date', 'thankyou_date', 'membership_start_date', 'membership_end_date', 'join_date');
+    $dateTimeFields = array(
+      'participant_register_date',
+      'activity_date_time',
+      'receive_date',
+      'receipt_date',
+      'cancel_date',
+      'thankyou_date',
+      'membership_start_date',
+      'membership_end_date',
+      'join_date',
+    );
     foreach ($fields as $name => $field) {
       $fldName = $isStandalone ? $name : "field[$componentId][$name]";
       if (in_array($name, $dateTimeFields)) {
@@ -3202,17 +3273,21 @@ AND    ( entity_id IS NULL OR entity_id <= 0 )
         $defaults[$fldName] = $values[$name];
       }
       elseif ($name == 'participant_note') {
-        $noteDetails        = CRM_Core_BAO_Note::getNote($componentId, 'civicrm_participant');
+        $noteDetails = CRM_Core_BAO_Note::getNote($componentId, 'civicrm_participant');
         $defaults[$fldName] = array_pop($noteDetails);
       }
       elseif (in_array($name, array(
-        'financial_type', 'payment_instrument', 'participant_status', 'participant_role'))) {
+        'financial_type',
+        'payment_instrument',
+        'participant_status',
+        'participant_role',
+      ))) {
         $defaults[$fldName] = $values["{$name}_id"];
       }
       elseif ($name == 'membership_type') {
         // since membership_type field is a hierselect -
-        $defaults[$fldName][0] =
-          CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipType',$values['membership_type_id'],'member_of_contact_id','id');
+        $defaults[$fldName][0]
+          = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipType', $values['membership_type_id'], 'member_of_contact_id', 'id');
         $defaults[$fldName][1] = $values['membership_type_id'];
       }
       elseif ($name == 'membership_status') {
@@ -3293,12 +3368,12 @@ AND    ( entity_id IS NULL OR entity_id <= 0 )
     ));
     $links = $append = array();
     if (!empty($retrieved['values'])) {
-      foreach($retrieved['values'] as $id => $profile) {
+      foreach ($retrieved['values'] as $id => $profile) {
         if (in_array($profile['name'], $profiles)) {
           $links[] = array(
             'label' => $profile['title'],
             'url' => CRM_Utils_System::url('civicrm/profile/create', "reset=1&context=dialog&gid=$id",
-              NULL, NULL, FALSE, FALSE, TRUE) ,
+              NULL, NULL, FALSE, FALSE, TRUE),
             'type' => ucfirst(str_replace('new_', '', $profile['name'])),
           );
         }
@@ -3316,13 +3391,13 @@ AND    ( entity_id IS NULL OR entity_id <= 0 )
   }
 
   /**
-   * Retrieve groups of  profiles
+   * Retrieve groups of  profiles.
    *
    * @param int $profileID
    *   Id of the profile.
    *
-   * @return array  returns array
-   * @static
+   * @return array
+   *   returns array
    */
   public static function profileGroups($profileID) {
     $groupTypes = array();
@@ -3343,7 +3418,8 @@ AND    ( entity_id IS NULL OR entity_id <= 0 )
    * @param int $contactId
    *   User contact id.
    *
-   * @return array  $subscribeGroupIds  This contains array of groups for subscription
+   * @return array
+   *   This contains array of groups for subscription
    */
   public static function getDoubleOptInGroupIds(&$params, $contactId = NULL) {
     $config = CRM_Core_Config::singleton();
@@ -3411,13 +3487,13 @@ SELECT  group_id
   }
 
   /**
-   * Check if we are rendering mixed profiles
+   * Check if we are rendering mixed profiles.
    *
    * @param array $profileIds
    *   Associated array of profile ids.
    *
-   * @return boolean $mixProfile true if profile is mixed
-   * @static
+   * @return bool
+   *   true if profile is mixed
    */
   public static function checkForMixProfiles($profileIds) {
     $mixProfile = FALSE;
@@ -3464,10 +3540,10 @@ SELECT  group_id
   }
 
   /**
-   * Determine of we show overlay profile or not
+   * Determine of we show overlay profile or not.
    *
-   * @return boolean true if profile should be shown else false
-   * @static
+   * @return bool
+   *   true if profile should be shown else false
    */
   public static function showOverlayProfile() {
     $showOverlay = TRUE;
@@ -3488,13 +3564,13 @@ SELECT  group_id
   }
 
   /**
-   * Get group type values of the profile
+   * Get group type values of the profile.
    *
    * @param int $profileId
    * @param string $groupType
    *
-   * @return Array   group type values
-   * @static
+   * @return array
+   *   group type values
    */
   public static function groupTypeValues($profileId, $groupType = NULL) {
     $groupTypeValue = array();
@@ -3564,18 +3640,18 @@ SELECT  group_id
   }
 
   /**
-   * Get profiles used for batch entry
+   * Get profiles used for batch entry.
    *
-   * @return array profileIds profile ids
-   * @static
+   * @return array
+   *   profileIds profile ids
    */
   public static function getBatchProfiles() {
     $query = "SELECT id
       FROM civicrm_uf_group
       WHERE name IN ('contribution_batch_entry', 'membership_batch_entry')";
-    $dao = CRM_Core_DAO::executeQuery( $query );
+    $dao = CRM_Core_DAO::executeQuery($query);
     $profileIds = array();
-    while( $dao->fetch() ) {
+    while ($dao->fetch()) {
       $profileIds[$dao->id] = $dao->id;
     }
     return $profileIds;
@@ -3590,7 +3666,7 @@ SELECT  group_id
    * @return array|null
    */
   public static function shiftMultiRecordFields(&$source, &$destination, $returnMultiSummaryFields = FALSE) {
-    $multiSummaryFields = $returnMultiSummaryFields ? array( ) : NULL;
+    $multiSummaryFields = $returnMultiSummaryFields ? array() : NULL;
     foreach ($source as $field => $properties) {
       if (!CRM_Core_BAO_CustomField::getKeyID($field)) {
         continue;
@@ -3609,18 +3685,17 @@ SELECT  group_id
   }
 
   /**
-   * This is function is used to format pseudo fields
+   * This is function is used to format pseudo fields.
    *
    * @param array $fields
    *   Associated array of profile fields.
    *
-   * @static
    */
   public static function reformatProfileFields(&$fields) {
     //reformat fields array
     foreach ($fields as $name => $field) {
       //reformat phone and extension field
-      if ( substr($field['name'], 0, 13) == 'phone_and_ext') {
+      if (substr($field['name'], 0, 13) == 'phone_and_ext') {
         $fieldSuffix = str_replace('phone_and_ext-', '', $field['name']);
 
         // retain existing element properties and just update and replace key
@@ -3630,7 +3705,7 @@ SELECT  group_id
 
         // add additional phone extension field
         $fields["phone_ext-{$fieldSuffix}"] = $field;
-        $fields["phone_ext-{$fieldSuffix}"]['title'] = $field['title'] .' - '.ts('Ext.');
+        $fields["phone_ext-{$fieldSuffix}"]['title'] = $field['title'] . ' - ' . ts('Ext.');
         $fields["phone_ext-{$fieldSuffix}"]['name'] = "phone_ext-{$fieldSuffix}";
         $fields["phone_ext-{$fieldSuffix}"]['where'] = 'civicrm_phone.phone_ext';
         $fields["phone_ext-{$fieldSuffix}"]['skipDisplay'] = 1;
@@ -3639,4 +3714,5 @@ SELECT  group_id
       }
     }
   }
+
 }