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