2011-07-06, 02:45 PM
In the Group Notice plugin? Currenlty my message is to many chars and I can't get it all on it.
So I want to set a maxium amount of chars, here is the 1 and only file of the mod:
So I want to set a maxium amount of chars, here is the 1 and only file of the mod:
<?php
$plugins->add_hook('admin_user_groups_edit', 'gn');
$plugins->add_hook('admin_user_groups_edit_commit', 'gn_do');
$plugins->add_hook("index_start", "gn_notice");
function gn_info()
{
return array(
'name' => 'Group Notice',
'description' => 'Allows you to set a notice displayed to certain groups.',
'website' => 'http://www.coderzplanet.net',
'author' => 'Jammerx2',
'authorsite' => 'http://www.coderzplanet.net',
'version' => '1.0',
'guid' => '7027f0d07a6a84e998eea8ef6b62bda3'
);
}
function gn_activate()
{
global $mybb, $db;
$db->query("ALTER TABLE `".TABLE_PREFIX."usergroups` ADD `gn` VARCHAR(1500) NOT NULL");
$gn = array(
"title" => "group_notice",
"template" => "<style>
.gnotice {
background: #D6ECA6;
border-top: 2px solid #8DC93E;
border-bottom: 2px solid #8DC93E;
text-align: center;
margin: 10px auto;
padding: 5px 20px;
}
</style>
<p class=\"gnotice\"><b>{\$notice}</b></p>
<br>",
"sid" => -1,
"dateline" => TIME_NOW
);
$db->insert_query("templates", $gn);
include MYBB_ROOT."/inc/adminfunctions_templates.php";
find_replace_templatesets("index", "#".preg_quote("{\$header}")."#i", "{\$header}\r\n{\$gn}");
}
function gn_deactivate()
{
global $mybb, $db;
$db->query("ALTER TABLE ".TABLE_PREFIX."usergroups DROP `gn`");
include MYBB_ROOT."/inc/adminfunctions_templates.php";
find_replace_templatesets("index", "#".preg_quote("\r\n{\$gn}")."#i", "", 0);
$db->delete_query("templates", "title = 'group_notice'");
}
function gn()
{
global $plugins;
$plugins->add_hook("admin_formcontainer_output_row", "gn_row");
}
function gn_do()
{
global $db, $mybb, $usergroup;
$update_array = array(
"gn" => $db->escape_string($mybb->input['gn']),
);
$db->update_query("usergroups", $update_array, "gid='".intval($usergroup['gid'])."'");
}
function gn_row($pluginargs)
{
global $db, $mybb, $lang, $user, $form, $form_container, $usergroup;
if($pluginargs['title'] == "Miscellaneous")
{
$gn = array(
$form->generate_text_area('gn', $usergroup['gn'], array()),
);
$form_container->output_row("Group Notice", "Set a group notice that will be displayed to members of this group.", "<div class=\"group_settings_bit\">".implode("</div><div class=\"group_settings_bit\">", $gn)."</div>");
}
}
function gn_notice()
{
global $db, $mybb, $templates, $gn, $notice;
if($mybb->usergroup['gn'] != "")
{
$notice = $mybb->usergroup['gn'];
eval("\$gn = \"".$templates->get("group_notice")."\";");
}
}
?>