<?php
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("postbit", "show_additional");
$plugins->add_hook("member_profile_end", "profile_additional");
function show_usergroups_info()
{
return array(
"name" => "SA-Groups",
"description" => "Shows additional groupimages on profiles and posts.",
"website" => "N/A",
"author" => "Mr Josh",
"authorsite" => "http://inkbuild.com",
"version" => "1.1.1",
"compatibility" => "16*",
"guid" => "aaa37e798d91627e86452a5f310b744c");
}
function profile_additional()
{
global $memprofile, $groupimage, $cache, $mybb;
if ($mybb->settings["display_in_profiles"] == 1) {
$read = $cache->read("usergroups");
$split_additional = explode(",", $memprofile["additionalgroups"]);
foreach ($split_additional as $group) {
$group_info = $read[$group];
$groupimage .= "<img src=\"$group_info[image]\" alt=\"\" title=\"$group_info[title]\" /><br />";
}
}
}
function show_additional(&$post)
{
global $cache, $mybb;
if ($mybb->settings["show_usergroups_plugin_display"] == 1) {
$group_info = $cache->read("usergroups");
$split_additional = explode(",", $post["additionalgroups"]);
$normal_group = $group_info[$post["usergroup"]];
$post["groupimage"] = "<img src=\"$normal_group[image]\" title=\"$normal_group[title]\" alt=\"\" /><br />";
$post["groupimage"] .= ($mybb->user["classicpostbit"] == 1) || ($mybb->user["uid"] == 0 && $mybb->settings["postlayout"] == "classic") ? "<br />" : "";
foreach ($split_additional as $i) {
$group_up = $group_info[$i];
$post["groupimage"] .= "<img src=\"$group_up[image]\" title=\"$group_up[title]\" alt=\"\" /><br />";
$post["groupimage"] .= ($mybb->user["classicpostbit"] == 1) || ($mybb->user["uid"] == 0 && $mybb->settings["postlayout"] == "classic") ? "<br />" : "";
}
}
}
function show_usergroups_activate()
{
global $db;
$classic_user_groups = array(
"gid" => "NULL",
"name" => "show_usergroups_plugin",
"title" => "SA-Groups",
"description" => "",
"disporder" => "1",
"isdefault" => "no");
$db->insert_query("settinggroups", $classic_user_groups);
$gid = $db->insert_id();
$classic_user_groups_setting = array(
"name" => "show_usergroups_plugin_display",
"title" => "Enable/Disable plugin",
"description" => "",
"optionscode" => "yesno",
"value" => "1",
"disporder" => "1",
"gid" => intval($gid));
$display_in_profiles = array(
"name" => "display_in_profiles",
"title" => "Enable/Disable plugin for profiles",
"description" => "Adds additional groupimages to profiles",
"optionscode" => "yesno",
"value" => "0",
"disporder" => "1",
"gid" => intval($gid));
$db->insert_query("settings", $classic_user_groups_setting);
$db->insert_query("settings", $display_in_profiles);
rebuild_settings();
}
function show_usergroups_deactivate()
{
global $db;
$db->query("DELETE FROM " . TABLE_PREFIX .
"settings WHERE `name` IN('show_usergroups_plugin_display', 'display_in_profiles')");
$db->query("DELETE FROM " . TABLE_PREFIX .
"settinggroups WHERE `name` = 'show_usergroups_plugin'");
rebuild_settings();
}
?>