$plugins->add_hook("pre_output_page", "welcome");
function welcome_info()
{
.........................................................
}
function welcome_activate()
{
require "./inc/adminfunctions_templates.php";
global $db;
find_replace_templatesets("index", '#</table>\n\n</div>\n<hr class=\"hidden\" />\n<div id=\"panel\">#', "</table>\n<table align=\"center\"><tr><td width=\"40%\">\$welcome</td></tr></table>\n</div>\n<hr class=\"hidden\" />\n<div id=\"panel\">");
$newtable = "CREATE TABLE `welcome` (
`id` INT AUTO_INCREMENT,
`gruppe` TEXT NOT NULL,
`text` LONGBLOB NOT NULL,
PRIMARY KEY (`id`)
)";
$db->query($newtable);
$welcome_group = array(
"gid" => "NULL",
"name" => "Wilkommensnachricht",
"description" => "",
"disporder" => "1",
"isdefault" => "no",
);
$db->insert_query(TABLE_PREFIX."settinggroups", $welcome_group);
$gid = $db->insert_id();
// Benutzergruppen auslesen
$query = $db->query("SELECT gid,title FROM ".TABLE_PREFIX."usergroups");
// Nachricht und Option für jede Benutzergruppe erstellen
$i = "1";
while($usergroups = $db->fetch_array($query))
{
// Optionsschalter Ja/Nein
$welcome = array(
"sid" => "NULL",
"name" => "welcome_yesno_".$usergroups['gid']."",
"title" => "Willkommensnachricht für die Gruppe ".$usergroups['title']." zeigen?",
"description" => "Soll der Gruppe ".$usergroups['title']." eine Nachricht gezeigt werden?",
"optionscode" => "yesno",
"value" => "no",
"disporder" => $i,
"gid" => intval($gid),
);
$db->insert_query(TABLE_PREFIX."settings", $welcome);
$i++;
// Nachricht
$welcome2 = array(
"sid" => "NULL",
"name" => "welcome_message_".$usergroups['gid']."",
"title" => "Willkommensnachricht für die Gruppe ".$usergroups['title']."",
"description" => "Die Nachricht für die Gruppe ".$usergroups['title'].".",
"optionscode" => "textarea",
"value" => "",
"disporder" => $i,
"gid" => intval($gid),
);
$db->insert_query(TABLE_PREFIX."settings", $welcome2);
$i++;
}
}
function welcome_deactivate()
{
require "./inc/adminfunctions_templates.php";
global $db;
$drop = "DROP TABLE `welcome`;";
$db->query($drop);
$query = $db->query("SELECT gid FROM ".TABLE_PREFIX."settinggroups WHERE name='Wilkommensnachricht'");
$g = $db->fetch_array($query);
$db->query("DELETE FROM ".TABLE_PREFIX."settinggroups WHERE gid='".$g['gid']."'");
$db->query("DELETE FROM ".TABLE_PREFIX."settings WHERE gid='".$g['gid']."'");
find_replace_templatesets("index", '</table>\n<table align=\"center\"><tr><td width=\"40%\">\$welcome</td></tr></table>\n</div>\n<hr class=\"hidden\" />\n<div id=\"panel\">#</table>\n\n</div>\n<hr class=\"hidden\" />\n<div id=\"panel\">#', "#</table>\n\n</div>\n<hr class=\"hidden\" />\n<div id=\"panel\">#");
}
function welcome_world($welcome)
{
global $db, $mybb, $cache, $templates, $lang, $overview;
$result =$db->query("SELECT 'text' FROM 'welcome' WHERE 'gruppe='".$mybb->user['gid']."'");
$row = (fetch_array($result, MYSQL_BOTH));
$welcome.= "<h2>".$row."</h2>";
}