Merge pull request #3962 from totten/master-test-autoload
[civicrm-core.git] / CRM / Profile / Selector / Listings.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.5 |
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 * @access protected
65 */
66 protected $_params;
67
68 /**
69 * the public visible fields to be shown to the user
70 *
71 * @var array
72 * @access protected
73 */
74 protected $_fields;
75
76 /**
77 * the custom fields for this domain
78 *
79 * @var array
80 * @access protected
81 */
82 protected $_customFields;
83
84 /**
85 * cache the query object
86 *
87 * @var object
88 * @access protected
89 */
90 protected $_query;
91
92 /**
93 * cache the expanded options list if any
94 *
95 * @var object
96 * @access protected
97 */
98 protected $_options;
99
100 /**
101 * The group id that we are editing
102 *
103 * @var int
104 */
105 protected $_gid;
106
107 /**
108 * Do we enable mapping of users
109 *
110 * @var boolean
111 */
112 protected $_map;
113
114 /**
115 * Do we enable edit link
116 *
117 * @var boolean
118 */
119 protected $_editLink;
120
121 /**
122 * Should we link to the UF Profile
123 *
124 * @var boolean
125 */
126 protected $_linkToUF;
127
128 /**
129 * Store profile ids if multiple profile ids are passed using comma separated.
130 * Currently lets implement this functionality only for dialog mode
131 */
132 protected $_profileIds = array();
133
134 protected $_multiRecordTableName = NULL;
135
136 /**
137 * Class constructor
138 *
139 * @param $params
140 * @param $customFields
141 * @param string params the params for the where clause
142 *
143 * @param bool $map
144 * @param bool $editLink
145 * @param bool $linkToUF
146 *
147 * @return \CRM_Profile_Selector_Listings
148 @access public
149 */
150 function __construct(
151 &$params,
152 &$customFields,
153 $ufGroupIds = NULL,
154 $map = FALSE,
155 $editLink = FALSE,
156 $linkToUF = FALSE
157 ) {
158 $this->_params = $params;
159
160 if (is_array($ufGroupIds)) {
161 $this->_profileIds = $ufGroupIds;
162 $this->_gid = $ufGroupIds[0];
163 }
164 else {
165 $this->_profileIds = array($ufGroupIds);
166 $this->_gid = $ufGroupIds;
167 }
168
169 $this->_map = $map;
170 $this->_editLink = $editLink;
171 $this->_linkToUF = $linkToUF;
172
173 //get the details of the uf group
174 if ($this->_gid) {
175 $groupId = CRM_Core_DAO::getFieldValue('CRM_Core_BAO_UFGroup',
176 $this->_gid, 'limit_listings_group_id'
177 );
178 }
179
180 // add group id to params if a uf group belong to a any group
181 if ($groupId) {
182 if (!empty($this->_params['group'])) {
183 $this->_params['group'][$groupId] = 1;
184 }
185 else {
186 $this->_params['group'] = array($groupId => 1);
187 }
188 }
189
190 $this->_fields = CRM_Core_BAO_UFGroup::getListingFields(CRM_Core_Action::VIEW,
191 CRM_Core_BAO_UFGroup::PUBLIC_VISIBILITY |
192 CRM_Core_BAO_UFGroup::LISTINGS_VISIBILITY,
193 FALSE, $this->_profileIds
194 );
195
196 $this->_customFields = &$customFields;
197
198 $returnProperties = CRM_Contact_BAO_Contact::makeHierReturnProperties($this->_fields);
199 $returnProperties['contact_type'] = 1;
200 $returnProperties['contact_sub_type'] = 1;
201 $returnProperties['sort_name'] = 1;
202
203 $queryParams = CRM_Contact_BAO_Query::convertFormValues($this->_params, 1);
204 $this->_query = new CRM_Contact_BAO_Query($queryParams, $returnProperties, $this->_fields);
205
206 //the below is done for query building for multirecord custom field listing
207 //to show all the custom field multi valued records of a particular contact
208 $this->setMultiRecordTableName($this->_fields);
209
210 $this->_options = &$this->_query->_options;
211 }
212 //end of constructor
213
214 /**
215 * This method returns the links that are given for each search row.
216 *
217 * @param bool $map
218 * @param bool $editLink
219 * @param bool $ufLink
220 * @param null $gids
221 *
222 * @return array
223 * @access public
224 */
225 static function &links($map = FALSE, $editLink = FALSE, $ufLink = FALSE, $gids = NULL) {
226 if (!self::$_links) {
227 self::$_links = array();
228
229 $viewPermission = TRUE;
230 if ($gids) {
231 // check view permission for each profile id, in case multiple profile ids are rendered
232 // then view action is disabled if any profile returns false
233 foreach ($gids as $profileId) {
234 $viewPermission = CRM_Core_Permission::ufGroupValid($profileId, CRM_Core_Permission::VIEW);
235 if (!$viewPermission) {
236 break;
237 }
238 }
239 }
240
241 if ($viewPermission) {
242 self::$_links[CRM_Core_Action::VIEW] = array(
243 'name' => ts('View'),
244 'url' => 'civicrm/profile/view',
245 'qs' => 'reset=1&id=%%id%%&gid=%%gid%%',
246 'title' => ts('View Profile Details'),
247 );
248 }
249
250 if ($editLink) {
251 self::$_links[CRM_Core_Action::UPDATE] = array(
252 'name' => ts('Edit'),
253 'url' => 'civicrm/profile/edit',
254 'qs' => 'reset=1&id=%%id%%&gid=%%gid%%',
255 'title' => ts('Edit'),
256 );
257 }
258
259 if ($ufLink) {
260 self::$_links[CRM_Core_Action::PROFILE] = array(
261 'name' => ts('Website Profile'),
262 'url' => 'user/%%ufID%%',
263 'qs' => ' ',
264 'title' => ts('View Website Profile'),
265 );
266 }
267
268 if ($map) {
269 self::$_links[CRM_Core_Action::MAP] = array(
270 'name' => ts('Map'),
271 'url' => 'civicrm/profile/map',
272 'qs' => 'reset=1&cid=%%id%%&gid=%%gid%%',
273 'title' => ts('Map'),
274 );
275 }
276 }
277 return self::$_links;
278 }
279 //end of function
280
281 /**
282 * getter for array of the parameters required for creating pager.
283 *
284 * @param $action
285 * @param $params
286 *
287 * @internal param $
288 * @access public
289 */
290 function getPagerParams($action, &$params) {
291 $status =
292 CRM_Utils_System::isNull($this->_multiRecordTableName) ? ts('Contact %%StatusMessage%%') : ts('Contact Multi Records %%StatusMessage%%');
293 $params['status'] = $status;
294 $params['csvString'] = NULL;
295 $params['rowCount'] = CRM_Utils_Pager::ROWCOUNT;
296
297 $params['buttonTop'] = 'PagerTopButton';
298 $params['buttonBottom'] = 'PagerBottomButton';
299 }
300 //end of function
301
302 /**
303 * returns the column headers as an array of tuples:
304 * (name, sortName (key to the sort array))
305 *
306 * @param string $action the action being performed
307 * @param enum $output what should the result set include (web/email/csv)
308 *
309 * @return array the column headers that need to be displayed
310 * @access public
311 */
312 function &getColumnHeaders($action = NULL, $output = NULL) {
313 static $skipFields = array('group', 'tag');
314 $multipleFields = array('url');
315 $direction = CRM_Utils_Sort::ASCENDING;
316 $empty = TRUE;
317 if (!isset(self::$_columnHeaders)) {
318 self::$_columnHeaders = array(array('name' => ''),
319 array(
320 'name' => ts('Name'),
321 'sort' => 'sort_name',
322 'direction' => CRM_Utils_Sort::ASCENDING,
323 'field_name' => 'sort_name',
324 ),
325 );
326
327 $locationTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id');
328
329 foreach ($this->_fields as $name => $field) {
330 // skip pseudo fields
331 if (substr($name, 0, 9) == 'phone_ext') {
332 continue;
333 }
334
335 if (!empty($field['in_selector']) &&
336 !in_array($name, $skipFields)
337 ) {
338
339 if (strpos($name, '-') !== FALSE) {
340 $value = explode('-', $name);
341 $fieldName = CRM_Utils_Array::value(0, $value);
342 $lType = CRM_Utils_Array::value(1, $value);
343 $type = CRM_Utils_Array::value(2, $value);
344
345 if (!in_array($fieldName, $multipleFields)) {
346 if ($lType == 'Primary') {
347 $locationTypeName = 1;
348 }
349 else {
350 $locationTypeName = $locationTypes[$lType];
351 }
352
353 if (in_array($fieldName, array(
354 'phone', 'im', 'email'))) {
355 if ($type) {
356 $name = "`$locationTypeName-$fieldName-$type`";
357 }
358 else {
359 $name = "`$locationTypeName-$fieldName`";
360 }
361 }
362 else {
363 $name = "`$locationTypeName-$fieldName`";
364 }
365 }
366 else {
367 $name = "website-{$lType}-{$fieldName}";
368 }
369 }
370
371 self::$_columnHeaders[] = array(
372 'name' => $field['title'],
373 'sort' => $name,
374 'direction' => $direction,
375 'field_name' => CRM_Core_BAO_UFField::isValidFieldName($name) ? $name : $fieldName,
376 );
377
378 $direction = CRM_Utils_Sort::DONTCARE;
379 $empty = FALSE;
380 }
381 }
382
383 // if we dont have any valid columns, dont add the implicit ones
384 // this allows the template to check on emptiness of column headers
385 if ($empty) {
386 self::$_columnHeaders = array();
387 }
388 else {
389 self::$_columnHeaders[] = array('desc' => ts('Actions'));
390 }
391 }
392 return self::$_columnHeaders;
393 }
394
395 /**
396 * Returns total number of rows for the query.
397 *
398 * @param
399 *
400 * @return int Total number of rows
401 * @access public
402 */
403 function getTotalCount($action) {
404 $additionalWhereClause = 'contact_a.is_deleted = 0';
405 $additionalFromClause = NULL;
406 $returnQuery = NULL;
407
408 if ($this->_multiRecordTableName &&
409 !array_key_exists($this->_multiRecordTableName, $this->_query->_whereTables)) {
410 $additionalFromClause = CRM_Utils_Array::value($this->_multiRecordTableName, $this->_query->_tables);
411 $returnQuery = TRUE;
412 }
413
414 $countVal = $this->_query->searchQuery(0, 0, NULL, TRUE, NULL, NULL, NULL,
415 $returnQuery, $additionalWhereClause, NULL, $additionalFromClause
416 );
417
418 if (!$returnQuery) {
419 return $countVal;
420 }
421
422 if ($returnQuery) {
423 $sql = preg_replace('/DISTINCT/', '', $countVal);
424 return CRM_Core_DAO::singleValueQuery($sql);
425 }
426 }
427
428 /**
429 * Return the qill for this selector
430 *
431 * @return string
432 * @access public
433 */
434 function getQill() {
435 return $this->_query->qill();
436 }
437
438 /**
439 * returns all the rows in the given offset and rowCount
440 *
441 * @param enum $action the action being performed
442 * @param int $offset the row number to start from
443 * @param int $rowCount the number of rows to return
444 * @param string $sort the sql string that describes the sort order
445 * @param enum $output what should the result set include (web/email/csv)
446 *
447 * @return int the total number of rows for this action
448 */
449 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', 'im', 'email'))) {
557 if ($type) {
558 $names[] = "{$locationTypeName}-{$fieldName}-{$type}";
559 }
560 else {
561 $names[] = "{$locationTypeName}-{$fieldName}";
562 }
563 }
564 else {
565 $names[] = "{$locationTypeName}-{$fieldName}";
566 }
567 }
568 else {
569 $names[] = "website-{$id}-{$fieldName}";
570 }
571 }
572 elseif ($field['name'] == 'id') {
573 $names[] = 'contact_id';
574 }
575 else {
576 $names[] = $field['name'];
577 }
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 ?
602 $result->contact_sub_type : $result->contact_type,
603 FALSE,
604 $result->contact_id,
605 $showProfileOverlay
606 );
607 if ($result->sort_name) {
608 $row[] = $result->sort_name;
609 $empty = FALSE;
610 }
611 else {
612 continue;
613 }
614
615 foreach ($names as $name) {
616 if ($cfID = CRM_Core_BAO_CustomField::getKeyID($name)) {
617 $row[] = CRM_Core_BAO_CustomField::getDisplayValue($result->$name,
618 $cfID,
619 $this->_options,
620 $result->contact_id
621 );
622 }
623 elseif (substr($name, -4) == '-url' &&
624 !empty($result->$name)
625 ) {
626 $url = CRM_Utils_System::fixURL($result->$name);
627 $typeId = substr($name, 0, -4) . "-website_type_id";
628 $typeName = CRM_Core_PseudoConstant::getLabel('CRM_Core_DAO_Website', 'website_type_id', $result->$typeId);
629 if ($typeName) {
630 $row[] = "<a href=\"$url\">{$result->$name} (${typeName})</a>";
631 }
632 else {
633 $row[] = "<a href=\"$url\">{$result->$name}</a>";
634 }
635 }
636 elseif ($name == 'preferred_language') {
637 $row[] = CRM_Core_PseudoConstant::getLabel('CRM_Contact_DAO_Contact', 'preferred_language', $result->$name);
638 }
639 elseif ($multipleSelectFields &&
640 array_key_exists($name, $multipleSelectFields)
641 ) {
642 $paramsNew = array($name => $result->$name);
643 $name = array($name => array('newName' => $name, 'groupName' => $name));
644
645 CRM_Core_OptionGroup::lookupValues($paramsNew, $name, FALSE);
646 $row[] = $paramsNew[$key];
647 }
648 elseif (strpos($name, '-im')) {
649 if (!empty($result->$name)) {
650 $providerId = $name . "-provider_id";
651 $providerName = CRM_Core_PseudoConstant::getLabel('CRM_Core_DAO_IM', 'provider_id', $result->$providerId);
652 $row[] = $result->$name . " ({$providerName})";
653 }
654 else {
655 $row[] = '';
656 }
657 }
658 elseif (strpos($name, '-phone-')) {
659 $phoneExtField = str_replace('phone', 'phone_ext', $name);
660 if (isset($result->$phoneExtField)) {
661 $row[] = $result->$name . " (" . $result->$phoneExtField . ")";
662 }
663 else {
664 $row[] = $result->$name;
665 }
666 }
667 elseif (in_array($name, array(
668 'addressee', 'email_greeting', 'postal_greeting'))) {
669 $dname = $name . '_display';
670 $row[] = $result->$dname;
671 }
672 elseif (in_array($name, array(
673 'birth_date', 'deceased_date'))) {
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 = array(
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 type of output
735 *
736 * @return string name of the file
737 */
738 function getExportFileName($output = 'csv') {
739 return ts('CiviCRM Profile Listings');
740 }
741
742 /**
743 * set the _multiRecordTableName to display the result set
744 * according to multi record custom field values
745 */
746 function setMultiRecordTableName($fields) {
747 $customGroupId = $multiRecordTableName = NULL;
748 $selectorSet = FALSE;
749
750 foreach ($fields as $field => $properties) {
751 if (!CRM_Core_BAO_CustomField::getKeyID($field)) {
752 continue;
753 }
754 if ($cgId = CRM_Core_BAO_CustomField::isMultiRecordField($field)) {
755 $customGroupId = CRM_Utils_System::isNull($customGroupId) ? $cgId : $customGroupId;
756
757 //if the field is submitted set multiRecordTableName
758 if ($customGroupId) {
759 $isSubmitted = FALSE;
760 foreach ($this->_query->_params as $key => $value) {
761 //check the query params 'where' element
762 if ($value[0] == $field) {
763 $isSubmitted = TRUE;
764 break;
765 }
766 }
767
768 if ($isSubmitted) {
769 $this->_multiRecordTableName = $multiRecordTableName =
770 CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomGroup', $customGroupId, 'table_name');
771 if ($multiRecordTableName) {
772 return;
773 }
774 }
775
776 if (!empty($properties['in_selector'])) {
777 $selectorSet = TRUE;
778 }
779 }
780 }
781 }
782
783 if (!isset($customGroupId) || !$customGroupId) {
784 return;
785 }
786
787 //if the field is in selector and not a searchable field
788 //get the proper customvalue table name
789 if ($selectorSet) {
790 $this->_multiRecordTableName = $multiRecordTableName =
791 CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomGroup', $customGroupId, 'table_name');
792 }
793 } //func close
794 }
795 //end of class
796