Skip to content

Commit

Permalink
Add backend checks for accept rules checkbox
Browse files Browse the repository at this point in the history
  • Loading branch information
CrazyHackGUT committed Oct 14, 2021
1 parent 7899878 commit a520a49
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 2 deletions.
28 changes: 28 additions & 0 deletions XF/Pub/Controller/Forum.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

/**
* This file is a part of free add-on "Forum Rules Accept".
* Developed by HLModerators.
*
* License - MIT.
*/

namespace HLModerators\ForumRulesAccept\XF\Pub\Controller;


use XF\Mvc\ParameterBag;

class Forum extends XFCP_Forum
{
protected function setupThreadCreate(\XF\Entity\Forum $forum)
{
/** @var string $rulesUrl */
$rulesUrl = $forum->hlmod_rules_url;
if (!empty($rulesUrl) && $rulesUrl !== $this->filter('hlmod_rules_url_accept', 'str,no-trim'))
{
throw $this->errorException(\XF::phrase('hlmod_forum_rules_accept.you_must_accept_rules'), 400);
}

return parent::setupThreadCreate($forum);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"from_class": "XF\\Pub\\Controller\\Forum",
"to_class": "HLModerators\\ForumRulesAccept\\XF\\Pub\\Controller\\Forum",
"execute_order": 25,
"active": true
}
3 changes: 3 additions & 0 deletions _output/class_extensions/_metadata.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
{
"XF-Admin-Controller-Forum_HLModerators-ForumRulesAccept-XF-Admin-Controller-Forum.json": {
"hash": "004a41870794b2d257393ab2d0fcce61"
},
"XF-Pub-Controller-Forum_HLModerators-ForumRulesAccept-XF-Pub-Controller-Forum.json": {
"hash": "05b5337ac132d7abb87afd8b5d912d2c"
}
}
5 changes: 5 additions & 0 deletions _output/extension_hint.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,9 @@
namespace HLModerators\ForumRulesAccept\XF\Admin\Controller
{
class XFCP_Forum extends \XF\Admin\Controller\Forum {}
}

namespace HLModerators\ForumRulesAccept\XF\Pub\Controller
{
class XFCP_Forum extends \XF\Pub\Controller\Forum {}
}
6 changes: 6 additions & 0 deletions _output/phrases/_metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,11 @@
"version_id": 1000011,
"version_string": "1.0.0 Alpha 1",
"hash": "bbee0d653e71dd07760ae09aa5575d25"
},
"hlmod_forum_rules_accept.you_must_accept_rules.txt": {
"global_cache": false,
"version_id": 1000170,
"version_string": "1.0.1",
"hash": "d78b151c7217bd689d2cdbafdcaee797"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
You must accept the rules for creating a thread
2 changes: 1 addition & 1 deletion _output/templates/_metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
"public/hlmod_forum_rules_accept_macros.html": {
"version_id": 1000170,
"version_string": "1.0.1",
"hash": "ab0db537fe5313ae97e6327c87dca7c3"
"hash": "4b06cda6bf7273646b0229d64bfa844f"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
arg-rowType="">
<xf:if is="$forum.hlmod_rules_url is not empty">
<xf:checkboxrow rowtype="{$rowType}">
<xf:option data-xf-init="disabler" data-container="{$container}" data-controls="{$controls}">
<xf:option name="hlmod_rules_url_accept" value="{$forum.hlmod_rules_url}"
data-xf-init="disabler" data-container="{$container}" data-controls="{$controls}">
{{ phrase('hlmod_forum_rules_accept.i_read_and_accept_forum_rules', {'url': $forum.hlmod_rules_url}) }}
</xf:option>
</xf:checkboxrow>
Expand Down

0 comments on commit a520a49

Please sign in to comment.