IPB

Здравствуйте, гость ( Вход | Регистрация )

 
Ответить в данную темуНачать новую тему
> Закреплённый первый пост, мод для Invision Power Board v2.1.x
builder
сообщение 28.3.2008, 17:31
Сообщение #1


Администратор
********

Группа: Главные администраторы
Сообщений: 1194
Регистрация: 2.9.2010
Пользователь №: 1



Для установки мода проделываем следующее!!



1.Выполните следующий запрос SQL на базе данных

Код
ALTER TABLE `Forum_topics` ADD `pinned_post` TINYINT( 1 ) DEFAULT '0';




2. Открываем файл ./sources/action_public/moderate.php

Ищем

Код
//-----------------------------------------
            // Edit member
            //-----------------------------------------
            case 'editmember':
                $this->edit_member();
                break;

НИЖЕ, ДОБАВИТЬ

Код
// [BEGIN] Alex/AT Mod: Pinning first post in the topics
        case 'pinpost':
            $this->pin_post();
            break;
        case 'unpinpost':
            $this->unpin_post();
            break;
        // [END] Alex/AT Mod: Pinning first post in the topics


Ищем

Код
?>


ВЫШЕ, НАЙТИ

Код
}


ВЫШЕ, ДОБАВИТЬ

Код
// [BEGIN] Alex/AT Mod: Pinning first post in the topics

    /*-------------------------------------------------------------------------*/
    // PIN POST:
    /*-------------------------------------------------------------------------*/
    
    function pin_post()
    {
        if ($this->topic['pinned_post'])
        {
            $this->moderate_error();
        }

        $passed = 0;
        
        if ($this->ipsclass->member['g_is_supmod'] == 1)
        {
            $passed = 1;
        }
        else if ($this->moderator['pin_topic'] == 1)
        {
            $passed = 1;
        }
        else if ($this->topic['starter_id'] == $this->ipsclass->member['id'])
        {
            $passed = 1;
        }
        else
        {
            $passed = 0;
        }
        
        if ($passed != 1) $this->moderate_error();
        
        $this->modfunc->post_pin($this->topic['tid']);
        
        $this->moderate_log("Первое сообщение темы «закреплено»");
    
        $this->ipsclass->print->redirect_screen( $this->ipsclass->lang['p_pinned_post'], "showtopic=".$this->topic['tid']."&st=".$this->ipsclass->input['st'] );
        
    }
    
    /*-------------------------------------------------------------------------*/
    // UNPIN POST:
    /*-------------------------------------------------------------------------*/
    
    function unpin_post()
    {
        if (! $this->topic['pinned_post'])
        {
            $this->moderate_error();
        }
        
        $passed = 0;
        
        if ($this->ipsclass->member['g_is_supmod'] == 1)
        {
            $passed = 1;
        }
        else if ($this->moderator['unpin_topic'] == 1)
        {
            $passed = 1;
        }
        else if ($this->topic['starter_id'] == $this->ipsclass->member['id'])
        {
            $passed = 1;
        }
        else
        {
            $passed = 0;
        }
        
        if ($passed != 1) $this->moderate_error();
        
        $this->modfunc->post_unpin($this->topic['tid']);
        
        $this->moderate_log("Первое сообщение темы «откреплено»");
    
        $this->ipsclass->print->redirect_screen( $this->ipsclass->lang['p_unpinned_post'], "act=ST&f=".$this->forum['id']."&t=".$this->topic['tid']."&st=".$this->ipsclass->input['st'] );
    }

    // [END] Alex/AT Mod: Pinning first post in the topics



3. Открываем файл ./sources/action_public/topics.php

Ищем

Код
//-----------------------------------------
        // Post number
        //-----------------------------------------
        
        if ( $this->topic_view_mode == 'linearplus' and $this->topic['topic_firstpost'] == $row['pid'])
        {
            $row['post_count'] = 1;
            
            if ( ! $this->first )
            {
                $this->post_count++;
            }
        }


НИЖЕ, ДОБАВИТЬ

Код
  // [BEGIN] Alex/AT Mod: Pinning first post in the topics
        elseif ($this->topic_view_mode == 'linear' and $this->topic['pinned_post'] and $this->topic['topic_firstpost'] == $row['pid'])
        {
            $row['post_count'] = '1 '.$this->ipsclass->lang['post_pinned'];

            if ( $this->first < 1 )
            {
                $this->post_count++;
            }
        }
        // [END] Alex/AT Mod: Pinning first post in the topics


Ищем

Код
  $actions = array( 'MOVE_TOPIC', 'CLOSE_TOPIC', 'OPEN_TOPIC', 'DELETE_TOPIC', 'EDIT_TOPIC', 'PIN_TOPIC', 'UNPIN_TOPIC', 'MERGE_TOPIC', 'UNSUBBIT' );


ЗАМЕНИТЕ

Код
// Alex/AT Mod: Pinning first post in the topics
        $actions = array( 'MOVE_TOPIC', 'CLOSE_TOPIC', 'OPEN_TOPIC', 'DELETE_TOPIC', 'EDIT_TOPIC', 'PIN_TOPIC', 'UNPIN_TOPIC', 'MERGE_TOPIC', 'PIN_POST', 'UNPIN_POST', 'UNSUBBIT' );


Ищем

Код
  if ($key == 'MERGE_TOPIC' or $key == 'SPLIT_TOPIC')
                {
                    if ($this->moderator['split_merge'] == 1)
                    {
                        $mod_links .= $this->append_link($key);
                    }
                }


НИЖЕ, ДОБАВИТЬ

Код
// [BEGIN] Alex/AT Mod: Pinning first post in the topics
                elseif ($key == 'PIN_POST' or $key == 'UNPIN_POST')
                {
                    if ($this->ipsclass->member['g_open_close_posts'])
                    {
                        $mod_links .= $this->append_link($key);
                    }
                }
// [END] Alex/AT Mod: Pinning first post in the topics


Ищем

Код
elseif ($key == 'OPEN_TOPIC' or $key == 'CLOSE_TOPIC')
            {
                if ($this->ipsclass->member['g_open_close_posts'])
                {
                    $mod_links .= $this->append_link($key);
                }
            }


НИЖЕ, ДОБАВИТЬ

Код
// [BEGIN] Alex/AT Mod: Pinning first post in the topics
            elseif ($key == 'PIN_POST' or $key == 'UNPIN_POST')
            {
                if ($this->ipsclass->member['g_open_close_posts'])
                {
                    $mod_links .= $this->append_link($key);
                }
            }
// [END] Alex/AT Mod: Pinning first post in the topics


Ищем

Код
if ($this->topic['pinned'] == 1 and $key == 'PIN_TOPIC')   return "";
        if ($this->topic['pinned'] == 0 and $key == 'UNPIN_TOPIC') return "";


НИЖЕ, ДОБАВИТЬ

Код
// [BEGIN] Alex/AT Mod: Pinning first post in the topics
        if (($key == 'PIN_POST' or $key == 'UNPIN_POST') and $this->topic['state'] != 'open') return "";
        if ($this->topic['pinned_post'] == 1 and $key == 'PIN_POST')   return "";
        if ($this->topic['pinned_post'] == 0 and $key == 'UNPIN_POST') return "";
        // [END] Alex/AT Mod: Pinning first post in the topics


Ищем

Код
  'PIN_TOPIC'     => '15',
                                   'UNPIN_TOPIC'   => '16',
                                   'UNSUBBIT'      => '30',
                                   'MERGE_TOPIC'   => '60',
                                   'TOPIC_HISTORY' => '90',


НИЖЕ, ДОБАВИТЬ

Код
// [BEGIN] Alex/AT Mod: Pinning first post in the topics
                                   'PIN_POST' => 'pinpost',
                                   'UNPIN_POST' => 'unpinpost',
// [END] Alex/AT Mod: Pinning first post in the topics




4. Открываем файл ./sources/lib/func_mod.php

Ищем

Код
?>


ВЫШЕ, НАЙТИ

Код
}


ВЫШЕ, ДОБАВИТЬ

Код
// [BEGIN] Alex/AT Mod: Pinning first post in the topics

    //-----------------------------------------
    // @post_pin: pin topic first post
    // -----------
    // Accepts: Array ID's | Single ID
    // Returns: NOTHING (TRUE/FALSE)
    //-----------------------------------------
    
    function post_pin($id)
    {
        $this->stm_init();
        $this->stm_add_post_pin();
        $this->stm_exec($id);
        return TRUE;
    }
    
    //-----------------------------------------
    // @post_unpin: unpin topic first post
    // -----------
    // Accepts: Array ID's | Single ID
    // Returns: NOTHING (TRUE/FALSE)
    //-----------------------------------------
    
    function post_unpin($id)
    {
        $this->stm_init();
        $this->stm_add_post_unpin();
        $this->stm_exec($id);
        return TRUE;
    }

    //-----------------------------------------
    // @stm_add_post_pin: add post pin command to statement
    // -----------
    // Accepts: NOTHING
    // Returns: NOTHING (TRUE/FALSE)
    //-----------------------------------------
    
    function stm_add_post_pin()
    {
        $this->stm[] = array( 'pinned_post' => 1 );
        
        return TRUE;
    }
    
    //-----------------------------------------
    // @stm_add_post_unpin: add post unpin command to statement
    // -----------
    // Accepts: NOTHING
    // Returns: NOTHING (TRUE/FALSE)
    //-----------------------------------------
    
    function stm_add_post_unpin()
    {
        $this->stm[] = array( 'pinned_post' => 0 );
        
        return TRUE;
    }

    // [END] Alex/AT Mod: Pinning first post in the topics



5. Открываем файл ./sources/lib/func_topic_linear.php

Ищем

Код
//-----------------------------------------
            // Run query
            //-----------------------------------------
            
            $this->lib->topic_view_mode = 'linear';


НИЖЕ, ДОБАВИТЬ

Код
// [BEGIN] Alex/AT Mod: Pinning first post in the topics
            if ($this->topic['pinned_post'] and $first > 0)
            {
                $this->pids = array( 0 => $this->topic['topic_firstpost'] );
            }
            // [END] Alex/AT Mod: Pinning first post in the topics


Ищем

Код
//-----------------------------------------
            // Show end first post
            //-----------------------------------------
            
            if ( $this->lib->topic_view_mode == 'linearplus' and $this->first_printed == 0 and $row['pid'] == $this->topic['topic_firstpost'] and $this->topic['posts'] > 0)
            {
                $this->output .= $this->ipsclass->compiled_templates['skin_topic']->topic_end_first_post( array( 'TOPIC' => $this->topic, 'FORUM' => $this->forum ) );
            }


НИЖЕ, ДОБАВИТЬ

Код
// [BEGIN] Alex/AT Mod: Pinning first post in the topics
            if ( $this->lib->topic_view_mode == 'linear' and $this->first_printed == 0 and $row['pid'] == $this->topic['topic_firstpost'] and $first > 0)
            {
                $this->output .= $this->ipsclass->compiled_templates['skin_topic']->topic_end_outline( array( 'TOPIC' => $this->topic, 'FORUM' => $this->forum ) );
                # A little hack to exclude rules/post
                $this->output .= strtr( $this->ipsclass->compiled_templates['skin_topic']->topic_page_top( array( 'TOPIC' => $this->topic, 'FORUM' => $this->forum ), 1 ) , array( '<!--Forum.FORUM_RULES-->' => '', '<!--{Forum.POLL}-->' => '') );
            }
            // [END] Alex/AT Mod: Pinning first post in the topics




6. Открываем файл ./cache/lang_cache/*/lang_mod.php

Ищем

Код
$lang = array (


НИЖЕ, ДОБАВИТЬ

Код
// [BEGIN] Alex/AT Mod: Pinning first post in the topics
'p_pinned_post' => 'Первое сообщение закреплено',
'p_unpinned_post' => 'Первое сообщение откреплено',
// [END] Alex/AT Mod: Pinning first post in the topics





7. Открываем файл ./cache/lang_cache/*/lang_topic.php

Ищем

Код
$lang = array (


НИЖЕ, ДОБАВИТЬ

Код
// [BEGIN] Alex/AT Mod: Pinning first post in the topics
'PIN_POST' => 'Закрепить первое сообщение',
'UNPIN_POST' => 'Открепить первое сообщение',
'post_pinned' => '(закреплено)',
// [END] Alex/AT Mod: Pinning first post in the topics
Перейти в начало страницы
 
+Цитировать сообщение

Быстрый ответОтветить в данную темуНачать новую тему
2 чел. читают эту тему (гостей: 2, скрытых пользователей: 0)
Пользователей: 0

 

Текстовая версия Сейчас: 24.6.2024, 20:24
 
     


Мнение администрации сайта может не совпадать с точкой зрения авторов статей и других материалов, опубликованных на сайте.
Все файлы расположенные на данном ресурсе были взяты из открытых источников.