$Date: 2006-01-31 22:47:20 +0000 (Tue, 31 Jan 2006) $
| > $Revision: 131 $
| > $Author: bfarber $
+---------------------------------------------------------------------------
|
| > Admin Forum functions
| > Module written by Matt Mecham
| > Date started: 1st march 2002
|
| > Module Version Number: 1.0.0
| > DBA Checked: Mon 24th May 2004
+--------------------------------------------------------------------------
*/
if ( ! defined( 'IN_ACP' ) )
{
print "
Неверный вход
У Вас нет доступа к директиве этого файла. Если Вы проводили обновления, убедитесь, что не забыли обновить 'admin.php'.";
exit();
}
class ad_forums
{
# Global
var $ipsclass;
var $html;
var $forumfunc;
var $base_url;
/**
* Section title name
*
* @var string
*/
var $perm_main = "content";
/**
* Section title name
*
* @var string
*/
var $perm_child = "forum";
/*-------------------------------------------------------------------------*/
// RUN!
/*-------------------------------------------------------------------------*/
function auto_run()
{
//-----------------------------------------
// Kill globals - globals bad, Homer good.
//-----------------------------------------
$tmp_in = array_merge( $_GET, $_POST, $_COOKIE );
foreach ( $tmp_in as $k => $v )
{
unset($$k);
}
$this->ipsclass->forums->forums_init();
//-----------------------------------------
// Load class
//-----------------------------------------
require ROOT_PATH.'sources/lib/admin_forum_functions.php';
$this->forumfunc = new admin_forum_functions();
$this->forumfunc->ipsclass =& $this->ipsclass;
//-----------------------------------------
// LOAD HTML
//-----------------------------------------
$this->html = $this->ipsclass->acp_load_template('cp_skin_forums');
$this->forumfunc->html =& $this->html;
//-----------------------------------------
// To do...
//-----------------------------------------
switch($this->ipsclass->input['code'])
{
case 'new':
$this->ipsclass->admin->cp_permission_check( $this->perm_main.'|'.$this->perm_child.':add' );
$this->forum_form('new');
break;
case 'donew':
$this->ipsclass->admin->cp_permission_check( $this->perm_main.'|'.$this->perm_child.':add' );
$this->forum_save('new');
break;
//-----------------------------------------
case 'edit':
$this->ipsclass->admin->cp_permission_check( $this->perm_main.'|'.$this->perm_child.':edit' );
$this->forum_form('edit');
break;
case 'doedit':
$this->ipsclass->admin->cp_permission_check( $this->perm_main.'|'.$this->perm_child.':edit' );
$this->forum_save('edit');
break;
//-----------------------------------------
case 'pedit':
$this->ipsclass->admin->cp_permission_check( $this->perm_main.'|'.$this->perm_child.':permedit' );
$this->perm_edit_form();
break;
case 'pdoedit':
$this->ipsclass->admin->cp_permission_check( $this->perm_main.'|'.$this->perm_child.':permedit' );
$this->perm_do_edit();
break;
//-----------------------------------------
case 'reorder':
$this->ipsclass->admin->cp_permission_check( $this->perm_main.'|'.$this->perm_child.':reorder' );
$this->reorder_form();
break;
case 'doreorder':
$this->ipsclass->admin->cp_permission_check( $this->perm_main.'|'.$this->perm_child.':reorder' );
$this->do_reorder();
break;
case 'doreordercat':
$this->ipsclass->admin->cp_permission_check( $this->perm_main.'|'.$this->perm_child.':reorder' );
$this->do_reorder();
break;
//-----------------------------------------
case 'delete':
$this->ipsclass->admin->cp_permission_check( $this->perm_main.'|'.$this->perm_child.':remove' );
$this->delete_form();
break;
case 'dodelete':
$this->ipsclass->admin->cp_permission_check( $this->perm_main.'|'.$this->perm_child.':remove' );
$this->do_delete();
break;
//-----------------------------------------
case 'recount':
$this->ipsclass->admin->cp_permission_check( $this->perm_main.'|'.$this->perm_child.':recount' );
$this->recount();
break;
//-----------------------------------------
case 'empty':
$this->ipsclass->admin->cp_permission_check( $this->perm_main.'|'.$this->perm_child.':empty' );
$this->empty_form();
break;
case 'doempty':
$this->ipsclass->admin->cp_permission_check( $this->perm_main.'|'.$this->perm_child.':empty' );
$this->do_empty();
break;
//-----------------------------------------
case 'frules':
$this->ipsclass->admin->cp_permission_check( $this->perm_main.'|'.$this->perm_child.':rules' );
$this->show_rules();
break;
case 'dorules':
$this->ipsclass->admin->cp_permission_check( $this->perm_main.'|'.$this->perm_child.':rules' );
$this->do_rules();
break;
//-----------------------------------------
case 'skinedit':
$this->ipsclass->admin->cp_permission_check( $this->perm_main.'|'.$this->perm_child.':skin' );
$this->skin_edit();
break;
case 'doskinedit':
$this->ipsclass->admin->cp_permission_check( $this->perm_main.'|'.$this->perm_child.':skin' );
$this->do_skin_edit();
break;
//-----------------------------------------
default:
$this->ipsclass->admin->cp_permission_check( $this->perm_main.'|'.$this->perm_child.':' );
$this->show_forums();
break;
}
}
/*-------------------------------------------------------------------------*/
// Edit forum skins
/*-------------------------------------------------------------------------*/
function skin_edit()
{
if ($this->ipsclass->input['f'] == "")
{
$this->ipsclass->admin->error("Невозможно определить ID форума, чтобы очистить его.");
}
$forum = $this->ipsclass->forums->forum_by_id[ $this->ipsclass->input['f'] ];
//-----------------------------------------
// Make sure we have a legal forum
//-----------------------------------------
if ( ! $forum['id'] )
{
$this->ipsclass->admin->error("Нельзя изменить ID этого Форума");
}
if ( ! $forum['skin_id'] )
{
$forum['skin_id'] = -1;
}
//-----------------------------------------
// Get skins..
//-----------------------------------------
$tmp = $this->ipsclass->skin['_setid'];
$this->ipsclass->skin['_setid'] = $forum['skin_id'];
require_once( ROOT_PATH.'sources/classes/class_display.php' );
$display = new display();
$display->ipsclass =& $this->ipsclass;
$skin_list = $display->_build_skin_list();
$this->ipsclass->skin['_setid'] = $tmp;
//-----------------------------------------
// Do form..
//-----------------------------------------
$this->ipsclass->admin->page_title = "Настройки шаблона форума";
$this->ipsclass->admin->page_detail = "В этой секции вы можете установить или удалить шаблон для выбранного форума. Этот выбор шаблона заменит шаблоны, выбранные пользователями.";
$this->ipsclass->html .= $this->ipsclass->adskin->start_form( array( 1 => array( 'code' , 'doskinedit'),
2 => array( 'act' , 'forum' ),
3 => array( 'section', 'content' ),
4 => array( 'f' , $this->ipsclass->input['f'] ),
) );
$this->ipsclass->adskin->td_header[] = array( " " , "40%" );
$this->ipsclass->adskin->td_header[] = array( " " , "60%" );
$this->ipsclass->html .= $this->ipsclass->adskin->start_table( "Выбор шаблона для форума: {$forum['name']}" );
$this->ipsclass->html .= $this->ipsclass->adskin->add_td_row( array( "Какой шаблон установить для этого форума?" ,
""
) );
$this->ipsclass->html .= $this->ipsclass->adskin->add_td_row( array( "Применить ко всем подфорумам?" ,
$this->ipsclass->adskin->form_yes_no( 'apply_to_children' )
) );
$this->ipsclass->html .= $this->ipsclass->adskin->end_form("Установить настройки шаблона");
$this->ipsclass->html .= $this->ipsclass->adskin->end_table();
$this->ipsclass->admin->output();
}
/*-------------------------------------------------------------------------*/
// Complete forum skin edit
/*-------------------------------------------------------------------------*/
function do_skin_edit()
{
if ($this->ipsclass->input['f'] == "")
{
$this->ipsclass->admin->error("Невозможно определить ID форума, чтобы принять этот стиль.");
}
$forum = $this->ipsclass->forums->forum_by_id[ $this->ipsclass->input['f'] ];
//-----------------------------------------
// Make sure we have a legal forum
//-----------------------------------------
$this->ipsclass->DB->do_update( 'forums', array( 'skin_id' => $this->ipsclass->input['fsid'] ), 'id='.$this->ipsclass->input['f'] );
//-----------------------------------------
// Find children?
//-----------------------------------------
if ( $this->ipsclass->input['apply_to_children'] )
{
//-----------------------------------------
// Get children!
//-----------------------------------------
$ids = $this->ipsclass->forums->forums_get_children( $this->ipsclass->input['f'] );
if ( count( $ids ) )
{
$this->ipsclass->DB->do_update( 'forums', array( 'skin_id' => $this->ipsclass->input['fsid'] ), 'id IN ('.implode(",",$ids).')' );
}
}
$this->ipsclass->main_msg = "Шаблон форума обновлен";
$this->recache_forums();
$this->ipsclass->forums->forums_init();
//-----------------------------------------
// Bounce back to parent...
//-----------------------------------------
$this->ipsclass->input['f'] = $this->ipsclass->forums->forum_by_id[ $this->ipsclass->input['f'] ]['parent_id'];
$this->show_forums();
}
/*-------------------------------------------------------------------------*/
// Show forum rules
/*-------------------------------------------------------------------------*/
function show_rules()
{
if ($this->ipsclass->input['f'] == "")
{
$this->ipsclass->admin->error("Невозможно определить ID форума, чтобы очистить его.");
}
$this->ipsclass->DB->simple_construct( array( 'select' => 'id, name, show_rules, rules_title, rules_text', 'from' => 'forums', 'where' => "id=".$this->ipsclass->input['f'] ) );
$this->ipsclass->DB->simple_exec();
//-----------------------------------------
// Make sure we have a legal forum
//-----------------------------------------
if ( ! $this->ipsclass->DB->get_num_rows() )
{
$this->ipsclass->admin->error("Нельзя изменить ID этого Форума");
}
$forum = $this->ipsclass->DB->fetch_row();
//-----------------------------------------
$this->ipsclass->admin->page_title = "Правила форума";
$this->ipsclass->admin->page_detail = "В этой секции вы можете добавлять, изменять и удалять отображаемые правила выбранного форума";
$this->ipsclass->html .= $this->ipsclass->adskin->start_form( array( 1 => array( 'code' , 'dorules'),
2 => array( 'act' , 'forum' ),
3 => array( 'section', 'content' ),
4 => array( 'f' , $this->ipsclass->input['f'] ),
) );
$this->ipsclass->adskin->td_header[] = array( " " , "40%" );
$this->ipsclass->adskin->td_header[] = array( " " , "60%" );
$this->ipsclass->html .= $this->ipsclass->adskin->start_table( "Настройки правил форума" );
$this->ipsclass->html .= $this->ipsclass->adskin->add_td_row( array( "Способ отображения" ,
$this->ipsclass->adskin->form_dropdown( "show_rules",
array(
0 => array( '0' , 'Не показывать' ),
1 => array( '1' , 'Показывать только ссылку' ),
2 => array( '2' , 'Показывать весь текст' )
),
$forum['show_rules']
)
) );
$this->ipsclass->html .= $this->ipsclass->adskin->add_td_row( array( "Заголовок правил" ,
$this->ipsclass->adskin->form_input("title", $this->ipsclass->txt_stripslashes(str_replace( "'", ''', $forum['rules_title'])))
) );
$this->ipsclass->html .= $this->ipsclass->adskin->add_td_row( array( "Текст правил
(HTML разрешен)" ,
$this->ipsclass->adskin->form_textarea( "body", htmlspecialchars($forum['rules_text'], ENT_QUOTES), 65, 20 )
) );
$this->ipsclass->html .= $this->ipsclass->adskin->end_form("Сохранить изменения");
$this->ipsclass->html .= $this->ipsclass->adskin->end_table();
$this->ipsclass->admin->output();
}
/*-------------------------------------------------------------------------*/
// Save forum rules
/*-------------------------------------------------------------------------*/
function do_rules()
{
if ($this->ipsclass->input['f'] == "")
{
$this->ipsclass->admin->error("Невозможно определить ID форума, чтобы очистить его.");
}
$rules = array(
'rules_title' => $this->ipsclass->admin->make_safe($this->ipsclass->txt_stripslashes($_POST['title'])),
'rules_text' => $this->ipsclass->admin->make_safe($this->ipsclass->txt_stripslashes(html_entity_decode($_POST['body'], ENT_QUOTES))),
'show_rules' => $this->ipsclass->input['show_rules']
);
$this->ipsclass->DB->do_update( 'forums', $rules, 'id='.$this->ipsclass->input['f'] );
$this->recache_forums();
$this->ipsclass->main_msg = "Правила форума обновлены";
//-----------------------------------------
// Bounce back to parent...
//-----------------------------------------
$this->ipsclass->input['f'] = $this->ipsclass->forums->forum_by_id[ $this->ipsclass->input['f'] ]['parent_id'];
$this->show_forums();
}
/*-------------------------------------------------------------------------*/
// RECOUNT FORUM: Recounts topics and posts
/*-------------------------------------------------------------------------*/
function recount($f_override="")
{
if ($f_override != "")
{
// Internal call, remap
$this->ipsclass->input['f'] = $f_override;
}
require_once( ROOT_PATH.'sources/lib/func_mod.php' );
$modfunc = new func_mod();
$modfunc->ipsclass =& $this->ipsclass;
$modfunc->forum_recount($this->ipsclass->input['f']);
$this->recache_forums();
$this->ipsclass->admin->save_log("Все сообщения на форуме пересчитаны '{$this->ipsclass->forums->forum_by_id[$this->ipsclass->input['f']]['name']}'");
$this->ipsclass->main_msg = "Форум ресинхронизирован";
//-----------------------------------------
// Bounce back to parent...
//-----------------------------------------
$this->ipsclass->input['f'] = $this->ipsclass->forums->forum_by_id[ $this->ipsclass->input['f'] ]['parent_id'];
$this->show_forums();
}
/*-------------------------------------------------------------------------*/
// EMPTY FORUM: Removes all topics and posts, etc.
/*-------------------------------------------------------------------------*/
function empty_form()
{
$form_array = array();
if ($this->ipsclass->input['f'] == "")
{
$this->ipsclass->admin->error("Невозможно определить ID форума, чтобы очистить его.");
}
$this->ipsclass->DB->simple_construct( array( 'select' => 'id, name', 'from' => 'forums', 'where' => "id=".$this->ipsclass->input['f'] ) );
$this->ipsclass->DB->simple_exec();
//-----------------------------------------
// Make sure we have a legal forum
//-----------------------------------------
if ( !$this->ipsclass->DB->get_num_rows() )
{
$this->ipsclass->admin->error("Нельзя изменить ID этого Форума");
}
$forum = $this->ipsclass->DB->fetch_row();
//-----------------------------------------
$this->ipsclass->admin->page_title = "Очистить форум '{$forum['name']}'";
$this->ipsclass->admin->page_detail = "ЭТА ОПЦИЯ УДАЛЯЕТ ВСЕ ТЕМЫ, СООБЩЕНИЯ И ГОЛОСОВАНИЯ.
Сам же форум не будет удален - убедитесь в том, что это действительно необходимо.";
//-----------------------------------------
$this->ipsclass->html .= $this->ipsclass->adskin->start_form( array( 1 => array( 'code' , 'doempty' ),
2 => array( 'act' , 'forum' ),
2 => array( 'section' , 'content' ),
3 => array( 'f' , $this->ipsclass->input['f'] ),
4 => array( 'name' , $forum['name'] ),
) );
//-----------------------------------------
$this->ipsclass->adskin->td_header[] = array( " " , "40%" );
$this->ipsclass->adskin->td_header[] = array( " " , "60%" );
//-----------------------------------------
$this->ipsclass->html .= $this->ipsclass->adskin->start_table( "Очистка форума '{$forum['name']}'" );
$this->ipsclass->html .= $this->ipsclass->adskin->add_td_row( array( "Очистить форум: " , $forum['name'] ) );
$this->ipsclass->html .= $this->ipsclass->adskin->end_form("Очистить этот форум");
$this->ipsclass->html .= $this->ipsclass->adskin->end_table();
$this->ipsclass->admin->output();
}
/*-------------------------------------------------------------------------*/
// Do empty
/*-------------------------------------------------------------------------*/
function do_empty()
{
//-----------------------------------------
// Get module
//-----------------------------------------
require_once( ROOT_PATH.'sources/lib/func_mod.php' );
$modfunc = new func_mod();
$modfunc->ipsclass =& $this->ipsclass;
if ($this->ipsclass->input['f'] == "")
{
$this->ipsclass->admin->error("Невозможно определить ID форума");
}
//-----------------------------------------
// Check to make sure its a valid forum.
//-----------------------------------------
$this->ipsclass->DB->simple_construct( array( 'select' => 'id, posts, topics', 'from' => 'forums', 'where' => "id=".$this->ipsclass->input['f'] ) );
$this->ipsclass->DB->simple_exec();
if ( ! $forum = $this->ipsclass->DB->fetch_row() )
{
$this->ipsclass->admin->error("Невозможно определить ID форума");
}
$this->ipsclass->DB->simple_construct( array( 'select' => 'tid', 'from' => 'topics', 'where' => "forum_id=".$this->ipsclass->input['f'] ) );
$outer = $this->ipsclass->DB->simple_exec();
//-----------------------------------------
// What to do..
//-----------------------------------------
while( $t = $this->ipsclass->DB->fetch_row($outer) )
{
$modfunc->topic_delete($t['tid']);
}
//-----------------------------------------
// Rebuild stats
//-----------------------------------------
$modfunc->forum_recount($this->ipsclass->input['f']);
$modfunc->stats_recount();
//-----------------------------------------
// Rebuild forum cache
//-----------------------------------------
$this->recache_forums();
$this->ipsclass->admin->save_log("'{$this->ipsclass->input['name']}' очищен от всех сообщений");
$this->ipsclass->input['f'] = "";
$this->ipsclass->main_msg = "Форум очищен ;(";
$this->show_forums();
}
/*-------------------------------------------------------------------------*/
// REMOVE FORUM
/*-------------------------------------------------------------------------*/
function delete_form()
{
$form_array = array();
$this->ipsclass->input['f'] = intval($this->ipsclass->input['f']);
if ( ! $this->ipsclass->input['f'] )
{
$this->ipsclass->admin->error("Невозможно определить ID форума, чтобы удалить.");
}
$this->ipsclass->DB->simple_construct( array( 'select' => 'id, name', 'from' => 'forums', 'order' => 'position' ) );
$this->ipsclass->DB->simple_exec();
//-----------------------------------------
// Make sure we have more than 1
// forum..
//-----------------------------------------
if ( $this->ipsclass->DB->get_num_rows() < 2 )
{
$this->ipsclass->admin->error("Вы не можете удалить этот форум, создайте хоть один форум кроме этого для удаления выбранного форума.");
}
while ( $r = $this->ipsclass->DB->fetch_row() )
{
if ($r['id'] == $this->ipsclass->input['f'])
{
$name = $r['name'];
continue;
}
}
$form_array = $this->forumfunc->ad_forums_forum_list(1);
//-----------------------------------------
// Count the number of topics
//-----------------------------------------
$posts = $this->ipsclass->DB->simple_exec_query( array( 'select' => 'count(*) as count', 'from' => 'topics', 'where' => 'forum_id='.$this->ipsclass->input['f'] ) );
//-----------------------------------------
// Count the number of children
//-----------------------------------------
$children = $this->ipsclass->DB->simple_exec_query( array( 'select' => 'count(*) as count', 'from' => 'forums', 'where' => 'parent_id='.$this->ipsclass->input['f'] ) );
//-----------------------------------------
// Start form
//-----------------------------------------
$this->ipsclass->admin->page_title = "Удаление форума '$name'";
$this->ipsclass->admin->page_detail = "До того как вы удалите этот форум: если выбранный форум не пуст, выберите, что вы будете делать с сообщениями этого форума.";
$this->ipsclass->html .= $this->ipsclass->adskin->start_form( array( 1 => array( 'code' , 'dodelete'),
2 => array( 'act' , 'forum' ),
3 => array( 'section', 'content' ),
4 => array( 'f' , $this->ipsclass->input['f'] ),
) );
$this->ipsclass->adskin->td_header[] = array( " " , "40%" );
$this->ipsclass->adskin->td_header[] = array( " " , "60%" );
//-----------------------------------------
// Main form
//-----------------------------------------
$this->ipsclass->html .= $this->ipsclass->adskin->start_table( "Дополнительная информация" );
$this->ipsclass->html .= $this->ipsclass->adskin->add_td_row( array( "Удалить форум: " , $name ) );
if ( $posts['count'] )
{
$this->ipsclass->html .= $this->ipsclass->adskin->add_td_row( array( "Переместить все имеющиеся темы и сообщения в этом форуме в другой?" ,
$this->ipsclass->adskin->form_dropdown( "MOVE_ID", $form_array )
) );
}
if ( $children['count'] )
{
$this->ipsclass->html .= $this->ipsclass->adskin->add_td_row( array( "Переместить все существующие темы, сообщения и голосования из этого форума в форум:" ,
$this->ipsclass->adskin->form_dropdown( "new_parent_id", $form_array )
) );
}
$this->ipsclass->html .= $this->ipsclass->adskin->end_form( "Удалить форум" );
$this->ipsclass->html .= $this->ipsclass->adskin->end_table();
$this->ipsclass->admin->output();
}
/*-------------------------------------------------------------------------*/
// PROCESS DELETE
/*-------------------------------------------------------------------------*/
function do_delete()
{
$this->ipsclass->input['f'] = intval($this->ipsclass->input['f']);
$this->ipsclass->input['MOVE_ID'] = intval($this->ipsclass->input['MOVE_ID']);
$this->ipsclass->input['new_parent_id'] = intval($this->ipsclass->input['new_parent_id']);
$this->ipsclass->DB->simple_construct( array( 'select' => '*', 'from' => 'forums', 'where' => "id=".$this->ipsclass->input['f'] ) );
$this->ipsclass->DB->simple_exec();
$forum = $this->ipsclass->DB->fetch_row();
if ( ! $this->ipsclass->input['f'] )
{
$this->ipsclass->admin->error("Невозможно определить источник ID форума.");
}
if ( ! $this->ipsclass->input['new_parent_id'] )
{
$this->ipsclass->input['new_parent_id'] = -1;
}
else
{
if ( $this->ipsclass->input['new_parent_id'] == $this->ipsclass->input['f'] )
{
$this->ipsclass->main_msg = "Вы не можете переместить подфорумы в удаляемый форум!";
$this->delete_form();
}
}
//-----------------------------------------
// Get library
//-----------------------------------------
require_once( ROOT_PATH.'sources/lib/func_mod.php' );
$modfunc = new func_mod();
$modfunc->ipsclass =& $this->ipsclass;
//-----------------------------------------
// Move stuff
//-----------------------------------------
if ( $this->ipsclass->input['MOVE_ID'] )
{
if ( $this->ipsclass->input['MOVE_ID'] == $this->ipsclass->input['f'] )
{
$this->ipsclass->main_msg = "Вы не можете переместить темы, сообщения и голосования в удаляемый форум!";
$this->delete_form();
}
//-----------------------------------------
// Move topics...
//-----------------------------------------
$this->ipsclass->DB->do_update( 'topics', array( 'forum_id' => $this->ipsclass->input['MOVE_ID'] ), 'forum_id='.$this->ipsclass->input['f'] );
//-----------------------------------------
// Move polls...
//-----------------------------------------
$this->ipsclass->DB->do_update( 'polls', array( 'forum_id' => $this->ipsclass->input['MOVE_ID'] ), 'forum_id='.$this->ipsclass->input['f'] );
//-----------------------------------------
// Move voters...
//-----------------------------------------
$this->ipsclass->DB->do_update( 'voters', array( 'forum_id' => $this->ipsclass->input['MOVE_ID'] ), 'forum_id='.$this->ipsclass->input['f'] );
$modfunc->forum_recount( $this->ipsclass->input['MOVE_ID'] );
}
//-----------------------------------------
// Delete the forum
//-----------------------------------------
$this->ipsclass->DB->simple_exec_query( array( 'delete' => 'forums', 'where' => "id=".$this->ipsclass->input['f'] ) );
//-----------------------------------------
// Delete any moderators, if any..
//-----------------------------------------
$this->ipsclass->DB->simple_exec_query( array( 'delete' => 'moderators', 'where' => "forum_id=".$this->ipsclass->input['f'] ) );
//-----------------------------------------
// Delete forum subscriptions
//-----------------------------------------
$this->ipsclass->DB->simple_exec_query( array( 'delete' => 'forum_tracker', 'where' => "forum_id=".$this->ipsclass->input['f'] ) );
//-----------------------------------------
// Update children
//-----------------------------------------
if ( ! $this->ipsclass->input['new_parent_id'] )
{
$this->ipsclass->input['new_parent_id'] = -1;
}
$this->ipsclass->DB->do_update( 'forums', array( 'parent_id' => $this->ipsclass->input['new_parent_id'] ), "parent_id={$this->ipsclass->input['f']}" );
//-----------------------------------------
// Rebuild forum cache
//-----------------------------------------
$this->recache_forums();
//-----------------------------------------
// Rebuild moderator cache
//-----------------------------------------
require_once( ROOT_PATH.'sources/action_admin/moderator.php' );
$moderator = new ad_moderator();
$moderator->ipsclass =& $this->ipsclass;
$moderator->rebuild_moderator_cache();
$this->ipsclass->admin->save_log("Форум удален '{$forum['name']}'");
$this->ipsclass->admin->done_screen("Форум был успешно удален", "Управление форумом", $this->ipsclass->form_code, 'redirect' );
}
/*-------------------------------------------------------------------------*/
// ADD / EDIT FORUM
/*-------------------------------------------------------------------------*/
function forum_form( $type='edit' )
{
//-----------------------------------------
// INIT
//-----------------------------------------
$form = array();
$forum = array();
$forum_id = intval($this->ipsclass->input['f']);
$parentid = intval($this->ipsclass->input['p']) ? intval($this->ipsclass->input['p']) : -1;
$cat_id = intval($this->ipsclass->input['c']);
$f_name = $this->ipsclass->parse_clean_value(urldecode($_REQUEST['name']));
$subcanpost = ( $this->ipsclass->input['c'] == 1 ) ? 0 : 1;
$perm_matrix = "";
$dd_state = array( 0 => array( 1, 'Активный' ), 1 => array( 0, 'Только для чтения архивов' ) );
$dd_moderate = array(
0 => array( 0, 'Нет' ),
1 => array( 1, 'Модерировать все новые темы и сообщения' ),
2 => array( 2, 'Модерировать только новые темы' ),
3 => array( 3, 'Модерировать только новые ответы' ),
);
$dd_prune = array(
0 => array( 1, 'День' ),
1 => array( 5, '5 дней' ),
2 => array( 7, '7 дней' ),
3 => array( 10, '10 дней' ),
4 => array( 15, '15 дней' ),
5 => array( 20, '20 дней' ),
6 => array( 25, '25 дней' ),
7 => array( 30, '30 дней' ),
8 => array( 60, '60 дней' ),
9 => array( 90, '90 дней' ),
10=> array( 100,'Показывать все' ),
);
$dd_order = array(
0 => array( 'last_post', 'По дате последнего сообщения' ),
1 => array( 'title' , 'Названиям тем' ),
2 => array( 'starter_name', 'Автору тем' ),
3 => array( 'posts' , 'Сообщениям в темах' ),
4 => array( 'views' , 'Просмотру тем' ),
5 => array( 'start_date', 'Дате создания тем' ),
6 => array( 'last_poster_name' , 'Последним авторам' )
);
$dd_by = array(
0 => array( 'Z-A', 'По убыванию (Z - A, 0 - 10)' ),
1 => array( 'A-Z', 'По возрастанию (A - Z, 10 - 0)' )
);
$dd_filter = array(
0 => array( 'all', 'Все темы' ),
1 => array( 'open', 'Открытые темы' ),
2 => array( 'hot', 'Горячие темы' ),
3 => array( 'poll', 'Опросы' ),
4 => array( 'locked', 'Закрытые темы' ),
5 => array( 'moved', 'Открытые темы' ),
6 => array( 'istarted', 'Темы, созданные пользователем' ),
7 => array( 'ireplied', 'Темы, с ответами пользователя' ),
);
//-----------------------------------------
// Set up title, desc
//-----------------------------------------
$this->ipsclass->admin->page_detail = "Эта секция позволяет вам добавлять новые и изменять уже существующие форумы.
Если вы хотите установить маски доступа к существующему форуму (такие как возможность просмотра форума, создание тем, ответы и загрузки) нажмите на 'Маски доступа'.";
//-----------------------------------------
// EDIT
//-----------------------------------------
if ( $type == 'edit' )
{
//-----------------------------------------
// Check
//-----------------------------------------
if ( ! $forum_id )
{
$this->ipsclass->admin->error("Вы не выбрали форум для редактирования!");
}
//-----------------------------------------
// Do not show forum in forum list
//-----------------------------------------
$this->forumfunc->exclude_from_list = $forum_id;
//-----------------------------------------
// Get this forum
//-----------------------------------------
$forum = $this->ipsclass->DB->simple_exec_query( array( 'select' => '*', 'from' => 'forums', 'where' => 'id='.$this->ipsclass->input['f'] ) );
//-----------------------------------------
// Check
//-----------------------------------------
if ($forum['id'] == "")
{
$this->ipsclass->admin->error("Невозможно найти форум с ID {$this->ipsclass->input['f']}");
}
//-----------------------------------------
// Set up code buttons
//-----------------------------------------
$title = "Редактируемый форум: {$forum['name']}";
$button = "Редактировать форум";
$code = "doedit";
//-----------------------------------------
// Basic title
//-----------------------------------------
$basic_title = "
| Основные настройки {$forum['name']} |
".
$this->ipsclass->adskin->js_make_button("Правила форума" , $this->ipsclass->base_url."&{$this->ipsclass->form_code}&code=frules&f={$this->ipsclass->input['f']}")." ".
$this->ipsclass->adskin->js_make_button("Шаблон форума", $this->ipsclass->base_url."&{$this->ipsclass->form_code}&code=skinedit&f={$this->ipsclass->input['f']}")." ".
$this->ipsclass->adskin->js_make_button("Пересчет сообщений" , $this->ipsclass->base_url."&{$this->ipsclass->form_code}&code=recount&f={$this->ipsclass->input['f']}")
." |
";
}
//-----------------------------------------
// NEW
//-----------------------------------------
else
{
# Ensure there is an ID
$this->ipsclass->input['f'] = 0;
$forum = array(
'sub_can_post' => $subcanpost,
'name' => $f_name ? $f_name : 'Новый форум',
'parent_id' => $parentid,
'use_ibc' => 1,
'quick_reply' => 1,
'allow_poll' => 1,
'prune' => 100,
'topicfilter' => 'all',
'sort_key' => 'last_post',
'sort_order' => 'Z-A',
'inc_postcount'=> 1,
);
$title = "Добавление форума";
$button = "Добавить форум";
$code = "donew";
$basic_title = 'Основные настройки';
}
//-----------------------------------------
// Build forumlist
//-----------------------------------------
$forumlist = $this->forumfunc->ad_forums_forum_list();
//-----------------------------------------
// Page title...
//-----------------------------------------
$this->ipsclass->admin->page_title = $title;
//-----------------------------------------
// Generate form items
//-----------------------------------------
# Main settings
$form['name'] = $this->ipsclass->adskin->form_input( 'name' , $this->ipsclass->parse_clean_value( $_POST['name'] ) ? $this->ipsclass->parse_clean_value( $_POST['name'] ) : $forum['name'] );
$form['description'] = $this->ipsclass->adskin->form_textarea("description" , $this->ipsclass->my_br2nl( $_POST['description'] ? $_POST['description'] : $forum['description'] ) );
$form['parent_id'] = $this->ipsclass->adskin->form_dropdown("parent_id" , $forumlist, $_POST['parent_id'] ? $_POST['parent_id'] : $forum['parent_id'] );
$form['status'] = $this->ipsclass->adskin->form_dropdown("status" , $dd_state , $_POST['status'] ? $_POST['status'] : $forum['status'] );
$form['sub_can_post'] = $this->ipsclass->adskin->form_yes_no( 'sub_can_post', $_POST['sub_can_post'] ? $_POST['sub_can_post'] : $forum['sub_can_post'] );
# Redirect options
$form['redirect_url'] = $this->ipsclass->adskin->form_input( 'redirect_url' , $_POST['redirect_url'] ? $_POST['redirect_url'] : $forum['redirect_url'] );
$form['redirect_on'] = $this->ipsclass->adskin->form_yes_no('redirect_on' , $_POST['redirect_on'] ? $_POST['redirect_on'] : $forum['redirect_on'] );
$form['redirect_hits'] = $this->ipsclass->adskin->form_input( 'redirect_hits', $_POST['redirect_hits'] ? $_POST['redirect_hits'] : $forum['redirect_hits'] );
# Permission settings
$form['permission_showtopic'] = $this->ipsclass->adskin->form_yes_no( 'permission_showtopic' , $_POST['permission_showtopic'] ? $_POST['permission_showtopic'] : $forum['permission_showtopic'] );
$form['permission_custom_error'] = $this->ipsclass->adskin->form_textarea("permission_custom_error", $this->ipsclass->my_br2nl( $_POST['permission_custom_error'] ? $_POST['permission_custom_error'] : $forum['permission_custom_error'] ) );
# Forum settings
$form['use_html'] = $this->ipsclass->adskin->form_yes_no('use_html' , $_POST['use_html'] ? $_POST['use_html'] : $forum['use_html'] );
$form['use_ibc'] = $this->ipsclass->adskin->form_yes_no('use_ibc' , $_POST['use_ibc'] ? $_POST['use_ibc'] : $forum['use_ibc'] );
$form['quick_reply'] = $this->ipsclass->adskin->form_yes_no('quick_reply' , $_POST['quick_reply'] ? $_POST['quick_reply'] : $forum['quick_reply'] );
$form['allow_poll'] = $this->ipsclass->adskin->form_yes_no('allow_poll' , $_POST['allow_poll'] ? $_POST['allow_poll'] : $forum['allow_poll'] );
$form['allow_pollbump'] = $this->ipsclass->adskin->form_yes_no('allow_pollbump' , $_POST['allow_pollbump'] ? $_POST['allow_pollbump'] : $forum['allow_pollbump'] );
$form['inc_postcount'] = $this->ipsclass->adskin->form_yes_no('inc_postcount' , $_POST['inc_postcount'] ? $_POST['inc_postcount'] : $forum['inc_postcount'] );
$form['forum_allow_rating'] = $this->ipsclass->adskin->form_yes_no('forum_allow_rating', $_POST['forum_allow_rating'] ? $_POST['forum_allow_rating'] : $forum['forum_allow_rating'] );
# Mod settings
$form['preview_posts'] = $this->ipsclass->adskin->form_dropdown("preview_posts" , $dd_moderate, $_POST['preview_posts'] ? $_POST['preview_posts'] : $forum['preview_posts'] );
$form['notify_modq_emails'] = $this->ipsclass->adskin->form_input( 'notify_modq_emails', $_POST['notify_modq_emails'] ? $_POST['notify_modq_emails'] : $forum['notify_modq_emails'] );
$form['password'] = $this->ipsclass->adskin->form_input( 'password' , $_POST['password'] ? $_POST['password'] : $forum['password'] );
# Sorting settings
$form['prune'] = $this->ipsclass->adskin->form_dropdown("prune" , $dd_prune, $_POST['prune'] ? $_POST['prune'] : $forum['prune'] );
$form['sort_key'] = $this->ipsclass->adskin->form_dropdown("sort_key" , $dd_order, $_POST['sort_key'] ? $_POST['sort_key'] : $forum['sort_key'] );
$form['sort_order'] = $this->ipsclass->adskin->form_dropdown("sort_order", $dd_by , $_POST['sort_order'] ? $_POST['sort_order'] : $forum['sort_order'] );
$form['topicfilter'] = $this->ipsclass->adskin->form_dropdown("topicfilter", $dd_filter , $_POST['topicfilter'] ? $_POST['topicfilter'] : $forum['topicfilter'] );
//-----------------------------------------
// Show permission matrix
//-----------------------------------------
if ( $type != 'edit' )
{
$perm_matrix = $this->build_group_perms( $forum['show_perms'], $forum['read_perms'], $forum['start_perms'], $forum['reply_perms'], $forum['upload_perms'] );
}
//-----------------------------------------
// Show form...
//-----------------------------------------
$this->ipsclass->html .= $this->html->forum_form( $form, $button, $code, $title, $button, $forum, $perm_matrix );
//-----------------------------------------
// Nav and print
//-----------------------------------------
$this->ipsclass->admin->nav[] = array( $this->ipsclass->form_code, 'Управление форумами' );
$this->ipsclass->admin->nav[] = array( '', 'Добавить/Редактировать форум' );
$this->ipsclass->admin->output();
}
/*-------------------------------------------------------------------------*/
// Do save form
/*-------------------------------------------------------------------------*/
function forum_save($type='new')
{
//-----------------------------------------
// INIT
//-----------------------------------------
$this->ipsclass->input['name'] = trim($this->ipsclass->input['name']);
$this->ipsclass->input['f'] = intval($this->ipsclass->input['f']);
//-----------------------------------------
// Check
//-----------------------------------------
if ($this->ipsclass->input['name'] == "")
{
$this->ipsclass->main_msg = "Вы должны ввести название форума";
$this->forum_form( $type );
return;
}
//-----------------------------------------
// Are we trying to do something stupid
// like running with scissors or moving
// the parent of a forum into itself
// spot?
//-----------------------------------------
if ( $this->ipsclass->input['parent_id'] != $this->ipsclass->forums->forum_by_id[ $this->ipsclass->input['f'] ]['parent_id'] )
{
$ids = $this->ipsclass->forums->forums_get_children( $this->ipsclass->input['f'] );
$ids[] = $this->ipsclass->input['f'];
if ( in_array( $this->ipsclass->input['parent_id'], $ids ) )
{
$this->ipsclass->main_msg = "Извините, сделать это невозможно. Вы хотите переместить родительский форума в него же самого. Пожалуйста, вернитесь назад и попытайтесь выбрать другой форум.";
$this->forum_form( $type );
return;
}
}
//-----------------------------------------
// Save array
//-----------------------------------------
$save = array ( 'name' => $this->ipsclass->input['name'],
'description' => $this->ipsclass->my_nl2br( $this->ipsclass->txt_stripslashes($_POST['description']) ),
'use_ibc' => intval($this->ipsclass->input['use_ibc']),
'use_html' => intval($this->ipsclass->input['use_html']),
'status' => $this->ipsclass->input['status'],
'password' => $this->ipsclass->input['password'],
'sort_key' => $this->ipsclass->input['sort_key'],
'sort_order' => $this->ipsclass->input['sort_order'],
'prune' => $this->ipsclass->input['prune'],
'topicfilter' => $this->ipsclass->input['topicfilter'],
'preview_posts' => $this->ipsclass->input['preview_posts'],
'allow_poll' => intval($this->ipsclass->input['allow_poll']),
'allow_pollbump' => intval($this->ipsclass->input['allow_pollbump']),
'forum_allow_rating' => intval($this->ipsclass->input['forum_allow_rating']),
'inc_postcount' => intval($this->ipsclass->input['inc_postcount']),
'parent_id' => intval($this->ipsclass->input['parent_id']),
'sub_can_post' => intval($this->ipsclass->input['sub_can_post']),
'quick_reply' => intval($this->ipsclass->input['quick_reply']),
'redirect_on' => intval($this->ipsclass->input['redirect_on']),
'redirect_hits' => $this->ipsclass->input['redirect_hits'],
'redirect_url' => $this->ipsclass->input['redirect_url'],
'redirect_loc' => $this->ipsclass->input['redirect_loc'],
'notify_modq_emails' => $this->ipsclass->input['notify_modq_emails'],
'permission_showtopic' => $this->ipsclass->input['permission_showtopic'],
'permission_custom_error' => $this->ipsclass->my_nl2br( $this->ipsclass->txt_stripslashes($_POST['permission_custom_error']) ) );
//-----------------------------------------
// ADD
//-----------------------------------------
if ( $type == 'new' )
{
$this->ipsclass->DB->simple_construct( array( 'select' => 'MAX(id) as top_forum', 'from' => 'forums' ) );
$this->ipsclass->DB->simple_exec();
$row = $this->ipsclass->DB->fetch_row();
if ( $row['top_forum'] < 1 )
{
$row['top_forum'] = 0;
}
$row['top_forum']++;
$perms = $this->ipsclass->admin->compile_forum_perms();
$perm_array = addslashes(serialize(array(
'start_perms' => $perms['START'],
'reply_perms' => $perms['REPLY'],
'read_perms' => $perms['READ'],
'upload_perms' => $perms['UPLOAD'],
'show_perms' => $perms['SHOW']
) ) );
//-----------------------------------------
// Add to save array
//-----------------------------------------
$save['id'] = $row['top_forum'];
$save['position'] = $row['top_forum'];
$save['topics'] = 0;
$save['posts'] = 0;
$save['last_post'] = "";
$save['last_poster_id'] = "";
$save['last_poster_name'] = "";
$save['permission_array'] = $perm_array;
$this->ipsclass->DB->do_insert( 'forums', $save );
$this->ipsclass->main_msg = "Форум создан";
$this->ipsclass->admin->save_log("Forum '{$this->ipsclass->input['name']}' created");
}
else
{
$this->ipsclass->DB->do_update( 'forums', $save, "id={$this->ipsclass->input['f']}" );
$this->ipsclass->main_msg = "Форум отредактирован";
$this->ipsclass->admin->save_log("Форум '{$this->ipsclass->input['name']}' отредактирован");
}
$this->recache_forums();
$this->ipsclass->input['f'] = "";
$this->ipsclass->forums->forums_init();
$this->show_forums();
}
/*-------------------------------------------------------------------------*/
// EDIT FORUM
/*-------------------------------------------------------------------------*/
function perm_edit_form()
{
//-----------------------------------------
// INIT
//-----------------------------------------
$this->ipsclass->input['f'] = intval($this->ipsclass->input['f']);
//-----------------------------------------
// check..
//-----------------------------------------
if ( ! $this->ipsclass->input['f'] )
{
$this->ipsclass->admin->error("Вы не выбрали форум для редактирования!");
}
//-----------------------------------------
// Get this forum details
//-----------------------------------------
$forum = $this->ipsclass->forums->forum_by_id[$this->ipsclass->input['f']];
//-----------------------------------------
// Next id...
//-----------------------------------------
$relative = $this->get_next_id( $this->ipsclass->input['f'] );
//-----------------------------------------
// check...
//-----------------------------------------
if ( ! $forum['id'] )
{
$this->ipsclass->admin->error("Нельзя извлечь из базы данных ID форума {$this->ipsclass->input['f']}");
}
$this->ipsclass->admin->page_title = "Редактировать права для ".$forum['name'];
$this->ipsclass->admin->page_detail = "Управление правами доступа
(Проверьте поля для доступа: если разрешаете – поставьте галочку, запрещаете – снимите)
Если вы запретили чтение для этой группы, они не увидят этот форум";
//-----------------------------------------
// HTML
//-----------------------------------------
$perm_matrix = $this->build_group_perms( $forum['show_perms'], $forum['read_perms'], $forum['start_perms'], $forum['reply_perms'], $forum['upload_perms'],
$this->ipsclass->forums->forum_by_id[ $forum['parent_id'] ]['name'].' > '.$forum['name'].' > '."Уровень прав доступа" );
$this->ipsclass->html .= $this->html->forum_permission_form( $forum, $relative, $perm_matrix );
$this->ipsclass->admin->nav[] = array( $this->ipsclass->form_code, 'Управление форумами' );
$this->ipsclass->admin->nav[] = array( '', 'Доступ на форум для '.$forum['name'] );
$this->ipsclass->admin->output();
}
/*-------------------------------------------------------------------------*/
// Get next forum ID
/*-------------------------------------------------------------------------*/
function get_next_id($fid)
{
$nextid = 0;
$ids = array();
$index = 0;
$count = 0;
foreach( $this->ipsclass->forums->forum_cache['root'] as $id => $forum_data )
{
$ids[ $count ] = $forum_data['id'];
if ( $forum_data['id'] == $fid )
{
$index = $count;
}
$count++;
if ( is_array( $this->ipsclass->forums->forum_cache[ $forum_data['id'] ] ) )
{
foreach( $this->ipsclass->forums->forum_cache[ $forum_data['id'] ] as $id => $forum_data )
{
$children = $this->ipsclass->forums->forums_get_children( $forum_data['id'] );
$ids[ $count ] = $forum_data['id'];
if ( $forum_data['id'] == $fid )
{
$index = $count;
}
$count++;
if ( is_array($children) and count($children) )
{
foreach( $children as $kid )
{
$ids[ $count ] = $kid;
if ( $kid == $fid )
{
$index = $count;
}
$count++;
}
}
}
}
}
return array( 'next' => $ids[ $index + 1 ], 'previous' => $ids[ $index - 1 ] );
}
/*-------------------------------------------------------------------------*/
// RECACHE FORUMS
/*-------------------------------------------------------------------------*/
function recache_forums()
{
$this->ipsclass->update_forum_cache();
}
/*-------------------------------------------------------------------------*/
// SAVE PERM CHANGES
/*-------------------------------------------------------------------------*/
function perm_do_edit()
{
$perms = $this->ipsclass->admin->compile_forum_perms();
$this->ipsclass->DB->do_update( 'forums', array( 'permission_array' => addslashes(serialize(array(
'start_perms' => $perms['START'],
'reply_perms' => $perms['REPLY'],
'read_perms' => $perms['READ'],
'upload_perms' => $perms['UPLOAD'],
'show_perms' => $perms['SHOW']
) ) ) ), 'id='.$this->ipsclass->input['f']);
$this->ipsclass->admin->save_log("Изменены маски доступа к '{$this->ipsclass->input['name']}'");
$this->recache_forums();
if ( $this->ipsclass->input['doprevious'] and $this->ipsclass->input['previd'] > 0 )
{
$this->ipsclass->main_msg = 'Маски доступа изменены';
$this->ipsclass->input['f'] = $this->ipsclass->input['previd'];
$this->ipsclass->boink_it( $this->ipsclass->base_url."&{$this->ipsclass->form_code}&code=pedit&f={$this->ipsclass->input['f']}" );
}
else if ( $this->ipsclass->input['donext'] and $this->ipsclass->input['nextid'] > 0 )
{
$this->ipsclass->main_msg = 'Маски доступа изменены';
$this->ipsclass->input['f'] = $this->ipsclass->input['nextid'];
$this->ipsclass->boink_it( $this->ipsclass->base_url."&{$this->ipsclass->form_code}&code=pedit&f={$this->ipsclass->input['f']}" );
}
else if ( $this->ipsclass->input['reload'] )
{
$this->ipsclass->boink_it( $this->ipsclass->base_url."&{$this->ipsclass->form_code}&code=pedit&f={$this->ipsclass->input['f']}" );
}
else
{
$this->ipsclass->admin->done_screen("Маски доступа изменены", "Управление форумами", $this->ipsclass->form_code, 'redirect' );
}
}
/*-------------------------------------------------------------------------*/
// RE-ORDER FORUMS
/*-------------------------------------------------------------------------*/
function reorder_form()
{
//-----------------------------------------
// INIT
//-----------------------------------------
$temp_html = "";
$depth_guide = "";
//-----------------------------------------
// Check...
//-----------------------------------------
if ( ! $this->ipsclass->input['f'] )
{
$this->ipsclass->admin->error("Продолжить нельзя, F не годен");
}
$this->ipsclass->admin->page_detail = "Эта секция позволяет вам изменить порядок отображения (сортировку) форумов и категорий, достаточно ввести лишь порядковый номер для каждого форума.";
$this->forumfunc->type = 'reorder';
$this->ipsclass->html .= $this->ipsclass->adskin->start_form( array( 1 => array( 'code' , 'doreorder' ),
2 => array( 'act' , 'forum' ),
3 => array( 'section', $this->ipsclass->section_code ),
) );
$cat_data = $this->ipsclass->forums->forum_by_id[ $this->ipsclass->input['f'] ];
if ( is_array( $this->ipsclass->forums->forum_cache[ $this->ipsclass->input['f'] ] ) )
{
foreach( $this->ipsclass->forums->forum_cache[ $this->ipsclass->input['f'] ] as $id => $forum_data )
{
$temp_html .= $this->forumfunc->render_forum($forum_data, $depth_guide);
$temp_html = $this->forumfunc->forum_build_children( $forum_data['id'], $temp_html, $depth_guide . $this->ipsclass->forums->depth_guide );
}
}
$this->ipsclass->html .= $this->forumfunc->forum_show_cat($temp_html, $cat_data);
$this->ipsclass->html .= $this->ipsclass->adskin->end_form_standalone("Пересортировать");
$this->ipsclass->admin->output();
}
/*-------------------------------------------------------------------------*/
// Re order the root forums
/*-------------------------------------------------------------------------*/
function do_reorder()
{
$ids = array();
foreach ($this->ipsclass->input as $key => $value)
{
if ( preg_match( "/^f_(\d+)$/", $key, $match ) )
{
if ($this->ipsclass->input[$match[0]])
{
$ids[ $match[1] ] = $this->ipsclass->input[$match[0]];
}
}
}
//-----------------------------------------
// Save changes
//-----------------------------------------
if ( count($ids) )
{
foreach( $ids as $forum_id => $new_position )
{
$this->ipsclass->DB->do_update( 'forums', array( 'position' => intval($new_position) ), 'id='.$forum_id );
}
}
$this->recache_forums();
$this->ipsclass->boink_it( $this->ipsclass->base_url.'&'.$this->ipsclass->form_code );
}
/*-------------------------------------------------------------------------*/
// SHOW THE FORUMS WOOHOO, ETC
/*-------------------------------------------------------------------------*/
function show_forums()
{
//-----------------------------------------
// INIT
//-----------------------------------------
$this->ipsclass->admin->page_title = "Управление форумами";
$this->ipsclass->admin->page_detail = "В этой секции вы можете создавать новые, изменять и удалять существующие форумы. А также устанавливать правила и шаблоны для каждого форума.";
//-----------------------------------------
// Nav
//-----------------------------------------
if ( $this->ipsclass->input['f'] )
{
$nav = $this->ipsclass->forums->forums_breadcrumb_nav($this->ipsclass->input['f'], '&'.$this->ipsclass->form_code.'&f=');
if ( is_array($nav) and count($nav) > 1 )
{
array_shift($nav);
$this->ipsclass->html .= "Форумы > ".implode( " > ", $nav )."
";
}
}
//-----------------------------------------
// Grab the moderators
//-----------------------------------------
$this->forumfunc->moderators = array();
$this->ipsclass->DB->simple_construct( array( 'select' => '*', 'from' => 'moderators' ) );
$this->ipsclass->DB->simple_exec();
while ($r = $this->ipsclass->DB->fetch_row())
{
$this->forumfunc->moderators[] = $r;
}
//-----------------------------------------
// Print screen
//-----------------------------------------
$this->forumfunc->type = 'manage';
$this->ipsclass->html .= $this->ipsclass->adskin->start_form( array( 1 => array( 'code' , 'doreordercat'),
2 => array( 'act' , 'forum' ),
3 => array( 'section', $this->ipsclass->section_code ),
) );
$this->ipsclass->html .= $this->html->render_forum_header();
$this->forumfunc->forums_list_forums();
$choose = "";
//-----------------------------------------
// Member groups
//-----------------------------------------
$mem_group = "";
//-----------------------------------------
// Add footer
//-----------------------------------------
$this->ipsclass->html .= $this->html->render_forum_footer( $choose, $mem_group );
$this->ipsclass->admin->nav[] = array( '', 'Настройка форумов' );
$this->ipsclass->admin->output();
}
/*-------------------------------------------------------------------------*/
// Build group permissions
/*-------------------------------------------------------------------------*/
function build_group_perms( $show='*', $read='*', $write='*', $reply='*', $upload='*', $title="" )
{
//-----------------------------------------
// Load skin if required
//-----------------------------------------
if ( ! $this->html )
{
$this->html = $this->ipsclass->acp_load_template('cp_skin_forums');
}
//-----------------------------------------
// INIT
//-----------------------------------------
$global = array();
$perm = array();
$data = array();
$checked = "";
$check = " checked='checked'";
$content = "";
//-----------------------------------------
// GLOBALS
//-----------------------------------------
# SHOW FORUM
$checked = ($show == '*') ? $check : "";
$global['html_show'] = "\n";
# READ FORUM
$checked = ($read == '*') ? $check : "";
$global['html_read'] = "\n";
# REPLY FORUM
$checked = ($reply == '*') ? $check : "";
$global['html_reply'] = "\n";
# START TOPICS
$checked = ($write == '*') ? $check : "";
$global['html_start'] = "\n";
# UPLOAD
$checked = ($upload == '*') ? $check : "";
$global['html_upload'] = "\n";
//-----------------------------------------
// Per mask settings
//-----------------------------------------
$this->ipsclass->DB->simple_construct( array( 'select' => '*', 'from' => 'forum_perms', 'order' => "perm_name ASC" ) );
$this->ipsclass->DB->simple_exec();
while ( $data = $this->ipsclass->DB->fetch_row() )
{
# SHOW FORUM
$checked = ($show == '*' OR preg_match( "/(^|,)".$data['perm_id']."(,|$)/", $show ) ) ? $check : "";
$perm['html_show'] = "";
# READ FORUM
$checked = ($read == '*' OR preg_match( "/(^|,)".$data['perm_id']."(,|$)/", $read ) ) ? $check : "";
$perm['html_read'] = "";
# REPLY FORUM
$checked = ($reply == '*' OR preg_match( "/(^|,)".$data['perm_id']."(,|$)/", $reply ) ) ? $check : "";
$perm['html_reply'] = "";
# WRITE FORUM
$checked = ($write == '*' OR preg_match( "/(^|,)".$data['perm_id']."(,|$)/", $write ) ) ? $check : "";
$perm['html_start'] = "";
# UPLOAD
$checked = ($upload == '*' OR preg_match( "/(^|,)".$data['perm_id']."(,|$)/", $upload ) ) ? $check : "";
$perm['html_upload'] = "";
$content .= $this->html->render_forum_permissions_row( $perm, $data );
}
//-----------------------------------------
// Wrapper...
//-----------------------------------------
return $this->html->render_forum_permissions( $global, $content, $title );
}
}
?>