Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions plugins/TrollManagement/class.trollmanagement.plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -410,4 +410,53 @@ public function profileController_beforeProfileOptions_handler($sender) {
}
}

/**
* Check if the user creating the discussion is a troll.
*
* @param DiscussionModel $sender
* @param array $args
*/
public function discussionModel_BeforeNotification_handler(DiscussionModel $sender, array &$args) {
$discussion = $args['Discussion'];
$this->checkTroll($discussion['InsertUserID'], $args);
}

/**
* Check if the user creating the comment is a troll.
*
* @param CommentModel $sender
* @param array $args
*/
public function commentModel_BeforeNotification_handler(CommentModel $sender, array &$args) {
$comment = $args['Comment'];
$this->checkTroll($comment['InsertUserID'], $args);
}

/**
* Check if the user creating the activity post or comment is a troll.
*
* @param ActivityModel $sender
* @param array $args
*/
public function activityModel_beforeWallNotificationSend_handler(ActivityModel $sender, array &$args) {
$activity = $args['Activity'];
$this->checkTroll($activity['ActivityUserID'], $args);
}

/**
* Check if the user is a troll.
*
* @param int $userID
* @param array $args
*/
private function checkTroll(int $userID, array &$args) {
if ($args['IsValid'] === false || !isset($args['UserModel'])) {
return;
}
$userModel = $args['UserModel'];
$user = $userModel->get($userID);
if ($user && $user->Troll === 1) {
$args['IsValid'] = false;
}
}
}