[MOD] Easy Sub Forum / Kolay Alt Forum

Phpbb [MOD] Easy Sub Forum / Kolay Alt Forum CMS - içerik yönetim hakkında bilgi paylaş; Açıklama=Sitenize alt forum eklemeye yarar PHP- Kodu: ############################################################## ## MOD İSMİ: Easy Sub-Forums ## MOD&...
Cevapla
 
Seçenekler
  #1  
Arama 01-12-2007, 08:22
Miliotta - ait Kullanıcı Resmi (Avatar)

Üyelik Tarihi: 30/10/07
Mesajlar: 279
 
     WS-Ticareti: (1)
Teşekkürleri: 0
35 Msg. 55 Tşkr.
Rep Gücü: 3 Miliotta deneyimleri belirsiz.

[MOD] Easy Sub Forum / Kolay Alt Forum

Açıklama=Sitenize alt forum eklemeye yarar

PHP- Kodu:
##############################################################
## MOD İSMİ: Easy Sub-Forums
## MOD YAPIMCILARI: acoolwelshbloke <> () http://www.www.tec2spec.co.uk/forum/
## MOD AÇIKLAMASI; This mod allows you to "attach" specific forums to another so that they are not displayed on the main index page but inside another forum. This emulates the sub-forums features but does not really create true sub-forum functionality.
##
## MOD VERSİYONU: 1.0.8
##
## KURULUM SEVİYESİ : ORTA
## KURULUM SÜRESİ   : 30 DK
## EDİTLENECEK DOSYALAR :   
##               includes/functions.php
##               admin/admin_forums.php
##               index.php
##               viewforum.php
##               viewtopic.php
##               posting.php
##               templates/subSilver/index_body.tpl
##               templates/subSilver/viewforum_body.tpl
##               templates/subSilver/viewtopic_body.tpl
##               templates/subSilver/admin/forum_edit_body.tpl
##               templates/subSilver/admin/forum_admin_body.tpl
##               templates/subSilver/posting_body.tpl
##               language/lang_english/lang_main.php
##               language/lang_english/lang_admin.php
##
## Included Files: (n/a)
##############################################################
## Author Notes:
##
## This mod is based on pseudo attached forum mod by Harishankar (http://literaryforums.org).
## It has been re-written from the ground up.
## Test this MOD in a testing/isolated enviroment if you have heavy modded forum.
## Installs fine with EasyMod on vanilla phpBB setup
##
##############################################################
## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD
##############################################################

#
#-----[ SQL  OLUŞTUR ]-------------------------------------------------
#
# Modu kurmadan önce SQL unuzu oluşturunuz.
#
#

   
ALTER TABLE `phpbb_topicsADD INDEX (topic_last_post_id);
   
ALTER TABLE `phpbb_forumsADD attached_forum_id MEDIUMINT(8) DEFAULT '-1' NOT NULL;
   
#
#-----[ AÇ ]------------------------------------------------
#
   
/includes/functions.php


#
#-----[ BUL ]------------------------------------------------
#

function get_db_stat($mode)
{


#
#-----[ ÖNCESİNE EKLE ]------------------------------------------
#
   // Added by Easy Sub-Forums MOD

function check_unread($forum_id)
{
global 
$new_topic_data$tracking_topics$tracking_forums$HTTP_COOKIE_VARS$board_config;
   if ( !empty(
$new_topic_data[$forum_id]) )
   {
      
$forum_last_post_time 0;

      while( list(
$check_topic_id$check_post_time) = @each($new_topic_data[$forum_id]) )
      {
         if ( empty(
$tracking_topics[$check_topic_id]) )
         {
            
$unread_topics true;
            
$forum_last_post_time max($check_post_time$forum_last_post_time);

         }
         else
         {
            if ( 
$tracking_topics[$check_topic_id] < $check_post_time )
            {
               
$unread_topics true;
               
$forum_last_post_time max($check_post_time$forum_last_post_time);
            }
         }
      }

      if ( !empty(
$tracking_forums[$forum_id]) )
      {
         if ( 
$tracking_forums[$forum_id] > $forum_last_post_time )
         {
            
$unread_topics false;
         }
      }

      if ( isset(
$HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f_all']) )
      {
         if ( 
$HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f_all'] > $forum_last_post_time )
         {
            
$unread_topics false;
         }
      }

   }

return 
$unread_topics;

}

   
// END Added by Easy Sub-Forums MOD


#
#-----[ BUL ]------------------------------------------------
#
function make_jumpbox($action$match_forum_id 0)
{
   global 
$template$userdata$lang$db$nav_links$phpEx$SID;


#
#-----[ ARDINA EKLE]------------------------------------------
#
   
global $parent_lookup;


#
#-----[ BUL ]------------------------------------------------
#
               
if ( $forum_rows[$j]['cat_id'] == $category_rows[$i]['cat_id'] && $forum_rows[$j]['auth_view'] <= AUTH_REG )
               {


#
#-----[ ÖNCESİNE EKLE ]------------------------------------------
#
                  
if ($parent_lookup==$forum_rows[$j]['forum_id'] && !$assigned)
                  {
                     
$template->assign_block_vars('switch_parent_link', array() );

                     
$template->assign_vars(array(
                        
'PARENT_NAME' => $forum_rows[$j]['forum_name'],
                        
'PARENT_URL'=>append_sid("viewforum.$phpEx?" POST_FORUM_URL "=" $forum_rows[$j]['forum_id'])
                        ));
                     
$assigned=TRUE;
                  }


#
#-----[ AÇ ]------------------------------------------------
#
   
/admin/admin_forums.php

#
#-----[ BUL ]------------------------------------------------
#
   
$forumstatus $row['forum_status'];
   
#
#-----[ ARDINA EKLE ]------------------------------------------
#
   // Added by Easy Sub-Forums MOD
   
            
$forum_attached_id $row['attached_forum_id'];
            
$sql "SELECT * from "FORUMS_TABLE" WHERE attached_forum_id = $forum_id";
            if( !
$r $db->sql_query($sql) )
            {
               
message_die(GENERAL_ERROR"Couldn't get list of children Forums"""__LINE____FILE__$sql);
            }

            if( 
$db->sql_numrows($r) > )
            {

               
$not_attachable=1;
               
$has_subforums=1;
               
$template->assign_block_vars('switch_attached_no', array());
               if (
intval($HTTP_POST_VARS['detach_enabled'])) $detach_enabled "checked=\"checked\"";

            }
            else
            {

               
// this forum is not a parent of any other forum
               
$sql "SELECT * FROM "FORUMS_TABLE" WHERE attached_forum_id=-1 and cat_id= $cat_id and forum_id<>$forum_id ORDER BY forum_order";

               if( !
$result1 $db->sql_query($sql) )
               {
                  
message_die(GENERAL_ERROR"Couldn't get list of attachable Forums"""__LINE____FILE__$sql);
               }
               if( 
$db->sql_numrows($result1) > )
               {
                  
$attachable_forums '<option value = "-1"'.($forum_attached_id==-1?' selected':'').'> NOT ATTACHED TO ANY FORUM </a>';
                  while( 
$row1 $db->sql_fetchrow($result1) )
                  {
                     
$s='';
                     if (
$forum_attached_id == $row1['forum_id'])
                     {
                        
$s " selected=\"selected\"";
                     }
                     
$attachable_forums .= '<option value="'.$row1[forum_id].$s.'">' $row1[forum_name] . '</option>\n';
                  }
               }
               else
               {
                  
$no_attachable_forums=1;
               }

            }
   
// End Added by Easy Sub-Forums MOD


#
#-----[ BUL ]------------------------------------------------
#

            
$forum_id '';
            
$prune_enabled '';
#
#-----[ ARDINA EKLE ]------------------------------------------
#
   // Added by Easy Sub-Forums MOD

               
$sql "SELECT * FROM "FORUMS_TABLE" WHERE attached_forum_id=-1 and cat_id= $cat_id ORDER BY forum_order";

               if( !
$result1 $db->sql_query($sql) )
               {
                  
message_die(GENERAL_ERROR"Couldn't get list of Categories/Forums"""__LINE____FILE__$sql);
               }
            if( 
$db->sql_numrows($result1) > )
            {
               
$attachable_forums '<option value = "-1"'.(($forum_attached_id==-|| !$forum_attached_id)?' selected':'').'> NOT ATTACHED TO ANY FORUM </a>';
               while( 
$row1 $db->sql_fetchrow($result1) )
               {

                  if (
$forum_attached_id == $row1['forum_id'])
                  {
                     
$s " selected=\"selected\"";
                  }
                  
$attachable_forums .= '<option value="'.$row1[forum_id].$s.'">' $row1[forum_name] . '</option>\n';
               }


            }
            else
            {
               
$no_attachable_forums=1;
            }
   
// END Added by Easy Sub-Forums MOD

#
#-----[ BUL ]------------------------------------------------
#
   
$catlist get_list('category'$cat_idTRUE);
#
#-----[ ÖNCESİNE EKLE ]------------------------------------------
#

   // Added by Easy Sub-Forums MOD

         
$forum_attached_id $attachable_forums;
   
// END Added by Easy Sub-Forums MOD


#
#-----[ BUL ]------------------------------------------------
#

         
$s_hidden_fields '<input type="hidden" name="mode" value="' $newmode .'" /><input type="hidden" name="' POST_FORUM_URL '" value="' $forum_id '" />';
#
#-----[ ARDINA EKLE ]------------------------------------------
#
   // Added by Easy Sub-Forums MOD

         
if ($not_attachable or $no_attachable_forums)
         {
            if (
$has_subforums)
            {
               
$lang['Attached_Description'] = $lang['Has_attachments'].'<br>'$lang['Attached_Description'];
               
$s_hidden_fields .='<input type="hidden" name="has_subforums" value="1" />';
            }
            if (
$no_attachable_forums$lang['Attached_Description'] = $lang['No_attach_forums'].'<br>'$lang['Attached_Description'];
            
$s_hidden_fields .='<input type="hidden" name="attached_forum_id" value="-1" />';
         }
         else
         {
            
$template->assign_block_vars('switch_attached_yes', array());
         }
            
$s_hidden_fields .='<input type="hidden" name="old_cat_id" value="'.$cat_id.'" />';
   
// END Added by Easy Sub-Forums MOD

#
#-----[ BUL ]------------------------------------------------
#
   
   
'S_PRUNE_ENABLED' => $prune_enabled,

#
#-----[ ARDINA EKLE ]------------------------------------------
#
   // Added by Easy Sub-Forums MOD
   
'S_ATTACHED_FORUM_ID' => $forum_attached_id,
   
'S_DETACH_ENABLED'=> $detach_enabled,
   
// End Added by Easy Sub-Forums MOD
     
#
#-----[ BUL ]------------------------------------------------
#
   
'L_CATEGORY' => $lang['Category'],

#
#-----[ ARDINA EKLE ]------------------------------------------
#

   // Added by Easy Sub-Forums MOD
   
'L_ATTACHED_FORUM' => $lang['Attached_Field_Title'] ,
   
'L_ATTACHED_DESC' => $lang['Attached_Description'],
   
'L_DETACH_DESC'   => $lang['Detach_Description'],
   
// End Added by Easy Sub-Forums MOD

#
#-----[ BUL ]------------------------------------------------
#
      
$sql "INSERT INTO " FORUMS_TABLE " (forum_id, forum_name, cat_id, forum_desc, forum_order, forum_status, prune_enable" $field_sql ")
            VALUES ('" 
$next_id "', '" str_replace("\'""''"$HTTP_POST_VARS['forumname']) . "', " intval($HTTP_POST_VARS[POST_CAT_URL]) . ", '" str_replace("\'""''"$HTTP_POST_VARS['forumdesc']) . "', $next_order, " intval($HTTP_POST_VARS['forumstatus']) . ", " intval($HTTP_POST_VARS['prune_enable']) . $value_sql ")";

#
#-----[ BUNUNLA DEĞİŞTİR ]----------------------------------------
#
   // Modified by Easy Sub-Forums MOD
   
         
if (intval($HTTP_POST_VARS['old_cat_id']) != intval($HTTP_POST_VARS[POST_CAT_URL]))
         {
               
$HTTP_POST_VARS['attached_forum_id']=-1;
            }

      
$sql "INSERT INTO " FORUMS_TABLE " (forum_id, forum_name, cat_id, attached_forum_id, forum_desc, forum_order, forum_status, prune_enable" $field_sql ")
            VALUES ('" 
$next_id "', '" str_replace("\'""''"$HTTP_POST_VARS['forumname']) . "', " intval($HTTP_POST_VARS[POST_CAT_URL]) .  ", " intval($HTTP_POST_VARS['attached_forum_id']) . ", '" str_replace("\'""''"$HTTP_POST_VARS['forumdesc']) . "', $next_order, " intval($HTTP_POST_VARS['forumstatus']) . ", " intval($HTTP_POST_VARS['prune_enable']) . $value_sql ")";
   
// End Added by Easy Sub-Forums MOD


#
#-----[ BUL ]------------------------------------------------
#
            
$sql "UPDATE " FORUMS_TABLE "
            SET forum_name = '" 
str_replace("\'""''"$HTTP_POST_VARS['forumname']) . "', cat_id = " intval($HTTP_POST_VARS[POST_CAT_URL]) . ", forum_desc = '" str_replace("\'""''"$HTTP_POST_VARS['forumdesc']) . "', forum_status = " intval($HTTP_POST_VARS['forumstatus']) . ", prune_enable = " intval($HTTP_POST_VARS['prune_enable']) . "
            WHERE forum_id = " 
intval($HTTP_POST_VARS[POST_FORUM_URL]);

#
#-----[ BUNUNLA DEĞİŞTİR ]----------------------------------------
#
   // Modified by Easy Sub-Forums MOD
         
if (isset($HTTP_POST_VARS['detach_enabled']) && isset($HTTP_POST_VARS['has_subforums']))
         {
            
$sql "UPDATE "FORUMS_TABLE" SET attached_forum_id=-1 WHERE attached_forum_id=" intval($HTTP_POST_VARS[POST_FORUM_URL]);
            if( !
$result $db->sql_query($sql) )
            {
               
message_die(GENERAL_ERROR"Couldn't detach subforums"""__LINE____FILE__$sql);
            }

         }

         if (
intval($HTTP_POST_VARS['old_cat_id']) != intval($HTTP_POST_VARS[POST_CAT_URL]))
            {
            
$HTTP_POST_VARS['attached_forum_id']=-1;
            if (isset(
$HTTP_POST_VARS['has_subforums']) && !isset($HTTP_POST_VARS['detach_enabled']))
            {
               
$sql "UPDATE "FORUMS_TABLE ." SET cat_id="intval($HTTP_POST_VARS[POST_CAT_URL]) ." WHERE attached_forum_id=" intval($HTTP_POST_VARS[POST_FORUM_URL]);
               if( !
$result $db->sql_query($sql) )
               {
                  
message_die(GENERAL_ERROR"Couldn't update subforums to new category"""__LINE____FILE__$sql);
               }

            }
         }

         
$sql "UPDATE " FORUMS_TABLE "
            SET forum_name = '" 
str_replace("\'""''"$HTTP_POST_VARS['forumname']) . "', cat_id = " intval($HTTP_POST_VARS[POST_CAT_URL]) .", attached_forum_id = " intval($HTTP_POST_VARS['attached_forum_id']) . ", forum_desc = '" str_replace("\'""''"$HTTP_POST_VARS['forumdesc']) . "', forum_status = " intval($HTTP_POST_VARS['forumstatus']) . ", prune_enable = " intval($HTTP_POST_VARS['prune_enable']) . "
            WHERE forum_id = " 
intval($HTTP_POST_VARS[POST_FORUM_URL]);
   
// End Added by Easy Sub-Forums MOD

#
#-----[ BUL ]------------------------------------------------
#
   
if( $total_forums $db->sql_numrows($q_forums) )
   {
      
$forum_rows $db->sql_fetchrowset($q_forums);
   }

#
#-----[ ARDINA EKLE ]------------------------------------------
#

   
$subforum_rows=$forum_rows;


#
#-----[ BUL ]------------------------------------------------
#

            
$template->assign_block_vars("catrow.forumrow",   array(
               
'FORUM_NAME' => $forum_rows[$j]['forum_name'],
               
'FORUM_DESC' => $forum_rows[$j]['forum_desc'],
               
'ROW_COLOR' => $row_color,
               
'NUM_TOPICS' => $forum_rows[$j]['forum_topics'],
               
'NUM_POSTS' => $forum_rows[$j]['forum_posts'],

               
'U_VIEWFORUM' => append_sid($phpbb_root_path."viewforum.$phpEx?" POST_FORUM_URL "=$forum_id"),
               
'U_FORUM_EDIT' => append_sid("admin_forums.$phpEx?mode=editforum&amp;" POST_FORUM_URL "=$forum_id"),
               
'U_FORUM_DELETE' => append_sid("admin_forums.$phpEx?mode=deleteforum&amp;" POST_FORUM_URL "=$forum_id"),
               
'U_FORUM_MOVE_UP' => append_sid("admin_forums.$phpEx?mode=forum_order&amp;move=-15&amp;" POST_FORUM_URL "=$forum_id"),
               
'U_FORUM_MOVE_DOWN' => append_sid("admin_forums.$phpEx?mode=forum_order&amp;move=15&amp;" POST_FORUM_URL "=$forum_id"),
               
'U_FORUM_RESYNC' => append_sid("admin_forums.$phpEx?mode=forum_sync&amp;" POST_FORUM_URL "=$forum_id"))
            );

#
#-----[ DEĞİŞTİR ]----------------------------------------
#
            
$sub_error=false;
            
$do_template=false;
            if (
$forum_rows[$j]['attached_forum_id'] !=-1)
            {
            
$ok='';
               for(
$k 0$k $total_forums$k++)
               {
                  
$subforum_id $subforum_rows[$k]['forum_id'];

                  if (
$subforum_id == $forum_rows[$j]['attached_forum_id'] && $forum_rows[$k]['attached_forum_id']==-1)
                  {
                     
$ok=TRUE;//normal parent found
                  
}
               }
               if (
$forum_rows[$j]['attached_forum_id']==$forum_id$ok=FALSE//attached to itself
               
if ($forum_rows[$j]['attached_forum_id']==0$ok=FALSE//invalid parent
               
if (!$ok)
               {
                  
$do_template=TRUE;
                  
$sub_error=true;
               }
            }
            else
            {
               
$do_template=true;
            }
//attached_forum_id'] ==-1


            
if ($do_template)
            {
               
$template->assign_block_vars("catrow.forumrow",   array(
                  
'FORUM_NAME' => $forum_rows[$j]['forum_name'],
                  
'FORUM_DESC' => $forum_rows[$j]['forum_desc'],
                  
'ROW_COLOR' => $row_color,
                  
'NUM_TOPICS' => $forum_rows[$j]['forum_topics'],
                  
'NUM_POSTS' => $forum_rows[$j]['forum_posts'],

                  
'U_VIEWFORUM' => append_sid($phpbb_root_path."viewforum.$phpEx?" POST_FORUM_URL "=$forum_id"),
                  
'U_FORUM_EDIT' => append_sid("admin_forums.$phpEx?mode=editforum&amp;" POST_FORUM_URL "=$forum_id"),
                  
'U_FORUM_DELETE' => append_sid("admin_forums.$phpEx?mode=deleteforum&amp;" POST_FORUM_URL "=$forum_id"),
                  
'U_FORUM_MOVE_UP' => append_sid("admin_forums.$phpEx?mode=forum_order&amp;move=-15&amp;" POST_FORUM_URL "=$forum_id"),
                  
'U_FORUM_MOVE_DOWN' => append_sid("admin_forums.$phpEx?mode=forum_order&amp;move=15&amp;" POST_FORUM_URL "=$forum_id"),
                  
'U_FORUM_RESYNC' => append_sid("admin_forums.$phpEx?mode=forum_sync&amp;" POST_FORUM_URL "=$forum_id"))
               );
               if (
$sub_error)
               {
                  
$template->assign_block_vars ('catrow.forumrow.switch_error',array());
               }

               for(
$k 0$k $total_forums$k++)
               {
                  
$subforum_id $subforum_rows[$k]['forum_id'];
                  if (
$subforum_rows[$k]['attached_forum_id'] == $forum_id)
                  {
                     
$template->assign_block_vars("catrow.forumrow",   array(
                        
'FORUM_NAME' => $subforum_rows[$k]['forum_name'],
                        
'FORUM_DESC' => $subforum_rows[$k]['forum_desc'],
                        
'ROW_COLOR' => $row_color,
                        
'NUM_TOPICS' => $subforum_rows[$k]['forum_topics'],
                        
'NUM_POSTS' => $subforum_rows[$k]['forum_posts'],

                        
'U_VIEWFORUM' => append_sid($phpbb_root_path."viewforum.$phpEx?" POST_FORUM_URL "=$subforum_id"),
                        
'U_FORUM_EDIT' => append_sid("admin_forums.$phpEx?mode=editforum&amp;" POST_FORUM_URL "=$subforum_id"),
                        
'U_FORUM_DELETE' => append_sid("admin_forums.$phpEx?mode=deleteforum&amp;" POST_FORUM_URL "=$subforum_id"),
                        
'U_FORUM_MOVE_UP' => append_sid("admin_forums.$phpEx?mode=forum_order&amp;move=-15&amp;" POST_FORUM_URL "=$subforum_id"),
                        
'U_FORUM_MOVE_DOWN' => append_sid("admin_forums.$phpEx?mode=forum_order&amp;move=15&amp;" POST_FORUM_URL "=$subforum_id"),
                        
'U_FORUM_RESYNC' => append_sid("admin_forums.$phpEx?mode=forum_sync&amp;" POST_FORUM_URL "=$subforum_id"))
                     );
                     
$template->assign_block_vars ('catrow.forumrow.switch_attached_forum',array());
                  }
               }
            }


#
#-----[ AÇ ]------------------------------------------------
#
   
index.php


#
#-----[ BUL ]------------------------------------------------
#
         
$sql "SELECT f.*, p.post_time, p.post_username, u.username, u.user_id
            FROM (( " 
FORUMS_TABLE " f
            LEFT JOIN " 
POSTS_TABLE " p ON p.post_id = f.forum_last_post_id )
            LEFT JOIN " 
USERS_TABLE " u ON u.user_id = p.poster_id )
            ORDER BY f.cat_id, f.forum_order"
;
#
#-----[ BUNUNLA DEĞİŞTİR ]----------------------------------------
#
   // Modified by Easy Sub-Forums MOD

         
$sql "SELECT f.*, p.post_time, p.post_username,  u.username, u.user_id, t.topic_id, t.topic_title
            FROM ((( " 
FORUMS_TABLE " f
            LEFT JOIN " 
POSTS_TABLE " p ON p.post_id = f.forum_last_post_id )
            LEFT JOIN " 
USERS_TABLE " u ON u.user_id = p.poster_id )
            LEFT JOIN " 
TOPICS_TABLE " t ON t.topic_last_post_id = f.forum_last_post_id)
            GROUP BY f.forum_id ORDER BY f.cat_id, f.forum_order"
;
   
// END Modified by Easy Sub-Forums MOD



#
#-----[ BUL ]------------------------------------------------
#
   
{
      
$forum_data[] = $row;
   }
#
#-----[ ARDINA EKLE ]------------------------------------------
#
   // Added by Easy Sub-Forums MOD
   
   
$attach=$forum_data;
   
// END Added by Easy Sub-Forums MOD
   
#
#-----[ BUL ]------------------------------------------------
#
   
$forum_id $forum_data[$j]['forum_id'];

#
#-----[ ARDINA EKLE ]------------------------------------------
#

   // Added by Easy Sub-Forums MOD

   
$attached_id $forum_data[$j]['attached_forum_id'];
                  if ( 
$is_auth_ary[$forum_id]['auth_view'] && $attached_id == -)
                  {
                     
$attached_forums = array();
                     foreach (
$attach as $key => $value)
                     {
                        
$sub_forum_id $value['forum_id'];
                        if (
$value['attached_forum_id']==$forum_id && $is_auth_ary[$sub_forum_id]['auth_view'])
                        {
                           
//combining topic and post count for forum and subforums
                           
$forum_data[$j]['forum_posts']=$forum_data[$j]['forum_posts']+$value['forum_posts'];
                           
$forum_data[$j]['forum_topics']=$forum_data[$j]['forum_topics']+$value['forum_topics'];
                           
//END combining topic and post count

                           //Last post link - check if any of subforums have newest posts and link to them instead
                           
if ($value['post_time']>$forum_data[$j]['post_time'])
                  &nbs