Skip to content

Commit

Permalink
4.2.0 (#1)
Browse files Browse the repository at this point in the history
* adapt to 4.2.0

* minor improvement
  • Loading branch information
vbezruchkin authored Aug 30, 2018
1 parent d33e9f2 commit 2dc41a5
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 47 deletions.
5 changes: 5 additions & 0 deletions docs/changelog.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
<ul>
<li>4.2.0
<ul>
<li>Adapted for Subrion 4.2</li>
</ul>
</li>
<li>4.0.0
<ul>
<li>Adapted for Subrion 4.0</li>
Expand Down
48 changes: 22 additions & 26 deletions includes/hook.check-field.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,32 +24,28 @@
*
******************************************************************************/

if (in_array($value['type'], array(iaField::TEXT, iaField::TEXTAREA)))
{
static $badWordsRegExp;
if (in_array($field['type'], [iaField::TEXT, iaField::TEXTAREA])) {

if (is_null($badWordsRegExp))
{
$list = explode(',', $iaCore->get('bad_word_list'));
$array = array();
foreach ($list as $word)
{
if ($word = trim($word))
{
$array[] = '\b' . preg_quote($word) . '\b';
}
}
empty($array) || $array = array_unique($array);
$badWordsRegExp = $array ? '/' . implode('|', $array) . '/i' : '';
}
static $badWordsRegExp;

if ($badWordsRegExp)
{
$matches = array();
if (preg_match_all($badWordsRegExp, $item, $matches))
{
$error = true;
$msg[] = iaLanguage::getf('error_bad_words', array('field' => iaLanguage::get('field_' . $field_name), 'words' => implode(', ', $matches[0])));
}
}
if (is_null($badWordsRegExp)) {
$list = explode(',', $iaCore->get('bad_word_list'));
$array = [];
foreach ($list as $word) {
if ($word = trim($word)) {
$array[] = '\b' . preg_quote($word) . '\b';
}
}
empty($array) || $array = array_unique($array);
$badWordsRegExp = $array ? '/' . implode('|', $array) . '/i' : '';
}


if ($badWordsRegExp) {
$matches = array();

if (preg_match_all($badWordsRegExp, $value, $matches)) {
$errors[] = iaLanguage::getf('error_bad_words', array('field' => iaLanguage::get('field_' . $field['item'] . '_' . $field['name']), 'words' => implode(', ', $matches[0])));
}
}
}
42 changes: 21 additions & 21 deletions install.xml
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
<?xml version="1.0" encoding="utf-8" ?>
<plugin name="badwords">
<title>Bad Words</title>
<summary>Bad Words filter for packages items and members fields like text and textarea.</summary>
<author>Intelliants LLC</author>
<contributor>Intelliants LLC</contributor>
<version>4.0.0</version>
<date>2016-01-05</date>
<compatibility>4.0</compatibility>
<module name="badwords" type="plugin">
<title>Bad Words</title>
<summary>Bad Words filter for packages items and members fields like text and textarea.</summary>
<author>Intelliants LLC</author>
<contributor>Intelliants LLC</contributor>
<version>4.2.0</version>
<date>2018-08-30</date>
<compatibility>4.2</compatibility>

<hooks>
<hook name="phpParsePostAfterCheckField" filename="plugins/badwords/includes/hook.check-field.php"><![CDATA[]]></hook>
</hooks>
<hooks>
<hook name="phpParsePostAfterCheckField" filename="hook.check-field.php"><![CDATA[]]></hook>
</hooks>

<phrases>
<phrase key="error_bad_words" category="common">":field" field contains restricted words (:words).</phrase>
</phrases>
<phrases>
<phrase key="error_bad_words" category="common">":field" field contains restricted words (:words).</phrase>
</phrases>

<configgroup name="bad_words">Bad words</configgroup>
<configgroup name="bad_words">Bad words</configgroup>

<config group="bad_words" name="bad_word_divider1" type="divider">Options</config>
<config group="bad_words" name="bad_word_list" type="textarea" description="List of restricted words">
<![CDATA[
<config group="bad_words" name="bad_word_divider1" type="divider">Options</config>
<config group="bad_words" name="bad_word_list" type="textarea" description="List of restricted words">
<![CDATA[
anus,
arse,
arsehole,
Expand Down Expand Up @@ -333,6 +333,6 @@ unclefucker,
vagina,
wank,
whore
]]>
</config>
</plugin>
]]>
</config>
</module>

0 comments on commit 2dc41a5

Please sign in to comment.