Commit 96f94695 authored by eileen's avatar eileen

Array syntax reformat on activity files

parent c2be63a9
......@@ -56,7 +56,7 @@ class CRM_Activity_ActionMapping extends \Civi\ActionSchedule\Mapping {
* @param \Civi\ActionSchedule\Event\MappingRegisterEvent $registrations
*/
public static function onRegisterActionMappings(\Civi\ActionSchedule\Event\MappingRegisterEvent $registrations) {
$registrations->register(CRM_Activity_ActionMapping::create(array(
$registrations->register(CRM_Activity_ActionMapping::create([
'id' => CRM_Activity_ActionMapping::ACTIVITY_MAPPING_ID,
'entity' => 'civicrm_activity',
'entity_label' => ts('Activity'),
......@@ -65,7 +65,7 @@ class CRM_Activity_ActionMapping extends \Civi\ActionSchedule\Mapping {
'entity_status' => 'activity_status',
'entity_status_label' => ts('Activity Status'),
'entity_date_start' => 'activity_date_time',
)));
]));
}
/**
......
This diff is collapsed.
......@@ -71,7 +71,7 @@ class CRM_Activity_BAO_ActivityAssignment extends CRM_Activity_DAO_ActivityConta
* @return array
*/
public static function retrieveAssigneeIdsByActivityId($activity_id) {
$assigneeArray = array();
$assigneeArray = [];
if (!CRM_Utils_Rule::positiveInteger($activity_id)) {
return $assigneeArray;
}
......@@ -87,7 +87,12 @@ WHERE activity_id = %1
AND record_type_id = $assigneeID
AND civicrm_contact.is_deleted = 0
";
$assignment = CRM_Core_DAO::executeQuery($sql, array(1 => array($activity_id, 'Integer')));
$assignment = CRM_Core_DAO::executeQuery($sql, [
1 => [
$activity_id,
'Integer',
],
]);
while ($assignment->fetch()) {
$assigneeArray[] = $assignment->contact_id;
}
......@@ -108,7 +113,7 @@ AND civicrm_contact.is_deleted = 0
* @return array
*/
public static function getAssigneeNames($activityIDs, $isDisplayName = FALSE, $skipDetails = TRUE) {
$assigneeNames = array();
$assigneeNames = [];
if (empty($activityIDs)) {
return $assigneeNames;
}
......
......@@ -72,11 +72,11 @@ class CRM_Activity_BAO_ActivityContact extends CRM_Activity_DAO_ActivityContact
* @return array
*/
public static function getNames($activityID, $recordTypeID, $alsoIDs = FALSE) {
$names = array();
$ids = array();
$names = [];
$ids = [];
if (empty($activityID)) {
return $alsoIDs ? array($names, $ids) : $names;
return $alsoIDs ? [$names, $ids] : $names;
}
$query = "
......@@ -87,10 +87,10 @@ WHERE civicrm_activity_contact.activity_id = %1
AND civicrm_activity_contact.record_type_id = %2
AND contact_a.is_deleted = 0
";
$params = array(
1 => array($activityID, 'Integer'),
2 => array($recordTypeID, 'Integer'),
);
$params = [
1 => [$activityID, 'Integer'],
2 => [$recordTypeID, 'Integer'],
];
$dao = CRM_Core_DAO::executeQuery($query, $params);
while ($dao->fetch()) {
......@@ -98,7 +98,7 @@ AND contact_a.is_deleted = 0
$ids[] = $dao->id;
}
return $alsoIDs ? array($names, $ids) : $names;
return $alsoIDs ? [$names, $ids] : $names;
}
/**
......@@ -110,7 +110,7 @@ AND contact_a.is_deleted = 0
* @return mixed
*/
public static function retrieveContactIdsByActivityId($activityID, $recordTypeID) {
$activityContact = array();
$activityContact = [];
if (!CRM_Utils_Rule::positiveInteger($activityID) ||
!CRM_Utils_Rule::positiveInteger($recordTypeID)
) {
......@@ -124,10 +124,10 @@ WHERE activity_id = %1
AND record_type_id = %2
AND civicrm_contact.is_deleted = 0
";
$params = array(
1 => array($activityID, 'Integer'),
2 => array($recordTypeID, 'Integer'),
);
$params = [
1 => [$activityID, 'Integer'],
2 => [$recordTypeID, 'Integer'],
];
$dao = CRM_Core_DAO::executeQuery($sql, $params);
while ($dao->fetch()) {
......@@ -152,7 +152,7 @@ AND civicrm_contact.is_deleted = 0
* null - if no links.ini exists for this database (hence try auto_links).
*/
public function links() {
$link = array('activity_id' => 'civicrm_activity:id');
$link = ['activity_id' => 'civicrm_activity:id'];
return $link;
}
......
......@@ -69,7 +69,7 @@ class CRM_Activity_BAO_ActivityTarget extends CRM_Activity_DAO_ActivityContact {
* @return mixed
*/
public static function retrieveTargetIdsByActivityId($activity_id) {
$targetArray = array();
$targetArray = [];
if (!CRM_Utils_Rule::positiveInteger($activity_id)) {
return $targetArray;
}
......@@ -85,7 +85,12 @@ WHERE activity_id = %1
AND record_type_id = $targetID
AND civicrm_contact.is_deleted = 0
";
$target = CRM_Core_DAO::executeQuery($sql, array(1 => array($activity_id, 'Integer')));
$target = CRM_Core_DAO::executeQuery($sql, [
1 => [
$activity_id,
'Integer',
],
]);
while ($target->fetch()) {
$targetArray[] = $target->contact_id;
}
......@@ -100,7 +105,7 @@ AND civicrm_contact.is_deleted = 0
* @return array
*/
public static function getTargetNames($activityID) {
$targetNames = array();
$targetNames = [];
if (empty($activityID)) {
return $targetNames;
......@@ -116,7 +121,7 @@ WHERE civicrm_activity_contact.activity_id = %1
AND civicrm_activity_contact.record_type_id = $targetID
AND contact_a.is_deleted = 0
";
$queryParam = array(1 => array($activityID, 'Integer'));
$queryParam = [1 => [$activityID, 'Integer']];
$dao = CRM_Core_DAO::executeQuery($query, $queryParam);
while ($dao->fetch()) {
......
......@@ -86,14 +86,14 @@ class CRM_Activity_BAO_ICalendar {
$calendar = $template->fetch('CRM/Activity/Calendar/ICal.tpl');
if (file_put_contents($this->icsfile, $calendar) !== FALSE) {
if (empty($attachments)) {
$attachments = array();
$attachments = [];
}
$attachments['activity_ics'] = array(
$attachments['activity_ics'] = [
'mime_type' => 'text/calendar',
'fileName' => $icsFileName,
'cleanName' => $icsFileName,
'fullPath' => $this->icsfile,
);
];
return 'activity_ics';
}
}
......@@ -105,7 +105,7 @@ class CRM_Activity_BAO_ICalendar {
* Remove temp file.
*/
public function cleanup() {
if (!empty ($this->icsfile)) {
if (!empty($this->icsfile)) {
@unlink($this->icsfile);
}
}
......
This diff is collapsed.
This diff is collapsed.
......@@ -62,14 +62,14 @@ class CRM_Activity_Import_Form_MapField extends CRM_Import_Form_MapField {
else {
$this->assign('rowDisplayCount', 2);
}
$highlightedFields = array();
$requiredFields = array(
$highlightedFields = [];
$requiredFields = [
'activity_date_time',
'activity_type_id',
'activity_label',
'target_contact_id',
'activity_subject',
);
];
foreach ($requiredFields as $val) {
$highlightedFields[] = $val;
}
......@@ -103,8 +103,8 @@ class CRM_Activity_Import_Form_MapField extends CRM_Import_Form_MapField {
$this->assign('loadedMapping', $savedMapping);
$this->set('loadedMapping', $savedMapping);
$params = array('id' => $savedMapping);
$temp = array();
$params = ['id' => $savedMapping];
$temp = [];
$mappingDetails = CRM_Core_BAO_Mapping::retrieve($params, $temp);
$this->assign('savedName', $mappingDetails->name);
......@@ -117,13 +117,13 @@ class CRM_Activity_Import_Form_MapField extends CRM_Import_Form_MapField {
$this->add('text', 'saveMappingDesc', ts('Description'));
}
$this->addElement('checkbox', 'saveMapping', $saveDetailsName, NULL, array('onclick' => "showSaveDetails(this)"));
$this->addElement('checkbox', 'saveMapping', $saveDetailsName, NULL, ['onclick' => "showSaveDetails(this)"]);
$this->addFormRule(array('CRM_Activity_Import_Form_MapField', 'formRule'));
$this->addFormRule(['CRM_Activity_Import_Form_MapField', 'formRule']);
//-------- end of saved mapping stuff ---------
$defaults = array();
$defaults = [];
$mapperKeys = array_keys($this->_mapperFields);
$hasHeaders = !empty($this->_columnHeaders);
......@@ -148,7 +148,7 @@ class CRM_Activity_Import_Form_MapField extends CRM_Import_Form_MapField {
$warning = 0;
for ($i = 0; $i < $this->_columnCount; $i++) {
$sel = &$this->addElement('hierselect', "mapper[$i]", ts('Mapper for Field %1', array(1 => $i)), NULL);
$sel = &$this->addElement('hierselect', "mapper[$i]", ts('Mapper for Field %1', [1 => $i]), NULL);
$jsSet = FALSE;
if ($this->get('savedMapping')) {
if (isset($mappingName[$i])) {
......@@ -165,15 +165,15 @@ class CRM_Activity_Import_Form_MapField extends CRM_Import_Form_MapField {
}
$js .= "{$formName}['mapper[$i][3]'].style.display = 'none';\n";
$defaults["mapper[$i]"] = array(
$defaults["mapper[$i]"] = [
$mappingHeader[0],
(isset($locationId)) ? $locationId : "",
(isset($phoneType)) ? $phoneType : "",
);
];
$jsSet = TRUE;
}
else {
$defaults["mapper[$i]"] = array();
$defaults["mapper[$i]"] = [];
}
if (!$jsSet) {
for ($k = 1; $k < 4; $k++) {
......@@ -186,14 +186,10 @@ class CRM_Activity_Import_Form_MapField extends CRM_Import_Form_MapField {
$js .= "swapOptions($formName, 'mapper[$i]', 0, 3, 'hs_mapper_" . $i . "_');\n";
if ($hasHeaders) {
$defaults["mapper[$i]"] = array(
$this->defaultFromHeader($this->_columnHeaders[$i],
$headerPatterns
),
);
$defaults["mapper[$i]"] = [$this->defaultFromHeader($this->_columnHeaders[$i], $headerPatterns)];
}
else {
$defaults["mapper[$i]"] = array($this->defaultFromData($dataPatterns, $i));
$defaults["mapper[$i]"] = [$this->defaultFromData($dataPatterns, $i)];
}
}
// End of load mapping.
......@@ -202,23 +198,23 @@ class CRM_Activity_Import_Form_MapField extends CRM_Import_Form_MapField {
$js .= "swapOptions($formName, 'mapper[$i]', 0, 3, 'hs_mapper_" . $i . "_');\n";
if ($hasHeaders) {
// Infer the default from the skipped headers if we have them
$defaults["mapper[$i]"] = array(
$this->defaultFromHeader($this->_columnHeaders[$i],
$headerPatterns
),
$defaults["mapper[$i]"] = [
$this->defaultFromHeader($this->_columnHeaders[$i], $headerPatterns),
0,
);
];
}
else {
// Otherwise guess the default from the form of the data
$defaults["mapper[$i]"] = array(
$this->defaultFromData($dataPatterns, $i),
0,
);
$defaults["mapper[$i]"] = [$this->defaultFromData($dataPatterns, $i), 0];
}
}
$sel->setOptions(array($sel1, $sel2, (isset($sel3)) ? $sel3 : "", (isset($sel4)) ? $sel4 : ""));
$sel->setOptions([
$sel1,
$sel2,
(isset($sel3)) ? $sel3 : "",
(isset($sel4)) ? $sel4 : "",
]);
}
$js .= "</script>\n";
$this->assign('initHideBoxes', $js);
......@@ -240,22 +236,22 @@ class CRM_Activity_Import_Form_MapField extends CRM_Import_Form_MapField {
$this->setDefaults($defaults);
$this->addButtons(array(
array(
$this->addButtons([
[
'type' => 'back',
'name' => ts('Previous'),
),
array(
],
[
'type' => 'next',
'name' => ts('Continue'),
'spacing' => '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;',
'isDefault' => TRUE,
),
array(
],
[
'type' => 'cancel',
'name' => ts('Cancel'),
),
)
],
]
);
}
......@@ -269,28 +265,28 @@ class CRM_Activity_Import_Form_MapField extends CRM_Import_Form_MapField {
* list of errors to be posted back to the form
*/
public static function formRule($fields) {
$errors = array();
$errors = [];
// define so we avoid notices below
$errors['_qf_default'] = '';
$fieldMessage = NULL;
if (!array_key_exists('savedMapping', $fields)) {
$importKeys = array();
$importKeys = [];
foreach ($fields['mapper'] as $mapperPart) {
$importKeys[] = $mapperPart[0];
}
// FIXME: should use the schema titles, not redeclare them
$requiredFields = array(
$requiredFields = [
'target_contact_id' => ts('Contact ID'),
'activity_date_time' => ts('Activity Date'),
'activity_subject' => ts('Activity Subject'),
'activity_type_id' => ts('Activity Type ID'),
);
];
$params = array(
$params = [
'used' => 'Unsupervised',
'contact_type' => 'Individual',
);
];
list($ruleFields, $threshold) = CRM_Dedupe_BAO_RuleGroup::dedupeRuleFieldsWeight($params);
$weightSum = 0;
foreach ($importKeys as $key => $val) {
......@@ -310,7 +306,7 @@ class CRM_Activity_Import_Form_MapField extends CRM_Import_Form_MapField {
else {
$errors['_qf_default'] .= ts('Missing required contact matching fields.')
. $fieldMessage . ' '
. ts('(Sum of all weights should be greater than or equal to threshold: %1).', array(1 => $threshold))
. ts('(Sum of all weights should be greater than or equal to threshold: %1).', [1 => $threshold])
. '<br />';
}
}
......@@ -320,14 +316,14 @@ class CRM_Activity_Import_Form_MapField extends CRM_Import_Form_MapField {
}
else {
$errors['_qf_default'] .= ts('Missing required field: Provide %1 or %2',
array(
[
1 => $title,
2 => 'Activity Type Label',
)) . '<br />';
]) . '<br />';
}
}
else {
$errors['_qf_default'] .= ts('Missing required field: %1', array(1 => $title)) . '<br />';
$errors['_qf_default'] .= ts('Missing required field: %1', [1 => $title]) . '<br />';
}
}
}
......@@ -378,12 +374,12 @@ class CRM_Activity_Import_Form_MapField extends CRM_Import_Form_MapField {
$seperator = $this->controller->exportValue('DataSource', 'fieldSeparator');
$skipColumnHeader = $this->controller->exportValue('DataSource', 'skipColumnHeader');
$mapperKeys = array();
$mapper = array();
$mapperKeys = [];
$mapper = [];
$mapperKeys = $this->controller->exportValue($this->_name, 'mapper');
$mapperKeysMain = array();
$mapperLocType = array();
$mapperPhoneType = array();
$mapperKeysMain = [];
$mapperLocType = [];
$mapperPhoneType = [];
for ($i = 0; $i < $this->_columnCount; $i++) {
$mapper[$i] = $this->_mapperFields[$mapperKeys[$i][0]];
......@@ -417,7 +413,7 @@ class CRM_Activity_Import_Form_MapField extends CRM_Import_Form_MapField {
$mappingFields->mapping_id = $params['mappingId'];
$mappingFields->find();
$mappingFieldsId = array();
$mappingFieldsId = [];
while ($mappingFields->fetch()) {
if ($mappingFields->id) {
$mappingFieldsId[$mappingFields->column_number] = $mappingFields->id;
......@@ -437,11 +433,11 @@ class CRM_Activity_Import_Form_MapField extends CRM_Import_Form_MapField {
// Saving Mapping Details and Records.
if (!empty($params['saveMapping'])) {
$mappingParams = array(
$mappingParams = [
'name' => $params['saveMappingName'],
'description' => $params['saveMappingDesc'],
'mapping_type_id' => CRM_Core_PseudoConstant::getKey('CRM_Core_BAO_Mapping', 'mapping_type_id', 'Import Activity'),
);
];
$saveMapping = CRM_Core_BAO_Mapping::add($mappingParams);
for ($i = 0; $i < $this->_columnCount; $i++) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment