(dev/core#959) Expose contribution page in Contribution Summary report
[civicrm-core.git] / CRM / Profile / Selector / Listings.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | CiviCRM version 5 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2019 |
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-2019
32 */
33
34 /**
35 * This class is used to retrieve and display a range of
36 * contacts that match the given criteria (specifically for
37 * results of advanced search options.
38 *
39 */
40 class CRM_Profile_Selector_Listings extends CRM_Core_Selector_Base implements CRM_Core_Selector_API {
41
42 /**
43 * Array of supported links, currently view and edit
44 *
45 * @var array
46 */
47 public static $_links = NULL;
48
49 /**
50 * We use desc to remind us what that column is, name is used in the tpl
51 *
52 * @var array
53 */
54 public static $_columnHeaders;
55
56 /**
57 * The sql params we use to get the list of contacts.
58 *
59 * @var string
60 */
61 protected $_params;
62
63 /**
64 * The public visible fields to be shown to the user.
65 *
66 * @var array
67 */
68 protected $_fields;
69
70 /**
71 * The custom fields for this domain.
72 *
73 * @var array
74 */
75 protected $_customFields;
76
77 /**
78 * Cache the query object.
79 *
80 * @var object
81 */
82 protected $_query;
83
84 /**
85 * Cache the expanded options list if any.
86 *
87 * @var object
88 */
89 protected $_options;
90
91 /**
92 * The group id that we are editing.
93 *
94 * @var int
95 */
96 protected $_gid;
97
98 /**
99 * Do we enable mapping of users.
100 *
101 * @var boolean
102 */
103 protected $_map;
104
105 /**
106 * Do we enable edit link.
107 *
108 * @var boolean
109 */
110 protected $_editLink;
111
112 /**
113 * Should we link to the UF Profile.
114 *
115 * @var boolean
116 */
117 protected $_linkToUF;
118
119 /**
120 * Store profile ids if multiple profile ids are passed using comma separated.
121 * Currently lets implement this functionality only for dialog mode
122 * @var array
123 */
124 protected $_profileIds = [];
125
126 protected $_multiRecordTableName = NULL;
127
128 /**
129 * Class constructor.
130 *
131 * @param array $params the params for the where clause
132 * @param array $customFields
133 * @param array $ufGroupIds
134 * @param bool $map
135 * @param bool $editLink
136 * @param bool $linkToUF
137 *
138 * @return \CRM_Profile_Selector_Listings
139 */
140 public function __construct(
141 &$params,
142 &$customFields,
143 $ufGroupIds = NULL,
144 $map = FALSE,
145 $editLink = FALSE,
146 $linkToUF = FALSE
147 ) {
148 $this->_params = $params;
149
150 if (is_array($ufGroupIds)) {
151 $this->_profileIds = $ufGroupIds;
152 $this->_gid = $ufGroupIds[0];
153 }
154 else {
155 $this->_profileIds = [$ufGroupIds];
156 $this->_gid = $ufGroupIds;
157 }
158
159 $this->_map = $map;
160 $this->_editLink = $editLink;
161 $this->_linkToUF = $linkToUF;
162
163 //get the details of the uf group
164 if ($this->_gid) {
165 $groupId = CRM_Core_DAO::getFieldValue('CRM_Core_BAO_UFGroup',
166 $this->_gid, 'limit_listings_group_id'
167 );
168 }
169
170 // add group id to params if a uf group belong to a any group
171 if ($groupId) {
172 if (!empty($this->_params['group'])) {
173 $this->_params['group'][$groupId] = 1;
174 }
175 else {
176 $this->_params['group'] = [$groupId => 1];
177 }
178 }
179
180 $this->_fields = CRM_Core_BAO_UFGroup::getListingFields(CRM_Core_Action::VIEW,
181 CRM_Core_BAO_UFGroup::PUBLIC_VISIBILITY |
182 CRM_Core_BAO_UFGroup::LISTINGS_VISIBILITY,
183 FALSE, $this->_profileIds
184 );
185
186 $this->_customFields = &$customFields;
187
188 $returnProperties = CRM_Contact_BAO_Contact::makeHierReturnProperties($this->_fields);
189 $returnProperties['contact_type'] = 1;
190 $returnProperties['contact_sub_type'] = 1;
191 $returnProperties['sort_name'] = 1;
192
193 $queryParams = CRM_Contact_BAO_Query::convertFormValues($this->_params, 1);
194 $this->_query = new CRM_Contact_BAO_Query($queryParams, $returnProperties, $this->_fields);
195
196 //the below is done for query building for multirecord custom field listing
197 //to show all the custom field multi valued records of a particular contact
198 $this->setMultiRecordTableName($this->_fields);
199
200 $this->_options = &$this->_query->_options;
201 }
202
203 /**
204 * This method returns the links that are given for each search row.
205 *
206 * @param bool $map
207 * @param bool $editLink
208 * @param bool $ufLink
209 * @param null $gids
210 *
211 * @return array
212 */
213 public static function &links($map = FALSE, $editLink = FALSE, $ufLink = FALSE, $gids = NULL) {
214 if (!self::$_links) {
215 self::$_links = [];
216
217 $viewPermission = TRUE;
218 if ($gids) {
219 // check view permission for each profile id, in case multiple profile ids are rendered
220 // then view action is disabled if any profile returns false
221 foreach ($gids as $profileId) {
222 $viewPermission = CRM_Core_Permission::ufGroupValid($profileId, CRM_Core_Permission::VIEW);
223 if (!$viewPermission) {
224 break;
225 }
226 }
227 }
228
229 if ($viewPermission) {
230 self::$_links[CRM_Core_Action::VIEW] = [
231 'name' => ts('View'),
232 'url' => 'civicrm/profile/view',
233 'qs' => 'reset=1&id=%%id%%&gid=%%gid%%',
234 'title' => ts('View Profile Details'),
235 ];
236 }
237
238 if ($editLink) {
239 self::$_links[CRM_Core_Action::UPDATE] = [
240 'name' => ts('Edit'),
241 'url' => 'civicrm/profile/edit',
242 'qs' => 'reset=1&id=%%id%%&gid=%%gid%%',
243 'title' => ts('Edit'),
244 ];
245 }
246
247 if ($ufLink) {
248 self::$_links[CRM_Core_Action::PROFILE] = [
249 'name' => ts('Website Profile'),
250 'url' => 'user/%%ufID%%',
251 'qs' => ' ',
252 'title' => ts('View Website Profile'),
253 ];
254 }
255
256 if ($map) {
257 self::$_links[CRM_Core_Action::MAP] = [
258 'name' => ts('Map'),
259 'url' => 'civicrm/profile/map',
260 'qs' => 'reset=1&cid=%%id%%&gid=%%gid%%',
261 'title' => ts('Map'),
262 ];
263 }
264 }
265 return self::$_links;
266 }
267
268 /**
269 * Getter for array of the parameters required for creating pager.
270 *
271 * @param $action
272 * @param array $params
273 */
274 public function getPagerParams($action, &$params) {
275 $status = CRM_Utils_System::isNull($this->_multiRecordTableName) ? ts('Contact %%StatusMessage%%') : ts('Contact Multi Records %%StatusMessage%%');
276 $params['status'] = $status;
277 $params['csvString'] = NULL;
278 $params['rowCount'] = CRM_Utils_Pager::ROWCOUNT;
279
280 $params['buttonTop'] = 'PagerTopButton';
281 $params['buttonBottom'] = 'PagerBottomButton';
282 }
283
284 /**
285 * Returns the column headers as an array of tuples:
286 * (name, sortName (key to the sort array))
287 *
288 * @param string $action
289 * The action being performed.
290 * @param string $output
291 * What should the result set include (web/email/csv).
292 *
293 * @return array
294 * the column headers that need to be displayed
295 */
296 public function &getColumnHeaders($action = NULL, $output = NULL) {
297 static $skipFields = ['group', 'tag'];
298 $multipleFields = ['url'];
299 $direction = CRM_Utils_Sort::ASCENDING;
300 $empty = TRUE;
301 if (!isset(self::$_columnHeaders)) {
302 self::$_columnHeaders = [
303 ['name' => ''],
304 [
305 'name' => ts('Name'),
306 'sort' => 'sort_name',
307 'direction' => CRM_Utils_Sort::ASCENDING,
308 'field_name' => 'sort_name',
309 ],
310 ];
311
312 $locationTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id');
313
314 foreach ($this->_fields as $name => $field) {
315 // skip pseudo fields
316 if (substr($name, 0, 9) == 'phone_ext') {
317 continue;
318 }
319
320 if (!empty($field['in_selector']) &&
321 !in_array($name, $skipFields)
322 ) {
323
324 if (strpos($name, '-') !== FALSE) {
325 $value = explode('-', $name);
326 $fieldName = CRM_Utils_Array::value(0, $value);
327 $lType = CRM_Utils_Array::value(1, $value);
328 $type = CRM_Utils_Array::value(2, $value);
329
330 if (!in_array($fieldName, $multipleFields)) {
331 if ($lType == 'Primary') {
332 $locationTypeName = 1;
333 }
334 else {
335 $locationTypeName = $locationTypes[$lType];
336 }
337
338 if (in_array($fieldName, [
339 'phone',
340 'im',
341 'email',
342 ])) {
343 if ($type) {
344 $name = "`$locationTypeName-$fieldName-$type`";
345 }
346 else {
347 $name = "`$locationTypeName-$fieldName`";
348 }
349 }
350 else {
351 $name = "`$locationTypeName-$fieldName`";
352 }
353 }
354 else {
355 $name = "website-{$lType}-{$fieldName}";
356 }
357 }
358
359 self::$_columnHeaders[] = [
360 'name' => $field['title'],
361 'sort' => $name,
362 'direction' => $direction,
363 'field_name' => CRM_Core_BAO_UFField::isValidFieldName($name) ? $name : $fieldName,
364 ];
365
366 $direction = CRM_Utils_Sort::DONTCARE;
367 $empty = FALSE;
368 }
369 }
370
371 // if we don't have any valid columns, don't add the implicit ones
372 // this allows the template to check on emptiness of column headers
373 if ($empty) {
374 self::$_columnHeaders = [];
375 }
376 else {
377 self::$_columnHeaders[] = ['desc' => ts('Actions')];
378 }
379 }
380 return self::$_columnHeaders;
381 }
382
383 /**
384 * Returns total number of rows for the query.
385 *
386 * @param int $action
387 *
388 * @return int
389 * Total number of rows
390 */
391 public function getTotalCount($action) {
392 $additionalWhereClause = 'contact_a.is_deleted = 0';
393 $additionalFromClause = NULL;
394 $returnQuery = NULL;
395
396 if ($this->_multiRecordTableName &&
397 !array_key_exists($this->_multiRecordTableName, $this->_query->_whereTables)
398 ) {
399 $additionalFromClause = CRM_Utils_Array::value($this->_multiRecordTableName, $this->_query->_tables);
400 $returnQuery = TRUE;
401 }
402
403 $countVal = $this->_query->searchQuery(0, 0, NULL, TRUE, NULL, NULL, NULL,
404 $returnQuery, $additionalWhereClause, NULL, $additionalFromClause
405 );
406
407 if (!$returnQuery) {
408 return $countVal;
409 }
410
411 if ($returnQuery) {
412 $sql = preg_replace('/DISTINCT/', '', $countVal);
413 return CRM_Core_DAO::singleValueQuery($sql);
414 }
415 }
416
417 /**
418 * Return the qill for this selector.
419 *
420 * @return string
421 */
422 public function getQill() {
423 return $this->_query->qill();
424 }
425
426 /**
427 * Returns all the rows in the given offset and rowCount.
428 *
429 * @param string $action
430 * The action being performed.
431 * @param int $offset
432 * The row number to start from.
433 * @param int $rowCount
434 * The number of rows to return.
435 * @param string $sort
436 * The sql string that describes the sort order.
437 * @param string $output
438 * What should the result set include (web/email/csv).
439 *
440 * @param string $extraWhereClause
441 *
442 * @return int
443 * the total number of rows for this action
444 */
445 public function &getRows($action, $offset, $rowCount, $sort, $output = NULL, $extraWhereClause = NULL) {
446
447 $multipleFields = ['url'];
448 //$sort object processing for location fields
449 if ($sort) {
450 $vars = $sort->_vars;
451 $varArray = [];
452 foreach ($vars as $key => $field) {
453 $field = $vars[$key];
454 $fieldArray = explode('-', $field['name']);
455 $fieldType = CRM_Utils_Array::value('2', $fieldArray);
456 if (is_numeric(CRM_Utils_Array::value('1', $fieldArray))) {
457 if (!in_array($fieldType, $multipleFields)) {
458 $locationType = new CRM_Core_DAO_LocationType();
459 $locationType->id = $fieldArray[1];
460 $locationType->find(TRUE);
461 if ($fieldArray[0] == 'email' || $fieldArray[0] == 'im' || $fieldArray[0] == 'phone') {
462 $field['name'] = "`" . $locationType->name . "-" . $fieldArray[0] . "-1`";
463 }
464 else {
465 $field['name'] = "`" . $locationType->name . "-" . $fieldArray[0] . "`";
466 }
467 }
468 else {
469 $field['name'] = "`website-" . $fieldArray[1] . "-{$fieldType}`";
470 }
471 }
472 $varArray[$key] = $field;
473 }
474 $sort->_vars = $varArray;
475 }
476
477 $additionalWhereClause = 'contact_a.is_deleted = 0';
478
479 if ($extraWhereClause) {
480 $additionalWhereClause .= " AND {$extraWhereClause}";
481 }
482
483 $returnQuery = NULL;
484 if ($this->_multiRecordTableName) {
485 $returnQuery = TRUE;
486 }
487 $this->_query->_useGroupBy = TRUE;
488 $result = $this->_query->searchQuery($offset, $rowCount, $sort, NULL, NULL,
489 NULL, NULL, $returnQuery, $additionalWhereClause
490 );
491
492 if ($returnQuery) {
493 $resQuery = preg_replace('/GROUP BY contact_a.id[\s]+ORDER BY/', ' ORDER BY', $result);
494 $result = CRM_Core_DAO::executeQuery($resQuery);
495 }
496
497 // process the result of the query
498 $rows = [];
499
500 // check if edit is configured in profile settings
501 if ($this->_gid) {
502 $editLink = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', $this->_gid, 'is_edit_link');
503 }
504
505 //FIXME : make sure to handle delete separately. CRM-4418
506 $mask = CRM_Core_Action::mask([CRM_Core_Permission::getPermission()]);
507 if ($editLink && ($mask & CRM_Core_Permission::EDIT)) {
508 // do not allow edit for anon users in joomla frontend, CRM-4668
509 $config = CRM_Core_Config::singleton();
510 if (!$config->userFrameworkFrontend || CRM_Core_Session::singleton()->getLoggedInContactID()) {
511 $this->_editLink = TRUE;
512 }
513 }
514 $links = self::links($this->_map, $this->_editLink, $this->_linkToUF, $this->_profileIds);
515
516 $locationTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id');
517
518 $names = [];
519 static $skipFields = ['group', 'tag'];
520
521 foreach ($this->_fields as $key => $field) {
522 // skip pseudo fields
523 if (substr($key, 0, 9) == 'phone_ext') {
524 continue;
525 }
526
527 if (!empty($field['in_selector']) &&
528 !in_array($key, $skipFields)
529 ) {
530 if (strpos($key, '-') !== FALSE) {
531 $value = explode('-', $key);
532 $fieldName = CRM_Utils_Array::value(0, $value);
533 $id = CRM_Utils_Array::value(1, $value);
534 $type = CRM_Utils_Array::value(2, $value);
535
536 if (!in_array($fieldName, $multipleFields)) {
537 $locationTypeName = NULL;
538 if (is_numeric($id)) {
539 $locationTypeName = CRM_Utils_Array::value($id, $locationTypes);
540 }
541 else {
542 if ($id == 'Primary') {
543 $locationTypeName = 1;
544 }
545 }
546
547 if (!$locationTypeName) {
548 continue;
549 }
550 $locationTypeName = str_replace(' ', '_', $locationTypeName);
551 if (in_array($fieldName, [
552 'phone',
553 'im',
554 'email',
555 ])) {
556 if ($type) {
557 $names[] = "{$locationTypeName}-{$fieldName}-{$type}";
558 }
559 else {
560 $names[] = "{$locationTypeName}-{$fieldName}";
561 }
562 }
563 else {
564 $names[] = "{$locationTypeName}-{$fieldName}";
565 }
566 }
567 else {
568 $names[] = "website-{$id}-{$fieldName}";
569 }
570 }
571 elseif ($field['name'] == 'id') {
572 $names[] = 'contact_id';
573 }
574 else {
575 $names[] = $field['name'];
576 }
577 }
578 }
579
580 $multipleSelectFields = ['preferred_communication_method' => 1];
581 $multiRecordTableId = NULL;
582 if ($this->_multiRecordTableName) {
583 $multiRecordTableId = "{$this->_multiRecordTableName}_id";
584 }
585
586 // we need to determine of overlay profile should be shown
587 $showProfileOverlay = CRM_Core_BAO_UFGroup::showOverlayProfile();
588
589 while ($result->fetch()) {
590 $this->_query->convertToPseudoNames($result);
591
592 if (isset($result->country)) {
593 // the query returns the untranslated country name
594 $i18n = CRM_Core_I18n::singleton();
595 $result->country = $i18n->translate($result->country);
596 }
597 $row = [];
598 $empty = TRUE;
599 $row[] = CRM_Contact_BAO_Contact_Utils::getImage($result->contact_sub_type ? $result->contact_sub_type : $result->contact_type,
600 FALSE,
601 $result->contact_id,
602 $showProfileOverlay
603 );
604 if ($result->sort_name) {
605 $row[] = $result->sort_name;
606 $empty = FALSE;
607 }
608 else {
609 continue;
610 }
611
612 foreach ($names as $name) {
613 if ($cfID = CRM_Core_BAO_CustomField::getKeyID($name)) {
614 $row[] = CRM_Core_BAO_CustomField::displayValue($result->$name,
615 $cfID,
616 $result->contact_id
617 );
618 }
619 elseif (substr($name, -4) == '-url' &&
620 !empty($result->$name)
621 ) {
622 $url = CRM_Utils_System::fixURL($result->$name);
623 $typeId = substr($name, 0, -4) . "-website_type_id";
624 $typeName = CRM_Core_PseudoConstant::getLabel('CRM_Core_DAO_Website', 'website_type_id', $result->$typeId);
625 if ($typeName) {
626 $row[] = "<a href=\"$url\">{$result->$name} (${typeName})</a>";
627 }
628 else {
629 $row[] = "<a href=\"$url\">{$result->$name}</a>";
630 }
631 }
632 elseif ($name == 'preferred_language') {
633 $row[] = CRM_Core_PseudoConstant::getLabel('CRM_Contact_DAO_Contact', 'preferred_language', $result->$name);
634 }
635 elseif ($multipleSelectFields &&
636 array_key_exists($name, $multipleSelectFields)
637 ) {
638 $paramsNew = [$name => $result->$name];
639 $name = [$name => ['newName' => $name, 'groupName' => $name]];
640
641 CRM_Core_OptionGroup::lookupValues($paramsNew, $name, FALSE);
642 $row[] = $paramsNew[$key];
643 }
644 elseif (strpos($name, '-im')) {
645 if (!empty($result->$name)) {
646 $providerId = $name . "-provider_id";
647 $providerName = CRM_Core_PseudoConstant::getLabel('CRM_Core_DAO_IM', 'provider_id', $result->$providerId);
648 $row[] = $result->$name . " ({$providerName})";
649 }
650 else {
651 $row[] = '';
652 }
653 }
654 elseif (strpos($name, '-phone-')) {
655 $phoneExtField = str_replace('phone', 'phone_ext', $name);
656 if (isset($result->$phoneExtField)) {
657 $row[] = $result->$name . " (" . $result->$phoneExtField . ")";
658 }
659 else {
660 $row[] = $result->$name;
661 }
662 }
663 elseif (in_array($name, [
664 'addressee',
665 'email_greeting',
666 'postal_greeting',
667 ])) {
668 $dname = $name . '_display';
669 $row[] = $result->$dname;
670 }
671 elseif (in_array($name, [
672 'birth_date',
673 'deceased_date',
674 ])) {
675 $row[] = CRM_Utils_Date::customFormat($result->$name);
676 }
677 elseif (isset($result->$name)) {
678 $row[] = $result->$name;
679 }
680 else {
681 $row[] = '';
682 }
683
684 if (!empty($result->$name)) {
685 $empty = FALSE;
686 }
687 }
688
689 $newLinks = $links;
690 $params = [
691 'id' => $result->contact_id,
692 'gid' => implode(',', $this->_profileIds),
693 ];
694
695 // pass record id param to view url for multi record view
696 if ($multiRecordTableId && $newLinks) {
697 if ($result->$multiRecordTableId) {
698 if ($newLinks[CRM_Core_Action::VIEW]['url'] == 'civicrm/profile/view') {
699 $newLinks[CRM_Core_Action::VIEW]['qs'] .= "&multiRecord=view&recordId=%%recordId%%&allFields=1";
700 $params['recordId'] = $result->$multiRecordTableId;
701 }
702 }
703 }
704
705 if ($this->_linkToUF) {
706 $ufID = CRM_Core_BAO_UFMatch::getUFId($result->contact_id);
707 if (!$ufID) {
708 unset($newLinks[CRM_Core_Action::PROFILE]);
709 }
710 else {
711 $params['ufID'] = $ufID;
712 }
713 }
714
715 $row[] = CRM_Core_Action::formLink($newLinks,
716 $mask,
717 $params,
718 ts('more'),
719 FALSE,
720 'profile.selector.row',
721 'Contact',
722 $result->contact_id
723 );
724
725 if (!$empty) {
726 $rows[] = $row;
727 }
728 }
729 return $rows;
730 }
731
732 /**
733 * Name of export file.
734 *
735 * @param string $output
736 * Type of output.
737 *
738 * @return string
739 * name of the file
740 */
741 public function getExportFileName($output = 'csv') {
742 return ts('CiviCRM Profile Listings');
743 }
744
745 /**
746 * Set the _multiRecordTableName to display the result set.
747 *
748 * (according to multi record custom field values).
749 *
750 * @param array $fields
751 */
752 public function setMultiRecordTableName($fields) {
753 $customGroupId = $multiRecordTableName = NULL;
754 $selectorSet = FALSE;
755
756 foreach ($fields as $field => $properties) {
757 if (!CRM_Core_BAO_CustomField::getKeyID($field)) {
758 continue;
759 }
760 if ($cgId = CRM_Core_BAO_CustomField::isMultiRecordField($field)) {
761 $customGroupId = CRM_Utils_System::isNull($customGroupId) ? $cgId : $customGroupId;
762
763 //if the field is submitted set multiRecordTableName
764 if ($customGroupId) {
765 $isSubmitted = FALSE;
766 foreach ($this->_query->_params as $key => $value) {
767 //check the query params 'where' element
768 if ($value[0] == $field) {
769 $isSubmitted = TRUE;
770 break;
771 }
772 }
773
774 if ($isSubmitted) {
775 $this->_multiRecordTableName
776 = $multiRecordTableName = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomGroup', $customGroupId, 'table_name');
777 if ($multiRecordTableName) {
778 return;
779 }
780 }
781
782 if (!empty($properties['in_selector'])) {
783 $selectorSet = TRUE;
784 }
785 }
786 }
787 }
788
789 if (!isset($customGroupId) || !$customGroupId) {
790 return;
791 }
792
793 //if the field is in selector and not a searchable field
794 //get the proper custom value table name
795 if ($selectorSet) {
796 $this->_multiRecordTableName
797 = $multiRecordTableName = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomGroup', $customGroupId, 'table_name');
798 }
799 } //func close
800
801 }