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