Skip to content

Commit

Permalink
[4.0] Convert plugin user terms to prepared statements (#25545)
Browse files Browse the repository at this point in the history
  • Loading branch information
HLeithner authored and wilsonge committed Jul 23, 2019
1 parent f63670e commit d029939
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions plugins/user/terms/field/terms.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use Joomla\CMS\Form\FormHelper;
use Joomla\CMS\Language\Associations;
use Joomla\CMS\Language\Text;
use Joomla\Database\ParameterType;

FormHelper::loadFieldClass('radio');

Expand Down Expand Up @@ -81,9 +82,10 @@ protected function getLayoutData()
{
$db = Factory::getDbo();
$query = $db->getQuery(true)
->select($db->quoteName(array('id', 'alias', 'catid', 'language')))
->select($db->quoteName(['id', 'alias', 'catid', 'language']))
->from($db->quoteName('#__content'))
->where($db->quoteName('id') . ' = ' . (int) $termsArticle);
->where($db->quoteName('id') . ' = :id')
->bind(':id', $termsArticle, ParameterType::INTEGER);
$db->setQuery($query);
$article = $db->loadObject();

Expand All @@ -109,16 +111,16 @@ protected function getLayoutData()
}
}

$extraData = array(
'termsnote' => !empty($this->element['note']) ? $this->element['note'] : Text::_('PLG_USER_TERMS_NOTE_FIELD_DEFAULT'),
'options' => $this->getOptions(),
'value' => (string) $this->value,
'translateLabel' => $this->translateLabel,
$extraData = [
'termsnote' => !empty($this->element['note']) ? $this->element['note'] : Text::_('PLG_USER_TERMS_NOTE_FIELD_DEFAULT'),
'options' => $this->getOptions(),
'value' => (string) $this->value,
'translateLabel' => $this->translateLabel,
'translateDescription' => $this->translateDescription,
'translateHint' => $this->translateHint,
'termsArticle' => $termsArticle,
'article' => $article,
);
'translateHint' => $this->translateHint,
'termsArticle' => $termsArticle,
'article' => $article,
];

return array_merge($data, $extraData);
}
Expand Down

0 comments on commit d029939

Please sign in to comment.