$Date: 2008-04-21 17:32:17 -0400 (Mon, 21 Apr 2008) $
| > $Revision: 1249 $
| > $Author: bfarber $
+---------------------------------------------------------------------------
|
| > Moderation core module
| > Module written by Matt Mecham
| > Date started: 19th February 2002
|
| > Module Version 1.0.0
| > DBA Checked: Wed 19 May 2004
| > Quality Checked: Wed 15 Sept. 2004
+--------------------------------------------------------------------------
*/
if ( ! defined( 'IN_IPB' ) )
{
print "
Incorrect access
You cannot access this file directly. If you have recently upgraded, make sure you upgraded all the relevant files.";
exit();
}
class moderate
{
var $output = "";
var $base_url = "";
var $html = "";
var $moderator = "";
var $modfunc = "";
var $forum = array( 'id' => 0 );
var $topic = array();
var $upload_dir = "";
var $trash_forum = 0;
var $trash_inuse = 0;
/*-------------------------------------------------------------------------*/
// Our constructor, load words, load skin, print the topic listing
/*-------------------------------------------------------------------------*/
function auto_run()
{
$post_array = array( '04', '02', '20', '22', 'resync', 'prune_start', 'prune_finish', 'prune_move', 'editmember' );
$not_forum_array = array( 'editmember' );
//-----------------------------------------
// Make sure this is a POST request
// not a naughty IMG redirect
//-----------------------------------------
if ( ! in_array( $this->ipsclass->input['CODE'], $post_array ) )
{
if ( $_POST['act'] == '')
{
$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'incorrect_use') );
}
}
//-----------------------------------------
// Nawty, Nawty!
//-----------------------------------------
if ($this->ipsclass->input['CODE'] != '02' and $this->ipsclass->input['CODE'] != '05')
{
if ($this->ipsclass->input['auth_key'] != $this->ipsclass->return_md5_check() )
{
$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'del_post') );
}
}
//-----------------------------------------
// Compile the language file
//-----------------------------------------
$this->ipsclass->load_language('lang_mod');
$this->ipsclass->load_template('skin_mod');
//-----------------------------------------
// Check the input
//-----------------------------------------
if ( ! in_array( $this->ipsclass->input['CODE'], $not_forum_array ) )
{
//-----------------------------------------
// t
//-----------------------------------------
if ($this->ipsclass->input['t'])
{
$this->ipsclass->input['t'] = intval($this->ipsclass->input['t']);
if ( ! $this->ipsclass->input['t'] )
{
$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'missing_files') );
}
else
{
$this->ipsclass->DB->simple_construct( array( 'select' => '*', 'from' => 'topics', 'where' => 'tid='.intval($this->ipsclass->input['t']) ) );
$this->ipsclass->DB->simple_exec();
$this->topic = $this->ipsclass->DB->fetch_row();
if (empty($this->topic['tid']))
{
$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'missing_files') );
}
if ( $this->ipsclass->input['f'] AND ( $this->topic['forum_id'] != $this->ipsclass->input['f'] ) )
{
$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'missing_files') );
}
}
}
//-----------------------------------------
// p
//-----------------------------------------
if ($this->ipsclass->input['p'])
{
$this->ipsclass->input['p'] = intval($this->ipsclass->input['p']);
if (! $this->ipsclass->input['p'] )
{
$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'missing_files') );
}
}
//-----------------------------------------
// F?
//-----------------------------------------
$this->ipsclass->input['f'] = intval($this->ipsclass->input['f']);
if ( ! $this->ipsclass->input['f'] )
{
$this->ipsclass->Error( array( 'LEVEL' => 1,'MSG' => 'missing_files') );
}
$this->ipsclass->input['st'] = intval($this->ipsclass->input['st']) > 0 ? intval($this->ipsclass->input['st']) : 0;
//-----------------------------------------
// Get the forum info based on the forum ID,
//-----------------------------------------
$this->forum = $this->ipsclass->forums->forum_by_id[ $this->ipsclass->input['f'] ];
$this->base_url = $this->ipsclass->base_url;
//-----------------------------------------
// Are we a moderator?
//-----------------------------------------
if ( isset( $this->ipsclass->member['_moderator'][ $this->ipsclass->input['f'] ]) AND $this->ipsclass->member['_moderator'][ $this->ipsclass->input['f'] ] )
{
$this->moderator = $this->ipsclass->member['_moderator'][ $this->ipsclass->input['f'] ];
}
}
//-----------------------------------------
// Load mod module...
//-----------------------------------------
require( ROOT_PATH.'sources/lib/func_mod.php');
$this->modfunc = new func_mod();
$this->modfunc->ipsclass =& $this->ipsclass;
$this->modfunc->init($this->forum);
$this->upload_dir = $this->ipsclass->vars['upload_dir'];
//-----------------------------------------
// Trash-can set up
//-----------------------------------------
if ( $this->ipsclass->vars['forum_trash_can_enable'] and $this->ipsclass->vars['forum_trash_can_id'] )
{
if ( $this->ipsclass->cache['forum_cache'][ $this->ipsclass->vars['forum_trash_can_id'] ]['sub_can_post'] )
{
if ( $this->ipsclass->member['mgroup'] == $this->ipsclass->vars['admin_group'] )
{
$this->trash_forum = $this->ipsclass->vars['forum_trash_can_use_radmin'] ? $this->ipsclass->vars['forum_trash_can_id'] : 0;
}
else if ( $this->ipsclass->member['g_access_cp'] )
{
$this->trash_forum = $this->ipsclass->vars['forum_trash_can_use_admin'] ? $this->ipsclass->vars['forum_trash_can_id'] : 0;
}
else if ( $this->ipsclass->member['g_is_supmod'] )
{
$this->trash_forum = $this->ipsclass->vars['forum_trash_can_use_smod'] ? $this->ipsclass->vars['forum_trash_can_id'] : 0;
}
else if ( $this->ipsclass->member['is_mod'] )
{
$this->trash_forum = $this->ipsclass->vars['forum_trash_can_use_mod'] ? $this->ipsclass->vars['forum_trash_can_id'] : 0;
}
else
{
$this->trash_forum = $this->ipsclass->vars['forum_trash_can_id'];
}
}
}
//-----------------------------------------
// Convert the code ID's into something
// use mere mortals can understand....
//-----------------------------------------
switch ($this->ipsclass->input['CODE'])
{
case '02':
$this->move_form();
break;
case '03':
$this->delete_form();
break;
case '04':
$this->delete_post();
break;
case '05':
$this->edit_form();
break;
case '00':
$this->close_topic();
break;
case '01':
$this->open_topic();
break;
case '08':
$this->delete_topic();
break;
case '12':
$this->do_edit();
break;
case '14':
$this->do_move();
break;
case '15':
$this->pin_topic();
break;
case '16':
$this->unpin_topic();
break;
case '17':
$this->rebuild_topic();
break;
//-----------------------------------------
// Unsubscribe
//-----------------------------------------
case '30':
$this->unsubscribe_all_form();
break;
case '31':
$this->unsubscribe_all();
break;
//-----------------------------------------
// Merge Start
//-----------------------------------------
case '60':
$this->merge_start();
break;
case '61':
$this->merge_complete();
break;
//-----------------------------------------
// Topic History
//-----------------------------------------
case '90':
$this->topic_history();
break;
//-----------------------------------------
// Multi---
//-----------------------------------------
case 'topicchoice':
$this->multi_topic_modify();
break;
//-----------------------------------------
// Multi---
//-----------------------------------------
case 'postchoice':
$this->multi_post_modify();
break;
//-----------------------------------------
// Resynchronize Forum
//-----------------------------------------
case 'resync':
$this->resync_forum();
break;
//-----------------------------------------
// Prune / Move Topics
//-----------------------------------------
case 'prune_start':
$this->prune_start();
break;
case 'prune_finish':
$this->prune_finish();
break;
case 'prune_move':
$this->prune_move();
break;
//-----------------------------------------
// Add. topic view func.
//-----------------------------------------
case 'topic_approve':
$this->topic_approve_alter('approve');
break;
case 'topic_unapprove':
$this->topic_approve_alter('unapprove');
break;
//-----------------------------------------
// Edit member
//-----------------------------------------
case 'editmember':
$this->edit_member();
break;
default:
$this->moderate_error();
break;
}
// If we have any HTML to print, do so...
$this->ipsclass->print->add_output( $this->output );
$this->ipsclass->print->do_output( array( 'TITLE' => $this->page_title, 'JS' => 0, 'NAV' => $this->nav ) );
}
/*-------------------------------------------------------------------------*/
// Edit member
/*-------------------------------------------------------------------------*/
function edit_member()
{
$mid = intval($this->ipsclass->input['mid']) ? intval($this->ipsclass->input['mid']) : intval($this->ipsclass->input['member']);
//-----------------------------------------
// Check Permissions
//-----------------------------------------
if ( ! $this->ipsclass->member['g_is_supmod'] )
{
$this->moderate_error();
}
//-----------------------------------------
// Load and config the post parser
//-----------------------------------------
require_once( ROOT_PATH."sources/handlers/han_parse_bbcode.php" );
$parser = new parse_bbcode();
$parser->ipsclass = $this->ipsclass;
$parser->parse_html = intval($this->ipsclass->vars['sig_allow_html']);
$parser->parse_nl2br = 1;
$parser->parse_smilies = 0;
$parser->parse_bbcode = $this->ipsclass->vars['sig_allow_ibc'];
$this->ipsclass->load_language( 'lang_post' );
//-----------------------------------------
// Got anyfink?
//-----------------------------------------
if ( ! $mid )
{
$this->moderate_error();
}
//-----------------------------------------
// Get member
//-----------------------------------------
$this->ipsclass->DB->cache_add_query( 'profile_get_all' , array( 'mid' => $mid ) );
$this->ipsclass->DB->cache_exec_query();
$member = $this->ipsclass->DB->fetch_row();
//-----------------------------------------
// Show Form?
//-----------------------------------------
if ( !isset($this->ipsclass->input['checked']) OR !$this->ipsclass->input['checked'] )
{
$this->output .= $this->html_start_form( array( 1 => array( 'CODE' , 'editmember'),
4 => array( 'mid' , $mid ),
5 => array( 'checked', 1 ),
) );
//-----------------------------------------
// No editing of admins!
//-----------------------------------------
if ( ! $this->ipsclass->member['g_access_cp'] )
{
if ( $this->ipsclass->cache['group_cache'][ $member['mgroup'] ]['g_access_cp'] )
{
$this->moderate_error('cp_admin_user');
return;
}
}
$editable['signature'] = $parser->pre_edit_parse( $member['signature'] );
$editable['location'] = $member['location'];
$editable['interests'] = $this->ipsclass->my_br2nl($member['interests']);
$editable['website'] = $member['website'];
$editable['id'] = $member['id'];
$editable['members_display_name'] = $member['members_display_name'];
$editable['aim_name'] = $member['aim_name'];
$editable['icq_number'] = $member['icq_number'];
$editable['msnname'] = $member['msnname'];
$editable['yahoo'] = $member['yahoo'];
$optional_output = "";
//-----------------------------------------
// Profile fields
//-----------------------------------------
require_once( ROOT_PATH.'sources/classes/class_custom_fields.php' );
$fields = new custom_fields( $this->ipsclass->DB );
$fields->member_id = $this->ipsclass->member['id'];
$fields->mem_data_id = $member['id'];
$fields->admin = intval($this->ipsclass->member['g_access_cp']);
$fields->supmod = intval($this->ipsclass->member['g_is_supmod']);
$fields->init_data();
$fields->parse_to_edit();
foreach( $fields->out_fields as $id => $data )
{
if ( $fields->cache_data[ $id ]['pf_type'] == 'drop' )
{
$form_element = $this->ipsclass->compiled_templates['skin_mod']->field_dropdown( 'field_'.$id, $data );
}
else if ( $fields->cache_data[ $id ]['pf_type'] == 'area' )
{
$form_element = $this->ipsclass->compiled_templates['skin_mod']->field_textarea( 'field_'.$id, $data );
}
else
{
$form_element = $this->ipsclass->compiled_templates['skin_mod']->field_textinput( 'field_'.$id, $data );
}
$optional_output .= $this->ipsclass->compiled_templates['skin_mod']->field_entry( $fields->field_names[ $id ], $fields->field_desc[ $id ], $form_element );
}
//-----------------------------------------
// Show?
//-----------------------------------------
$this->output .= $this->ipsclass->compiled_templates['skin_mod']->edit_user_form($editable, $optional_output);
$this->page_title = $this->ipsclass->lang['cp_em_title'];
$this->nav[] = "{$this->ipsclass->lang['cp_vp_title']}";
$this->nav[] = $this->ipsclass->lang['cp_em_title'];
}
//-----------------------------------------
// Do edit
//-----------------------------------------
else
{
$this->ipsclass->input['signature'] = $parser->pre_display_parse( $parser->pre_db_parse( $this->ipsclass->input['signature'] ) );
if ($parser->error != "")
{
$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => $parser->error) );
}
$bet = array( 'website' => $this->ipsclass->input['website'],
'icq_number' => $this->ipsclass->input['icq_number'],
'aim_name' => $this->ipsclass->input['aim_name'],
'yahoo' => $this->ipsclass->input['yahoo'],
'msnname' => $this->ipsclass->input['msnname'],
'location' => $this->ipsclass->input['location'],
'interests' => $this->ipsclass->input['interests'],
'signature' => $this->ipsclass->input['signature'],
);
if ( $this->ipsclass->input['avatar'] == 1 )
{
$bet['avatar_location'] = "";
$bet['avatar_size'] = "";
$this->bash_uploaded_avatars($mid);
}
if ( $this->ipsclass->input['photo'] == 1 )
{
$this->bash_uploaded_photos($mid);
$this->ipsclass->DB->simple_construct( array( 'select' => '*', 'from' => 'profile_portal', 'where' => "pp_member_id=".intval($mid) ) );
$this->ipsclass->DB->simple_exec();
if ( $this->ipsclass->DB->get_num_rows() )
{
$this->ipsclass->DB->do_update( 'profile_portal', array( 'pp_main_photo' => '',
'pp_main_width' => 0,
'pp_main_height' => 0,
'pp_thumb_photo' => '',
'pp_thumb_width' => 0,
'pp_thumb_height' => 0 ), 'pp_member_id='.$mid );
}
else
{
$this->ipsclass->DB->do_insert( 'profile_portal', array( 'pp_main_photo' => '',
'pp_main_width' => 0,
'pp_main_height' => 0,
'pp_thumb_photo' => '',
'pp_thumb_width' => 0,
'pp_thumb_height' => 0,
'pp_member_id' => $mid ) );
}
}
//-----------------------------------------
// Write it to the DB.
//-----------------------------------------
if ( $mem = $this->ipsclass->DB->simple_exec_query( array( 'select' => 'id', 'from' => 'member_extra', 'where' => 'id='.$mid ) ) )
{
$this->ipsclass->DB->do_update( 'member_extra', $bet, 'id='.$mid );
}
else
{
$bet['id'] = $mid;
$this->ipsclass->DB->do_insert( 'member_extra', $bet );
}
//-----------------------------------------
// Custom profile field stuff
//-----------------------------------------
require_once( ROOT_PATH.'sources/classes/class_custom_fields.php' );
$fields = new custom_fields( $this->ipsclass->DB );
$fields->member_id = $this->ipsclass->member['id'];
$fields->admin = intval($this->ipsclass->member['g_access_cp']);
$fields->supmod = intval($this->ipsclass->member['g_is_supmod']);
$fields->init_data();
$fields->parse_to_save();
//-----------------------------------------
// Custom profile field stuff
//-----------------------------------------
if ( count( $fields->out_fields ) )
{
//-----------------------------------------
// Do we already have an entry in
// the content table?
//-----------------------------------------
$test = $this->ipsclass->DB->simple_exec_query( array( 'select' => 'member_id', 'from' => 'pfields_content', 'where' => 'member_id='.$mid ) );
if ( $test['member_id'] )
{
//-----------------------------------------
// We have it, so simply update
//-----------------------------------------
$this->ipsclass->DB->do_update( 'pfields_content', $fields->out_fields, 'member_id='.$mid );
}
else
{
$fields->out_fields['member_id'] = $mid;
$this->ipsclass->DB->do_insert( 'pfields_content', $fields->out_fields );
}
}
//-----------------------------------------
// Member sync?
//-----------------------------------------
if ( USE_MODULES == 1 )
{
require ROOT_PATH."modules/ipb_member_sync.php";
$this->modules = new ipb_member_sync();
$this->modules->ipsclass =& $this->ipsclass;
$bet['id'] = $mid;
$this->modules->register_class($this);
$this->modules->on_profile_update($bet, $custom_fields);
}
$this->moderate_log("{$this->ipsclass->lang['acp_edited_profile']} {$member['members_display_name']}");
$this->ipsclass->boink_it( $this->ipsclass->base_url.'act=mod&CODE=editmember&auth_key='.$this->ipsclass->return_md5_check().'&mid='.$mid.'&tid='.time() );
}
}
/*-------------------------------------------------------------------------*/
// Post act
/*-------------------------------------------------------------------------*/
function multi_post_modify()
{
$this->pids = $this->get_pids();
if ( count( $this->pids ) )
{
switch ( $this->ipsclass->input['tact'] )
{
case 'approve':
$this->multi_approve_post(1);
break;
case 'unapprove':
$this->multi_approve_post(0);
break;
case 'delete':
$this->multi_delete_post();
break;
case 'merge':
$this->multi_merge_post();
break;
case 'split':
$this->multi_split_topic();
break;
case 'move':
$this->multi_move_post();
break;
default:
break;
}
}
$this->ipsclass->my_setcookie('modpids', '', 0);
if ( $this->topic['tid'] )
{
$this->ipsclass->print->redirect_screen( $this->ipsclass->lang['cp_redirect_posts'], "showtopic=".$this->topic['tid'].'&st='.intval($this->ipsclass->input['st']) );
}
}
/*-------------------------------------------------------------------------*/
// Move Posts
/*-------------------------------------------------------------------------*/
function multi_move_post()
{
$passed = 0;
if ($this->ipsclass->member['g_is_supmod'] == 1)
{
$passed = 1;
}
else if ($this->moderator['split_merge'] == 1)
{
$passed = 1;
}
else {
$passed = 0;
}
if ($passed != 1) $this->moderate_error();
if ( ! $this->topic['tid'] )
{
$this->moderate_error();
}
//-----------------------------------------
// Get post parser
//-----------------------------------------
require_once( ROOT_PATH."sources/handlers/han_parse_bbcode.php" );
$this->parser = new parse_bbcode();
$this->parser->ipsclass = $this->ipsclass;
$this->parser->allow_update_caches = 0;
if ( $this->ipsclass->input['checked'] != 1 )
{
$jump_html = $this->ipsclass->build_forum_jump(0,1,1);
$this->output .= $this->html_start_form( array( 1 => array( 'CODE' , 'postchoice' ),
2 => array( 't' , $this->topic['tid'] ),
3 => array( 'f' , $this->forum['id'] ),
4 => array( 'tact' , 'move' ),
5 => array( 'checked', 1 ),
) );
$this->output .= $this->ipsclass->compiled_templates['skin_mod']->table_top( $this->ipsclass->lang['cmp_title'].": ".$this->forum['name']." -> ".$this->topic['title'] );
$this->output .= $this->ipsclass->compiled_templates['skin_mod']->move_post_body();
//-----------------------------------------
// Display the posty wosty's
//-----------------------------------------
$this->ipsclass->DB->simple_construct( array(
'select' => 'post, pid, post_date, author_id, author_name',
'from' => 'posts',
'where' => "pid IN (".implode(",", $this->pids).")",
'order' => 'post_date'
) );
$post_query = $this->ipsclass->DB->simple_exec();
$post_count = 0;
while ( $row = $this->ipsclass->DB->fetch_row($post_query) )
{
//-----------------------------------------
// Limit posts to 200 chars to stop shite
// loads of pages
//-----------------------------------------
if ( strlen($row['post']) > 800 )
{
$row['post'] = $this->parser->pre_edit_parse($row['post']);
$row['post'] = substr($row['post'], 0, 800) . '...';
}
$row['date'] = $this->ipsclass->get_date( $row['post_date'], 'LONG' );
$row['st_top_bit'] = sprintf( $this->ipsclass->lang['st_top_bit'], $row['author_name'], $row['date'] );
$row['post_css'] = $post_count % 2 ? 'row1' : 'row2';
$this->output .= $this->ipsclass->compiled_templates['skin_mod']->split_row( $row );
$post_count++;
}
//-----------------------------------------
// print my bottom, er, the bottom
//-----------------------------------------
$this->output .= $this->ipsclass->compiled_templates['skin_mod']->split_end_form( $this->ipsclass->lang['cmp_submit'] );
$this->page_title = $this->ipsclass->lang['cmp_title'].": ".$this->topic['title'];
$this->nav = array ( "{$this->forum['name']}",
"{$this->topic['title']}"
);
$this->ipsclass->print->add_output( $this->output );
$this->ipsclass->print->do_output( array( 'TITLE' => $this->page_title, 'JS' => 0, NAV => $this->nav ) );
}
else
{
//-----------------------------------------
// PROCESS Check the input
//-----------------------------------------
if ( ! intval($this->ipsclass->input['topic_url']) )
{
preg_match( "/(\?|&)(t|showtopic)=(\d+)($|&)/", $this->ipsclass->input['topic_url'], $match );
$old_id = intval(trim($match[3]));
}
else
{
$old_id = intval($this->ipsclass->input['topic_url']);
}
if ($old_id == "")
{
$this->ipsclass->input['checked'] = 0;
$this->output = $this->ipsclass->compiled_templates['skin_mod']->warn_errors( $this->ipsclass->lang['cmp_notopic'] );
$this->multi_move_post();
}
//-----------------------------------------
// Grab topic
//-----------------------------------------
$move_to_topic = $this->ipsclass->DB->simple_exec_query( array( 'select' => '*', 'from' => 'topics', 'where' => 'tid='.$old_id ) );
if ( ! $move_to_topic['tid'] or ! $this->ipsclass->forums->forum_by_id[ $move_to_topic['forum_id'] ]['id'] )
{
$this->ipsclass->input['checked'] = 0;
$this->output = $this->ipsclass->compiled_templates['skin_mod']->warn_errors( $this->ipsclass->lang['cmp_notopic'] );
$this->multi_move_post();
}
//-----------------------------------------
// Get the post ID's to split
//-----------------------------------------
$ids = array();
foreach ($this->ipsclass->input as $key => $value)
{
if ( preg_match( "/^post_(\d+)$/", $key, $match ) )
{
if ($this->ipsclass->input[$match[0]])
{
$ids[] = $match[1];
}
}
}
$ids = $this->ipsclass->clean_int_array( $ids );
$affected_ids = count($ids);
//-----------------------------------------
// Do we have enough?
//-----------------------------------------
if ($affected_ids < 1)
{
$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'split_not_enough' ) );
}
//-----------------------------------------
// Do we choose too many?
//-----------------------------------------
$this->ipsclass->DB->simple_construct( array( 'select' => 'count(pid) as cnt', 'from' => 'posts', 'where' => "topic_id={$this->topic['tid']}" ) );
$this->ipsclass->DB->simple_exec();
$count = $this->ipsclass->DB->fetch_row();
if ( $affected_ids >= $count['cnt'] )
{
$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'split_too_much' ) );
}
//-----------------------------------------
// Complete the PID string
//-----------------------------------------
$pid_string = implode( ",", $ids );
//-----------------------------------------
// Move the posts
//-----------------------------------------
$this->ipsclass->DB->do_update( 'posts', array( 'topic_id' => $move_to_topic['tid'], 'new_topic' => 0 ), "pid IN($pid_string)" );
//-----------------------------------------
// Move the posts
//-----------------------------------------
$this->ipsclass->DB->do_update( 'posts', array( 'new_topic' => 0 ), "topic_id={$this->topic['tid']}" );
//-----------------------------------------
// Is first post queued for new topic?
//-----------------------------------------
$topic_approved = 1;
$this->ipsclass->DB->build_query( array( 'select' => 'pid, queued',
'from' => 'posts',
'where' => "topic_id={$move_to_topic['tid']}",
'order' => 'pid ASC',
'limit' => array(0,1),
) );
$this->ipsclass->DB->exec_query();
$first_post = $this->ipsclass->DB->fetch_row();
if( $first_post['queued'] )
{
$this->ipsclass->DB->do_update( 'topics', array( 'approved' => 0 ), "tid={$move_to_topic['tid']}" );
$this->ipsclass->DB->do_update( 'posts', array( 'queued' => 0 ), 'pid='.$first_post['pid'] );
}
//-----------------------------------------
// Is first post queued for old topic?
//-----------------------------------------
$topic_approved = 1;
$this->ipsclass->DB->build_query( array( 'select' => 'pid, queued',
'from' => 'posts',
'where' => "topic_id={$this->topic['tid']}",
'order' => 'pid ASC',
'limit' => array(0,1),
) );
$this->ipsclass->DB->exec_query();
$other_first_post = $this->ipsclass->DB->fetch_row();
if( $other_first_post['queued'] )
{
$this->ipsclass->DB->do_update( 'topics', array( 'approved' => 0 ), "tid={$this->topic['tid']}" );
$this->ipsclass->DB->do_update( 'posts', array( 'queued' => 0 ), 'pid='.$other_first_post['pid'] );
}
//-----------------------------------------
// Rebuild the topics
//-----------------------------------------
$this->modfunc->rebuild_topic($move_to_topic['tid']);
$this->modfunc->rebuild_topic($this->topic['tid']);
//-----------------------------------------
// Update the forum(s)
//-----------------------------------------
$this->modfunc->forum_recount($this->topic['forum_id']);
if ($this->topic['forum_id'] != $move_to_topic['forum_id'])
{
$this->modfunc->forum_recount($move_to_topic['forum_id']);
}
$this->moderate_log( sprintf( $this->ipsclass->lang['acp_moved_posts'], $this->topic['title'], $move_to_topic['title'] ) );
}
}
/*-------------------------------------------------------------------------*/
// Split topic
/*-------------------------------------------------------------------------*/
function multi_approve_post($approve=1)
{
$approve_topic = 1;
$queued_post = 0;
if ( $approve != 1 )
{
$approve_topic = 0;
$queued_post = 1;
}
$passed = 0;
if ($this->ipsclass->member['g_is_supmod'] == 1)
{
$passed = 1;
}
else if ($this->moderator['post_q'] == 1)
{
$passed = 1;
}
else
{
$passed = 0;
}
if ($passed != 1)
{
$this->moderate_error();
}
//-----------------------------------------
// Did we get the first post too?
//-----------------------------------------
if ( strstr( ",".implode(",",$this->pids).",", ",".$this->topic['topic_firstpost']."," ) )
{
$this->ipsclass->DB->do_update( 'topics', array( 'approved' => $approve_topic ), 'tid='.$this->topic['tid'] );
//-----------------------------------------
// Don't actually un-approve first post
// But allow approve
//-----------------------------------------
if ( $queued_post )
{
$tmp = $this->pids;
$this->pids = array();
foreach( $tmp as $t )
{
if ( $t != $this->topic['topic_firstpost'] )
{
$this->pids[] = $t;
}
}
}
}
if ( count($this->pids) )
{
$this->ipsclass->DB->do_update( 'posts', array( 'queued' => $queued_post ), 'topic_id=' . $this->topic['tid'] . ' AND pid IN ('. implode(",", $this->pids) .')' );
}
if( $approve )
{
$this->moderate_log( sprintf( $this->ipsclass->lang['acp_approved_posts'], count($this->pids), $this->topic['title'] ) );
}
else
{
$this->moderate_log( sprintf( $this->ipsclass->lang['acp_unapproved_posts'], count($this->pids), $this->topic['title'] ) );
}
$this->modfunc->rebuild_topic( $this->topic['tid'] );
$this->modfunc->forum_recount( $this->topic['forum_id'] );
$this->modfunc->stats_recount();
}
/*-------------------------------------------------------------------------*/
// Split topic
/*-------------------------------------------------------------------------*/
function multi_split_topic()
{
$passed = 0;
if ($this->ipsclass->member['g_is_supmod'] == 1)
{
$passed = 1;
}
else if ( $this->moderator['split_merge'] == 1 or $this->trash_inuse == 1 )
{
$passed = 1;
}
else
{
$passed = 0;
}
if ($passed != 1)
{
$this->moderate_error();
}
if ( ! $this->topic['tid'] )
{
$this->moderate_error();
}
//-----------------------------------------
// Get post parser
//-----------------------------------------
require_once( ROOT_PATH."sources/handlers/han_parse_bbcode.php" );
$this->parser = new parse_bbcode();
$this->parser->ipsclass = $this->ipsclass;
$this->parser->allow_update_caches = 0;
if ( $this->ipsclass->input['checked'] != 1 )
{
$jump_html = $this->ipsclass->build_forum_jump(0,1,1);
$this->output = $this->html_start_form( array( 1 => array( 'CODE', 'postchoice' ),
2 => array( 't' , $this->topic['tid'] ),
3 => array( 'f' , $this->forum['id'] ),
4 => array( 'tact', 'split' ),
5 => array( 'checked', 1 ),
) );
$this->output .= $this->ipsclass->compiled_templates['skin_mod']->table_top( $this->ipsclass->lang['st_top'].": ".$this->forum['name']." -> ".$this->topic['title'] );
$this->output .= $this->ipsclass->compiled_templates['skin_mod']->split_body( $jump_html );
//-----------------------------------------
// Display the posty wosty's
//-----------------------------------------
$this->ipsclass->DB->simple_construct( array(
'select' => 'post, pid, post_date, author_id, author_name',
'from' => 'posts',
'where' => 'topic_id=' . $this->topic['tid'] . ' AND pid IN (' . implode( ',', $this->pids) . ')',
'order' => 'post_date'
) );
$post_query = $this->ipsclass->DB->simple_exec();
$post_count = 0;
while ( $row = $this->ipsclass->DB->fetch_row($post_query) )
{
// Limit posts to 800 chars to stop shite loads of pages
if ( strlen($row['post']) > 800 )
{
$row['post'] = $this->parser->pre_edit_parse($row['post']);
$row['post'] = substr($row['post'], 0, 800) . '...';
}
$row['date'] = $this->ipsclass->get_date( $row['post_date'], 'LONG' );
$row['st_top_bit'] = sprintf( $this->ipsclass->lang['st_top_bit'], $row['author_name'], $row['date'] );
$row['post_css'] = $post_count % 2 ? 'row1' : 'row2';
$this->output .= $this->ipsclass->compiled_templates['skin_mod']->split_row( $row );
$post_count++;
}
//-----------------------------------------
// print my bottom, er, the bottom
//-----------------------------------------
$this->output .= $this->ipsclass->compiled_templates['skin_mod']->split_end_form( $this->ipsclass->lang['st_submit'] );
$this->page_title = $this->ipsclass->lang['st_top']." ".$this->topic['title'];
$this->nav = array ( "{$this->forum['name']}",
"{$this->topic['title']}"
);
$this->ipsclass->print->add_output( $this->output );
$this->ipsclass->print->do_output( array( 'TITLE' => $this->page_title, 'JS' => 0, NAV => $this->nav ) );
}
else
{
//-----------------------------------------
// PROCESS Check the input
//-----------------------------------------
if ($this->ipsclass->input['title'] == "")
{
$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'complete_form' ) );
}
//-----------------------------------------
// Get the post ID's to split
//-----------------------------------------
$ids = array();
foreach ($this->ipsclass->input as $key => $value)
{
if ( preg_match( "/^post_(\d+)$/", $key, $match ) )
{
if ($this->ipsclass->input[$match[0]])
{
$ids[] = $match[1];
}
}
}
$ids = $this->ipsclass->clean_int_array( $ids );
$affected_ids = count($ids);
//-----------------------------------------
// Do we have enough?
//-----------------------------------------
if ($affected_ids < 1)
{
$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'split_not_enough' ) );
}
//-----------------------------------------
// Do we choose too many?
//-----------------------------------------
$count = $this->ipsclass->DB->build_and_exec_query( array( 'select' => 'count(pid) as cnt', 'from' => 'posts', 'where' => "topic_id={$this->topic['tid']}" ) );
if ( $affected_ids >= $count['cnt'] )
{
$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'split_too_much' ) );
}
//-----------------------------------------
// Complete the PID string
//-----------------------------------------
$pid_string = implode( ",", $ids );
//-----------------------------------------
// Check the forum we're moving this too
//-----------------------------------------
$this->ipsclass->input['fid'] = intval($this->ipsclass->input['fid']);
if ($this->ipsclass->input['fid'] != $this->forum['id'])
{
if ( $this->trash_inuse )
{
$f = $this->ipsclass->cache['forum_cache'][ $this->ipsclass->input['fid'] ];
}
else
{
$f = $this->ipsclass->forums->forum_by_id[ $this->ipsclass->input['fid'] ];
}
if ( ! $f['id'] )
{
$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'move_no_forum' ) );
}
if ($f['sub_can_post'] != 1)
{
$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'forum_no_post_allowed' ) );
}
}
//-----------------------------------------
// Is first post queued?
//-----------------------------------------
$topic_approved = 1;
$this->ipsclass->DB->build_query( array( 'select' => 'pid, queued',
'from' => 'posts',
'where' => 'topic_id=' . $this->topic['tid'] . " AND pid IN($pid_string)",
'order' => 'pid ASC',
'limit' => array(0,1),
) );
$this->ipsclass->DB->exec_query();
$first_post = $this->ipsclass->DB->fetch_row();
if( $first_post['queued'] )
{
$topic_approved = 0;
$this->ipsclass->DB->do_update( 'posts', array( 'queued' => 0 ), 'pid='.$first_post['pid'] );
}
//-----------------------------------------
// Complete a new dummy topic
//-----------------------------------------
$this->ipsclass->DB->do_insert( 'topics', array(
'title' => $this->ipsclass->input['title'],
'description' => $this->ipsclass->input['desc'] ,
'state' => 'open',
'posts' => 0,
'starter_id' => 0,
'starter_name' => 0,
'start_date' => time(),
'last_poster_id' => 0,
'last_poster_name' => 0,
'last_post' => time(),
'icon_id' => 0,
'author_mode' => 1,
'poll_state' => 0,
'last_vote' => 0,
'views' => 0,
'forum_id' => $this->ipsclass->input['fid'],
'approved' => $topic_approved,
'pinned' => 0,
) );
$new_topic_id = $this->ipsclass->DB->get_insert_id();
//-----------------------------------------
// Move the posts
//-----------------------------------------
$this->ipsclass->DB->do_update( 'posts', array( 'topic_id' => $new_topic_id, 'new_topic' => 0 ), 'topic_id=' . $this->topic['tid'] . " AND pid IN($pid_string)" );
//-----------------------------------------
// Move the posts
//-----------------------------------------
if ( $this->trash_inuse )
{
$this->ipsclass->DB->do_update( 'posts', array( 'queued' => 0 ), "topic_id=$new_topic_id" );
}
$this->ipsclass->DB->do_update( 'posts', array( 'new_topic' => 0 ), "topic_id={$this->topic['tid']}" );
//-----------------------------------------
// Rebuild the topics
//-----------------------------------------
$this->modfunc->rebuild_topic($new_topic_id);
$this->modfunc->rebuild_topic($this->topic['tid']);
//-----------------------------------------
// Update the forum(s)
//-----------------------------------------
$this->modfunc->forum_recount($this->topic['forum_id']);
if ($this->topic['forum_id'] != $this->ipsclass->input['fid'])
{
$this->modfunc->forum_recount($this->ipsclass->input['fid']);
}
if ( $this->trash_inuse )
{
$this->moderate_log("{$this->ipsclass->lang['acp_trashcan_post']} '{$this->topic['title']}'");
}
else
{
$this->moderate_log("{$this->ipsclass->lang['acp_split_topic']} '{$this->topic['title']}'");
}
}
}
/*-------------------------------------------------------------------------*/
// Multi merge post
/*-------------------------------------------------------------------------*/
function multi_merge_post()
{
$passed = 0;
if ($this->ipsclass->member['g_is_supmod'] == 1)
{
$passed = 1;
}
else if ($this->moderator['delete_post'] == 1)
{
$passed = 1;
}
else
{
$passed = 0;
}
if ($passed != 1) $this->moderate_error();
if ( ! count( $this->pids ) )
{
$this->moderate_error();
}
//-----------------------------------------
// Load LIB
//-----------------------------------------
require_once( ROOT_PATH."sources/handlers/han_parse_bbcode.php" );
$this->parser = new parse_bbcode();
$this->parser->ipsclass =& $this->ipsclass;
$this->parser->allow_update_caches = 1;
$this->parser->bypass_badwords = intval($this->ipsclass->member['g_bypass_badwords']);
//-----------------------------------------
// Form or print?
//-----------------------------------------
if ( ! $this->ipsclass->input['checked'] )
{
//-----------------------------------------
// Get post data
//-----------------------------------------
$master_post = "";
$dropdown = "";
$author = "";
$seen_author = array();
$upload_html = "";
//-----------------------------------------
// MOVE INTO DB CLASS
//-----------------------------------------
$this->ipsclass->DB->cache_add_query( 'moderate_get_topics', array( 'pids' => $this->pids ) );
$outer = $this->ipsclass->DB->cache_exec_query();
while ( $p = $this->ipsclass->DB->fetch_row( $outer ) )
{
if ( $this->ipsclass->check_perms( $this->ipsclass->forums->forum_by_id[ $p['forum_id'] ]['read_perms']) == TRUE )
{
$master_post .= "\n\n".$this->parser->pre_edit_parse( trim($p['post']) );
$dropdown .= "\n";
if ( ! $seen_author[ $p['author_id'] ] )
{
$author .= "\n";
$seen_author[ $p['author_id'] ] = 1;
}
}
}
//-----------------------------------------
// Get Attachment Data
//-----------------------------------------
$this->ipsclass->DB->simple_construct( array( "select" => '*',
'from' => 'attachments',
'where' => "attach_rel_module='post' AND attach_rel_id IN (".implode(",", $this->pids).")" ) );
$this->ipsclass->DB->simple_exec();
while( $row = $this->ipsclass->DB->fetch_row() )
{
$row['image'] = $this->ipsclass->cache['attachtypes'][ $row['attach_ext'] ]['atype_img'];
$row['size'] = $this->ipsclass->size_format( $row['attach_filesize'] );
if ( strlen( $row['attach_file'] ) > 40 )
{
$row['attach_file'] = substr( $row['attach_file'], 0, 35 ) .'...';
}
$upload_html .= $this->ipsclass->compiled_templates['skin_mod']->uploadbox_entry($row);
}
//-----------------------------------------
// Print form
//-----------------------------------------
$this->output .= $this->ipsclass->compiled_templates['skin_mod']->merge_post_form( trim($master_post), $dropdown, $author, $this->ipsclass->return_md5_check(), $upload_html );
if ( $this->topic['tid'] )
{
$this->nav[] = "{$this->topic['title']}";
}
$this->nav[] = $this->ipsclass->lang['cm_title'];
$this->page_title = $this->ipsclass->lang['cm_title'];
$this->ipsclass->print->add_output( $this->output );
$this->ipsclass->print->do_output( array( 'TITLE' => $this->page_title, 'JS' => 0, NAV => $this->nav ) );
}
else
{
//-----------------------------------------
// DO THE THING, WITH THE THING!!
//-----------------------------------------
$this->ipsclass->input['postdate'] = intval($this->ipsclass->input['postdate']);
if ( ! $this->ipsclass->input['selectedpids'] and ! $this->ipsclass->input['postdate'] and ! $this->ipsclass->input['postauthor'] and ! $this->ipsclass->input['Post'] )
{
$this->moderate_error();
}
$this->parser->parse_smilies = 1;
$this->parser->parse_html = 0;
$this->parser->parse_bbcode = 1;
$post = $this->parser->pre_display_parse( $this->parser->pre_db_parse( $this->ipsclass->input['Post'] ) );
//-----------------------------------------
// Post to keep...
//-----------------------------------------
$posts = array();
$author = array();
$post_to_delete = array();
$new_post_key = md5(time());
$topics = array();
$forums = array();
$append_edit = 0;
$this->ipsclass->DB->cache_add_query( 'moderate_get_topics', array( 'pids' => $this->pids ) );
$this->ipsclass->DB->cache_exec_query();
while ( $p = $this->ipsclass->DB->fetch_row() )
{
$posts[ $p['pid'] ] = $p;
$topics[ $p['topic_id'] ] = $p['topic_id'];
$forums[ $p['forum_id'] ] = $p['forum_id'];
if ( $p['author_id'] == $this->ipsclass->input['postauthor'] )
{
$author = array( 'id' => $p['author_id'], 'name' => $p['author_name'] );
}
if ( $p['pid'] != $this->ipsclass->input['postdate'] )
{
$post_to_delete[] = $p['pid'];
}
if( $p['append_edit'] )
{
$append_edit = 1;
}
}
//-----------------------------------------
// Update main post...
//-----------------------------------------
$this->ipsclass->DB->do_update( 'posts', array( 'author_id' => $author['id'],
'author_name' => $author['name'],
'post' => $post,
'post_key' => $new_post_key,
'post_parent' => 0,
'edit_time' => time(),
'edit_name' => $this->ipsclass->member['members_display_name'],
'append_edit' => ( $append_edit OR !$this->ipsclass->member['g_append_edit'] ) ? 1 : 0,
), 'pid='.$this->ipsclass->input['postdate']
);
//-----------------------------------------
// Fix attachments
//-----------------------------------------
$attach_keep = array();
$attach_kill = array();
foreach ($this->ipsclass->input as $key => $value)
{
if ( preg_match( "/^attach_(\d+)$/", $key, $match ) )
{
if ( $this->ipsclass->input[$match[0]] == 'keep' )
{
$attach_keep[] = $match[1];
}
else
{
$attach_kill[] = $match[1];
}
}
}
$attach_keep = $this->ipsclass->clean_int_array( $attach_keep );
$attach_kill = $this->ipsclass->clean_int_array( $attach_kill );
//-----------------------------------------
// Keep
//-----------------------------------------
if ( count( $attach_keep ) )
{
$this->ipsclass->DB->do_update( 'attachments', array( 'attach_rel_id' => $this->ipsclass->input['postdate'],
'attach_post_key' => $new_post_key,
'attach_member_id' => $author['id'] ), 'attach_id IN('.implode(",",$attach_keep).')' );
}
//-----------------------------------------
// Kill
//-----------------------------------------
if ( count( $attach_kill ) )
{
$this->ipsclass->DB->simple_construct( array( "select" => '*', 'from' => 'attachments', 'where' => 'attach_id IN('.implode(",",$attach_kill).')') );
$this->ipsclass->DB->simple_exec();
while ( $killmeh = $this->ipsclass->DB->fetch_row() )
{
if ( $killmeh['attach_location'] )
{
@unlink( $this->ipsclass->vars['upload_dir']."/".$killmeh['attach_location'] );
}
if ( $killmeh['attach_thumb_location'] )
{
@unlink( $this->ipsclass->vars['upload_dir']."/".$killmeh['attach_thumb_location'] );
}
}
$this->ipsclass->DB->simple_construct( array( 'delete' => 'attachments', 'where' => 'attach_id IN('.implode(",",$attach_kill).')' ) );
$this->ipsclass->DB->simple_exec();
}
//-----------------------------------------
// Kill old posts
//-----------------------------------------
if ( count($post_to_delete) )
{
$this->ipsclass->DB->simple_construct( array( 'delete' => 'posts', 'where' => 'pid IN('.implode(",",$post_to_delete).')' ) );
$this->ipsclass->DB->simple_exec();
}
foreach( $topics as $t )
{
$this->modfunc->rebuild_topic($t, 0);
}
foreach( $forums as $f )
{
$this->modfunc->forum_recount($f);
}
$this->modfunc->stats_recount();
$this->moderate_log( sprintf( $this->ipsclass->lang['acp_merged_posts'], implode( ", ", $this->pids ) ) );
}
}
/*-------------------------------------------------------------------------*/
// Multi delete post
/*-------------------------------------------------------------------------*/
function multi_delete_post()
{
$passed = 0;
if ($this->ipsclass->member['g_is_supmod'] == 1)
{
$passed = 1;
}
else if ($this->moderator['delete_post'] == 1)
{
$passed = 1;
}
else
{
$passed = 0;
}
if ($passed != 1) $this->moderate_error();
//-----------------------------------------
// Check to make sure that this isn't the first post in the topic..
//-----------------------------------------
foreach( $this->pids as $p )
{
if ( $this->topic['topic_firstpost'] == $p )
{
$this->moderate_error('no_delete_post');
}
}
if ( $this->trash_forum and $this->trash_forum != $this->forum['id'] )
{
//-----------------------------------------
// Set up and pass to split topic handler
//-----------------------------------------
$this->ipsclass->input['checked'] = 1;
$this->ipsclass->input['fid'] = $this->trash_forum;
$this->ipsclass->input['title'] = $this->ipsclass->lang['mod_from'] ." ".$this->topic['title'];
$this->ipsclass->input['desc'] = $this->ipsclass->lang['mod_from_id']." ".$this->topic['tid'];
foreach( $this->pids as $p )
{
$this->ipsclass->input[ 'post_'.$p ] = 1;
}
$this->trash_inuse = 1;
$this->multi_split_topic();
$this->trash_inuse = 0;
}
else
{
$this->modfunc->post_delete( $this->pids );
$this->modfunc->forum_recount( $this->topic['forum_id'] );
}
}
/*-------------------------------------------------------------------------*/
// Alter approved thingy
/*-------------------------------------------------------------------------*/
function topic_approve_alter($type='approve')
{
$pass = 0;
if ($this->ipsclass->member['g_is_supmod'] == 1)
{
$pass = 1;
}
else if ($this->moderator['post_q'] == 1)
{
$pass = 1;
}
else
{
$pass = 0;
}
if ($pass == 0)
{
$this->moderate_error();
return;
}
$approve_int = $type == 'approve' ? 1 : 0;
$this->ipsclass->DB->do_update( 'topics', array( 'approved' => $approve_int ), 'tid='.$this->topic['tid'] );
$this->modfunc->forum_recount( $this->forum['id'] );
$this->modfunc->stats_recount();
$this->moderate_log( sprintf( $type == 'approve' ? $this->ipsclass->lang['acp_approve_topic'] : $this->ipsclass->lang['acp_unapprove_topic'], $this->topic['tid'] ) );
$this->ipsclass->print->redirect_screen( $this->ipsclass->lang['redirect_modified'], "showtopic=".$this->topic['tid']."&st=".intval($this->ipsclass->input['st']) );
}
/*-------------------------------------------------------------------------*/
// Prune move
/*-------------------------------------------------------------------------*/
function prune_move()
{
//-----------------------------------------
// Check
//-----------------------------------------
$pass = 0;
if ($this->ipsclass->member['g_is_supmod'] == 1)
{
$pass = 1;
}
else if ($this->moderator['mass_move'] == 1)
{
$pass = 1;
}
else
{
$pass = 0;
}
if ($pass == 0)
{
$this->moderate_error();
return;
}
///-----------------------------------------
// SET UP
//-----------------------------------------
$pergo = intval( $this->ipsclass->input['pergo'] ) ? intval( $this->ipsclass->input['pergo'] ) : 50;
$max = intval( $this->ipsclass->input['max'] );
$current = intval($this->ipsclass->input['current']);
$maxdone = $pergo + $current;
$tid_array = array();
$starter = trim( $this->ipsclass->input['starter'] );
$state = trim( $this->ipsclass->input['state'] );
$posts = intval( $this->ipsclass->input['posts'] );
$dateline = intval( $this->ipsclass->input['dateline'] );
$ignore_pin = intval( $this->ipsclass->input['ignore_pin'] );
$source = $this->forum['id'];
$moveto = intval($this->ipsclass->input['df']);
//-----------------------------------------
// Carry on...
//-----------------------------------------
$db_query = $this->modfunc->sql_prune_create( $this->forum['id'], $starter, $state, $posts, $dateline, $ignore_pin, $pergo, $current );
$this->ipsclass->DB->query($db_query);
if ( ! $num_rows = $this->ipsclass->DB->get_num_rows() )
{
if ( ! $current )
{
$this->moderate_error('cp_error_no_topics');
return;
}
}
//-----------------------------------------
// Get tids
//-----------------------------------------
while ( $row = $this->ipsclass->DB->fetch_row() )
{
$tid_array[] = $row['tid'];
}
//-----------------------------------------
// Check for an attempt to move into a subwrap forum
//-----------------------------------------
$f = $this->ipsclass->forums->forum_by_id[ $moveto ];
if ( $f['sub_can_post'] != 1 )
{
$this->moderate_error('cp_error_no_subforum');
return;
}
$this->modfunc->topic_move( $tid_array, $source, $moveto );
$this->moderate_log( $this->ipsclass->lang['acp_mass_moved'] );
//-----------------------------------------
// Show results or refresh..
//-----------------------------------------
if ( ! $num_rows )
{
//-----------------------------------------
// Update forum deletion
//-----------------------------------------
$this->ipsclass->forums->forum_by_id[ $moveto ]['_update_deletion'] = 1;
$this->ipsclass->forums->forum_by_id[ $source ]['_update_deletion'] = 1;
//-----------------------------------------
// Resync the forums..
//-----------------------------------------
$this->modfunc->forum_recount($source);
$this->modfunc->forum_recount($moveto);
//-----------------------------------------
// Done...
//-----------------------------------------
$this->ipsclass->input['check'] = 0;
$this->ipsclass->input['dateline'] = $this->ipsclass->input['dateline'] > 0 ? round((time()-$this->ipsclass->input['dateline'])/24/60/60) : 0;
$this->prune_start( $this->ipsclass->compiled_templates['skin_mod']->mod_simple_page( $this->ipsclass->lang['cp_results'], $this->ipsclass->lang['cp_result_move']. ($max) ) );
}
else
{
$link = "act=mod&f={$this->forum['id']}&CODE=prune_move&df={$this->ipsclass->input['df']}&pergo={$pergo}¤t={$maxdone}&max={$max}";
$link .= "&starter={$starter}&state={$state}&posts={$posts}&dateline={$dateline}&ignore_pin={$ignore_pin}";
$link .= "&auth_key=".$this->ipsclass->md5_check;
$done = $current + $num_rows;
$text = sprintf( $this->ipsclass->lang['cp_batch_done'], $done, $max - $done );
$this->ipsclass->print->redirect_screen( $text, $link );
}
}
/*-------------------------------------------------------------------------*/
// Do prune
/*-------------------------------------------------------------------------*/
function prune_finish()
{
//-----------------------------------------
// INIT
//-----------------------------------------
$pass = 0;
if ($this->ipsclass->member['g_is_supmod'] == 1)
{
$pass = 1;
}
else if ($this->moderator['mass_prune'] == 1)
{
$pass = 1;
}
else
{
$pass = 0;
}
if ($pass == 0)
{
$this->moderate_error();
return;
}
//-----------------------------------------
// SET UP
//-----------------------------------------
$pergo = intval( $this->ipsclass->input['pergo'] ) ? intval( $this->ipsclass->input['pergo'] ) : 50;
$max = intval( $this->ipsclass->input['max'] );
$current = intval($this->ipsclass->input['current']);
$maxdone = $pergo + $current;
$tid_array = array();
$starter = trim( $this->ipsclass->input['starter'] );
$state = trim( $this->ipsclass->input['state'] );
$posts = intval( $this->ipsclass->input['posts'] );
$dateline = intval( $this->ipsclass->input['dateline'] );
$ignore_pin = intval( $this->ipsclass->input['ignore_pin'] );
//-----------------------------------------
// Carry on...
//-----------------------------------------
$db_query = $this->modfunc->sql_prune_create( $this->forum['id'], $starter, $state, $posts, $dateline, $ignore_pin, $pergo, $current );
$batch = $this->ipsclass->DB->query($db_query);
//-----------------------------------------
// Got anything?
//-----------------------------------------
if ( ! $num_rows = $this->ipsclass->DB->get_num_rows() )
{
if ( ! $current )
{
$this->moderate_error('cp_error_no_topics');
return;
}
}
//-----------------------------------------
// Get tiddles
//-----------------------------------------
while ( $tid = $this->ipsclass->DB->fetch_row() )
{
$tid_array[] = $tid['tid'];
}
$this->modfunc->topic_delete($tid_array);
//-----------------------------------------
// Show results or refresh..
//-----------------------------------------
if ( ! $num_rows )
{
//-----------------------------------------
// Done...
//-----------------------------------------
$this->moderate_log( $this->ipsclass->lang['acp_pruned_forum'] );
$this->ipsclass->input['check'] = 0;
$this->prune_start( $this->ipsclass->compiled_templates['skin_mod']->mod_simple_page( $this->ipsclass->lang['cp_results'], $this->ipsclass->lang['cp_result_del'].($max) ) );
}
else
{
$link = "act=mod&f={$this->forum['id']}&CODE=prune_finish&pergo={$pergo}¤t={$maxdone}&max={$max}";
$link .= "&starter={$starter}&state={$state}&posts={$posts}&dateline={$dateline}&ignore_pin={$ignore_pin}";
$link .= "&auth_key=".$this->ipsclass->md5_check;
$done = $current + $num_rows;
$text = sprintf( $this->ipsclass->lang['cp_batch_done'], $done, $max - $done );
$this->ipsclass->print->redirect_screen( $text, $link );
}
$this->ipsclass->print->pop_up_window( "", $this->output );
}
/*-------------------------------------------------------------------------*/
// Prune / Move Start
/*-------------------------------------------------------------------------*/
function prune_start( $complete_html="" )
{
//-----------------------------------------
// Check permissions
//-----------------------------------------
if ($this->ipsclass->member['g_is_supmod'] == 1)
{
$pass = 1;
}
else if ($this->moderator['mass_prune'] == 1)
{
$pass = 1;
}
else
{
$pass = 0;
}
if ($pass == 0)
{
$this->moderate_error();
return;
}
$confirm_data = array( 'show' => '' );
//-----------------------------------------
// Check per go
//-----------------------------------------
$this->ipsclass->input['pergo'] = isset($this->ipsclass->input['pergo']) ? intval($this->ipsclass->input['pergo']) : 50;
$this->ipsclass->input['posts'] = isset($this->ipsclass->input['posts']) ? intval($this->ipsclass->input['posts']) : '';
$this->ipsclass->input['member'] = isset($this->ipsclass->input['member']) ? $this->ipsclass->input['member'] : '';
$this->ipsclass->input['determine'] = isset($this->ipsclass->input['determine']) ? $this->ipsclass->input['determine'] : '';
$this->ipsclass->input['dateline'] = isset($this->ipsclass->input['dateline']) ? $this->ipsclass->input['dateline'] : '';
// If length of dateline is greater than 8, assume it's a timestamp
if( strlen( $this->ipsclass->input['dateline'] ) > 8 )
{
$this->ipsclass->input['dateline'] = round( ( time() - $this->ipsclass->input['dateline']) /60/60/24 );
}
//-----------------------------------------
// Are we checking first?
//-----------------------------------------
if ( isset($this->ipsclass->input['check']) AND $this->ipsclass->input['check'] == 1 )
{
$link = "&pergo=".$this->ipsclass->input['pergo'];
$link_text = $this->ipsclass->lang['cp_prune_dorem'];
$tcount = $this->ipsclass->DB->simple_exec_query( array( 'select' => 'COUNT(*) as tcount', 'from' => 'topics', 'where' => "forum_id={$this->forum['id']}" ) );
$db_query = "";
//-----------------------------------------
// date...
//-----------------------------------------
if ($this->ipsclass->input['dateline'])
{
$date = time() - $this->ipsclass->input['dateline']*60*60*24;
$db_query .= " AND last_post < $date";
$link .= "&dateline=$date";
}
//-----------------------------------------
// Member...
//-----------------------------------------
if ( $this->ipsclass->input['member'] )
{
$this->ipsclass->DB->build_query( array( 'select' => 'id', 'from' => 'members', 'where' => "members_display_name='".$this->ipsclass->input['member']."'" ) );
$this->ipsclass->DB->exec_query();
if (! $mem = $this->ipsclass->DB->fetch_row() )
{
$this->moderate_error('cp_error_no_mem');
return;
}
else
{
$db_query .= " AND starter_id='".$mem['id']."'";
$link .= "&starter={$mem['id']}";
}
}
//-----------------------------------------
// Posts / Topic type
//-----------------------------------------
if ($this->ipsclass->input['posts'])
{
$db_query .= " AND posts < '".$this->ipsclass->input['posts']."'";
$link .= "&posts={$this->ipsclass->input['posts']}";
}
if ($this->ipsclass->input['topic_type'] != 'all')
{
$db_query .= " AND state='".$this->ipsclass->input['topic_type']."'";
$link .= "&state={$this->ipsclass->input['topic_type']}";
}
if ($this->ipsclass->input['ignore_pin'] == 1)
{
$db_query .= " AND pinned <> 1";
$link .= "&ignore_pin=1";
}
$this->ipsclass->DB->simple_construct( array( 'select' => 'COUNT(*) as count',
'from' => 'topics',
'where' => "forum_id='".$this->forum['id']."'" . $db_query ) );
$this->ipsclass->DB->simple_exec();
$count = $this->ipsclass->DB->fetch_row();
//-----------------------------------------
// Prune?
//-----------------------------------------
if ($this->ipsclass->input['df'] == 'prune')
{
$link = "act=mod&f={$this->forum['id']}&CODE=prune_finish&".$link;
}
else
{
if ( $this->ipsclass->input['df'] == $this->forum['id'] )
{
$this->moderate_error('cp_same_forum');
return;
}
else if ($this->ipsclass->input['df'] == -1)
{
$this->moderate_error('cp_no_forum');
return;
}
$link = "act=mod&f={$this->forum['id']}&CODE=prune_move&df=".$this->ipsclass->input['df'].$link;
$link_text = $this->ipsclass->lang['cp_prune_domove'];
}
//-----------------------------------------
// Build data
//-----------------------------------------
$confirm_data = array( 'tcount' => $tcount['tcount'],
'count' => $count['count'],
'link' => $link . '&max='.$count['count'],
'link_text' => $link_text,
'show' => 1 );
}
$select = "\n";
$html_forums = "";
$tmp_jump_setting = $this->ipsclass->vars['short_forum_jump'];
$this->ipsclass->vars['short_forum_jump'] = 0;
$html_forums .= $this->ipsclass->build_forum_jump(0,0,1);
$this->ipsclass->vars['short_forum_jump'] = $tmp_jump_setting;
unset($tmp_jump_setting);
//-----------------------------------------
// Make current destination forum this one if selected
// before
//-----------------------------------------
if ( isset($this->ipsclass->input['df']) AND $this->ipsclass->input['df'] )
{
$html_forums = preg_replace( "/