/**
* @var array details of the UFGroup used on this page
*/
- protected $_ufGroup = array('name' => 'unknown');
+ protected $_ufGroup = ['name' => 'unknown'];
/**
* The group id that we are passing in url.
/**
* Name of button for saving matching contacts.
- * @var
+ * @var string
*/
protected $_duplicateButtonName;
/**
/**
* Dedupe using a specific rule (CRM-6131).
* Not currently exposed in profile settings, but can be set in a buildForm hook.
+ * @var int
*/
public $_ruleGroupID = NULL;
/**
* Store profile ids if multiple profile ids are passed using comma separated.
* Currently lets implement this functionality only for dialog mode.
+ * @var array
*/
- protected $_profileIds = array();
+ protected $_profileIds = [];
/**
* Contact profile having activity fields?
CRM_Core_Session::setStatus(ts('Note: this contact may be a duplicate of an existing record.'), ts('Possible Duplicate Detected'), 'alert');
}
elseif ($form->_isUpdateDupe == 1) {
- if (!$form->_id) {
- $form->_id = $ids[0];
- }
+ $form->_id = $ids[0];
}
else {
if ($form->_context == 'dialog') {
}
if ($this->_multiRecord &&
- !in_array($this->_multiRecord, array(CRM_Core_Action::UPDATE, CRM_Core_Action::ADD, CRM_Core_Action::DELETE))
+ !in_array($this->_multiRecord, [CRM_Core_Action::UPDATE, CRM_Core_Action::ADD, CRM_Core_Action::DELETE])
) {
CRM_Core_Error::fatal(ts('Proper action not specified for this custom value record profile'));
}
$dao->free();
if (!CRM_Utils_Array::value('is_active', $this->_ufGroup)) {
- CRM_Core_Error::fatal(ts('The requested profile (gid=%1) is inactive or does not exist.', array(
+ CRM_Core_Error::fatal(ts('The requested profile (gid=%1) is inactive or does not exist.', [
1 => $this->_gid,
- )));
+ ]));
}
}
$this->assign('ufGroupName', $this->_ufGroup['name']);
&& ($this->_multiRecord == CRM_Core_Action::UPDATE || $this->_multiRecord == CRM_Core_Action::DELETE)
) {
CRM_Core_Error::fatal(ts('The requested Profile (gid=%1) requires record id while performing this action',
- array(1 => $this->_gid)
+ [1 => $this->_gid]
));
}
elseif (empty($this->_multiRecordFields)) {
CRM_Core_Error::fatal(ts('No Multi-Record Fields configured for this profile (gid=%1)',
- array(1 => $this->_gid)
+ [1 => $this->_gid]
));
}
$fieldId = CRM_Core_BAO_CustomField::getKeyID(key($this->_multiRecordFields));
- $customGroupDetails = CRM_Core_BAO_CustomGroup::getGroupTitles(array($fieldId));
+ $customGroupDetails = CRM_Core_BAO_CustomGroup::getGroupTitles([$fieldId]);
$this->_customGroupTitle = $customGroupDetails[$fieldId]['groupTitle'];
$this->_customGroupId = $customGroupDetails[$fieldId]['groupID'];
else {
$this->_recordExists = FALSE;
if ($this->_multiRecord & CRM_Core_Action::UPDATE) {
- CRM_Core_Session::setStatus(ts('Note: The record %1 doesnot exists. Upon save a new record will be create', array(1 => $this->_recordId)), ts('Record doesnot exist'), 'alert');
+ CRM_Core_Session::setStatus(ts('Note: The record %1 doesnot exists. Upon save a new record will be create', [1 => $this->_recordId]), ts('Record doesnot exist'), 'alert');
}
}
}
}
elseif (!empty($this->_multiRecordFields)
- && (!$this->_multiRecord || !in_array($this->_multiRecord, array(
+ && (!$this->_multiRecord || !in_array($this->_multiRecord, [
CRM_Core_Action::DELETE,
CRM_Core_Action::UPDATE,
- )))
+ ]))
) {
CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.livePage.js', 1, 'html-header');
//multi-record listing page
*
*/
public function setDefaultsValues() {
- $this->_defaults = array();
+ $this->_defaults = [];
if ($this->_multiRecordProfile && ($this->_multiRecord == CRM_Core_Action::DELETE)) {
return;
}
if ($this->_id && !$this->_multiRecordProfile) {
if ($this->_isContactActivityProfile) {
- $contactFields = $activityFields = array();
+ $contactFields = $activityFields = [];
foreach ($this->_fields as $fieldName => $field) {
if (CRM_Utils_Array::value('field_type', $field) == 'Activity') {
$activityFields[$fieldName] = $field;
$fieldIds[] = CRM_Core_BAO_CustomField::getKeyID($key);
}
- $defaultValues = array();
+ $defaultValues = [];
if ($this->_multiRecord && $this->_multiRecord == CRM_Core_Action::UPDATE) {
$defaultValues = CRM_Core_BAO_CustomValueTable::getEntityValues($this->_id, NULL, $fieldIds, TRUE);
if ($this->_recordExists == TRUE) {
$deleteExtra = ts("Are you sure you want to delete attached file?");
$fileId = $url['file_id'];
+ $fileHash = CRM_Core_BAO_File::generateFileHash($entityId, $fileId);
$deleteURL = CRM_Utils_System::url('civicrm/file',
- "reset=1&id={$fileId}&eid=$entityId&fid={$key}&action=delete"
+ "reset=1&id={$fileId}&eid=$entityId&fid={$key}&action=delete&fcs={$fileHash}"
);
$text = ts("Delete Attached File");
$customFiles[$field['name']]['deleteURL'] = "<a href=\"{$deleteURL}\" onclick = \"if (confirm( ' $deleteExtra ' )) this.href+='&confirmed=1'; else return false;\">$text</a>";
$deleteExtra = ts("Are you sure you want to delete attached file?");
$fileId = $url['file_id'];
+ $fileHash = CRM_Core_BAO_File::generateFileHash($entityId, $fileId); /* fieldId=$customFieldID */
$deleteURL = CRM_Utils_System::url('civicrm/file',
- "reset=1&id={$fileId}&eid=$entityId&fid={$customFieldID}&action=delete"
+ "reset=1&id={$fileId}&eid=$entityId&fid={$customFieldID}&action=delete&fcs={$fileHash}"
);
$text = ts("Delete Attached File");
$customFiles[$field['name']]['deleteURL'] = "<a href=\"{$deleteURL}\" onclick = \"if (confirm( ' $deleteExtra ' )) this.href+='&confirmed=1'; else return false;\">$text</a>";
$this->removeFileRequiredRules('image_URL');
}
- if (array_key_exists('contact_sub_type', $this->_defaults) &&
- !empty($this->_defaults['contact_sub_type'])
- ) {
- $this->_defaults['contact_sub_type'] = explode(CRM_Core_DAO::VALUE_SEPARATOR,
- trim($this->_defaults['contact_sub_type'], CRM_Core_DAO::VALUE_SEPARATOR)
- );
- }
-
$this->setDefaults($this->_defaults);
}
if (($this->_multiRecord & CRM_Core_Action::DELETE)) {
if (!$this->_recordExists) {
- CRM_Core_Session::setStatus(ts('The record %1 doesnot exists', array(1 => $this->_recordId)), ts('Record doesnot exists'), 'alert');
+ CRM_Core_Session::setStatus(ts('The record %1 doesnot exists', [1 => $this->_recordId]), ts('Record doesnot exists'), 'alert');
}
else {
$this->assign('deleteRecord', TRUE);
$return = TRUE;
if (!$statusMessage) {
$statusMessage = ts("This profile is configured for contact type '%1'. It cannot be used to edit contacts of other types.",
- array(1 => $profileSubType ? $profileSubType : $profileType));
+ [1 => $profileSubType ? $profileSubType : $profileType]);
}
}
}
if (
in_array(
$profileType,
- array("Membership", "Participant", "Contribution")
+ ["Membership", "Participant", "Contribution"]
)
) {
$return = TRUE;
}
$this->assign('anonUser', $anonUser);
- $addCaptcha = array();
+ $addCaptcha = [];
$emailPresent = FALSE;
// add the form elements
* @return array
*/
public static function validateContactActivityProfile($activityId, $contactId, $gid) {
- $errors = array();
+ $errors = [];
if (!$activityId) {
$errors[] = ts('Profile is using one or more activity fields, and is missing the activity Id (aid) in the URL.');
return $errors;
}
- $activityDetails = array();
- $activityParams = array('id' => $activityId);
+ $activityDetails = [];
+ $activityParams = ['id' => $activityId];
CRM_Activity_BAO_Activity::retrieve($activityParams, $activityDetails);
if (empty($activityDetails)) {
$register = NULL;
// hack we use a -1 in options to indicate that its registration
+ // ... and I can't remove that comment because even though it's clear as mud
+ // perhaps someone will find it helpful in the absence of ANY OTHER EXPLANATION
+ // as to what it means....
if ($form->_id) {
+ // @todo - wonder if it ever occurred to someone that if they didn't document this param
+ // it might not be crystal clear why we have it....
$form->_isUpdateDupe = 1;
}
$fields['phone-Primary'] = $fields['phone-Primary-1'];
}
- self::handleDuplicateChecking($errors, $fields, $form);
+ if (!$form->_id) {
+ self::handleDuplicateChecking($errors, $fields, $form);
+ }
}
foreach ($fields as $key => $value) {
$customizedValue = CRM_Core_PseudoConstant::getKey('CRM_Contact_BAO_Contact', $greeting . '_id', 'Customized');
if ($customizedValue == $greetingType && empty($fields[$greeting . '_custom'])) {
$errors[$greeting . '_custom'] = ts('Custom %1 is a required field if %1 is of type Customized.',
- array(1 => ucwords(str_replace('_', ' ', $greeting)))
+ [1 => ucwords(str_replace('_', ' ', $greeting))]
);
}
}
if ($this->_deleteButtonName) {
if (!empty($_POST[$this->_deleteButtonName]) && $this->_recordId) {
$filterParams['id'] = $this->_customGroupId;
- $returnProperties = array('is_multiple', 'table_name');
+ $returnProperties = ['is_multiple', 'table_name'];
CRM_Core_DAO::commonRetrieve("CRM_Core_DAO_CustomGroup", $filterParams, $returnValues, $returnProperties);
if (!empty($returnValues['is_multiple'])) {
if ($tableName = CRM_Utils_Array::value('table_name', $returnValues)) {
$sql = "DELETE FROM {$tableName} WHERE id = %1 AND entity_id = %2";
- $sqlParams = array(
- 1 => array($this->_recordId, 'Integer'),
- 2 => array($this->_id, 'Integer'),
- );
+ $sqlParams = [
+ 1 => [$this->_recordId, 'Integer'],
+ 2 => [$this->_id, 'Integer'],
+ ];
CRM_Core_DAO::executeQuery($sql, $sqlParams);
CRM_Core_Session::setStatus(ts('Your record has been deleted.'), ts('Deleted'), 'success');
}
CRM_Contact_BAO_Contact::processImageParams($params);
}
- $greetingTypes = array(
+ $greetingTypes = [
'addressee' => 'addressee_id',
'email_greeting' => 'email_greeting_id',
'postal_greeting' => 'postal_greeting_id',
- );
+ ];
- $details = array();
+ $details = [];
if ($this->_id) {
$contactDetails = CRM_Contact_BAO_Contact::getHierContactDetails($this->_id,
$greetingTypes
//used to send subscribe mail to the group which user want.
//if the profile double option in is enabled
- $mailingType = array();
+ $mailingType = [];
$result = NULL;
foreach ($params as $name => $values) {
}
//array of group id, subscribed by contact
- $contactGroup = array();
+ $contactGroup = [];
if (!empty($params['group']) &&
CRM_Core_BAO_UFGroup::isProfileDoubleOptin()
) {
- $groupSubscribed = array();
+ $groupSubscribed = [];
if (!empty($result['email'])) {
if ($this->_id) {
$contactGroups = new CRM_Contact_DAO_GroupContact();
$contactGroups->contact_id = $this->_id;
$contactGroups->status = 'Added';
$contactGroups->find();
- $contactGroup = array();
+ $contactGroup = [];
while ($contactGroups->fetch()) {
$contactGroup[] = $contactGroups->group_id;
$groupSubscribed[$contactGroups->group_id] = 1;
) {
if (!count($contactGroup)) {
//array of group id, subscribed by contact
- $contactGroup = array();
+ $contactGroup = [];
if ($this->_id) {
$contactGroups = new CRM_Contact_DAO_GroupContact();
$contactGroups->contact_id = $this->_id;
$contactGroups->status = 'Added';
$contactGroups->find();
- $contactGroup = array();
+ $contactGroup = [];
while ($contactGroups->fetch()) {
$contactGroup[] = $contactGroups->group_id;
$groupSubscribed[$contactGroups->group_id] = 1;
$profileFields = $this->_fields;
if (($this->_mode & self::MODE_EDIT) && $this->_activityId && $this->_isContactActivityProfile) {
- $profileFields = $activityParams = array();
+ $profileFields = $activityParams = [];
foreach ($this->_fields as $fieldName => $field) {
if (CRM_Utils_Array::value('field_type', $field) == 'Activity') {
if (isset($params[$fieldName])) {
CRM_Mailing_Event_BAO_Subscribe::commonSubscribe($mailingType, $result, $this->_id, 'profile');
}
- $ufGroups = array();
+ $ufGroups = [];
if ($this->_gid) {
$ufGroups[$this->_gid] = 1;
}