Fix right, only super admin can change min length of comment to filter
This commit is contained in:
parent
12779f437d
commit
08d5ac715e
@ -16,15 +16,15 @@ if (!defined('DC_RC_PATH')) {
|
||||
}
|
||||
|
||||
$this->registerModule(
|
||||
"dcFilterDuplicate",
|
||||
"Duplicate filter",
|
||||
"Antispam for duplicate comments on multiblog",
|
||||
"Jean-Christian Denis, Pierre Van Glabeke",
|
||||
'0.8',
|
||||
[
|
||||
'requires' => [['core', '2.19']],
|
||||
'permissions' => 'admin',
|
||||
'priority' => 200,
|
||||
'type' => 'plugin',
|
||||
'dc_min' => '2.19',
|
||||
'support' => 'http://forum.dotclear.org/viewtopic.php?pid=332947#p332947',
|
||||
'details' => 'http://plugins.dotaddict.org/dc2/details/dcFilterDuplicate',
|
||||
'repository' => 'https://raw.githubusercontent.com/JcDenis/dcFilterDuplicate/master/dcstore.xml'
|
||||
|
@ -16,7 +16,6 @@ if (!defined('DC_CONTEXT_ADMIN')) {
|
||||
}
|
||||
|
||||
# -- Module specs --
|
||||
$dc_min = '2.6';
|
||||
$mod_id = 'dcFilterDuplicate';
|
||||
$mod_conf = [[
|
||||
'dcfilterduplicate_minlen',
|
||||
@ -31,12 +30,15 @@ try {
|
||||
if (version_compare(
|
||||
$core->getVersion($mod_id),
|
||||
$core->plugins->moduleInfo($mod_id, 'version'),
|
||||
'>=')) {
|
||||
'>='
|
||||
)) {
|
||||
return null;
|
||||
}
|
||||
# Check Dotclear version
|
||||
$dc_min = $this->modules[$mod_id]['requires'][0][1];
|
||||
if (!method_exists('dcUtils', 'versionsCompare')
|
||||
|| dcUtils::versionsCompare(DC_VERSION, $dc_min, '<', false)) {
|
||||
|| dcUtils::versionsCompare(DC_VERSION, $dc_min, '<', false)
|
||||
) {
|
||||
throw new Exception(sprintf(
|
||||
'%s requires Dotclear %s', $mod_id, $dc_min
|
||||
));
|
||||
|
@ -22,7 +22,7 @@ if (!defined('DC_RC_PATH')) {
|
||||
*/
|
||||
class dcFilterDuplicate extends dcSpamFilter
|
||||
{
|
||||
public $name = 'Duplicate comment filter';
|
||||
public $name = 'Duplicate filter';
|
||||
public $has_gui = true;
|
||||
|
||||
protected function setInfo()
|
||||
@ -36,7 +36,7 @@ class dcFilterDuplicate extends dcSpamFilter
|
||||
if ($type != 'comment') {
|
||||
return null;
|
||||
}
|
||||
if (strlen($content) < abs((integer) $this->core->blog->settings->dcFilterDuplicate->dcfilterduplicate_minlen)) {
|
||||
if (strlen($content) < abs((integer) $this->core->blog->settings->dcFilterDuplicate->getGlobal('dcfilterduplicate_minlen'))) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -84,28 +84,45 @@ class dcFilterDuplicate extends dcSpamFilter
|
||||
|
||||
public function gui($url)
|
||||
{
|
||||
if (isset($_POST['dcfilterduplicate_minlen'])) {
|
||||
$this->core->blog->settings->dcFilterDuplicate->put(
|
||||
'dcfilterduplicate_minlen',
|
||||
abs((integer) $_POST['dcfilterduplicate_minlen']),
|
||||
'integer'
|
||||
);
|
||||
dcPage::addSuccessNotice(__('Configuration successfully updated.'));
|
||||
http::redirect($url);
|
||||
}
|
||||
if ($this->core->auth->isSuperAdmin()) {
|
||||
$this->core->blog->settings->dcFilterDuplicate->drop('dcfilterduplicate_minlen');
|
||||
if (isset($_POST['dcfilterduplicate_minlen'])) {
|
||||
$this->core->blog->settings->dcFilterDuplicate->put(
|
||||
'dcfilterduplicate_minlen',
|
||||
abs((integer) $_POST['dcfilterduplicate_minlen']),
|
||||
'integer',
|
||||
'Minimum lenght of comment to filter',
|
||||
true,
|
||||
true
|
||||
);
|
||||
dcPage::addSuccessNotice(__('Configuration successfully updated.'));
|
||||
http::redirect($url);
|
||||
}
|
||||
|
||||
return
|
||||
'<form action="' . html::escapeURL($url) . '" method="post">' .
|
||||
'<p><label class="classic">' . __('Minimum content length before check for duplicate:') . '<br />' .
|
||||
form::field(
|
||||
['dcfilterduplicate_minlen'],
|
||||
65,
|
||||
255,
|
||||
abs((integer) $this->core->blog->settings->dcFilterDuplicate->dcfilterduplicate_minlen)
|
||||
) . '</label></p>' .
|
||||
'<p><input type="submit" name="save" value="' . __('Save') . '" />' .
|
||||
$this->core->formNonce() . '</p>' .
|
||||
'</form>';
|
||||
return
|
||||
'<form action="' . html::escapeURL($url) . '" method="post">' .
|
||||
'<p><label class="classic">' . __('Minimum content length before check for duplicate:') . '<br />' .
|
||||
form::field(
|
||||
['dcfilterduplicate_minlen'],
|
||||
65,
|
||||
255,
|
||||
$this->getMinlength(),
|
||||
) . '</label></p>' .
|
||||
'<p><input type="submit" name="save" value="' . __('Save') . '" />' .
|
||||
$this->core->formNonce() . '</p>' .
|
||||
'</form>';
|
||||
} else {
|
||||
return
|
||||
'<p class="info">' . sprintf(
|
||||
__('Super administrator set the minimum length of comment content to %d chars.'),
|
||||
$this->getMinlength()
|
||||
) . '</p>';
|
||||
}
|
||||
}
|
||||
|
||||
private function getMinLength()
|
||||
{
|
||||
return abs((integer) $this->core->blog->settings->dcFilterDuplicate->getGlobal('dcfilterduplicate_minlen'));
|
||||
}
|
||||
|
||||
public function triggerOtherBlogs($content, $ip)
|
||||
|
@ -1,8 +1,8 @@
|
||||
<?php
|
||||
// Language: Français
|
||||
// Module: dcFilterDuplicate - 0.7
|
||||
// Date: 2021-08-27 15:14:22
|
||||
// Translated with dcTranslater - 2021.08.18
|
||||
// Module: dcFilterDuplicate - 0.8
|
||||
// Date: 2021-09-15 19:57:37
|
||||
// Translated with dcTranslater - 2021.09.02.1
|
||||
|
||||
#inc/class.filter.duplicate.php:30
|
||||
$GLOBALS['__l10n']['Duplicate'] = 'Doublons';
|
||||
@ -10,9 +10,13 @@ $GLOBALS['__l10n']['Duplicate'] = 'Doublons';
|
||||
#inc/class.filter.duplicate.php:31
|
||||
$GLOBALS['__l10n']['Same comments on others blogs of a multiblog'] = 'Commentaires identiques sur les autres blogs du multiblog';
|
||||
|
||||
#inc/class.filter.duplicate.php:99
|
||||
#inc/class.filter.duplicate.php:104
|
||||
$GLOBALS['__l10n']['Minimum content length before check for duplicate:'] = 'Longueur minimum du contenu pour faire une vérification :';
|
||||
|
||||
$GLOBALS['__l10n']['Duplicate comment filter'] = 'Filtre de doublon de commentaires';
|
||||
#inc/class.filter.duplicate.php:117
|
||||
$GLOBALS['__l10n']['Super administrator set the minimum length of comment content to %d chars.'] = 'Un super administrateur a régler la longueur minimum d\'un commentaire à surveiller à %d caractères.';
|
||||
|
||||
$GLOBALS['__l10n']['Antispam for duplicate comments on multiblog'] = 'Antispam contre les doublons de commentaires sur un multiblog';
|
||||
|
||||
$GLOBALS['__l10n']['Duplicate filter'] = 'Filtre de doublons';
|
||||
|
||||
$GLOBALS['__l10n']['Antispam for duplicate comments on multiblog'] = 'Antispam contre les doublons de commentaires sur un multiblog';
|
@ -1,14 +1,14 @@
|
||||
# Language: Français
|
||||
# Module: dcFilterDuplicate - 0.7
|
||||
# Date: 2021-08-27 15:14:22
|
||||
# Translated with translater 2021.08.18
|
||||
# Module: dcFilterDuplicate - 0.8
|
||||
# Date: 2021-09-15 19:57:37
|
||||
# Translated with translater 2021.09.02.1
|
||||
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Project-Id-Version: dcFilterDuplicate 0.7\n"
|
||||
"Project-Id-Version: dcFilterDuplicate 0.8\n"
|
||||
"POT-Creation-Date: \n"
|
||||
"PO-Revision-Date: 2021-08-27T15:14:22+00:00\n"
|
||||
"PO-Revision-Date: 2021-09-15T19:57:37+00:00\n"
|
||||
"Last-Translator: Jean-Christian Denis\n"
|
||||
"Language-Team: \n"
|
||||
"MIME-Version: 1.0\n"
|
||||
@ -23,13 +23,17 @@ msgstr "Doublons"
|
||||
msgid "Same comments on others blogs of a multiblog"
|
||||
msgstr "Commentaires identiques sur les autres blogs du multiblog"
|
||||
|
||||
#: inc/class.filter.duplicate.php:99
|
||||
#: inc/class.filter.duplicate.php:104
|
||||
msgid "Minimum content length before check for duplicate:"
|
||||
msgstr "Longueur minimum du contenu pour faire une vérification :"
|
||||
|
||||
msgid "Duplicate comment filter"
|
||||
msgstr "Filtre de doublon de commentaires"
|
||||
#: inc/class.filter.duplicate.php:117
|
||||
msgid "Super administrator set the minimum length of comment content to %d chars."
|
||||
msgstr "Un super administrateur a régler la longueur minimum d'un commentaire à surveiller à %d caractères."
|
||||
|
||||
msgid "Antispam for duplicate comments on multiblog"
|
||||
msgstr "Antispam contre les doublons de commentaires sur un multiblog"
|
||||
|
||||
msgid "Duplicate filter"
|
||||
msgstr "Filtre de doublons"
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user