<?php
/*
+--------------------------------------------------------------------+
- | CiviCRM version 4.6 |
+ | CiviCRM version 4.7 |
+--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2014 |
+ | Copyright CiviCRM LLC (c) 2004-2015 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
/**
*
* @package CRM
- * @copyright CiviCRM LLC (c) 2004-2014
- * $Id$
- *
+ * @copyright CiviCRM LLC (c) 2004-2015
*/
/**
- * Class contains functions for individual contact type
+ * Class contains functions for individual contact type.
*/
class CRM_Contact_BAO_Individual extends CRM_Contact_DAO_Contact {
/**
- * This is a contructor of the class.
+ * Class constructor.
*/
public function __construct() {
}
*
* @param array $params
* (reference ) an assoc array of name/value pairs.
- * @param array $contact
+ * @param CRM $contact
* Contact object.
*
* @return CRM_Contact_BAO_Contact
}
//build the sort name.
- $format = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
- 'sort_name_format'
- );
+ $format = Civi::settings()->get('sort_name_format');
$sortName = CRM_Utils_Address::format($formatted, $format,
FALSE, FALSE, TRUE, $tokenFields
);
$sortName = trim($sortName);
//build the display name.
- $format = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
- 'display_name_format'
- );
+ $format = Civi::settings()->get('display_name_format');
$displayName = CRM_Utils_Address::format($formatted, $format,
FALSE, FALSE, TRUE, $tokenFields
);
}
//now set the names.
- $names = array('sortName' => 'sort_name', 'displayName' => 'display_name');
+ $names = array('displayName' => 'display_name', 'sortName' => 'sort_name');
foreach ($names as $value => $name) {
if (empty($$value)) {
if ($email) {
elseif ($uniqId) {
$$value = $uniqId;
}
+ elseif (!empty($params[$name])) {
+ $$value = $params[$name];
+ }
+ // If we have nothing else going on set sort_name to display_name.
+ elseif ($displayName) {
+ $$value = $displayName;
+ }
}
//finally if we could not pass anything lets keep db.
if (!empty($$value)) {
}
/**
- * Regenerates display_name for contacts with given prefixes/suffixes
+ * Regenerates display_name for contacts with given prefixes/suffixes.
*
* @param array $ids
* The array with the prefix/suffix id governing which contacts to regenerate.
* @param int $action
* The action describing whether prefix/suffix was UPDATED or DELETED.
- *
- * @return void
*/
public static function updateDisplayNames(&$ids, $action) {
// get the proper field name (prefix_id or suffix_id) and its value
* Check if there is data to create the object.
*
* @param array $params
- * (reference ) an assoc array of name/value pairs.
*
* @return bool
*/
- public static function dataExists(&$params) {
+ public static function dataExists($params) {
if ($params['contact_type'] == 'Individual') {
return TRUE;
}