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