################################################################
## MOD Title:    
## MOD Author: _Xz_ 
##
## Installation Level: Easy
## Installation Time: 5 Minutes
################################################################

#
#-----[ SQL ]------------------------------------------
#
ALTER TABLE `bb_forums` ADD `forum_icon` VARCHAR( 100 ) DEFAULT '0' NOT NULL AFTER `forum_name` ;

#
#-----[ OPEN ]------------------------------------------
#
admin/admin_forums.php

#
#-----[ FIND ]------------------------------------------
#
$show_main_page = false;

#
#-----[ AFTER, ADD ]------------------------------------------
#

$dir = $bb_cfg['dir_forum_icon'];

#
#-----[ FIND ]------------------------------------------
#
				$forumname = $row['forum_name'];

#
#-----[ AFTER, ADD ]------------------------------------------
#
				
				$forum_icon = $row['forum_icon'];
				

#
#-----[ FIND ]------------------------------------------
#
				$buttonvalue = $lang['CREATE_FORUM'];

#
#-----[ AFTER, ADD ]------------------------------------------
#
				// Forum icon
				$forum_icon = 0;
				// Forum icon [END]
#
#-----[ FIND ]------------------------------------------
#
			$forum_display_sort_list = get_forum_display_sort_option($forum_display_sort, 'list', 'sort');

#
#-----[ BEFORE, ADD ]------------------------------------------
#
			// Forum icon
			$dir_open = @opendir($dir);
			while($file = @readdir($dir_open))
			{
				if( !preg_match('#^new_#i', $file) && !@is_dir(phpbb_realpath($dir . $file)) && ($file != 'blank.gif') )
				{
					$img_size = @getimagesize($dir . $file);

					if( $img_size[0] && $img_size[1] )
					{
						$icon_images[] = $file;
					}
				}
			}
			@closedir($dir_open);

            $icon_selected = ( isset($forum_icon) ) ? '' : HTML_SELECTED;
			$icon_select = "<select name=\"forum_icon\" onChange=\"document.images['forum_icon_img'].src = '". $dir ."' + this.value;\" >";
			$icon_select .= '<option value="0">' . $lang['Select_icon'] . '</option>';
			for( $i = 0; $i < count($icon_images); $i++ )
			{
				if( $icon_images[$i] == $forum_icon )
				{
					$icon_selected = HTML_SELECTED;
                    $icon_edit_img = $icon_images[$i];
				}
				else
				{
					$icon_selected = '';
					$icon_edit_img = 'blank.gif';
				}

				$icon_select .= '<option value="'. $icon_images[$i] .'"'. $icon_selected .'>'. $icon_images[$i] .'</option>';
			}
			$icon_select .= '</select>';
			// Forum icon [END]

#
#-----[ FIND ]------------------------------------------
#
				'SHOW_ON_INDEX' => $show_on_index,

#
#-----[ BEFORE, ADD ]------------------------------------------
#
				// Forum icon
				'ICON_SELECT' => $icon_select,
				'ICON_IMG'       => $dir . $icon_edit_img,
				// Forum icon [END]

#
#-----[ FIND ]------------------------------------------
#
#    2 ,      ,  214 
#
			$forum_name = DB()->escape(trim($_POST['forumname']));

#
#-----[ AFTER, ADD ]------------------------------------------
#

            // Forum icon
           $forum_icon = addslashes(trim($_POST['forum_icon']));
            // Forum icon [END]

#
#-----[ FIND ]------------------------------------------
#
			$columns = ' forum_name,   cat_id

#
#-----[ IN_LINE, ADD ]------------------------------------------
#
,   forum_icon

#
#-----[ FIND ]------------------------------------------
#
			$values = "'$forum_name', $cat_id

#
#-----[ IN_LINE, ADD ]------------------------------------------
#
, '$forum_icon'

#
#-----[ FIND ]------------------------------------------
#
#    2 ,     ,  283 
#
			$forum_name = DB()->escape(trim($_POST['forumname']));

#
#-----[ AFTER, ADD ]------------------------------------------
#

			// Forum icon
			$forum_icon = addslashes(trim($_POST['forum_icon']));
			// Forum icon [END]

#
#-----[ FIND ]------------------------------------------
#
DB()->query("
				UPDATE ". BB_FORUMS ." SET
					forum_name    = '$forum_name',
					cat_id        = $cat_id,
#
#-----[ AFTER, ADD ]------------------------------------------
#
					forum_icon    = '$forum_icon',

#
#-----[ FIND ]------------------------------------------
#
						'FORUM_NAME' => htmlCHR($forum_rows[$j]['forum_name']),

#
#-----[ AFTER, ADD ]------------------------------------------
#
						// Forum icon
						'FORUM_ICON' => ($forum_rows[$j]['forum_icon']) ? $dir . $forum_rows[$j]['forum_icon'] : $images['forum'],
						// Forum icon [END]

#
#-----[ OPEN ]------------------------------------------
#
includes/datastore/build_cat_forums.php

#
#-----[ FIND ]------------------------------------------
#
$forum_store_fields += array_flip(array(
  'forum_id',
  'cat_id',
  'forum_name',

#
#-----[ AFTER, ADD ]------------------------------------------
#
  'forum_icon',

#
#-----[ OPEN ]------------------------------------------
#
lang/lang_russian/lang_admin.php

#
#-----[ FIND ]------------------------------------------
#
$lang['FORUM_NAME'] = ' ';

#
#-----[ AFTER, ADD ]------------------------------------------
#
$lang['Forum_icons'] = ' ';
$lang['FORUM_ICON'] = ' ';
$lang['Select_icon'] = ' ';

#
#-----[ OPEN ]------------------------------------------
#
config_mods.php

#
#-----[ ADD ]------------------------------------------
#
$bb_cfg['dir_forum_icon'] = BB_ROOT .'templates/default/images/forum_icons/';

#
#-----[ OPEN ]------------------------------------------
#
index.php

#
#-----[ FIND ]------------------------------------------
#
$sql = "
    SELECT SQL_CACHE
         f.cat_id, f.forum_id

#
#-----[ IN-LINE, ADD ]------------------------------------------
#
, f.forum_icon

#
#-----[ FIND ]------------------------------------------
#
		$f =& $forums['f'][$forum_id];

#
#-----[ AFTER, ADD ]------------------------------------------
#
		// Forum icon
		$row['forum_icon']   = $f['forum_icon'];
		// Forum icon [END]

#
#-----[ FIND ]------------------------------------------
#
		$folder_image = ($is_sf) ? $images["icon_minipost{$new}"] : $images["forum{$new}"];

#
#-----[ AFTER, ADD ]------------------------------------------
#
		// Forum icon
	
		$dir = $bb_cfg['dir_forum_icon'];
		$forum_icon = ($is_sf) ? $dir .'new_'. stripslashes($f['forum_icon']) : $dir . stripslashes($f['forum_icon']);

		$folder_image = ($f['forum_icon']) ? $forum_icon : $folder_image;
		// Forum icon [END]

#
#-----[ OPEN ]------------------------------------------
#
viewforum.php

#
#-----[ FIND ]------------------------------------------
#
	$sql = "
		SELECT
			f.forum_id

#
#-----[ IN-LINE, ADD ]------------------------------------------
#
, f.forum_icon

#
#-----[ FIND ]------------------------------------------
#
		else if (is_unread($sf_data['topic_last_post_time'], $sf_last_tid, $sf_forum_id))
		{
			$folder_image = $images['forum_new'];
		}

#
#-----[ BEFORE, ADD ]------------------------------------------
#
		// Forum icon
		else if ($sf_data['forum_icon'])
		{
			$dir = $bb_cfg['dir_forum_icon'];
			$folder_image = (is_unread($sf_data['topic_last_post_time'], $sf_last_tid, $sf_forum_id)) ? $dir .'new_'. $sf_data['forum_icon'] : $dir . $sf_data['forum_icon'];
		}
		// Forum icon [END]

#
#-----[ OPEN ]------------------------------------------
#
templates/admin/admin_forums.tpl

#
#-----[ FIND ]------------------------------------------
#
	<tr>
         <td class="row1">{L_FORUM_NAME}</td>
         <td class="row2"><input style="width: 96%;" type="text" name="forumname" value="{FORUM_NAME}" class="post" /></td>
    </tr>


#
#-----[ AFTER, ADD ]------------------------------------------
#
	<tr>
         <td class="row1">{L_FORUM_ICON}</td>
         <td class="forum_icon row2" style="height: 40px;">
              {ICON_SELECT}&nbsp;<img src="{ICON_IMG}" align="absmiddle" name="forum_icon_img"></td>
         </td>
    </tr>

#
#-----[ FIND ]------------------------------------------
#

<form method="post" action="{S_FORUM_ACTION}">
{SID_HIDDEN}

<!-- BEGIN catrow -->
<table class="forumline">
    <tr class="row3">
         <td class="tCenter"><a class="gen" title="{L_MOVE_UP}" href="{catrow.U_CAT_MOVE_UP}"><b>&nbsp;&#8593;&nbsp;</b></a><a class="gen" title="{L_MOVE_DOWN}" href="{catrow.U_CAT_MOVE_DOWN}"><b>&nbsp;&#8595;&nbsp;</b></a></td>

#
#-----[ FIND ]------------------------------------------
#
		<td colspan="5" width="100%" class="nowrap">


#-----[ REPLACE ]------------------------------------------
#
		<td colspan="6" width="100%" class="nowrap">

#
#-----[ FIND ]------------------------------------------
#
	<tr class="row1" onmouseover="hl('fname_{catrow.forumrow.FORUM_ID}', 1);" onmouseout="hl('fname_{catrow.forumrow.FORUM_ID}', 0);">

#
#-----[ AFTER, ADD ]------------------------------------------
#
		<td class="f_icon"><img class="forum_icon" src="{catrow.forumrow.FORUM_ICON}"></td>

#
#-----[ FIND ]------------------------------------------
#
	<tr>
		<td colspan="7" class="row3"><input class="post" type="text" name="categoryname" /> <input type="submit" name="addcategory" value="{L_CREATE_CATEGORY}" /></td>
	</tr>

#
#-----[ REPLACE ]------------------------------------------
#
	<tr>
         <td colspan="8" class="row3"><input class="post" type="text" name="categoryname" /> <input type="submit" name="addcategory" value="{L_CREATE_CATEGORY}" /></td>
    </tr>

#
#-----[ SAVE/CLOSE ALL FILES ]------------------------------------------
#
# EoM