more comment fixes
[civicrm-core.git] / CRM / Activity / BAO / Query.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.6 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2014 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
9 | |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
13 | |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
18 | |
19 | You should have received a copy of the GNU Affero General Public |
20 | License and the CiviCRM Licensing Exception along |
21 | with this program; if not, contact CiviCRM LLC |
22 | at info[AT]civicrm[DOT]org. If you have questions about the |
23 | GNU Affero General Public License or the licensing of CiviCRM, |
24 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
25 +--------------------------------------------------------------------+
26 */
27
28 /**
29 *
30 * @package CRM
31 * @copyright CiviCRM LLC (c) 2004-2014
32 * $Id$
33 */
34 class CRM_Activity_BAO_Query {
35
36 /**
37 * Build select for Case.
38 *
39 * @param $query
40 */
41 public static function select(&$query) {
42 if (!empty($query->_returnProperties['activity_id'])) {
43 $query->_select['activity_id'] = "civicrm_activity.id as activity_id";
44 $query->_element['activity_id'] = 1;
45 $query->_tables['civicrm_activity'] = $query->_whereTables['civicrm_activity'] = 1;
46 }
47
48 if (!empty($query->_returnProperties['activity_type_id'])) {
49 $query->_select['activity_type_id'] = "activity_type.value as activity_type_id";
50 $query->_element['activity_type_id'] = 1;
51 $query->_tables['civicrm_activity'] = 1;
52 $query->_tables['activity_type'] = 1;
53 $query->_whereTables['civicrm_activity'] = 1;
54 $query->_whereTables['activity_type'] = 1;
55 }
56
57 if (!empty($query->_returnProperties['activity_type'])) {
58 $query->_select['activity_type'] = "activity_type.label as activity_type";
59 $query->_element['activity_type'] = 1;
60 $query->_tables['civicrm_activity'] = 1;
61 $query->_tables['activity_type'] = 1;
62 $query->_whereTables['civicrm_activity'] = 1;
63 $query->_whereTables['activity_type'] = 1;
64 }
65
66 if (!empty($query->_returnProperties['activity_subject'])) {
67 $query->_select['activity_subject'] = "civicrm_activity.subject as activity_subject";
68 $query->_element['activity_subject'] = 1;
69 $query->_tables['civicrm_activity'] = $query->_whereTables['civicrm_activity'] = 1;
70 }
71
72 if (!empty($query->_returnProperties['activity_date_time'])) {
73 $query->_select['activity_date_time'] = "civicrm_activity.activity_date_time as activity_date_time";
74 $query->_element['activity_date_time'] = 1;
75 $query->_tables['civicrm_activity'] = $query->_whereTables['civicrm_activity'] = 1;
76 }
77
78 if (!empty($query->_returnProperties['activity_status_id'])) {
79 $query->_select['activity_status_id'] = "activity_status.value as activity_status_id";
80 $query->_element['activity_status_id'] = 1;
81 $query->_tables['civicrm_activity'] = 1;
82 $query->_tables['activity_status'] = 1;
83 $query->_whereTables['civicrm_activity'] = 1;
84 $query->_whereTables['activity_status'] = 1;
85 }
86
87 if (!empty($query->_returnProperties['activity_status'])) {
88 $query->_select['activity_status'] = "activity_status.label as activity_status,
89 civicrm_activity.status_id as status_id";
90 $query->_element['activity_status'] = 1;
91 $query->_tables['civicrm_activity'] = 1;
92 $query->_tables['activity_status'] = 1;
93 $query->_whereTables['civicrm_activity'] = 1;
94 $query->_whereTables['activity_status'] = 1;
95 }
96
97 if (!empty($query->_returnProperties['activity_duration'])) {
98 $query->_select['activity_duration'] = "civicrm_activity.duration as activity_duration";
99 $query->_element['activity_duration'] = 1;
100 $query->_tables['civicrm_activity'] = $query->_whereTables['civicrm_activity'] = 1;
101 }
102
103 if (!empty($query->_returnProperties['activity_location'])) {
104 $query->_select['activity_location'] = "civicrm_activity.location as activity_location";
105 $query->_element['activity_location'] = 1;
106 $query->_tables['civicrm_activity'] = $query->_whereTables['civicrm_activity'] = 1;
107 }
108
109 if (!empty($query->_returnProperties['activity_details'])) {
110 $query->_select['activity_details'] = "civicrm_activity.details as activity_details";
111 $query->_element['activity_details'] = 1;
112 $query->_tables['civicrm_activity'] = $query->_whereTables['civicrm_activity'] = 1;
113 }
114
115 if (!empty($query->_returnProperties['source_record_id'])) {
116 $query->_select['source_record_id'] = "civicrm_activity.source_record_id as source_record_id";
117 $query->_element['source_record_id'] = 1;
118 $query->_tables['civicrm_activity'] = $query->_whereTables['civicrm_activity'] = 1;
119 }
120
121 if (!empty($query->_returnProperties['activity_is_test'])) {
122 $query->_select['activity_is_test'] = "civicrm_activity.is_test as activity_is_test";
123 $query->_element['activity_is_test'] = 1;
124 $query->_tables['civicrm_activity'] = $query->_whereTables['civicrm_activity'] = 1;
125 }
126
127 if (!empty($query->_returnProperties['activity_campaign_id'])) {
128 $query->_select['activity_campaign_id'] = 'civicrm_activity.campaign_id as activity_campaign_id';
129 $query->_element['activity_campaign_id'] = 1;
130 $query->_tables['civicrm_activity'] = $query->_whereTables['civicrm_activity'] = 1;
131 }
132
133 if (!empty($query->_returnProperties['activity_engagement_level'])) {
134 $query->_select['activity_engagement_level'] = 'civicrm_activity.engagement_level as activity_engagement_level';
135 $query->_element['activity_engagement_level'] = 1;
136 $query->_tables['civicrm_activity'] = $query->_whereTables['civicrm_activity'] = 1;
137 }
138
139 if (!empty($query->_returnProperties['source_contact'])) {
140 $query->_select['source_contact'] = 'source_contact.sort_name as source_contact';
141 $query->_element['source_contact'] = 1;
142 $query->_tables['source_contact'] = $query->_whereTables['source_contact'] = 1;
143 }
144
145 if (!empty($query->_returnProperties['activity_result'])) {
146 $query->_select['activity_result'] = 'civicrm_activity.result as activity_result';
147 $query->_element['result'] = 1;
148 $query->_tables['civicrm_activity'] = $query->_whereTables['civicrm_activity'] = 1;
149 }
150
151 if (CRM_Utils_Array::value('parent_id', $query->_returnProperties)) {
152 $query->_tables['parent_id'] = 1;
153 $query->_whereTables['parent_id'] = 1;
154 $query->_element['parent_id'] = 1;
155 }
156 }
157
158 /**
159 * Given a list of conditions in query generate the required
160 * where clause
161 *
162 * @param $query
163 *
164 * @return void
165 */
166 public static function where(&$query) {
167 foreach (array_keys($query->_params) as $id) {
168 if (substr($query->_params[$id][0], 0, 9) == 'activity_') {
169 if ($query->_mode == CRM_Contact_BAO_QUERY::MODE_CONTACTS) {
170 $query->_useDistinct = TRUE;
171 }
172 $query->_params[$id][3];
173 self::whereClauseSingle($query->_params[$id], $query);
174 }
175 }
176 }
177
178 /**
179 * Where clause for a single field
180 *
181 * @param $values
182 * @param $query
183 * @return void
184 */
185 public static function whereClauseSingle(&$values, &$query) {
186 list($name, $op, $value, $grouping) = $values;
187
188 $fields = CRM_Activity_BAO_Activity::exportableFields();
189 $query->_tables['civicrm_activity'] = $query->_whereTables['civicrm_activity'] = 1;
190 if ($query->_mode & CRM_Contact_BAO_Query::MODE_ACTIVITY) {
191 $query->_skipDeleteClause = TRUE;
192 }
193
194 switch ($name) {
195 case 'activity_type_id':
196 case 'activity_status_id':
197 case 'activity_engagement_level':
198 case 'activity_subject':
199 case 'activity_id':
200 $qillName = $name;
201 if (in_array($name, array('activity_engagement_level', 'activity_id'))) {
202 $name = $qillName = str_replace('activity_', '', $name);
203 }
204 if (in_array($name, array('activity_status_id', 'activity_subject'))) {
205 $name = str_replace('activity_', '', $name);
206 $qillName = str_replace('_id', '', $qillName);
207 }
208 $dataType = !empty($fields[$qillName]['type']) ? CRM_Utils_Type::typeToString($fields[$qillName]['type']) : 'String';
209
210 $query->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause("civicrm_activity.$name", $op, $value, $dataType);
211 list($op, $value) = CRM_Contact_BAO_Query::buildQillForFieldValue('CRM_Activity_DAO_Activity', $name, $value, $op);
212 $query->_qill[$grouping][] = ts('%1 %2 %3', array(1 => $fields[$qillName]['title'], 2 => $op, 3 => $value));
213 break;
214
215 case 'activity_type':
216 case 'activity_status':
217 $query->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause("$name.label", $op, $value, 'String');
218 list($op, $value) = CRM_Contact_BAO_Query::buildQillForFieldValue('CRM_Activity_DAO_Activity', $name, $value, $op);
219 $query->_qill[$grouping][] = ts('%1 %2 %3', array(1 => $fields[$name]['title'], 2 => $op, 3 => $value));
220 $query->_tables[$name] = $query->_whereTables[$name] = 1;
221 break;
222
223 case 'activity_survey_id':
224 if (!$value) {
225 break;
226 }
227 $value = CRM_Utils_Type::escape($value, 'Integer');
228 $query->_where[$grouping][] = " civicrm_activity.source_record_id = $value";
229 $query->_qill[$grouping][] = ts('Survey') . ' - ' . CRM_Core_DAO::getFieldValue('CRM_Campaign_DAO_Survey', $value, 'title');
230 break;
231
232 case 'activity_role':
233 CRM_Contact_BAO_Query::$_activityRole = $values[2];
234 $activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name');
235 $sourceID = CRM_Utils_Array::key('Activity Source', $activityContacts);
236 $assigneeID = CRM_Utils_Array::key('Activity Assignees', $activityContacts);
237 $targetID = CRM_Utils_Array::key('Activity Targets', $activityContacts);
238
239 if ($values[2]) {
240 $query->_tables['civicrm_activity_contact'] = $query->_whereTables['civicrm_activity_contact'] = 1;
241 if ($values[2] == 1) {
242 $query->_where[$grouping][] = " civicrm_activity_contact.record_type_id = $sourceID";
243 $query->_qill[$grouping][] = ts('Activity created by');
244 }
245 elseif ($values[2] == 2) {
246 $query->_where[$grouping][] = " civicrm_activity_contact.record_type_id = $assigneeID";
247 $query->_qill[$grouping][] = ts('Activity assigned to');
248 }
249 elseif ($values[2] == 3) {
250 $query->_where[$grouping][] = " civicrm_activity_contact.record_type_id = $targetID";
251 $query->_qill[$grouping][] = ts('Activity targeted to');
252 }
253 }
254 break;
255
256 case 'activity_test':
257 // We don't want to include all tests for sql OR CRM-7827
258 if (!$value || $query->getOperator() != 'OR') {
259 $query->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause("civicrm_activity.is_test", $op, $value, "Boolean");
260 if ($value) {
261 $query->_qill[$grouping][] = ts('Activity is a Test');
262 }
263 }
264 break;
265
266 case 'activity_date':
267 case 'activity_date_low':
268 case 'activity_date_high':
269 $query->dateQueryBuilder($values,
270 'civicrm_activity', 'activity_date', 'activity_date_time', ts('Activity Date')
271 );
272 break;
273
274 case 'activity_taglist':
275 $taglist = $value;
276 $value = array();
277 foreach ($taglist as $val) {
278 if ($val) {
279 $val = explode(',', $val);
280 foreach ($val as $tId) {
281 if (is_numeric($tId)) {
282 $value[$tId] = 1;
283 }
284 }
285 }
286 }
287
288 case 'activity_tags':
289 $value = array_keys($value);
290 $activityTags = CRM_Core_PseudoConstant::get('CRM_Core_DAO_EntityTag', 'tag_id', array('onlyActive' => FALSE));
291
292 $names = array();
293 if (is_array($value)) {
294 foreach ($value as $k => $v) {
295 $names[] = $activityTags[$v];
296 }
297 }
298 $query->_where[$grouping][] = "civicrm_activity_tag.tag_id IN (" . implode(",", $value) . ")";
299 $query->_qill[$grouping][] = ts('Activity Tag %1', array(1 => $op)) . ' ' . implode(' ' . ts('OR') . ' ', $names);
300 $query->_tables['civicrm_activity_tag'] = $query->_whereTables['civicrm_activity_tag'] = 1;
301 break;
302
303 case 'activity_campaign_id':
304 $campParams = array(
305 'op' => $op,
306 'campaign' => $value,
307 'grouping' => $grouping,
308 'tableName' => 'civicrm_activity',
309 );
310 CRM_Campaign_BAO_Query::componentSearchClause($campParams, $query);
311 break;
312
313 case 'activity_result':
314 if (is_array($value)) {
315 $safe = NULL;
316 while (list(, $k) = each($value)) {
317 $safe[] = "'" . CRM_Utils_Type::escape($k, 'String') . "'";
318 }
319 $query->_where[$grouping][] = "civicrm_activity.result IN (" . implode(',', $safe) . ")";
320 $query->_qill[$grouping][] = ts("Activity Result - %1", array(1 => implode(' or ', $safe)));
321 }
322 break;
323
324 case 'parent_id':
325 if ($value == 1) {
326 $query->_where[$grouping][] = "parent_id.parent_id IS NOT NULL";
327 $query->_qill[$grouping][] = ts('Activities which have Followup Activities');
328 }
329 elseif ($value == 2) {
330 $query->_where[$grouping][] = "parent_id.parent_id IS NULL";
331 $query->_qill[$grouping][] = ts('Activities without Followup Activities');
332 }
333 break;
334
335 case 'followup_parent_id':
336 if ($value == 1) {
337 $query->_where[$grouping][] = "civicrm_activity.parent_id IS NOT NULL";
338 $query->_qill[$grouping][] = ts('Activities which are Followup Activities');
339 }
340 elseif ($value == 2) {
341 $query->_where[$grouping][] = "civicrm_activity.parent_id IS NULL";
342 $query->_qill[$grouping][] = ts('Activities which are not Followup Activities');
343 }
344 break;
345 }
346 }
347
348 /**
349 * @param string $name
350 * @param $mode
351 * @param $side
352 *
353 * @return null|string
354 */
355 public static function from($name, $mode, $side) {
356 $from = NULL;
357 switch ($name) {
358 case 'civicrm_activity':
359 //CRM-7480 we are going to civicrm_activity table either
360 //from civicrm_activity_target or civicrm_activity_assignment.
361 //as component specific activities does not have entry in
362 //activity target table so lets consider civicrm_activity_assignment.
363 $from .= " INNER JOIN civicrm_activity_contact
364 ON ( civicrm_activity_contact.contact_id = contact_a.id ) ";
365 $from .= " INNER JOIN civicrm_activity
366 ON ( civicrm_activity.id = civicrm_activity_contact.activity_id
367 AND civicrm_activity.is_deleted = 0 AND civicrm_activity.is_current_revision = 1 )";
368
369 break;
370
371 case 'activity_status':
372 $from .= " $side JOIN civicrm_option_group option_group_activity_status ON (option_group_activity_status.name = 'activity_status')";
373 $from .= " $side JOIN civicrm_option_value activity_status ON (civicrm_activity.status_id = activity_status.value
374 AND option_group_activity_status.id = activity_status.option_group_id ) ";
375 break;
376
377 case 'activity_type':
378 $from .= " $side JOIN civicrm_option_group option_group_activity_type ON (option_group_activity_type.name = 'activity_type')";
379 $from .= " $side JOIN civicrm_option_value activity_type ON (civicrm_activity.activity_type_id = activity_type.value
380 AND option_group_activity_type.id = activity_type.option_group_id ) ";
381 break;
382
383 case 'civicrm_activity_tag':
384 $from .= " $side JOIN civicrm_entity_tag as civicrm_activity_tag ON ( civicrm_activity_tag.entity_table = 'civicrm_activity' AND civicrm_activity_tag.entity_id = civicrm_activity.id ) ";
385 break;
386
387 case 'source_contact':
388 $activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name');
389 $sourceID = CRM_Utils_Array::key('Activity Source', $activityContacts);
390 $from = "
391 LEFT JOIN civicrm_activity_contact ac
392 ON ( ac.activity_id = civicrm_activity_contact.activity_id AND ac.record_type_id = {$sourceID})
393 INNER JOIN civicrm_contact source_contact ON (ac.contact_id = source_contact.id)";
394 break;
395
396 case 'parent_id':
397 $from = "$side JOIN civicrm_activity AS parent_id ON civicrm_activity.id = parent_id.parent_id";
398 break;
399 }
400
401 return $from;
402 }
403
404 /**
405 * Getter for the qill object
406 *
407 * @return string
408 */
409 public function qill() {
410 return (isset($this->_qill)) ? $this->_qill : "";
411 }
412
413 /**
414 * Add all the elements shared between case activity search and advanced search
415 *
416 *
417 * @param CRM_Core_Form $form
418 * @return void
419 */
420 public static function buildSearchForm(&$form) {
421 $activityOptions = CRM_Core_PseudoConstant::activityType(TRUE, TRUE, FALSE, 'label', TRUE);
422 $form->addSelect('activity_type_id',
423 array('entity' => 'activity', 'label' => 'Activity Type(s)', 'multiple' => 'multiple', 'option_url' => NULL, 'placeholder' => ts('- any -'))
424 );
425
426 CRM_Core_Form_Date::buildDateRange($form, 'activity_date', 1, '_low', '_high', ts('From'), FALSE, FALSE);
427 $followUpActivity = array(
428 1 => ts('Yes'),
429 2 => ts('No'),
430 );
431 $form->addRadio('parent_id', NULL, $followUpActivity, array('allowClear' => TRUE));
432 $form->addRadio('followup_parent_id', NULL, $followUpActivity, array('allowClear' => TRUE));
433 $activityRoles = array(
434 3 => ts('With'),
435 2 => ts('Assigned to'),
436 1 => ts('Added by'),
437 );
438 $form->addRadio('activity_role', NULL, $activityRoles, array('allowClear' => TRUE));
439 $form->setDefaults(array('activity_role' => 3));
440 $activityStatus = CRM_Core_PseudoConstant::get('CRM_Activity_DAO_Activity', 'status_id', array('flip' => 1, 'labelColumn' => 'name'));
441 $form->addSelect('status_id',
442 array('entity' => 'activity', 'multiple' => 'multiple', 'option_url' => NULL, 'placeholder' => ts('- any -'))
443 );
444 $form->setDefaults(array('status_id' => array($activityStatus['Completed'], $activityStatus['Scheduled'])));
445 $form->addElement('text', 'activity_subject', ts('Subject'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'sort_name'));
446 $form->addYesNo('activity_test', ts('Activity is a Test?'));
447 $activity_tags = CRM_Core_BAO_Tag::getTags('civicrm_activity');
448 if ($activity_tags) {
449 foreach ($activity_tags as $tagID => $tagName) {
450 $form->_tagElement = &$form->addElement('checkbox', "activity_tags[$tagID]",
451 NULL, $tagName
452 );
453 }
454 }
455
456 $parentNames = CRM_Core_BAO_Tag::getTagSet('civicrm_activity');
457 CRM_Core_Form_Tag::buildQuickForm($form, $parentNames, 'civicrm_activity', NULL, TRUE, TRUE);
458
459 $surveys = CRM_Campaign_BAO_Survey::getSurveys(TRUE, FALSE, FALSE, TRUE);
460 if ($surveys) {
461 $form->add('select', 'activity_survey_id', ts('Survey / Petition'),
462 array('' => ts('- none -')) + $surveys, FALSE,
463 array('class' => 'crm-select2')
464 );
465 }
466 $extends = array('Activity');
467 $groupDetails = CRM_Core_BAO_CustomGroup::getGroupDetail(NULL, TRUE, $extends);
468 if ($groupDetails) {
469 $form->assign('activityGroupTree', $groupDetails);
470 foreach ($groupDetails as $group) {
471 foreach ($group['fields'] as $field) {
472 $fieldId = $field['id'];
473 $elementName = 'custom_' . $fieldId;
474 CRM_Core_BAO_CustomField::addQuickFormElement($form, $elementName, $fieldId, FALSE, FALSE, TRUE);
475 }
476 }
477 }
478
479 CRM_Campaign_BAO_Campaign::addCampaignInComponentSearch($form, 'activity_campaign_id');
480
481 //add engagement level CRM-7775
482 $buildEngagementLevel = FALSE;
483 $buildSurveyResult = FALSE;
484 if (CRM_Campaign_BAO_Campaign::isCampaignEnable() &&
485 CRM_Campaign_BAO_Campaign::accessCampaign()
486 ) {
487 $buildEngagementLevel = TRUE;
488 $form->addSelect('activity_engagement_level', array('entity' => 'activity', 'context' => 'search'));
489
490 // Add survey result field.
491 $optionGroups = CRM_Campaign_BAO_Survey::getResultSets('name');
492 $resultOptions = array();
493 foreach ($optionGroups as $gid => $name) {
494 if ($name) {
495 $value = array();
496 $value = CRM_Core_OptionGroup::values($name);
497 if (!empty($value)) {
498 while (list($k, $v) = each($value)) {
499 $resultOptions[$v] = $v;
500 }
501 }
502 }
503 }
504 // If no survey result options have been created, don't build
505 // the field to avoid clutter.
506 if (count($resultOptions) > 0) {
507 $buildSurveyResult = TRUE;
508 asort($resultOptions);
509 $form->add('select', 'activity_result', ts("Survey Result"),
510 $resultOptions, FALSE,
511 array('id' => 'activity_result', 'multiple' => 'multiple', 'class' => 'crm-select2')
512 );
513 }
514 }
515
516 $form->assign('buildEngagementLevel', $buildEngagementLevel);
517 $form->assign('buildSurveyResult', $buildSurveyResult);
518 $form->setDefaults(array('activity_test' => 0));
519 }
520
521 /**
522 * @param $mode
523 * @param bool $includeCustomFields
524 *
525 * @return array|null
526 */
527 public static function defaultReturnProperties($mode, $includeCustomFields = TRUE) {
528 $properties = NULL;
529 if ($mode & CRM_Contact_BAO_Query::MODE_ACTIVITY) {
530 $properties = array(
531 'activity_id' => 1,
532 'contact_type' => 1,
533 'contact_sub_type' => 1,
534 'sort_name' => 1,
535 'display_name' => 1,
536 'activity_type' => 1,
537 'activity_type_id' => 1,
538 'activity_subject' => 1,
539 'activity_date_time' => 1,
540 'activity_duration' => 1,
541 'activity_location' => 1,
542 'activity_details' => 1,
543 'activity_status' => 1,
544 'source_contact' => 1,
545 'source_record_id' => 1,
546 'activity_is_test' => 1,
547 'activity_campaign_id' => 1,
548 'result' => 1,
549 'activity_engagement_level' => 1,
550 'parent_id' => 1,
551 );
552
553 if ($includeCustomFields) {
554 // also get all the custom activity properties
555 $fields = CRM_Core_BAO_CustomField::getFieldsForImport('Activity');
556 if (!empty($fields)) {
557 foreach ($fields as $name => $dontCare) {
558 $properties[$name] = 1;
559 }
560 }
561 }
562 }
563
564 return $properties;
565 }
566
567 }