Skip to content

Commit

Permalink
edge case fix for user raw prefilter not finding element and incorrec…
Browse files Browse the repository at this point in the history
…tly generating an error
  • Loading branch information
pollen8 committed Feb 14, 2014
1 parent 1c45618 commit 05b51cf
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
1 change: 1 addition & 0 deletions components/com_fabrik/language/en-GB/en-GB.com_fabrik.ini
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ COM_FABRIK_ERR_ADMIN_LIST_TMPL_IN_FRONTEND="Sorry the admin template is only for
COM_FABRIK_ERR_CURL_NOT_INSTALLED="The Curl library is not installed some parts of this page have failed to execute"
COM_FABRIK_ERR_TAB_FORM_TEMPLATE_INCOMPATIBLE_WITH_MULTIPAGE_FORMS="The tabs template is incompatible with multi page forms. Either use the bootstrap template, or ensure that all groups have their 'Page break' option turned off"
COM_FABRIK_ERR_UPLOADS_DISABLED="The installer can't continue before file uploads are enabled. Please use the install from directory method."
COM_FABRIK_ERR_PREFILTER_NOT_APPLIED="A prefilter has been set up on an unpublished element, and will not be applied: %s"
COM_FABRIK_EXACT_TERMS="Exact phrase"
COM_FABRIK_EXPORT="Export"
COM_FABRIK_EXPORT_TO_CSV="Export to CSV"
Expand Down
14 changes: 13 additions & 1 deletion components/com_fabrik/models/list.php
Original file line number Diff line number Diff line change
Expand Up @@ -5349,6 +5349,18 @@ public function getPrefilterArray(&$filters)
$tmpfilter = $raw ? FabrikString::rtrimword($filter, '_raw') : $filter;
$elementModel = JArrayHelper::getValue($elements, FabrikString::safeColName($tmpfilter), false);

if ($elementModel === false)
{
/*
* HACK!
* http://fabrikar.com/forums/index.php?threads/a-prefilter-has-been-set-up-on-an-unpublished-element.37385/#post-189201
* Complex set up of joined group which has a user element which is linked to a parent one. Raw AS field has _0 applied to its name
* For this we'll just remove that to find the correct element.
*/
$tmpfilter = str_replace('_0.', '.', $tmpfilter);
$elementModel = JArrayHelper::getValue($elements, FabrikString::safeColName($tmpfilter), false);
}

if ($elementModel === false && $condition !== 'exists')
{
// Include the JLog class.
Expand All @@ -5358,7 +5370,7 @@ public function getPrefilterArray(&$filters)
JLog::addLogger(array('text_file' => 'fabrik.log.php'));

// Start logging...
$msg = 'A prefilter has been set up on an unpublished element, and will not be applied:' . FabrikString::safeColName($tmpfilter);
$msg = JText::sprintf('COM_FABRIK_ERR_PREFILTER_NOT_APPLIED', FabrikString::safeColName($tmpfilter));
JLog::add($msg, JLog::NOTICE, 'com_fabrik');

JFactory::getApplication()->enqueueMessage($msg, 'notice');
Expand Down

0 comments on commit 05b51cf

Please sign in to comment.