);
}
- if ($contact->contact_type == 'Individual' &&
- (isset($params['current_employer']) ||
- isset($params['employer_id'])
- )
- ) {
+ if ($contact->contact_type == 'Individual' && (isset($params['current_employer']) || isset($params['employer_id']))) {
+ $newEmployer = !empty($params['employer_id']) ? $params['employer_id'] : CRM_Utils_Array::value('current_employer', $params);
// create current employer
- if (isset($params['employer_id'])) {
- CRM_Contact_BAO_Contact_Utils::createCurrentEmployerRelationship($contact->id,
- $params['employer_id'], $employerId
- );
- }
- elseif ($params['current_employer']) {
- CRM_Contact_BAO_Contact_Utils::createCurrentEmployerRelationship($contact->id,
- $params['current_employer']
- );
+ if ($newEmployer) {
+ CRM_Contact_BAO_Contact_Utils::createCurrentEmployerRelationship($contact->id, $newEmployer, $employerId);
}
else {
//unset if employer id exits
*/
static function &create(&$params, $fixAddress = TRUE, $invokeHooks = TRUE, $skipDelete = FALSE) {
$contact = NULL;
- if (!CRM_Utils_Array::value('contact_type', $params) &&
- !CRM_Utils_Array::value('contact_id', $params)
- ) {
+ if (empty($params['contact_type']) && empty($params['contact_id'])) {
return $contact;
}
// Enabling multisite causes the contact to be added to the domain group
$domainGroupID = CRM_Core_BAO_Domain::getGroupId();
if(!empty($domainGroupID)){
- if (CRM_Utils_Array::value('group', $params) && is_array($params['group'])) {
+ if (!empty($params['group']) && is_array($params['group'])) {
$params['group'][$domainGroupID] = 1;
}
else {
$session = CRM_Core_Session::singleton();
$userID = $session->get('userID');
// add notes
- if (CRM_Utils_Array::value('note', $params)) {
+ if (!empty($params['note'])) {
if (is_array($params['note'])) {
foreach ($params['note'] as $note) {
$contactId = $contact->id;
// update the UF user_unique_id if that has changed
CRM_Core_BAO_UFMatch::updateUFName($contact->id);
- if (CRM_Utils_Array::value('custom', $params) &&
+ if (!empty($params['custom']) &&
is_array($params['custom'])
) {
CRM_Core_BAO_CustomValueTable::store($params['custom'], 'civicrm_contact', $contact->id);
}
// make a civicrm_subscription_history entry only on contact create (CRM-777)
- if (!CRM_Utils_Array::value('contact_id', $params)) {
+ if (empty($params['contact_id'])) {
$subscriptionParams = array(
'contact_id' => $contact->id,
'status' => 'Added',
* @param array $defaults (reference) the default values, some of which need to be resolved.
* @param boolean $reverse true if we want to resolve the values in the reverse direction (value -> name)
*
- * @return none
+ * @return void
* @access public
* @static
*/
static function resolveDefaults(&$defaults, $reverse = FALSE) {
// hack for birth_date
- if (CRM_Utils_Array::value('birth_date', $defaults)) {
+ if (!empty($defaults['birth_date'])) {
if (is_array($defaults['birth_date'])) {
$defaults['birth_date'] = CRM_Utils_Date::format($defaults['birth_date'], '-');
}
CRM_Utils_Array::lookupValue($defaults, 'prefix', CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'prefix_id'), $reverse);
CRM_Utils_Array::lookupValue($defaults, 'suffix', CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'suffix_id'), $reverse);
CRM_Utils_Array::lookupValue($defaults, 'gender', CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'gender_id'), $reverse);
+ CRM_Utils_Array::lookupValue($defaults, 'communication_style', CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'communication_style_id'), $reverse);
//lookup value of email/postal greeting, addressee, CRM-4575
foreach (self::$_greetingTypes as $greeting) {
if ($name == 'address') {
// FIXME: lookupValue doesn't work for vcard_name
- if (CRM_Utils_Array::value('location_type_id', $values)) {
+ if (!empty($values['location_type_id'])) {
$vcardNames = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id', array('labelColumn' => 'vcard_name'));
$values['vcard_name'] = $vcardNames[$values['location_type_id']];
}
*/
public static function processImage() {
- $action = CRM_Utils_Request::retrieve('action', 'String', $this);
- $cid = CRM_Utils_Request::retrieve('cid', 'Positive', $this);
+ $action = CRM_Utils_Request::retrieve('action', 'String');
+ $cid = CRM_Utils_Request::retrieve('cid', 'Positive');
// retrieve contact id in case of Profile context
- $id = CRM_Utils_Request::retrieve('id', 'Positive', $this);
+ $id = CRM_Utils_Request::retrieve('id', 'Positive');
$cid = $cid ? $cid : $id;
if ($action & CRM_Core_Action::DELETE) {
- if (CRM_Utils_Request::retrieve('confirmed', 'Boolean', $this)) {
+ if (CRM_Utils_Request::retrieve('confirmed', 'Boolean')) {
CRM_Contact_BAO_Contact::deleteContactImage($cid);
CRM_Core_Session::setStatus(ts('Contact image deleted successfully'), ts('Image Deleted'), 'success');
$session = CRM_Core_Session::singleton();
'first_name',
'middle_name',
'last_name',
+ 'formal_title',
'job_title',
'gender_id',
'prefix_id',
'first_name',
'middle_name',
'last_name',
+ 'formal_title',
'job_title',
'gender_id',
'prefix_id',
'first_name',
'middle_name',
'last_name',
+ 'formal_title',
'job_title',
'gender_id',
'prefix_id',
'first_name',
'middle_name',
'last_name',
+ 'formal_title',
'job_title',
'gender_id',
'prefix_id',
}
}
- if (!CRM_Utils_Array::value('location', $returnProperties)) {
+ if (empty($returnProperties['location'])) {
$returnProperties['location'] = array();
}
- if (!CRM_Utils_Array::value($locationTypeName, $returnProperties['location'])) {
+ if (empty($returnProperties['location'][$locationTypeName])) {
$returnProperties['location'][$locationTypeName] = array();
$returnProperties['location'][$locationTypeName]['location_type'] = $id;
}
$entityBlock = array('contact_id' => $contactId);
$blocks = CRM_Core_BAO_Location::getValues($entityBlock);
foreach($blocks[$block] as $key => $value){
- if (CRM_Utils_Array::value('is_primary', $value)){
+ if (!empty($value['is_primary'])){
$locationType = CRM_Utils_Array::value('location_type_id',$value);
}
}
$isOptOut = CRM_Utils_Array::value('is_opt_out', $params, FALSE);
$data['is_opt_out'] = $isOptOut;
// on change, create new civicrm_subscription_history entry
- if (($wasOptOut != $isOptOut) &&
- CRM_Utils_Array::value('contact_id', $contactDetails)
- ) {
+ if (($wasOptOut != $isOptOut) && !empty($contactDetails['contact_id'])) {
$shParams = array(
'contact_id' => $contactDetails['contact_id'],
'status' => $isOptOut ? 'Removed' : 'Added',
}
// Process group and tag
- if (CRM_Utils_Array::value('group', $fields)) {
+ if (!empty($fields['group'])) {
$method = 'Admin';
// this for sure means we are coming in via profile since i added it to fix
// removing contacts from user groups -- lobo
CRM_Contact_BAO_GroupContact::create($params['group'], $contactID, $visibility, $method);
}
- if (CRM_Utils_Array::value('tag', $fields)) {
+ if (!empty($fields['tag'])) {
CRM_Core_BAO_EntityTag::create($params['tag'], 'civicrm_contact', $contactID);
}
}
$valueId = NULL;
- if (CRM_Utils_Array::value('customRecordValues', $params)) {
+ if (!empty($params['customRecordValues'])) {
if (is_array($params['customRecordValues']) && !empty($params['customRecordValues'])) {
foreach ($params['customRecordValues'] as $recId => $customFields) {
if (is_array($customFields) && !empty($customFields)) {
}
$type = $data['contact_type'];
- if ( CRM_Utils_Array::value('contact_sub_type', $data) ) {
+ if (!empty($data['contact_sub_type'])) {
$type = $data['contact_sub_type'];
$type = explode(CRM_Core_DAO::VALUE_SEPARATOR, trim($type, CRM_Core_DAO::VALUE_SEPARATOR));
// generally a contact even if, has multiple subtypes the parent-type is going to be one only
$values['preferred_communication_method'] = $preffComm;
$values['preferred_communication_method_display'] = CRM_Utils_Array::value('preferred_communication_method_display', $temp);
- CRM_Contact_DAO_Contact::addDisplayEnums($values);
+ $preferredMailingFormat = CRM_Core_SelectValues::pmf();
+ $values['preferred_mail_format'] = $preferredMailingFormat[$contact->preferred_mail_format];
// get preferred languages
if (!empty($contact->preferred_language)) {
// fields that are required to calculate greeting and
// also other fields used in tokens etc,
// hence we need to retrieve it again.
- $contact->find(TRUE);
+ if ( $contact->_query !== FALSE ) {
+ $contact->find(TRUE);
+ }
// store object values to an array
$contactDetails = array();
}
if ($emailGreetingString) {
- CRM_Utils_Token::replaceGreetingTokens($emailGreetingString,
+ CRM_Contact_BAO_Contact_Utils::processGreetingTemplate($emailGreetingString,
$contactDetails,
$contact->id,
'CRM_Contact_BAO_Contact'
}
if ($postalGreetingString) {
- CRM_Utils_Token::replaceGreetingTokens($postalGreetingString,
+ CRM_Contact_BAO_Contact_Utils::processGreetingTemplate($postalGreetingString,
$contactDetails,
$contact->id,
'CRM_Contact_BAO_Contact'
}
if ($addresseeString) {
- CRM_Utils_Token::replaceGreetingTokens($addresseeString,
+ CRM_Contact_BAO_Contact_Utils::processGreetingTemplate($addresseeString,
$contactDetails,
$contact->id,
'CRM_Contact_BAO_Contact'
*/
static function contextMenu($contactId = NULL) {
$menu = array(
- 'view' => array('title' => ts('View Contact'),
+ 'view' => array(
+ 'title' => ts('View Contact'),
'weight' => 0,
'ref' => 'view-contact',
+ 'class' => 'no-popup',
'key' => 'view',
'permissions' => array('view all contacts'),
),
- 'add' => array('title' => ts('Edit Contact'),
+ 'add' => array(
+ 'title' => ts('Edit Contact'),
'weight' => 0,
'ref' => 'edit-contact',
+ 'class' => 'no-popup',
'key' => 'add',
'permissions' => array('edit all contacts'),
),
- 'delete' => array('title' => ts('Delete Contact'),
+ 'delete' => array(
+ 'title' => ts('Delete Contact'),
'weight' => 0,
'ref' => 'delete-contact',
'key' => 'delete',
'permissions' => array('access deleted contacts', 'delete contacts'),
),
- 'contribution' => array('title' => ts('Add Contribution'),
+ 'contribution' => array(
+ 'title' => ts('Add Contribution'),
'weight' => 5,
'ref' => 'new-contribution',
'key' => 'contribution',
+ 'tab' => 'contribute',
'component' => 'CiviContribute',
'href' => CRM_Utils_System::url('civicrm/contact/view/contribution',
'reset=1&action=add&context=contribution'
'edit contributions',
),
),
- 'participant' => array('title' => ts('Register for Event'),
+ 'participant' => array(
+ 'title' => ts('Register for Event'),
'weight' => 10,
'ref' => 'new-participant',
'key' => 'participant',
+ 'tab' => 'participant',
'component' => 'CiviEvent',
'href' => CRM_Utils_System::url('civicrm/contact/view/participant', 'reset=1&action=add&context=participant'),
'permissions' => array(
'edit event participants',
),
),
- 'activity' => array('title' => ts('Record Activity'),
+ 'activity' => array(
+ 'title' => ts('Record Activity'),
'weight' => 35,
'ref' => 'new-activity',
'key' => 'activity',
'permissions' => array('edit all contacts'),
),
- 'pledge' => array('title' => ts('Add Pledge'),
+ 'pledge' => array(
+ 'title' => ts('Add Pledge'),
'weight' => 15,
'ref' => 'new-pledge',
'key' => 'pledge',
+ 'tab' => 'pledge',
'href' => CRM_Utils_System::url('civicrm/contact/view/pledge',
'reset=1&action=add&context=pledge'
),
'edit pledges',
),
),
- 'membership' => array('title' => ts('Add Membership'),
+ 'membership' => array(
+ 'title' => ts('Add Membership'),
'weight' => 20,
'ref' => 'new-membership',
'key' => 'membership',
+ 'tab' => 'member',
'component' => 'CiviMember',
'href' => CRM_Utils_System::url('civicrm/contact/view/membership',
'reset=1&action=add&context=membership'
'edit memberships',
),
),
- 'case' => array('title' => ts('Add Case'),
+ 'case' => array(
+ 'title' => ts('Add Case'),
'weight' => 25,
'ref' => 'new-case',
'key' => 'case',
+ 'tab' => 'case',
'component' => 'CiviCase',
'href' => CRM_Utils_System::url('civicrm/case/add', 'reset=1&action=add&context=case'),
'permissions' => array('add cases'),
),
- 'grant' => array('title' => ts('Add Grant'),
+ 'grant' => array(
+ 'title' => ts('Add Grant'),
'weight' => 26,
'ref' => 'new-grant',
'key' => 'grant',
+ 'tab' => 'grant',
'component' => 'CiviGrant',
'href' => CRM_Utils_System::url('civicrm/contact/view/grant',
'reset=1&action=add&context=grant'
),
'permissions' => array('edit grants'),
),
- 'rel' => array('title' => ts('Add Relationship'),
+ 'rel' => array(
+ 'title' => ts('Add Relationship'),
'weight' => 30,
'ref' => 'new-relationship',
'key' => 'rel',
+ 'tab' => 'rel',
'href' => CRM_Utils_System::url('civicrm/contact/view/rel',
'reset=1&action=add'
),
'permissions' => array('edit all contacts'),
),
- 'note' => array('title' => ts('Add Note'),
+ 'note' => array(
+ 'title' => ts('Add Note'),
'weight' => 40,
'ref' => 'new-note',
'key' => 'note',
+ 'tab' => 'note',
'href' => CRM_Utils_System::url('civicrm/contact/view/note',
'reset=1&action=add'
),
'permissions' => array('edit all contacts'),
),
- 'email' => array('title' => ts('Send an Email'),
+ 'email' => array(
+ 'title' => ts('Send an Email'),
'weight' => 45,
'ref' => 'new-email',
'key' => 'email',
'permissions' => array('view all contacts'),
),
- 'group' => array('title' => ts('Add to Group'),
+ 'group' => array(
+ 'title' => ts('Add to Group'),
'weight' => 50,
'ref' => 'group-add-contact',
'key' => 'group',
+ 'tab' => 'group',
'permissions' => array('edit groups'),
),
- 'tag' => array('title' => ts('Tag'),
+ 'tag' => array(
+ 'title' => ts('Tag Contact'),
'weight' => 55,
'ref' => 'tag-contact',
'key' => 'tag',
+ 'tab' => 'tag',
'permissions' => array('edit all contacts'),
),
);
$contextMenu['primaryActions'][$key] = array(
'title' => $values['title'],
'ref' => $values['ref'],
+ 'class' => CRM_Utils_Array::value('class', $values),
'key' => $values['key'],
);
continue;
'title' => $values['title'],
'ref' => $values['ref'],
'href' => CRM_Utils_Array::value('href', $values),
+ 'tab' => CRM_Utils_Array::value('tab', $values),
+ 'class' => CRM_Utils_Array::value('class', $values),
'key' => $values['key'],
);
}