Merge remote-tracking branch 'upstream/4.5' into 4.5-master-2014-12-30-00-43-32
[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 * @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 array $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
213 /**
214 * This method returns the links that are given for each search row.
215 *
216 * @param bool $map
217 * @param bool $editLink
218 * @param bool $ufLink
219 * @param null $gids
220 *
221 * @return array
222 * @access public
223 */
224 static function &links($map = FALSE, $editLink = FALSE, $ufLink = FALSE, $gids = NULL) {
225 if (!self::$_links) {
226 self::$_links = array();
227
228 $viewPermission = TRUE;
229 if ($gids) {
230 // check view permission for each profile id, in case multiple profile ids are rendered
231 // then view action is disabled if any profile returns false
232 foreach ($gids as $profileId) {
233 $viewPermission = CRM_Core_Permission::ufGroupValid($profileId, CRM_Core_Permission::VIEW);
234 if (!$viewPermission) {
235 break;
236 }
237 }
238 }
239
240 if ($viewPermission) {
241 self::$_links[CRM_Core_Action::VIEW] = array(
242 'name' => ts('View'),
243 'url' => 'civicrm/profile/view',
244 'qs' => 'reset=1&id=%%id%%&gid=%%gid%%',
245 'title' => ts('View Profile Details'),
246 );
247 }
248
249 if ($editLink) {
250 self::$_links[CRM_Core_Action::UPDATE] = array(
251 'name' => ts('Edit'),
252 'url' => 'civicrm/profile/edit',
253 'qs' => 'reset=1&id=%%id%%&gid=%%gid%%',
254 'title' => ts('Edit'),
255 );
256 }
257
258 if ($ufLink) {
259 self::$_links[CRM_Core_Action::PROFILE] = array(
260 'name' => ts('Website Profile'),
261 'url' => 'user/%%ufID%%',
262 'qs' => ' ',
263 'title' => ts('View Website Profile'),
264 );
265 }
266
267 if ($map) {
268 self::$_links[CRM_Core_Action::MAP] = array(
269 'name' => ts('Map'),
270 'url' => 'civicrm/profile/map',
271 'qs' => 'reset=1&cid=%%id%%&gid=%%gid%%',
272 'title' => ts('Map'),
273 );
274 }
275 }
276 return self::$_links;
277 }
278
279 /**
280 * Getter for array of the parameters required for creating pager.
281 *
282 * @param $action
283 * @param array $params
284 *
285 * @access public
286 */
287 function getPagerParams($action, &$params) {
288 $status =
289 CRM_Utils_System::isNull($this->_multiRecordTableName) ? ts('Contact %%StatusMessage%%') : ts('Contact Multi Records %%StatusMessage%%');
290 $params['status'] = $status;
291 $params['csvString'] = NULL;
292 $params['rowCount'] = CRM_Utils_Pager::ROWCOUNT;
293
294 $params['buttonTop'] = 'PagerTopButton';
295 $params['buttonBottom'] = 'PagerBottomButton';
296 }
297
298 /**
299 * Returns the column headers as an array of tuples:
300 * (name, sortName (key to the sort array))
301 *
302 * @param string $action the action being performed
303 * @param enum $output what should the result set include (web/email/csv)
304 *
305 * @return array the column headers that need to be displayed
306 * @access public
307 */
308 function &getColumnHeaders($action = NULL, $output = NULL) {
309 static $skipFields = array('group', 'tag');
310 $multipleFields = array('url');
311 $direction = CRM_Utils_Sort::ASCENDING;
312 $empty = TRUE;
313 if (!isset(self::$_columnHeaders)) {
314 self::$_columnHeaders = array(array('name' => ''),
315 array(
316 'name' => ts('Name'),
317 'sort' => 'sort_name',
318 'direction' => CRM_Utils_Sort::ASCENDING,
319 'field_name' => 'sort_name',
320 ),
321 );
322
323 $locationTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id');
324
325 foreach ($this->_fields as $name => $field) {
326 // skip pseudo fields
327 if (substr($name, 0, 9) == 'phone_ext') {
328 continue;
329 }
330
331 if (!empty($field['in_selector']) &&
332 !in_array($name, $skipFields)
333 ) {
334
335 if (strpos($name, '-') !== FALSE) {
336 $value = explode('-', $name);
337 $fieldName = CRM_Utils_Array::value(0, $value);
338 $lType = CRM_Utils_Array::value(1, $value);
339 $type = CRM_Utils_Array::value(2, $value);
340
341 if (!in_array($fieldName, $multipleFields)) {
342 if ($lType == 'Primary') {
343 $locationTypeName = 1;
344 }
345 else {
346 $locationTypeName = $locationTypes[$lType];
347 }
348
349 if (in_array($fieldName, array(
350 'phone', 'im', 'email'))) {
351 if ($type) {
352 $name = "`$locationTypeName-$fieldName-$type`";
353 }
354 else {
355 $name = "`$locationTypeName-$fieldName`";
356 }
357 }
358 else {
359 $name = "`$locationTypeName-$fieldName`";
360 }
361 }
362 else {
363 $name = "website-{$lType}-{$fieldName}";
364 }
365 }
366
367 self::$_columnHeaders[] = array(
368 'name' => $field['title'],
369 'sort' => $name,
370 'direction' => $direction,
371 'field_name' => CRM_Core_BAO_UFField::isValidFieldName($name) ? $name : $fieldName,
372 );
373
374 $direction = CRM_Utils_Sort::DONTCARE;
375 $empty = FALSE;
376 }
377 }
378
379 // if we dont have any valid columns, dont add the implicit ones
380 // this allows the template to check on emptiness of column headers
381 if ($empty) {
382 self::$_columnHeaders = array();
383 }
384 else {
385 self::$_columnHeaders[] = array('desc' => ts('Actions'));
386 }
387 }
388 return self::$_columnHeaders;
389 }
390
391 /**
392 * Returns total number of rows for the query.
393 *
394 * @param
395 *
396 * @return int Total number of rows
397 * @access public
398 */
399 function getTotalCount($action) {
400 $additionalWhereClause = 'contact_a.is_deleted = 0';
401 $additionalFromClause = NULL;
402 $returnQuery = NULL;
403
404 if ($this->_multiRecordTableName &&
405 !array_key_exists($this->_multiRecordTableName, $this->_query->_whereTables)) {
406 $additionalFromClause = CRM_Utils_Array::value($this->_multiRecordTableName, $this->_query->_tables);
407 $returnQuery = TRUE;
408 }
409
410 $countVal = $this->_query->searchQuery(0, 0, NULL, TRUE, NULL, NULL, NULL,
411 $returnQuery, $additionalWhereClause, NULL, $additionalFromClause
412 );
413
414 if (!$returnQuery) {
415 return $countVal;
416 }
417
418 if ($returnQuery) {
419 $sql = preg_replace('/DISTINCT/', '', $countVal);
420 return CRM_Core_DAO::singleValueQuery($sql);
421 }
422 }
423
424 /**
425 * Return the qill for this selector
426 *
427 * @return string
428 * @access public
429 */
430 function getQill() {
431 return $this->_query->qill();
432 }
433
434 /**
435 * Returns all the rows in the given offset and rowCount
436 *
437 * @param enum $action the action being performed
438 * @param int $offset the row number to start from
439 * @param int $rowCount the number of rows to return
440 * @param string $sort the sql string that describes the sort order
441 * @param enum $output what should the result set include (web/email/csv)
442 *
443 * @return int the total number of rows for this action
444 */
445 function &getRows($action, $offset, $rowCount, $sort, $output = NULL, $extraWhereClause = NULL) {
446
447 $multipleFields = array('url');
448 //$sort object processing for location fields
449 if ($sort) {
450 $vars = $sort->_vars;
451 $varArray = array();
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 = array();
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(array(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) {
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 = array();
519 static $skipFields = array('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, array(
552 'phone', 'im', 'email'))) {
553 if ($type) {
554 $names[] = "{$locationTypeName}-{$fieldName}-{$type}";
555 }
556 else {
557 $names[] = "{$locationTypeName}-{$fieldName}";
558 }
559 }
560 else {
561 $names[] = "{$locationTypeName}-{$fieldName}";
562 }
563 }
564 else {
565 $names[] = "website-{$id}-{$fieldName}";
566 }
567 }
568 elseif ($field['name'] == 'id') {
569 $names[] = 'contact_id';
570 }
571 else {
572 $names[] = $field['name'];
573 }
574 }
575 }
576
577
578 $multipleSelectFields = array('preferred_communication_method' => 1);
579 $multiRecordTableId = NULL;
580 if ($this->_multiRecordTableName) {
581 $multiRecordTableId = "{$this->_multiRecordTableName}_id";
582 }
583
584 // we need to determine of overlay profile should be shown
585 $showProfileOverlay = CRM_Core_BAO_UFGroup::showOverlayProfile();
586
587 while ($result->fetch()) {
588 $this->_query->convertToPseudoNames($result);
589
590 if (isset($result->country)) {
591 // the query returns the untranslated country name
592 $i18n = CRM_Core_I18n::singleton();
593 $result->country = $i18n->translate($result->country);
594 }
595 $row = array();
596 $empty = TRUE;
597 $row[] = CRM_Contact_BAO_Contact_Utils::getImage($result->contact_sub_type ?
598 $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::getDisplayValue($result->$name,
614 $cfID,
615 $this->_options,
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 = array($name => $result->$name);
639 $name = array($name => array('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, array(
664 'addressee', 'email_greeting', 'postal_greeting'))) {
665 $dname = $name . '_display';
666 $row[] = $result->$dname;
667 }
668 elseif (in_array($name, array(
669 'birth_date', 'deceased_date'))) {
670 $row[] = CRM_Utils_Date::customFormat($result->$name);
671 }
672 elseif (isset($result->$name)) {
673 $row[] = $result->$name;
674 }
675 else {
676 $row[] = '';
677 }
678
679 if (!empty($result->$name)) {
680 $empty = FALSE;
681 }
682 }
683
684 $newLinks = $links;
685 $params = array(
686 'id' => $result->contact_id,
687 'gid' => implode(',', $this->_profileIds),
688 );
689
690 // pass record id param to view url for multi record view
691 if ($multiRecordTableId && $newLinks) {
692 if ($result->$multiRecordTableId){
693 if ($newLinks[CRM_Core_Action::VIEW]['url'] == 'civicrm/profile/view') {
694 $newLinks[CRM_Core_Action::VIEW]['qs'] .= "&multiRecord=view&recordId=%%recordId%%&allFields=1";
695 $params['recordId'] = $result->$multiRecordTableId;
696 }
697 }
698 }
699
700 if ($this->_linkToUF) {
701 $ufID = CRM_Core_BAO_UFMatch::getUFId($result->contact_id);
702 if (!$ufID) {
703 unset($newLinks[CRM_Core_Action::PROFILE]);
704 }
705 else {
706 $params['ufID'] = $ufID;
707 }
708 }
709
710 $row[] = CRM_Core_Action::formLink($newLinks,
711 $mask,
712 $params,
713 ts('more'),
714 FALSE,
715 'profile.selector.row',
716 'Contact',
717 $result->contact_id
718 );
719
720 if (!$empty) {
721 $rows[] = $row;
722 }
723 }
724 return $rows;
725 }
726
727 /**
728 * Name of export file.
729 *
730 * @param string $output type of output
731 *
732 * @return string name of the file
733 */
734 function getExportFileName($output = 'csv') {
735 return ts('CiviCRM Profile Listings');
736 }
737
738 /**
739 * set the _multiRecordTableName to display the result set
740 * according to multi record custom field values
741 */
742 function setMultiRecordTableName($fields) {
743 $customGroupId = $multiRecordTableName = NULL;
744 $selectorSet = FALSE;
745
746 foreach ($fields as $field => $properties) {
747 if (!CRM_Core_BAO_CustomField::getKeyID($field)) {
748 continue;
749 }
750 if ($cgId = CRM_Core_BAO_CustomField::isMultiRecordField($field)) {
751 $customGroupId = CRM_Utils_System::isNull($customGroupId) ? $cgId : $customGroupId;
752
753 //if the field is submitted set multiRecordTableName
754 if ($customGroupId) {
755 $isSubmitted = FALSE;
756 foreach ($this->_query->_params as $key => $value) {
757 //check the query params 'where' element
758 if ($value[0] == $field) {
759 $isSubmitted = TRUE;
760 break;
761 }
762 }
763
764 if ($isSubmitted) {
765 $this->_multiRecordTableName = $multiRecordTableName =
766 CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomGroup', $customGroupId, 'table_name');
767 if ($multiRecordTableName) {
768 return;
769 }
770 }
771
772 if (!empty($properties['in_selector'])) {
773 $selectorSet = TRUE;
774 }
775 }
776 }
777 }
778
779 if (!isset($customGroupId) || !$customGroupId) {
780 return;
781 }
782
783 //if the field is in selector and not a searchable field
784 //get the proper customvalue table name
785 if ($selectorSet) {
786 $this->_multiRecordTableName = $multiRecordTableName =
787 CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomGroup', $customGroupId, 'table_name');
788 }
789 } //func close
790 }
791