Skip to content

Commit

Permalink
Added some error checking to form limit plugin, to avoid cryptic SQL
Browse files Browse the repository at this point in the history
error if the plugin is not set up correctly (like if the user element
hasn't been specified, which was tossing an SQL error).  Will not refuse
to load form, and enqueue an informative msg.
  • Loading branch information
cheesegrits committed Oct 7, 2015
1 parent bb92dc0 commit 4a2f4a7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
Expand Up @@ -36,3 +36,5 @@ PLG_FORM_LIMIT_CONDITION_DESC="Optional PHP code. If code returns false, limit i
; front end
PLG_FORM_LIMIT_ENTRIES_LEFT_MESSAGE="You have %s of %s entries remaining"
PLG_FORM_LIMIT_LIMIT_REACHED="You have reached your limit of %s records"
PLG_FORM_LIMIT_NOT_SETUP="The limit plugin is not set up correctly, cannot load form"

12 changes: 12 additions & 0 deletions plugins/fabrik_form/limit/limit.php
Expand Up @@ -62,6 +62,13 @@ private function _process()

$limit = $this->limit();
$c = $this->count();

if ($c === false)
{
JFactory::getApplication()->enqueueMessage(FText::_("PLG_FORM_LIMIT_NOT_SETUP"));

return false;
}

// Allow for unlimited
if ($limit == -1)
Expand Down Expand Up @@ -102,6 +109,11 @@ protected function count()
$fk = $params->get('limit_fk');
$fkVal = '';

if (empty($field))
{
return false;
}

if (!empty($fk))
{
$fkVal = FArrayHelper::getValue(
Expand Down

0 comments on commit 4a2f4a7

Please sign in to comment.