2010-08-26, 09:07 PM
Ok so i want to integrate myBB in my website a little. So what i had in mind was that when you create a topic in a specific forum and you're in a specific usergroup (the admin one) in the Topic Creation Page you get an additional block below Attachments that has a textarea for entering a short news message and some other options (like the news image). When this topic is created, in the database in the the row of this topic there are additional fields that have those details saved so my website can access them and for example output the short news message on the website.
Now this is what i have now:
This is what i want to display under the attachment block (for now):
Now i was checking out the newthread.php and i cant find or understand what am i supposed to do next. I'd appreciate some help from you guys
Also this will be a private plugin and will not be uploaded to the Mods database, so what do i enter in those guid and GID fields?
Now this is what i have now:
<?php
//define no direct access
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("newthread_start", "stellarnews");
function stellarnews_info()
{
return array(
"name" => "Site News Plugin",
"description" => "Posts the news on the website!",
"website" => "http://site.net",
"author" => "Fabis",
"authorsite" => "http://site.net",
"version" => "1.0",
"guid" => "",
"compatibility" => "16*"
);
}
function stellarnews_activate() {
global $db;
$group = array(
"gid" => "NULL",
"title" => "StellarHelp News Plugin",
"name" => "stellarnews",
"description" => "Posts the news on the website!",
"disporder" => "88",
"isdefault" => "0",
);
$db->insert_query("settinggroups", $group);
$gid = $db->insert_id();
//This setting turns the first bar on
$snews1 = array(
"sid" => "NULL",
"name" => "snews1",
"title" => "News Forum ID's",
"description" => "Enter the ID's of the news forums, seperated by a comma",
"optionscode" => "text",
"value" => "1",
"disporder" => "1",
"gid" => intval($gid),
);
$db->insert_query("settings", $snews1);
$snews2 = array(
"sid" => "NULL",
"name" => "snews2",
"title" => "Usergroup ID's",
"description" => "Enter the ID's of the usergroups allowed to post news, seperated by a comma",
"optionscode" => "text",
"value" => "1",
"disporder" => "2",
"gid" => intval($gid),
);
$db->insert_query("settings", $snews2);
rebuildsettings();
}
function stellarnews_deactivate() {
global $db;
$db->query("DELETE FROM ".TABLE_PREFIX."settinggroups WHERE name IN ('stellarnews')");
$db->query("DELETE FROM ".TABLE_PREFIX."settings WHERE name IN('snews1','snews2')");
rebuild_settings();
}
function stellarnews() {
$ugroups = explode(",",$mybb->settings['snews2']);
$forums = explode(",",$mybb->settings['snews1']);
$admin = false;
$inforum = false;
for ($i = 0; $i < count($ugroups); $i++) {
if ($mybb->user['usergroup'] == $ugroups[$i]) {
$admin = true;
}
}
for ($i = 0; $i < count($forums); $i++) {
if ($forum_that_user_is_posting_in == $forums[$i]) {
$inforum = true;
}
}
if ($admin && $inforum) {
//Change whatever is necessary
}
}
?>
This is what i want to display under the attachment block (for now):
<br />
<table border="0" cellspacing="{$theme['borderwidth']}" cellpadding="{$theme['tablespace']}" class="tborder">
<tr>
<td class="thead" colspan="3"><strong>Website News Post</strong></td>
</tr>
<tr>
<td class="tcat smalltext" colspan="3">Please fill out this section, so the news post will succesfully work on the website.</td>
</tr>
<tr>
<td class="trow1" width="20%"><strong>News Image</strong></td>
<td class="trow1" style="white-space: nowrap"><input type="file" name="attachment" size="30" class="fileupload" /></td><td class="trow1" align="center"><input type="submit" class="button" name="updateattachment" value="Upload Image" tabindex="12" />
</td>
</tr>
<tr>
<td class="trow2" style="vertical-align: top"><strong>News Text</strong></td>
<td class="trow2"><textarea class="textbox" name="subject" rows="6" cols="40" tabindex="1" /></textarea></td>
</tr>
<tr>
<td class="trow1" style="vertical-align: top"><strong>Select the News Image</strong><br></td>
<td class="trow1" style="vertical-align: top">
<select>
<option value="image1">Image number 1</option>
<option value="image2">Image number 2</option>
<option value="image3">Image number 3</option>
<option value="image4">Image number 4</option>
</select>
</td>
</tr>
<tr>
<td class="trow2" style="vertical-align: top"><strong>Current Image</strong></td>
<td class="trow2"><img src="/icy_test/images/news_img_test.png"></td>
</tr>
</table>
Now i was checking out the newthread.php and i cant find or understand what am i supposed to do next. I'd appreciate some help from you guys

Also this will be a private plugin and will not be uploaded to the Mods database, so what do i enter in those guid and GID fields?