Tytuł: Zobacz interesujące tematy
Autor: nyyankeefans
Autor PL: Andiw
Kategoria : IPB 2.2.x, 2.3.x
Opis:
Dzięki tej modyfikacji obsługa twojego forum może oznaczać dowolne tematy jako interesujące i warte przeczytania. Wszystkie tak oznaczone tematy będą dostępne po kliknięciu linku „Zobacz interesujące tematy” w belce użytkownika
Pliki podlegające edycji:
cache/lang_cache/en/lang_boards.php
cache/lang_cache/en/lang_forum.php
cache/lang_cache/en/lang_global.php
cache/lang_cache/en/lang_mod.php
cache/lang_cache/en/lang_search.php
cache/lang_cache/en/lang_topic.php
sources/action_admin/groups.php
sources/action_public/moderate.php
sources/action_public/search.php
sources/action_public/topics.php
>> W przypadku gdy pliki językowe znajdują się w innym folderze niż „en” pamiętaj aby edytować pliki z folderu z którego korzysta twoje forum !!
1. Przejdź do ACP > ADMIN > SQL Management > SQL Toolbox >> Run a Query
i wykonaj następujące zapytanie:
alter table ibf_topics add (
picked numeric(1) default 0
)
oraz kolejne:
alter table ibf_groups add (
g_pick_topics tinyint(1)
)
2. Otwórz plik: lang_boards.php
Znajdź:
/*-------------------------------------------------------------------------*/
// UNPIN TOPIC:
/*-------------------------------------------------------------------------*/
function unpin_topic()
{
if ($this->topic['pinned'] == 0)
{
$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 {
$passed = 0;
}
if ($passed != 1) $this->moderate_error();
$this->modfunc->topic_unpin($this->topic['tid']);
$this->moderate_log( $this->ipsclass->lang['acp_unpinned_topic'] );
$this->ipsclass->print->redirect_screen( $this->ipsclass->lang['p_unpinned'], "showtopic=".$this->topic['tid']."&st=".intval($this->ipsclass->input['st']) );
}
Dodaj poniżej:
/*-------------------------------------------------------------------------*/
// PICK TOPIC:
/*-------------------------------------------------------------------------*/
function pick_topic($sql="")
{
$passed = 0;
if ($this->ipsclass->member['g_is_supmod'] == 1)
{
$passed = 1;
}
else if ($this->ipsclass->member['g_pick_topic'] == 1)
{
$passed = 1;
}
else {
$passed = 0;
}
if ($passed != 1) $this->moderate_error();
$this->ipsclass->DB->simple_exec_query( array( 'update' => 'topics', 'set' => $sql, 'where' => "tid=".$this->topic['tid']." AND state!='link'" ) );
$this->moderate_log( sprintf( $this->ipsclass->lang['acp_altered_topics'], $sql, $this->topic['tid']) );
if ($sql == "picked=1")
{
$this->ipsclass->print->redirect_screen( $this->ipsclass->lang['p_picked'], "showtopic=".$this->topic['tid']."&st=".intval($this->ipsclass->input['st']) );
}
else
{
$this->ipsclass->print->redirect_screen( $this->ipsclass->lang['p_unpicked'], "showtopic=".$this->topic['tid']."&st=".intval($this->ipsclass->input['st']) );
}
}
10. Otwórz plik: sources/action_public/search.php
Znajdź:
//-----------------------------------------
// Get Staff Picks
//-----------------------------------------
function get_picked()
{
//-----------------------------------------
// Do we have flood control enabled?
//-----------------------------------------
if ($this->ipsclass->member['g_search_flood'] > 0)
{
$flood_time = time() - $this->ipsclass->member['g_search_flood'];
//-----------------------------------------
// Get any old search results..
//-----------------------------------------
$this->ipsclass->DB->simple_construct( array( 'select' => 'id',
'from' => 'search_results',
'where' => "(member_id='".$this->ipsclass->member['id']."' OR ip_address='".$this->ipsclass->input['IP_ADDRESS']."') AND search_date > '$flood_time'" ) );
$this->ipsclass->DB->simple_exec();
if ( $this->ipsclass->DB->get_num_rows() )
{
$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'search_flood', 'EXTRA' => $this->ipsclass->member['g_search_flood']) );
}
}
$this->ipsclass->input['forums'] = 'all';
$forums = $this->get_searchable_forums();
//-----------------------------------------
// Do we have any forums to search in?
//-----------------------------------------
if ($forums == "")
{
$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'no_search_forum') );
}
//-----------------------------------------
// Get the topic ID's to serialize and store into
// the database
//-----------------------------------------
$this->ipsclass->DB->simple_construct( array( 'select' => 'count(*) as count', 'from' => 'topics t', 'where' => "t.approved=1 AND t.forum_id IN($forums) AND t.picked=1" ) );
$this->ipsclass->DB->simple_exec();
$row = $this->ipsclass->DB->fetch_row();
$results = intval($row['count']);
//-----------------------------------------
// Do we have any results?
//-----------------------------------------
if ( ! $results )
{
$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'no_search_results' ) );
}
//-----------------------------------------
// Cache query
//-----------------------------------------
$this->ipsclass->DB->simple_construct( array( 'select' => 't.*, t.title as topic_title',
'from' => 'topics t',
'where' => "t.approved=1 AND t.forum_id IN($forums) AND t.picked=1",
'order' => "t.last_post DESC" ) );
$query_to_cache = $this->ipsclass->DB->cur_query;
$this->ipsclass->DB->flush_query();
//-----------------------------------------
// If we are still here, store the data into the database...
//-----------------------------------------
$unique_id = md5(uniqid(microtime(),1));
$this->ipsclass->DB->do_insert( 'search_results', array (
'id' => $unique_id,
'search_date' => time(),
'post_max' => $results,
'sort_key' => $this->sort_key,
'sort_order' => $this->sort_order,
'member_id' => $this->ipsclass->member['id'],
'ip_address' => $this->ipsclass->input['IP_ADDRESS'],
'query_cache' => $query_to_cache
) );
$this->ipsclass->boink_it( $this->ipsclass->base_url."act=Search&nav=ap&CODE=show&searchid=$unique_id&search_in=topics&result_type=topics" );
}
Znajdź w funkcji show_results:
else if ( $this->ipsclass->input['nav'] == 'au' )
{
if( $this->ipsclass->input['result_type'] == 'topics' )
{
$this->nav = array( $this->ipsclass->lang['nav_aut'] );
}
else
{
$this->nav = array( $this->ipsclass->lang['nav_au'] );
}
}
Dodaj poniżej:
else if ( $this->ipsclass->input['nav'] == 'ap' )
{
$this->nav = array( $this->ipsclass->lang['nav_ap'] );
}
11. Otwórz plik: sources/action_public/topics.php
Znajdź w funkcji moderation_panel:
$actions = array( 'MOVE_TOPIC', 'CLOSE_TOPIC', 'OPEN_TOPIC', 'DELETE_TOPIC', 'EDIT_TOPIC', 'PIN_TOPIC', 'UNPIN_TOPIC', 'MERGE_TOPIC', 'UNSUBBIT' );
Zamień na:
$actions = array( 'MOVE_TOPIC', 'CLOSE_TOPIC', 'OPEN_TOPIC', 'DELETE_TOPIC', 'EDIT_TOPIC', 'PIN_TOPIC', 'UNPIN_TOPIC', 'MERGE_TOPIC', 'UNSUBBIT', 'PICK_TOPIC', 'UNPICK_TOPIC' );
Znajdź:
elseif ($key == 'DELETE_TOPIC')
{
if ($this->ipsclass->member['g_delete_own_topics'])
{
$mod_links .= $this->append_link($key);
}
}
Dodaj poniżej:
elseif ($key == 'PICK_TOPIC' or $key == 'UNPICK_TOPIC')
{
if ($this->ipsclass->member['g_pick_topics'])
{
$mod_links .= $this->append_link($key);
}
}
Znajdź w funkcji append_link:
if ($this->topic['pinned'] == 0 and $key == 'UNPIN_TOPIC') return "";
Dodaj poniżej:
if ($this->topic['picked'] == 1 and $key == 'PICK_TOPIC') return "";
if ($this->topic['picked'] == 0 and $key == 'UNPICK_TOPIC') return "";
Znajdź:
'MERGE_TOPIC' => '60',
'TOPIC_HISTORY' => '90',
Dodaj poniżej:
'PICK_TOPIC' => 'pick_topic',
'UNPICK_TOPIC' => 'unpick_topic',
12. Przejdź do: ACP > Look & Feel > ( wybór skina ) > Edit Template HTML > All Global HTML >> member_bar
Znajdź:
<b><a href="{$this->ipsclass->base_url}act=UserCP&CODE=00" title="{$this->ipsclass->lang['cp_tool_tip']}">{$this->ipsclass->lang['your_cp']}</a></b> · <a href="{$this->ipsclass->base_url}act=Search&CODE=getnew">{$this->ipsclass->lang['view_new_posts']}</a>
Zamień na:
<b><a href="{$this->ipsclass->base_url}act=UserCP&CODE=00" title="{$this->ipsclass->lang['cp_tool_tip']}">{$this->ipsclass->lang['your_cp']}</a></b> · <a href="{$this->ipsclass->base_url}act=Search&CODE=getpicked">{$this->ipsclass->lang['view_staff_picks']}</a> · <a href="{$this->ipsclass->base_url}act=Search&CODE=getnew">{$this->ipsclass->lang['view_new_posts']}</a>
13. Przejdź do: ACP > Look & Feel > ( wybór skina ) > Edit Template HTML > Forum Index >> TableEnd
Znajdź:
<option value="unapprove">{$this->ipsclass->lang['cpt_unapprove']}</option>
Dodaj poniżej:
<option value="pick">{$this->ipsclass->lang['cpt_pick']}</option>
<option value="unpick">{$this->ipsclass->lang['cpt_unpick']}</option>
14. DONE