-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Added support for XFRM (#1) - Move check of accepting rules into ControllerPlugin - Fix issue with possible calls `setupThreadCreate()` from another actions: now used `actionPostThread()` method - Event listener for entity structure now listens all entity structures, but modifies structure only for required entities - Added event listener for addon post install
- Loading branch information
1 parent
a520a49
commit 9b27abf
Showing
25 changed files
with
332 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
|
||
/** | ||
* This file is a part of free add-on "Forum Rules Accept". | ||
* Developed by HLModerators. | ||
* | ||
* License - MIT. | ||
*/ | ||
|
||
namespace HLModerators\ForumRulesAccept\ControllerPlugin; | ||
|
||
|
||
use XF\ControllerPlugin\AbstractPlugin; | ||
use XF\Mvc\Entity\Entity; | ||
use XF\Mvc\FormAction; | ||
|
||
class SubforumRules extends AbstractPlugin | ||
{ | ||
/** | ||
* Performs checking user accept with subforum rules. | ||
* | ||
* @param Entity $entity | ||
*/ | ||
public function assertRulesIsAccepted(Entity $entity): void | ||
{ | ||
/** @var string $rulesUrl */ | ||
$rulesUrl = $entity->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); | ||
} | ||
} | ||
|
||
/** | ||
* Append the operation for saving the subforum rules URL to entity | ||
* to already created form action object. | ||
* | ||
* @param FormAction $formAction | ||
* @param Entity $entity | ||
*/ | ||
public function setupSaveUrl(FormAction $formAction, Entity $entity): void | ||
{ | ||
$formAction->setupEntityInput($entity, [ | ||
'hlmod_rules_url' => $this->filter('hlmod_rules_url', 'str') | ||
]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
/** | ||
* This file is a part of free add-on "Forum Rules Accept". | ||
* Developed by HLModerators. | ||
* | ||
* License - MIT. | ||
*/ | ||
|
||
namespace HLModerators\ForumRulesAccept\XFRM\Admin\Controller; | ||
|
||
|
||
class Category extends XFCP_Category | ||
{ | ||
protected function categorySaveProcess(\XFRM\Entity\Category $category) | ||
{ | ||
$formAction = parent::categorySaveProcess($category); | ||
$this->plugin('HLModerators\ForumRulesAccept:SubforumRules') | ||
->setupSaveUrl($formAction, $category); | ||
|
||
return $formAction; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
/** | ||
* This file is a part of free add-on "Forum Rules Accept". | ||
* Developed by HLModerators. | ||
* | ||
* License - MIT. | ||
*/ | ||
|
||
namespace HLModerators\ForumRulesAccept\XFRM\Pub\Controller; | ||
|
||
|
||
use XF\Mvc\ParameterBag; | ||
|
||
class Category extends XFCP_Category | ||
{ | ||
public function actionAdd(ParameterBag $params) | ||
{ | ||
if ($this->isPost()) | ||
{ | ||
$nodeId = $params->resource_category_id; | ||
$node = $this->assertViewableCategory($nodeId); | ||
|
||
$this->plugin('HLModerators\ForumRulesAccept:SubforumRules') | ||
->assertRulesIsAccepted($node); | ||
} | ||
|
||
return parent::actionAdd($params); | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
...min-Controller-Category_HLModerators-ForumRulesAccept-XFRM-Admin-Controller-Category.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"from_class": "XFRM\\Admin\\Controller\\Category", | ||
"to_class": "HLModerators\\ForumRulesAccept\\XFRM\\Admin\\Controller\\Category", | ||
"execute_order": 25, | ||
"active": true | ||
} |
6 changes: 6 additions & 0 deletions
6
...M-Pub-Controller-Category_HLModerators-ForumRulesAccept-XFRM-Pub-Controller-Category.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"from_class": "XFRM\\Pub\\Controller\\Category", | ||
"to_class": "HLModerators\\ForumRulesAccept\\XFRM\\Pub\\Controller\\Category", | ||
"execute_order": 25, | ||
"active": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
{ | ||
"entity_structure_0aafc4dbdd2a0e1d7cac25a19c8598bb.json": { | ||
"hash": "9e6d77c98287490e82170fd208eb49e7" | ||
"addon_post_install_8ee79074ea27c92ea8b088fda7b15e8a.json": { | ||
"hash": "834cce9c3decfe74533e38e0c0aca806" | ||
}, | ||
"entity_structure_60416710f20a783e44a318ae7c6e8ccf.json": { | ||
"hash": "d8f51f40311eb09ff0f4bf7cc16e1240" | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
_output/code_event_listeners/addon_post_install_8ee79074ea27c92ea8b088fda7b15e8a.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"event_id": "addon_post_install", | ||
"execute_order": 25, | ||
"callback_class": "HLModerators\\ForumRulesAccept\\EventListener", | ||
"callback_method": "onAddOnInstall", | ||
"active": true, | ||
"hint": "", | ||
"description": "Listens the add-on installs for creating tables where this is required" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.