2017-02-17, 11:51 PM
My plugin destroys the ability to view attachments even though it doesnt do anything with attachments.
with plugin disactivated:
[attachment=38417]
with plugin activated
[attachment=38416]
plugin
with plugin disactivated:
[attachment=38417]
with plugin activated
[attachment=38416]
plugin
<?php
// Disallow direct access to this file for security reasons
if(!defined("IN_MYBB"))
{
die("Direct initialization of this file is not allowed.<br /><br />Please make sure IN_MYBB is defined.");
}
$plugins->add_hook("parse_message", "team_mycode_run");
function customteamcodetags_info()
{
return array(
"name" => "Custom Team MyCodes",
"description" => "Custom MyCodes for team members only",
"website" => "",
"author" => "metulburr",
"authorsite" => "",
"version" => "1.0",
"guid" => "",
"compatibility" => "18*"
);
}
function my_user_permissions_check($good_groups)
{
// array-ify the list if necessary
if (!is_array($good_groups)) {
$good_groups = explode(',', $good_groups);
}
// no groups = all groups
if (empty($good_groups)) {
return true;
}
// get all the user's groups in one array
global $mybb;
$users_groups = array($mybb->user['usergroup']);
$adtl_groups = explode(',', $mybb->user['additionalgroups']);
array_merge($users_groups, $adtl_groups);
// !empty = true for allow and false for disallow
return !empty(array_intersect($users_groups, $good_groups));
}
function team_mycode_run($message)
{
global $mybb, $post;
if (my_user_permissions_check('3,4')) {
// yes
$message = preg_replace("#\[mod\](.*?)\[/mod\]#", '<code style="font-size: 1.0em; font-style: normal; line-height: 1.3em; background: #FFF; padding: 0 3px; color: black; display: inline; background:lightgrey;">Moderator: $1</code>', $message);
} else {
//no
$message = preg_replace("#\[mod\](.*?)\[/mod\]#", '$1', $message);
}
return $message;
}
?>