(2013-10-18, 08:08 PM)Yaldaram Wrote: [ -> ]Have you removed the $forum from global scope? Paste the complete "edited" code here.
<?php
/***************************************************************************
*
* cs mod plugin (/inc/plugins/cs mod.php)
* Author: DanielM
* Copyright: © 2009-2010 DanielM
*
* Website: http://mybb-il.net/
* License: license.txt
*
* this mod showing the forums as cs style
*
***************************************************************************/
if(!defined("IN_MYBB"))
die("This file cannot be accessed directly.");
require_once MYBB_ROOT."/inc/adminfunctions_templates.php";
function csmod_info()
{
return array(
"name" => "csmod",
"description" => "this mod showing the forums as cs style",
"website" => "http://mybb-il.net/",
"author" => "DanielM",
"authorsite" => "http://mybb-il.net/",
"version" => "1.0",
"guid" => "",
"compatibility" => "16*"
);
}
function csmod_activate()
{
global $db, $lang, $plugins;
// create settings group
$insertarray = array(
'name' => 'mod cs',
'title' => 'mod cs',
'description' => "the settings of the csmod",
'disporder' => 1,
'isdefault' => 0
);
$gid = $db->insert_query("settinggroups", $insertarray);
// add settings
$setting0 = array(
"sid" => NULL,
"name" => "cpl",
"title" => "cats per line",
"description" => " ",
"optionscode" => "text",
"value" => "4",
"disporder" => 1,
"gid" => $gid
);
$setting1 = array(
"sid" => NULL,
"name" => "cpl",
"title" => "Cat image",
"description" => " ",
"optionscode" => "text",
"value" => "0",
"disporder" => 1,
"gid" => $gid
);
$setting2 = array(
"sid" => NULL,
"name" => "cex",
"title" => "Expander",
"description" => " ",
"optionscode" => "text",
"value" => "0",
"disporder" => 1,
"gid" => $gid
);
$db->insert_query("settings", $setting0);
$db->insert_query("settings", $setting1);
$db->insert_query("settings", $setting2);
rebuild_settings();
// add templates
$db->update_query("templates", array("template" => $db->escape_string('<td width="{$csw}" valign="top">
<table border="0" cellspacing="{$theme[\'borderwidth\']}" cellpadding="{$theme[\'tablespace\']}" class="tborder">
<thead>
<tr>
<td colspan="2" valign="top" align="center">
{$ccc}<img src="images/catimg/{$forum[\'fid\']}.png" />{$ecc}
</td>
</tr>
<tr>
<td class="thead" colspan="2">
{$cc}
<div class="expcolimage"><img src="{$theme[\'imgdir\']}/{$expcolimage}" id="cat_{$forum[\'fid\']}_img" class="expander" alt="{$expaltext}" title="{$expaltext}" /></div>{$cce}
<div><strong><a href="{$forum_url}" title="{$forum[\'description\']}">{$forum[\'name\']}</a></strong><br />
</div>
</td>
</tr>
</thead>
<tbody style="{$expdisplay}" id="cat_{$forum[\'fid\']}_e">
{$sub_forums}
</tbody>
</table></td>
{$tr_end}')), "`title` = \"forumbit_depth1_cat\"");
$db->update_query("templates", array("template" => $db->escape_string('<tr><td class="{$bgcolor}" align="center" valign="top" width="1"><img src="{$theme[\'imgdir\']}/{$lightbulb[\'folder\']}.gif" alt="{$lightbulb[\'altonoff\']}" title="{$lightbulb[\'altonoff\']}" class="ajax_mark_read" id="mark_read_{$forum[\'fid\']}" /></td><td class="{$bgcolor}" valign="top"><strong><a href="{$forum_url}" title="{$forum[\'description\']}">{$forum[\'name\']}</a></strong></td></tr>')), "`title` = \"forumbit_depth2_forum\" OR `title` = \"forumbit_depth2_cat\"");
find_replace_templatesets("index", "#".preg_quote("{\$forums}")."#i", "<table width=\"100%\">\r\n<tr>\r\n{\$forums}\r\n</tr>\r\n</table>");
$plugins->add_hook("build_forumbits_forum", "csmodfunc");
function csmodfunc(&$forum){
global $mybb;
// CS Mod Start
$cpl = $mybb->settings['cpl'];
$c=$mybb->settings['cex'];
$catimg=$mybb->settings['catimg'];
$csw=100 / $cpl.'%';
if($forum['type'] == 'c'){
if($c==1){
$cc='<div class="hidden">';
$cce='</div>';
}else{
$cc='';
$cce='';
}
if($catimg==1){
$ccc='<!--';
$ecc='-->';
}else{
$ccc='';
$ecc='';
}
$i++;
}
if($i==$cpl){
$tr_end='</tr><tr><td colspan="'.$cpl.'"><hr></td></tr><tr>';
$i=$i-$i;
}else{
$tr_end='';
}
//CS Mod End
}
}
function csmod_deactivate()
{
global $db, $mybb;
// delete settings group
$db->delete_query("settinggroups", "name = 'mod cs'");
// remove settings
$db->delete_query('settings', 'name IN ( \'cpl\',\'cpl\',\'cex\')');
find_replace_templatesets("index", "#".preg_quote("<table width=\"100%\">\r\n<tr>\r\n{\$forums}\r\n</tr>\r\n</table>")."#i", "{\$forums}");
$db->update_query("templates", array("template" => $db->escape_string('<tr>
<td class="{$bgcolor}" align="center" valign="top" width="1"><img src="{$theme[\'imgdir\']}/{$lightbulb[\'folder\']}.gif" alt="{$lightbulb[\'altonoff\']}" title="{$lightbulb[\'altonoff\']}" class="ajax_mark_read" id="mark_read_{$forum[\'fid\']}" /></td>
<td class="{$bgcolor}" valign="top">
<strong><a href="{$forum_url}">{$forum[\'name\']}</a></strong>{$forum_viewers_text}<div class="smalltext">{$forum[\'description\']}{$modlist}{$subforums}</div>
</td>
<td class="{$bgcolor}" valign="top" align="center" style="white-space: nowrap">{$threads}{$unapproved[\'unapproved_threads\']}</td>
<td class="{$bgcolor}" valign="top" align="center" style="white-space: nowrap">{$posts}{$unapproved[\'unapproved_posts\']}</td>
<td class="{$bgcolor}" valign="top" align="right" style="white-space: nowrap">{$lastpost}</td>
</tr>')), "`title` = \"forumbit_depth2_forum\"");
$db->update_query("templates", array("template" => $db->escape_string('<tr>
<td class="{$bgcolor}" align="center" valign="top" width="1"><img src="{$theme[\'imgdir\']}/{$lightbulb[\'folder\']}.gif" alt="{$lightbulb[\'altonoff\']}" title="{$lightbulb[\'altonoff\']}" class="ajax_mark_read" id="mark_read_{$forum[\'fid\']}" /></td>
<td class="{$bgcolor}" valign="top">
<strong><a href="{$forum_url}">{$forum[\'name\']}</a></strong>{$forum_viewers_text}<div class="smalltext">{$forum[\'description\']}{$subforums}</div>
</td>
<td class="{$bgcolor}" valign="top" align="center" style="white-space: nowrap">{$threads}{$unapproved[\'unapproved_threads\']}</td>
<td class="{$bgcolor}" valign="top" align="center" style="white-space: nowrap">{$posts}{$unapproved[\'unapproved_posts\']}</td>
<td class="{$bgcolor}" valign="top" align="right" style="white-space: nowrap">{$lastpost}</td>
</tr>')), "`title` = \"forumbit_depth2_cat\"");
$db->update_query("templates", array("template" => $db->escape_string('<table border="0" cellspacing="{$theme[\'borderwidth\']}" cellpadding="{$theme[\'tablespace\']}" class="tborder">
<thead>
<tr>
<td class="thead" colspan="5">
<div class="expcolimage"><img src="{$theme[\'imgdir\']}/{$expcolimage}" id="cat_{$forum[\'fid\']}_img" class="expander" alt="{$expaltext}" title="{$expaltext}" /></div>
<div><strong><a href="{$forum_url}">{$forum[\'name\']}</a></strong><br /><div class="smalltext">{$forum[\'description\']}</div></div>
</td>
</tr>
</thead>
<tbody style="{$expdisplay}" id="cat_{$forum[\'fid\']}_e">
<tr>
<td class="tcat" colspan="2"><span class="smalltext"><strong>{$lang->forumbit_forum}</strong></span></td>
<td class="tcat" width="85" align="center" style="white-space: nowrap"><span class="smalltext"><strong>{$lang->forumbit_threads}</strong></span></td>
<td class="tcat" width="85" align="center" style="white-space: nowrap"><span class="smalltext"><strong>{$lang->forumbit_posts}</strong></span></td>
<td class="tcat" width="200" align="center"><span class="smalltext"><strong>{$lang->forumbit_lastpost}</strong></span></td>
</tr>
{$sub_forums}
</tbody>
</table>
<br />')), "`title` = \"forumbit_depth1_cat\"");
rebuild_settings();
}
?>