}
//fix for validate contact sub type CRM-5143
- if ( isset( $params['contact_sub_type'] ) ) {
- if ( empty($params['contact_sub_type']) ) {
+ if (isset($params['contact_sub_type'])) {
+ if (empty($params['contact_sub_type'])) {
$params['contact_sub_type'] = 'null';
}
else {
if (!CRM_Contact_BAO_ContactType::isExtendsContactType($params['contact_sub_type'],
$params['contact_type'], TRUE
- )) {
+ )
+ ) {
// we'll need to fix tests to handle this
// CRM-7925
CRM_Core_Error::fatal(ts('The Contact Sub Type does not match the Contact type for this record'));
* @static
*/
public static function &create(&$params, $fixAddress = TRUE, $invokeHooks = TRUE, $skipDelete = FALSE) {
- $contact = NULL;
- if (empty($params['contact_type']) && empty($params['contact_id'])) {
- return $contact;
- }
+ $contact = NULL;
+ if (empty($params['contact_type']) && empty($params['contact_id'])) {
+ return $contact;
+ }
- $isEdit = TRUE;
- if ($invokeHooks) {
- if (!empty($params['contact_id'])) {
- CRM_Utils_Hook::pre('edit', $params['contact_type'], $params['contact_id'], $params);
- }
- else {
- CRM_Utils_Hook::pre('create', $params['contact_type'], NULL, $params);
- $isEdit = FALSE;
- }
+ $isEdit = TRUE;
+ if ($invokeHooks) {
+ if (!empty($params['contact_id'])) {
+ CRM_Utils_Hook::pre('edit', $params['contact_type'], $params['contact_id'], $params);
+ }
+ else {
+ CRM_Utils_Hook::pre('create', $params['contact_type'], NULL, $params);
+ $isEdit = FALSE;
}
+ }
- $config = CRM_Core_Config::singleton();
+ $config = CRM_Core_Config::singleton();
- // CRM-6942: set preferred language to the current language if it’s unset (and we’re creating a contact)
- if (empty($params['contact_id']) && empty($params['preferred_language'])) {
- $params['preferred_language'] = $config->lcMessages;
- }
+ // CRM-6942: set preferred language to the current language if it’s unset (and we’re creating a contact)
+ if (empty($params['contact_id']) && empty($params['preferred_language'])) {
+ $params['preferred_language'] = $config->lcMessages;
+ }
- // CRM-9739: set greeting & addressee if unset and we’re creating a contact
- if (empty($params['contact_id'])) {
- foreach (self::$_greetingTypes as $greeting) {
- if (empty($params[$greeting . '_id'])) {
- if ($defaultGreetingTypeId =
- CRM_Contact_BAO_Contact_Utils::defaultGreeting($params['contact_type'], $greeting)
- ) {
- $params[$greeting . '_id'] = $defaultGreetingTypeId;
- }
+ // CRM-9739: set greeting & addressee if unset and we’re creating a contact
+ if (empty($params['contact_id'])) {
+ foreach (self::$_greetingTypes as $greeting) {
+ if (empty($params[$greeting . '_id'])) {
+ if ($defaultGreetingTypeId =
+ CRM_Contact_BAO_Contact_Utils::defaultGreeting($params['contact_type'], $greeting)
+ ) {
+ $params[$greeting . '_id'] = $defaultGreetingTypeId;
}
}
}
+ }
- $transaction = new CRM_Core_Transaction();
+ $transaction = new CRM_Core_Transaction();
- $contact = self::add($params);
- if (!$contact) {
- // not dying here is stupid, since we get into wierd situation and into a bug that
- // is impossible to figure out for the user or for us
- // CRM-7925
- CRM_Core_Error::fatal();
- }
+ $contact = self::add($params);
+ if (!$contact) {
+ // not dying here is stupid, since we get into wierd situation and into a bug that
+ // is impossible to figure out for the user or for us
+ // CRM-7925
+ CRM_Core_Error::fatal();
+ }
- $params['contact_id'] = $contact->id;
+ $params['contact_id'] = $contact->id;
- if (CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::MULTISITE_PREFERENCES_NAME,
- 'is_enabled'
- )) {
- // Enabling multisite causes the contact to be added to the domain group
- $domainGroupID = CRM_Core_BAO_Domain::getGroupId();
- if(!empty($domainGroupID)){
- if (!empty($params['group']) && is_array($params['group'])) {
- $params['group'][$domainGroupID] = 1;
- }
- else {
- $params['group'] = array($domainGroupID => 1);
- }
+ if (CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::MULTISITE_PREFERENCES_NAME, 'is_enabled')) {
+ // Enabling multisite causes the contact to be added to the domain group
+ $domainGroupID = CRM_Core_BAO_Domain::getGroupId();
+ if (!empty($domainGroupID)) {
+ if (!empty($params['group']) && is_array($params['group'])) {
+ $params['group'][$domainGroupID] = 1;
}
- }
-
- if (array_key_exists('group', $params)) {
- $contactIds = array($params['contact_id']);
- foreach ($params['group'] as $groupId => $flag) {
- if ($flag == 1) {
- CRM_Contact_BAO_GroupContact::addContactsToGroup($contactIds, $groupId);
- }
- elseif ($flag == -1) {
- CRM_Contact_BAO_GroupContact::removeContactsFromGroup($contactIds, $groupId);
- }
+ else {
+ $params['group'] = array($domainGroupID => 1);
}
}
+ }
- //add location Block data
- $blocks = CRM_Core_BAO_Location::create($params, $fixAddress);
- foreach ($blocks as $name => $value) {
- $contact->$name = $value;
+ if (array_key_exists('group', $params)) {
+ $contactIds = array($params['contact_id']);
+ foreach ($params['group'] as $groupId => $flag) {
+ if ($flag == 1) {
+ CRM_Contact_BAO_GroupContact::addContactsToGroup($contactIds, $groupId);
+ }
+ elseif ($flag == -1) {
+ CRM_Contact_BAO_GroupContact::removeContactsFromGroup($contactIds, $groupId);
+ }
}
+ }
- //add website
- CRM_Core_BAO_Website::create($params['website'], $contact->id, $skipDelete);
+ //add location Block data
+ $blocks = CRM_Core_BAO_Location::create($params, $fixAddress);
+ foreach ($blocks as $name => $value) {
+ $contact->$name = $value;
+ }
- //get userID from session
- $session = CRM_Core_Session::singleton();
- $userID = $session->get('userID');
- // add notes
- if (!empty($params['note'])) {
- if (is_array($params['note'])) {
- foreach ($params['note'] as $note) {
- $contactId = $contact->id;
- if (isset($note['contact_id'])) {
- $contactId = $note['contact_id'];
- }
- //if logged in user, overwrite contactId
- if ($userID) {
- $contactId = $userID;
- }
+ //add website
+ CRM_Core_BAO_Website::create($params['website'], $contact->id, $skipDelete);
- $noteParams = array(
- 'entity_id' => $contact->id,
- 'entity_table' => 'civicrm_contact',
- 'note' => $note['note'],
- 'subject' => CRM_Utils_Array::value('subject', $note),
- 'contact_id' => $contactId,
- );
- CRM_Core_BAO_Note::add($noteParams, CRM_Core_DAO::$_nullArray);
- }
- }
- else {
+ //get userID from session
+ $session = CRM_Core_Session::singleton();
+ $userID = $session->get('userID');
+ // add notes
+ if (!empty($params['note'])) {
+ if (is_array($params['note'])) {
+ foreach ($params['note'] as $note) {
$contactId = $contact->id;
if (isset($note['contact_id'])) {
$contactId = $note['contact_id'];
$noteParams = array(
'entity_id' => $contact->id,
'entity_table' => 'civicrm_contact',
- 'note' => $params['note'],
- 'subject' => CRM_Utils_Array::value('subject', $params),
+ 'note' => $note['note'],
+ 'subject' => CRM_Utils_Array::value('subject', $note),
'contact_id' => $contactId,
);
CRM_Core_BAO_Note::add($noteParams, CRM_Core_DAO::$_nullArray);
}
}
+ else {
+ $contactId = $contact->id;
+ if (isset($note['contact_id'])) {
+ $contactId = $note['contact_id'];
+ }
+ //if logged in user, overwrite contactId
+ if ($userID) {
+ $contactId = $userID;
+ }
-
- // update the UF user_unique_id if that has changed
- CRM_Core_BAO_UFMatch::updateUFName($contact->id);
-
- 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 (empty($params['contact_id'])) {
- $subscriptionParams = array(
- 'contact_id' => $contact->id,
- 'status' => 'Added',
- 'method' => 'Admin',
+ $noteParams = array(
+ 'entity_id' => $contact->id,
+ 'entity_table' => 'civicrm_contact',
+ 'note' => $params['note'],
+ 'subject' => CRM_Utils_Array::value('subject', $params),
+ 'contact_id' => $contactId,
);
- CRM_Contact_BAO_SubscriptionHistory::create($subscriptionParams);
+ CRM_Core_BAO_Note::add($noteParams, CRM_Core_DAO::$_nullArray);
}
+ }
- $transaction->commit();
- // CRM-6367: fetch the right label for contact type’s display
- $contact->contact_type_display = CRM_Core_DAO::getFieldValue(
- 'CRM_Contact_DAO_ContactType',
- $contact->contact_type,
- 'label',
- 'name'
+ // update the UF user_unique_id if that has changed
+ CRM_Core_BAO_UFMatch::updateUFName($contact->id);
+
+ 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 (empty($params['contact_id'])) {
+ $subscriptionParams = array(
+ 'contact_id' => $contact->id,
+ 'status' => 'Added',
+ 'method' => 'Admin',
);
+ CRM_Contact_BAO_SubscriptionHistory::create($subscriptionParams);
+ }
- if (!$config->doNotResetCache) {
- // Note: doNotResetCache flag is currently set by import contact process and merging,
- // since resetting and
- // rebuilding cache could be expensive (for many contacts). We might come out with better
- // approach in future.
- CRM_Contact_BAO_Contact_Utils::clearContactCaches($contact->id);
- }
+ $transaction->commit();
- if ($invokeHooks) {
- if ($isEdit) {
- CRM_Utils_Hook::post('edit', $params['contact_type'], $contact->id, $contact);
- }
- else {
- CRM_Utils_Hook::post('create', $params['contact_type'], $contact->id, $contact);
- }
+ // CRM-6367: fetch the right label for contact type’s display
+ $contact->contact_type_display = CRM_Core_DAO::getFieldValue(
+ 'CRM_Contact_DAO_ContactType',
+ $contact->contact_type,
+ 'label',
+ 'name'
+ );
+
+ if (!$config->doNotResetCache) {
+ // Note: doNotResetCache flag is currently set by import contact process and merging,
+ // since resetting and
+ // rebuilding cache could be expensive (for many contacts). We might come out with better
+ // approach in future.
+ CRM_Contact_BAO_Contact_Utils::clearContactCaches($contact->id);
+ }
+
+ if ($invokeHooks) {
+ if ($isEdit) {
+ CRM_Utils_Hook::post('edit', $params['contact_type'], $contact->id, $contact);
+ }
+ else {
+ CRM_Utils_Hook::post('create', $params['contact_type'], $contact->id, $contact);
}
+ }
- // process greetings CRM-4575, cache greetings
- self::processGreetings($contact);
+ // process greetings CRM-4575, cache greetings
+ self::processGreetings($contact);
- return $contact;
+ return $contact;
}
/**
//lookup value of email/postal greeting, addressee, CRM-4575
foreach (self::$_greetingTypes as $greeting) {
- $filterCondition = array('contact_type' => CRM_Utils_Array::value('contact_type', $defaults),
+ $filterCondition = array(
+ 'contact_type' => CRM_Utils_Array::value('contact_type', $defaults),
'greeting_type' => $greeting,
);
CRM_Utils_Array::lookupValue($defaults, $greeting,
//get the block information for this contact
$entityBlock = array('contact_id' => $params['contact_id']);
- $blocks = CRM_Core_BAO_Location::getValues($entityBlock, $microformat);
- $defaults = array_merge($defaults, $blocks);
- foreach ($blocks as $block => $value) $contact->$block = $value;
+ $blocks = CRM_Core_BAO_Location::getValues($entityBlock, $microformat);
+ $defaults = array_merge($defaults, $blocks);
+ foreach ($blocks as $block => $value) {
+ $contact->$block = $value;
+ }
if (!isset($params['noNotes'])) {
$contact->notes = CRM_Core_BAO_Note::getValues($params, $defaults);
$baseUrl,
str_replace('\\', '/', $absolutePath)
);
- } else if ( $config->userFramework == 'WordPress' ) {
- $userFrameworkBaseURL = trim( str_replace( '/wp-admin/', '', $config->userFrameworkBaseURL ) );
- $customFileUploadDirectory = strstr( str_replace('\\', '/', $absolutePath), '/wp-content/' );
- $relativePath = $userFrameworkBaseURL . $customFileUploadDirectory;
+ }
+ else if ($config->userFramework == 'WordPress') {
+ $userFrameworkBaseURL = trim(str_replace('/wp-admin/', '', $config->userFrameworkBaseURL));
+ $customFileUploadDirectory = strstr(str_replace('\\', '/', $absolutePath), '/wp-content/');
+ $relativePath = $userFrameworkBaseURL . $customFileUploadDirectory;
}
return $relativePath;
*
* @return boolean true if valid image extension
*/
- public static function processImageParams(&$params,
+ public static function processImageParams(
+ &$params,
$imageIndex = 'image_URL',
- $statusMsg = NULL,
- $opType = 'status'
+ $statusMsg = NULL,
+ $opType = 'status'
) {
$mimeType = array(
'image/jpeg',
if (in_array($params[$imageIndex]['type'], $mimeType)) {
$photo = basename($params[$imageIndex]['name']);
- $params[$imageIndex] = CRM_Utils_System::url('civicrm/contact/imagefile', 'photo='.$photo, TRUE, NULL, TRUE, TRUE);
+ $params[$imageIndex] = CRM_Utils_System::url('civicrm/contact/imagefile', 'photo=' . $photo, TRUE, NULL, TRUE, TRUE);
return TRUE;
}
else {
/**
* Function to set is_delete true or restore deleted contact
*
- * @param int $contact Contact DAO object
- * @param boolean $restore true to set the is_delete = 1 else false to restore deleted contact,
+ * @param int $contact Contact DAO object
+ * @param boolean $restore true to set the is_delete = 1 else false to restore deleted contact,
* i.e. is_delete = 0
*
- * @return void
+ * @return void
* @static
*/
public static function contactTrashRestore($contact, $restore = FALSE) {
*
*/
public static function getContactTypes($id) {
- $params = array('id' => $id);
+ $params = array('id' => $id);
$details = array();
$contact = CRM_Core_DAO::commonRetrieve('CRM_Contact_DAO_Contact',
$params,
* @return array array of importable Fields
* @static
*/
- static function importableFields($contactType = 'Individual',
- $status = FALSE,
- $showAll = FALSE,
- $isProfile = FALSE,
+ static function importableFields(
+ $contactType = 'Individual',
+ $status = FALSE,
+ $showAll = FALSE,
+ $isProfile = FALSE,
$checkPermission = TRUE,
$withMultiCustomFields = FALSE
) {
// get the fields thar are meant for contact types
if (in_array($contactType, array(
- 'Individual', 'Household', 'Organization', 'All'))) {
+ 'Individual',
+ 'Household',
+ 'Organization',
+ 'All'
+ ))) {
$fields = array_merge($fields, CRM_Core_OptionValue::getFields('', $contactType));
}
}
}
else {
- foreach (array(
- 'Individual', 'Household', 'Organization') as $type) {
+ foreach (array('Individual', 'Household', 'Organization') as $type) {
$fields = array_merge($fields,
CRM_Core_BAO_CustomField::getFieldsForImport($type,
$showAll,
$fields = CRM_Contact_DAO_Contact::export();
// the fields are meant for contact types
- if (
- in_array(
- $contactType,
- array('Individual', 'Household', 'Organization', 'All')
- )
- ) {
+ if (in_array($contactType, array('Individual', 'Household', 'Organization', 'All'))) {
$fields = array_merge($fields, CRM_Core_OptionValue::getFields('', $contactType));
}
// add current employer for individuals
'name' => 'organization_name',
'title' => ts('Current Employer'),
),
- ));
+ ));
$locationType = array(
'location_type' => array(
'name' => 'location_type',
'where' => 'civicrm_location_type.name',
'title' => ts('Location Type'),
- ));
+ )
+ );
$IMProvider = array(
'im_provider' => array(
'name' => 'im_provider',
'where' => 'civicrm_im.provider_id',
'title' => ts('IM Provider'),
- ));
+ )
+ );
$locationFields = array_merge($locationType,
CRM_Core_DAO_Address::export(),
}
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, TRUE, $withMultiRecord)
);
// we dont know the contents of return properties, but we need the lower level ids of the contact
// so add a few fields
$returnProperties['first_name'] =
- $returnProperties['organization_name'] =
- $returnProperties['household_name'] =
- $returnProperties['contact_type'] =
- $returnProperties['contact_sub_type'] = 1;
+ $returnProperties['organization_name'] =
+ $returnProperties['household_name'] =
+ $returnProperties['contact_type'] =
+ $returnProperties['contact_sub_type'] = 1;
return list($query, $options) = CRM_Contact_BAO_Query::apiQuery($params, $returnProperties, $options);
}
$returnProperties = array();
- $multipleFields = array('website' => 'url');
+ $multipleFields = array('website' => 'url');
foreach ($fields as $name => $dontCare) {
if (strpos($name, '-') !== FALSE) {
list($fieldName, $id, $type) = CRM_Utils_System::explode('-', $name, 3);
$returnProperties['location'][$locationTypeName]['location_type'] = $id;
}
if (in_array($fieldName, array(
- 'phone', 'im', 'email', 'openid', 'phone_ext'))) {
+ 'phone',
+ 'im',
+ 'email',
+ 'openid',
+ 'phone_ext'
+ ))) {
if ($type) {
$returnProperties['location'][$locationTypeName][$fieldName . '-' . $type] = 1;
}
* @static
*/
public static function getPrimaryLocationType($contactId, $skipDefaultPriamry = FALSE, $block = NULL) {
- if($block){
+ if ($block) {
$entityBlock = array('contact_id' => $contactId);
- $blocks = CRM_Core_BAO_Location::getValues($entityBlock);
- foreach($blocks[$block] as $key => $value){
- if (!empty($value['is_primary'])){
- $locationType = CRM_Utils_Array::value('location_type_id',$value);
+ $blocks = CRM_Core_BAO_Location::getValues($entityBlock);
+ foreach ($blocks[$block] as $key => $value) {
+ if (!empty($value['is_primary'])) {
+ $locationType = CRM_Utils_Array::value('location_type_id', $value);
}
}
}
else {
$name = $dao->display_name;
}
- $email = $dao->email;
+ $email = $dao->email;
$doNotEmail = $dao->do_not_email ? TRUE : FALSE;
- $onHold = $dao->on_hold ? TRUE : FALSE;
+ $onHold = $dao->on_hold ? TRUE : FALSE;
$isDeceased = $dao->is_deceased ? TRUE : FALSE;
return array($name, $email, $doNotEmail, $onHold, $isDeceased);
}
$contactID = NULL,
$addToGroupID = NULL,
$ufGroupId = NULL,
- $ctype = NULL,
- $visibility = FALSE
+ $ctype = NULL,
+ $visibility = FALSE
) {
// add ufGroupID to params array ( CRM-2012 )
if ($ufGroupId) {
// manage is_opt_out
if (array_key_exists('is_opt_out', $fields) && array_key_exists('is_opt_out', $params)) {
- $wasOptOut = CRM_Utils_Array::value('is_opt_out', $contactDetails, FALSE);
- $isOptOut = CRM_Utils_Array::value('is_opt_out', $params, FALSE);
+ $wasOptOut = CRM_Utils_Array::value('is_opt_out', $contactDetails, FALSE);
+ $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) && !empty($contactDetails['contact_id'])) {
if (array_key_exists('contact_sub_type', $params) &&
!empty($params['contact_sub_type'])
) {
- $data['contact_sub_type'] = CRM_Core_DAO::VALUE_SEPARATOR . implode(CRM_Core_DAO::VALUE_SEPARATOR, (array)$params['contact_sub_type']) . CRM_Core_DAO::VALUE_SEPARATOR;
+ $data['contact_sub_type'] = CRM_Core_DAO::VALUE_SEPARATOR . implode(CRM_Core_DAO::VALUE_SEPARATOR, (array) $params['contact_sub_type']) . CRM_Core_DAO::VALUE_SEPARATOR;
}
elseif (array_key_exists('contact_sub_type_hidden', $params) &&
!empty($params['contact_sub_type_hidden'])
) {
// if profile was used, and had any subtype, we obtain it from there
- $data['contact_sub_type'] = CRM_Core_DAO::VALUE_SEPARATOR . implode(CRM_Core_DAO::VALUE_SEPARATOR, (array)$params['contact_sub_type_hidden']) . CRM_Core_DAO::VALUE_SEPARATOR;
+ $data['contact_sub_type'] = CRM_Core_DAO::VALUE_SEPARATOR . implode(CRM_Core_DAO::VALUE_SEPARATOR, (array) $params['contact_sub_type_hidden']) . CRM_Core_DAO::VALUE_SEPARATOR;
}
if ($ctype == 'Organization') {
if ($locTypeId == 'Primary') {
if ($contactID) {
- if(in_array( $fieldName, $blocks)){
+ if (in_array($fieldName, $blocks)) {
$locTypeId = self::getPrimaryLocationType($contactID, FALSE, $fieldName);
}
- else{
+ else {
$locTypeId = self::getPrimaryLocationType($contactID, FALSE, 'address');
}
$primaryLocationType = $locTypeId;
$loc = CRM_Utils_Array::key($index, $locationType);
- $blockName = in_array( $fieldName, $blocks) ? $fieldName : 'address';
+ $blockName = in_array($fieldName, $blocks) ? $fieldName : 'address';
$data[$blockName][$loc]['location_type_id'] = $locTypeId;
$data[$blockName][$loc]['is_primary'] = 1;
}
- if ( in_array($fieldName, array('phone'))) {
+ if (in_array($fieldName, array('phone'))) {
if ($typeId) {
$data['phone'][$loc]['phone_type_id'] = $typeId;
}
// if auth source is not checksum / login && $value is blank, do not proceed - CRM-10128
if (($session->get('authSrc') & (CRM_Core_Permission::AUTH_SRC_CHECKSUM + CRM_Core_Permission::AUTH_SRC_LOGIN)) == 0 &&
- ($value == '' || !isset($value))) {
+ ($value == '' || !isset($value))
+ ) {
continue;
}
}
}
}
- if($key == 'phone' && isset($params['phone_ext'])){
+ if ($key == 'phone' && isset($params['phone_ext'])) {
$data[$key] = $value;
- foreach($value as $cnt => $phoneBlock){
- if($params[$key][$cnt]['location_type_id'] == $params['phone_ext'][$cnt]['location_type_id']){
+ foreach ($value as $cnt => $phoneBlock) {
+ if ($params[$key][$cnt]['location_type_id'] == $params['phone_ext'][$cnt]['location_type_id']) {
$data[$key][$cnt]['phone_ext'] = CRM_Utils_Array::retrieveValueRecursive($params['phone_ext'][$cnt], 'phone_ext');
}
}
}
else if (in_array($key,
- array('nick_name',
+ array(
+ 'nick_name',
'job_title',
'middle_name',
'birth_date',
'gender_id',
'current_employer',
'prefix_id',
- 'suffix_id')) &&
+ 'suffix_id'
+ )) &&
($value == '' || !isset($value)) &&
- ($session->get('authSrc') & (CRM_Core_Permission::AUTH_SRC_CHECKSUM + CRM_Core_Permission::AUTH_SRC_LOGIN)) == 0) {
+ ($session->get('authSrc') & (CRM_Core_Permission::AUTH_SRC_CHECKSUM + CRM_Core_Permission::AUTH_SRC_LOGIN)) == 0
+ ) {
// 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;
*/
public static function &matchContactOnEmail($mail, $ctype = NULL) {
$strtolower = function_exists('mb_strtolower') ? 'mb_strtolower' : 'strtolower';
- $mail = $strtolower(trim($mail));
- $query = "
+ $mail = $strtolower(trim($mail));
+ $query = "
SELECT civicrm_contact.id as contact_id,
civicrm_contact.hash as hash,
civicrm_contact.contact_type as contact_type,
INNER JOIN civicrm_email ON ( civicrm_contact.id = civicrm_email.contact_id )";
- if (CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::MULTISITE_PREFERENCES_NAME,
- 'uniq_email_per_site'
- )) {
+ if (CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::MULTISITE_PREFERENCES_NAME, 'uniq_email_per_site')) {
// try to find a match within a site (multisite).
$groups = CRM_Core_BAO_Domain::getChildGroupIds();
if (!empty($groups)) {
*/
public static function &matchContactOnOpenId($openId, $ctype = NULL) {
$strtolower = function_exists('mb_strtolower') ? 'mb_strtolower' : 'strtolower';
- $openId = $strtolower(trim($openId));
- $query = "
+ $openId = $strtolower(trim($openId));
+ $query = "
SELECT civicrm_contact.id as contact_id,
civicrm_contact.hash as hash,
civicrm_contact.contact_type as contact_type,
$temp = array('preferred_communication_method' => $contact->preferred_communication_method);
$names = array(
- 'preferred_communication_method' => array('newName' => 'preferred_communication_method_display',
+ 'preferred_communication_method' => array(
+ 'newName' => 'preferred_communication_method_display',
'groupName' => 'preferred_communication_method',
- ));
+ )
+ );
CRM_Core_OptionGroup::lookupValues($temp, $names, FALSE);
if ($contact->birth_date) {
$birthDate = CRM_Utils_Date::customFormat($contact->birth_date, '%Y%m%d');
if ($birthDate < date('Ymd')) {
- $age = CRM_Utils_Date::calculateAge($birthDate);
+ $age = CRM_Utils_Date::calculateAge($birthDate);
$values['age']['y'] = CRM_Utils_Array::value('years', $age);
$values['age']['m'] = CRM_Utils_Array::value('months', $age);
}
// fields that are required to calculate greeting and
// also other fields used in tokens etc,
// hence we need to retrieve it again.
- if ( $contact->_query !== FALSE ) {
+ if ($contact->_query !== FALSE) {
$contact->find(TRUE);
}
'greeting_type' => 'email_greeting',
);
- $emailGreeting = CRM_Core_PseudoConstant::greeting($filter);
+ $emailGreeting = CRM_Core_PseudoConstant::greeting($filter);
$emailGreetingString = $emailGreeting[$contact->email_greeting_id];
$updateQueryString[] = " email_greeting_custom = NULL ";
}
else {
if ($useDefaults) {
reset($contactDefaults['email_greeting']);
- $emailGreetingID = key($contactDefaults['email_greeting']);
+ $emailGreetingID = key($contactDefaults['email_greeting']);
$emailGreetingString = $contactDefaults['email_greeting'][$emailGreetingID];
$updateQueryString[] = " email_greeting_id = $emailGreetingID ";
$updateQueryString[] = " email_greeting_custom = NULL ";
'greeting_type' => 'addressee',
);
- $addressee = CRM_Core_PseudoConstant::greeting($filter);
- $addresseeString = $addressee[$contact->addressee_id];
+ $addressee = CRM_Core_PseudoConstant::greeting($filter);
+ $addresseeString = $addressee[$contact->addressee_id];
$updateQueryString[] = " addressee_custom = NULL ";
}
else {
if ($useDefaults) {
reset($contactDefaults['addressee']);
- $addresseeID = key($contactDefaults['addressee']);
- $addresseeString = $contactDefaults['addressee'][$addresseeID];
+ $addresseeID = key($contactDefaults['addressee']);
+ $addresseeString = $contactDefaults['addressee'][$addresseeID];
$updateQueryString[] = " addressee_id = $addresseeID ";
$updateQueryString[] = " addressee_custom = NULL ";
}
//3. edit and view contact are directly accessible to user.
$aclPermissionedTasks = array(
- 'view-contact', 'edit-contact', 'new-activity',
- 'new-email', 'group-add-contact', 'tag-contact', 'delete-contact',
+ 'view-contact',
+ 'edit-contact',
+ 'new-activity',
+ 'new-email',
+ 'group-add-contact',
+ 'tag-contact',
+ 'delete-contact',
);
$corePermission = CRM_Core_Permission::getPermission();
$hasAllPermissions = TRUE;
}
elseif (in_array($values['ref'], array(
- 'new-email'))) {
+ 'new-email'
+ ))) {
// grant permissions for these tasks.
$hasAllPermissions = TRUE;
}
// build directly accessible action menu.
if (in_array($values['ref'], array(
- 'view-contact', 'edit-contact'))) {
+ 'view-contact',
+ 'edit-contact'
+ ))) {
$contextMenu['primaryActions'][$key] = array(
'title' => $values['title'],
'ref' => $values['ref'],
public static function checkDomainContact($contactId) {
if (!$contactId)
return FALSE;
- $domainId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Domain', $contactId, 'id', 'contact_id');
+ $domainId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Domain', $contactId, 'id', 'contact_id');
if ($domainId) {
return TRUE;
- } else {
+ }
+ else {
return FALSE;
}
}