Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into tb/enable-styleci
Browse files Browse the repository at this point in the history
  • Loading branch information
samerton committed Mar 8, 2024
2 parents 73d29f6 + 86a6534 commit 1e7eec4
Show file tree
Hide file tree
Showing 15 changed files with 174 additions and 22 deletions.
23 changes: 23 additions & 0 deletions core/classes/Core/Validate.php
Expand Up @@ -96,6 +96,11 @@ class Validate
*/
public const NOT_START_WITH = 'not_start_with';

/**
* @var string Check that the value does not contain a pattern
*/
public const NOT_CONTAIN = 'not_contain';

/**
* @var string Set a rate limit
*/
Expand Down Expand Up @@ -364,6 +369,24 @@ public static function check(array $source, array $items = []): Validate
}
break;

case self::NOT_CONTAIN:
if (!is_array($rule_value)) {
$rule_value = [$rule_value];
}

foreach ($rule_value as $term) {
if (strpos(strtolower($value), strtolower($term)) !== false) {
$validator->addError([
'field' => $item,
'rule' => self::NOT_CONTAIN,
'fallback' => "$item must not contain $term",
]);
break;
}
}

break;

case self::IN:
$values = is_string($rule_value) ? [$rule_value] : $rule_value;
if (!in_array($value, $values)) {
Expand Down
12 changes: 12 additions & 0 deletions custom/panel_templates/Default/forum/forums_settings.tpl
Expand Up @@ -67,6 +67,18 @@
</label>
</div>

<div class="form-group">
<label for="InputBannedTerms">
{$BANNED_TERMS}
</label>
<span class="badge badge-info">
<i class="fas fa-question-circle" data-container="body" data-toggle="popover"
data-placement="top" title="{$INFO}"
data-content="{$BANNED_TERMS_INFO}"></i>
</span>
<textarea id="InputBannedTerms" class="form-control" name="banned_terms">{$BANNED_TERMS_VALUE}</textarea>
</div>

<div class="form-group">
<input type="hidden" name="token" value="{$TOKEN}">
<input type="submit" class="btn btn-primary" value="{$SUBMIT}" />
Expand Down
2 changes: 1 addition & 1 deletion modules/Cookie Consent/language/cs_CZ.json
Expand Up @@ -7,7 +7,7 @@
"cookie/cookie_popup_disallow": "Zakázat cookies",
"cookie/cookie_popup_more_info": "Více informací",
"cookie/cookies": "Cookies",
"cookie/update_settings": "Zobrazit cookies okno",
"cookie/update_settings": "Zobrazit nastavení cookies",
"cookie/cookie_notice_error": "Zadejte prosím oznámení o cookies s maximálně 10 000 znaky.",
"cookie/cookie_popup": "Tento web používá cookies pro vylepšení vašeho zážitku."
}
19 changes: 18 additions & 1 deletion modules/Core/language/es_ES.json
Expand Up @@ -1319,5 +1319,22 @@
"admin/queue_task_output": "Resultado de la tarea",
"admin/queue_task_scheduled_at": "Programado para",
"admin/queue_task_scheduled_for": "Programado para",
"admin/queue_task_status": "Estado"
"admin/queue_task_status": "Estado",
"user/integration_linked": "Has vinculado con éxito tu cuenta de {{integration}}.",
"admin/default_description": "Descripción Predeterminada",
"admin/default_keywords": "Palabras Clave Predeterminadas",
"admin/profile_widgets": "Widgets de Perfil",
"admin/reaction_added_event_info": "Reacción añadida",
"admin/reaction_deleted_event_info": "Reacción eliminada",
"admin/site_widgets": "Widgets del Sitio",
"api/groups_updates_ignored": "La solicitud de sincronización de grupos fue ignorada, porque la integración con Minecraft está desactivada o el servidor no está configurado como el servidor de sincronización de grupos en StaffCP.",
"admin/require_two_factor_for_staffcp": "Requerir autenticación de dos factores para el inicio de sesión en StaffCP (si está habilitada para el usuario)",
"user/profile_posts_score": "Puntuación de publicaciones de perfil",
"user/reaction_score": "Puntuación de reacciones",
"user/received": "Recibido",
"user/given": "Visto",
"user/minecraft_account": "Cuenta de Minecraft",
"user/two_factor_auth_code": "Código de Autenticación de Dos Factores",
"general/on": "Encendido",
"admin/custom_score": "Puntuación Personalizada"
}
10 changes: 10 additions & 0 deletions modules/Forum/classes/Forum.php
Expand Up @@ -798,6 +798,16 @@ public static function getAccessibleLabels(array $labels, array $user_groups): a
}, []);
}

/**
* Get banned terms from the Forum module
*
* @return array Array of banned terms
*/
public static function getBannedTerms(): array {
$terms = Settings::get('banned_terms', '', 'forum');
return explode("\n", $terms);
}

/**
* Get the latest post in a "View own topic" forum
* This could be a topic created by the user, or a sticky topic
Expand Down
6 changes: 3 additions & 3 deletions modules/Forum/language/cs_CZ.json
Expand Up @@ -4,7 +4,7 @@
"forum/average_posts": "Průměrný počet příspěvků uživatele",
"forum/by": "od",
"forum/can_create_topic": "Může vytvářet témata?",
"forum/can_edit_topic": "Může upravovat svá témata??",
"forum/can_edit_topic": "Může upravovat svá témata?",
"forum/can_moderate_forum": "Může moderovat fórum?",
"forum/can_post_reply": "Může vytvářet odpovědi?",
"forum/can_view_forum": "Může zobrazit fórum?",
Expand Down Expand Up @@ -121,7 +121,7 @@
"forum/quote": "Citát",
"forum/quoted_post": "Příspěvek citován",
"forum/re": "RE: ",
"forum/read_full_post": "Přečtěte si celý příspěvek",
"forum/read_full_post": "Přečíst celý příspěvek",
"forum/recent_posts": "Poslední příspěvky",
"forum/recent_topics": "Poslední témata",
"forum/redirect_forum": "Přesměrovat fórum?",
Expand Down Expand Up @@ -150,7 +150,7 @@
"forum/topic_stuck": "Téma bylo připnuto.",
"forum/topic_title": "Název tématu",
"forum/topic_unstuck": "Téma bylo odepnuto.",
"forum/topics": "témat",
"forum/topics": "témata",
"forum/topics_title": "Témata",
"forum/total_posts": "Celkový počet příspěvků",
"forum/unfollow": "Přestat sledovat",
Expand Down
3 changes: 3 additions & 0 deletions modules/Forum/language/en_UK.json
Expand Up @@ -3,6 +3,8 @@
"forum/available_hooks": "Available Hooks",
"forum/average_posts": "Average user post count",
"forum/topic_reply": "Topic reply",
"forum/banned_terms": "Banned Terms",
"forum/banned_terms_info": "One term per line, case insensitive",
"forum/by": "by",
"forum/can_create_topic": "Can create topics?",
"forum/can_edit_topic": "Can edit their topics?",
Expand All @@ -13,6 +15,7 @@
"forum/confirm_delete_post": "Are you sure you want to delete this post?",
"forum/confirm_delete_topic": "Are you sure you want to delete this topic?",
"forum/confirm_unfollow_all_topics": "Are you sure you want to unfollow all topics?",
"forum/content_contains_banned_term": "Your post content contains a banned term",
"forum/content_max_50000": "Your post content must be no longer than 50.000 characters",
"forum/content_min_2": "Your post content must be a minimum of 2 characters",
"forum/content_required": "Please input post content",
Expand Down
5 changes: 3 additions & 2 deletions modules/Forum/language/es_ES.json
Expand Up @@ -179,9 +179,10 @@
"forum/latest_posts_limit": "Límite de las últimas publicaciones",
"forum/no_posts_found": "No se encontraron publicaciones.",
"forum/most_posts": "Más publicaciones",
"forum/highest_reaction_scores": "Puntuaciones de reacciones más altas",
"forum/highest_reaction_scores": "Puntuaciones más altas de reacciones en el foro",
"forum/reaction_score": "Puntuación de reacción",
"forum/news_items_front_page_limit": "Número de noticias a mostrar en la página principal",
"forum/news_items_max": "El número de noticias debe ser al menos {{max}}",
"forum/news_items_min": "El número de noticias debe ser como mínimo {{min}}"
"forum/news_items_min": "El número de noticias debe ser como mínimo {{min}}",
"forum/forum_score": "Puntuación en el foro"
}
4 changes: 2 additions & 2 deletions modules/Forum/language/zh_CN.json
Expand Up @@ -53,8 +53,8 @@
"forum/input_forum_title": "请输入一个论坛标题。",
"forum/insert_quotes": "插入引用",
"forum/invalid_action": "无效的行为",
"forum/invalid_redirect_url": "你已经启用了论坛重定向,但你的URL并不是有效的 1 到 512 个字符之间。",
"forum/invalid_search_query": "请输入一个在 3 和 128 个字符长度之间的关键词。",
"forum/invalid_redirect_url": "你已经启用了论坛重定向,但你的URL并不是有效的 {{min}}到 {{max}} 个字符之间。",
"forum/invalid_search_query": "请输入一个在 {{min}}和 {{max}}个字符长度之间的关键词。",
"forum/label": "标签",
"forum/label_creation_error": "创建标签时遇到了错误。 请确保名称没有超过 32 个字符并且你已指定了一个种类。",
"forum/label_creation_success": "标签创建成功。",
Expand Down
6 changes: 4 additions & 2 deletions modules/Forum/pages/forum/edit.php
Expand Up @@ -85,7 +85,8 @@
'content' => [
Validate::REQUIRED => true,
Validate::MIN => 2,
Validate::MAX => 50000
Validate::MAX => 50000,
Validate::NOT_CONTAIN => Forum::getBannedTerms(),
]
];
// Add title to validation if we need to
Expand All @@ -101,7 +102,8 @@
'content' => [
Validate::REQUIRED => $forum_language->get('forum', 'content_required'),
Validate::MIN => $forum_language->get('forum', 'content_min_2'),
Validate::MAX => $forum_language->get('forum', 'content_max_50000')
Validate::MAX => $forum_language->get('forum', 'content_max_50000'),
Validate::NOT_CONTAIN => $forum_language->get('forum', 'content_contains_banned_term'),
],
'title' => [
Validate::REQUIRED => $forum_language->get('forum', 'title_required'),
Expand Down
6 changes: 4 additions & 2 deletions modules/Forum/pages/forum/new_topic.php
Expand Up @@ -112,7 +112,8 @@
'content' => [
Validate::REQUIRED => true,
Validate::MIN => 2,
Validate::MAX => 50000
Validate::MAX => 50000,
Validate::NOT_CONTAIN => Forum::getBannedTerms(),
]
])->messages([
'title' => [
Expand All @@ -123,7 +124,8 @@
'content' => [
Validate::REQUIRED => $forum_language->get('forum', 'content_required'),
Validate::MIN => $forum_language->get('forum', 'content_min_2'),
Validate::MAX => $forum_language->get('forum', 'content_max_50000')
Validate::MAX => $forum_language->get('forum', 'content_max_50000'),
Validate::NOT_CONTAIN => $forum_language->get('forum', 'content_contains_banned_term'),
]
]);

Expand Down
6 changes: 4 additions & 2 deletions modules/Forum/pages/forum/view_topic.php
Expand Up @@ -248,13 +248,15 @@
'content' => [
Validate::REQUIRED => true,
Validate::MIN => 2,
Validate::MAX => 50000
Validate::MAX => 50000,
Validate::NOT_CONTAIN => Forum::getBannedTerms(),
]
])->messages([
'content' => [
Validate::REQUIRED => $forum_language->get('forum', 'content_required'),
Validate::MIN => $forum_language->get('forum', 'content_min_2'),
Validate::MAX => $forum_language->get('forum', 'content_max_50000')
Validate::MAX => $forum_language->get('forum', 'content_max_50000'),
Validate::NOT_CONTAIN => $forum_language->get('forum', 'content_contains_banned_term'),
]
]);

Expand Down
5 changes: 5 additions & 0 deletions modules/Forum/pages/panel/settings.php
Expand Up @@ -58,6 +58,7 @@

Settings::set('forum_reactions', (isset($_POST['use_reactions']) && $_POST['use_reactions'] == 'on') ? '1' : 0);
Settings::set('news_items_front_page', $_POST['news_items'], 'forum');
Settings::set('banned_terms', $_POST['banned_terms'], 'forum');

Session::flash('admin_forums_settings', $forum_language->get('forum', 'settings_updated_successfully'));
} else {
Expand Down Expand Up @@ -114,6 +115,10 @@
'USE_REACTIONS_VALUE' => Settings::get('forum_reactions') === '1',
'NEWS_ITEMS_ON_FRONT_PAGE' => $forum_language->get('forum', 'news_items_front_page_limit'),
'NEWS_ITEMS_ON_FRONT_PAGE_VALUE' => Settings::get('news_items_front_page', 5, 'forum'),
'BANNED_TERMS' => $forum_language->get('forum', 'banned_terms'),
'BANNED_TERMS_INFO' => $forum_language->get('forum', 'banned_terms_info'),
'BANNED_TERMS_VALUE' => Output::getClean(Settings::get('banned_terms', '', 'forum')),
'INFO' => $language->get('general', 'info'),
'PAGE' => PANEL_PAGE,
'TOKEN' => Token::get(),
'SUBMIT' => $language->get('general', 'submit')
Expand Down
20 changes: 19 additions & 1 deletion modules/Members/language/zh_CN.json
@@ -1 +1,19 @@
{}
{
"members/members": "成员",
"members/new_members": "新成员",
"members/no_members": "未找到成员。",
"members/member_lists": "成员列表",
"members/member_list_hide_banned_users": "隐藏被封禁的用户?",
"members/member_list_toggled_enabled": "成功启用了 {{list}} 列表。",
"members/member_list_toggled_disabled": "成功禁用了 {{list}} 列表。",
"members/view_all": "查看全部",
"members/find_member": "查找成员",
"members/viewable_groups": "可查看的组",
"members/no_results_header": "未找到结果",
"members/no_results_text": "你的搜索没有返回任何结果",
"members/no_overview_lists_enabled": "未启用概览列表。",
"members/settings_updated_successfully": "设置已成功更新。",
"members/name": "名称...",
"members/view_group": "查看成员列表",
"members/group": "组..."
}
69 changes: 63 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 1e7eec4

Please sign in to comment.