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