X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FContact%2FBAO%2FContact.php;h=5a22a86d7850614dd166ec3e224723876f565e74;hb=9fd87c273d7e3242875b21db87f60bdd3db4d255;hp=4a8d50a5199ccbefc523c8bd1943846f041bf3d6;hpb=e4a739c78ba775f7ff343d197d56d8682ce822f1;p=civicrm-core.git diff --git a/CRM/Contact/BAO/Contact.php b/CRM/Contact/BAO/Contact.php index 4a8d50a519..5a22a86d78 100644 --- a/CRM/Contact/BAO/Contact.php +++ b/CRM/Contact/BAO/Contact.php @@ -62,7 +62,7 @@ class CRM_Contact_BAO_Contact extends CRM_Contact_DAO_Contact { * * @var array */ - static $_commPrefs = array( + public static $_commPrefs = array( 'do_not_phone', 'do_not_email', 'do_not_mail', @@ -75,7 +75,7 @@ class CRM_Contact_BAO_Contact extends CRM_Contact_DAO_Contact { * * @var array */ - static $_greetingTypes = array( + public static $_greetingTypes = array( 'addressee', 'email_greeting', 'postal_greeting', @@ -86,14 +86,14 @@ class CRM_Contact_BAO_Contact extends CRM_Contact_DAO_Contact { * * @var array */ - static $_importableFields = array(); + public static $_importableFields = array(); /** * Static field for all the contact information that we can potentially export. * * @var array */ - static $_exportableFields = NULL; + public static $_exportableFields = NULL; /** * Class constructor. @@ -272,6 +272,10 @@ class CRM_Contact_BAO_Contact extends CRM_Contact_DAO_Contact { return $contact; } + if (!empty($params['contact_id']) && empty($params['contact_type'])) { + $params['contact_type'] = self::getContactType($params['contact_id']); + } + $isEdit = TRUE; if ($invokeHooks) { if (!empty($params['contact_id'])) { @@ -462,7 +466,8 @@ class CRM_Contact_BAO_Contact extends CRM_Contact_DAO_Contact { if (!empty($params['contact_id']) && !empty($missingGreetingParams)) { $savedGreetings = civicrm_api3('Contact', 'getsingle', array( 'id' => $params['contact_id'], - 'return' => array_keys($missingGreetingParams)) + 'return' => array_keys($missingGreetingParams), + ) ); foreach (array_keys($missingGreetingParams) as $missingGreetingParam) { @@ -1489,7 +1494,7 @@ WHERE civicrm_contact.id = " . CRM_Utils_Type::escape($id, 'Integer'); * True when used during search, might conflict with export param?. * * @param bool $withMultiRecord - * + * @param bool $checkPermissions * @return array * array of exportable Fields */ @@ -1524,8 +1529,7 @@ WHERE civicrm_contact.id = " . CRM_Utils_Type::escape($id, 'Integer'); 'Household', 'Organization', 'All', - ) - )) { + ))) { $fields = array_merge($fields, CRM_Core_OptionValue::getFields('', $contactType)); } // add current employer for individuals @@ -1591,10 +1595,10 @@ WHERE civicrm_contact.id = " . CRM_Utils_Type::escape($id, 'Integer'); } else { foreach (array( - 'Individual', - 'Household', - 'Organization', - ) as $type) { + 'Individual', + 'Household', + 'Organization', + ) as $type) { $fields = array_merge($fields, CRM_Core_BAO_CustomField::getFieldsForImport($type, FALSE, FALSE, $search, $checkPermissions, $withMultiRecord) ); @@ -1732,7 +1736,7 @@ WHERE civicrm_contact.id = " . CRM_Utils_Type::escape($id, 'Integer'); * @return array * Contact details */ - public static function getHierContactDetails($contactId, &$fields) { + public static function getHierContactDetails($contactId, $fields) { $params = array(array('contact_id', '=', $contactId, 0, 0)); $options = array(); @@ -2069,7 +2073,7 @@ ORDER BY civicrm_email.is_primary DESC"; */ public static function formatProfileContactParams( &$params, - &$fields, + $fields, $contactID = NULL, $ufGroupId = NULL, $ctype = NULL, @@ -2387,23 +2391,21 @@ ORDER BY civicrm_email.is_primary DESC"; } } } - elseif (in_array($key, - array( - 'nick_name', - 'job_title', - 'middle_name', - 'birth_date', - 'gender_id', - 'current_employer', - 'prefix_id', - 'suffix_id', - )) && - ($value == '' || !isset($value)) && - ($session->get('authSrc') & (CRM_Core_Permission::AUTH_SRC_CHECKSUM + CRM_Core_Permission::AUTH_SRC_LOGIN)) == 0 || - ($key == 'current_employer' && empty($params['current_employer']))) { - // CRM-10128: if auth source is not checksum / login && $value is blank, do not fill $data with empty value - // to avoid update with empty values - continue; + elseif (in_array($key, array( + 'nick_name', + 'job_title', + 'middle_name', + 'birth_date', + 'gender_id', + 'current_employer', + 'prefix_id', + 'suffix_id', + )) && ($value == '' || !isset($value)) && + ($session->get('authSrc') & (CRM_Core_Permission::AUTH_SRC_CHECKSUM + CRM_Core_Permission::AUTH_SRC_LOGIN)) == 0 || + ($key == 'current_employer' && empty($params['current_employer']))) { + // CRM-10128: if auth source is not checksum / login && $value is blank, do not fill $data with empty value + // to avoid update with empty values + continue; } else { $data[$key] = $value; @@ -2947,7 +2949,6 @@ AND civicrm_openid.is_primary = 1"; while ($blockDAO->fetch()) { $locBlockIds[$name][] = $blockDAO->id; } - $blockDAO->free(); } return $locBlockIds; @@ -3416,8 +3417,7 @@ LEFT JOIN civicrm_address ON ( civicrm_address.contact_id = civicrm_contact.id ) array('table' => 'civicrm_im', 'column' => 'contact_id'), array('table' => 'civicrm_phone', 'column' => 'contact_id'), array('table' => 'civicrm_website', 'column' => 'contact_id'), - ) - ) + )) ->alterTriggerInfo($info, $tableName); // Update phone table to populate phone_numeric field @@ -3559,7 +3559,6 @@ LEFT JOIN civicrm_address ON ( civicrm_address.contact_id = civicrm_contact.id ) } } CRM_Utils_Hook::post('delete', $type, $id, $obj); - $obj->free(); return TRUE; }