$Date: 2006-09-22 11:28:54 +0100 (Fri, 22 Sep 2006) $
| > $Revision: 567 $
| > $Author: matt $
+---------------------------------------------------------------------------
|
| > Warn Log functions
| > Module written by Matt Mecham
| > Date started: 4th June 2003
|
| > Module Version Number: 1.0.0
| > DBA Checked: Tue 25th May 2004
+--------------------------------------------------------------------------
*/
if ( ! defined( 'IN_ACP' ) )
{
print "
Incorrect access
You cannot access this file directly. If you have recently upgraded, make sure you upgraded 'admin.php'.";
exit();
}
class ad_warnlogs {
var $base_url;
/**
* Section title name
*
* @var string
*/
var $perm_main = "admin";
/**
* Section title name
*
* @var string
*/
var $perm_child = "warnlog";
function auto_run()
{
$this->ipsclass->admin->nav[] = array( $this->ipsclass->form_code, 'Warn Logs' );
//-----------------------------------------
switch($this->ipsclass->input['code'])
{
case 'view':
$this->ipsclass->admin->cp_permission_check( $this->perm_main.'|'.$this->perm_child.':' );
$this->view();
break;
case 'viewcontact':
$this->ipsclass->admin->cp_permission_check( $this->perm_main.'|'.$this->perm_child.':' );
$this->view_contact();
break;
case 'viewnote':
$this->ipsclass->admin->cp_permission_check( $this->perm_main.'|'.$this->perm_child.':view' );
$this->view_note();
break;
case 'remove':
$this->ipsclass->admin->cp_permission_check( $this->perm_main.'|'.$this->perm_child.':remove' );
$this->remove();
break;
//-----------------------------------------
default:
$this->ipsclass->admin->cp_permission_check( $this->perm_main.'|'.$this->perm_child.':' );
$this->list_current();
break;
}
}
//-----------------------------------------
// View NOTE in da pop up innit
//-----------------------------------------
function view_note()
{
if ($this->ipsclass->input['id'] == "")
{
$this->ipsclass->admin->error("Could not resolve the email ID, please try again");
}
//-----------------------------------------
// Load and config the 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 = 1;
$this->parser->bypass_badwords = intval($this->ipsclass->member['g_bypass_badwords']);
$id = intval($this->ipsclass->input['id']);
$this->ipsclass->DB->cache_add_query( 'warnlogs_view_note', array( 'id' => $id ) );
$this->ipsclass->DB->cache_exec_query();
if ( ! $row = $this->ipsclass->DB->fetch_row() )
{
$this->ipsclass->admin->error("Could not resolve the email ID, please try again ($id)");
}
$this->ipsclass->adskin->td_header[] = array( " " , "100%" );
$content = preg_match( "#(.+?)#is", $row['wlog_notes'], $cont );
$this->ipsclass->html .= $this->ipsclass->adskin->start_table( "Warn Notes" );
$row['date'] = $this->ipsclass->admin->get_date( $row['wlog_date'], 'LONG' );
$this->parser->parse_html = 0;
$this->parser->parse_nl2br = 1;
$this->parser->parse_smilies = 1;
$this->parser->parse_bbcode = 1;
$text = $this->parser->pre_display_parse( $this->parser->pre_db_parse($cont[1]) );
$this->ipsclass->html .= $this->ipsclass->adskin->add_td_row( array(
"From: {$row['p_name']}
To: {$row['a_name']}
Sent: {$row['date']}
$text
"
) );
$this->ipsclass->html .= $this->ipsclass->adskin->end_table();
$this->ipsclass->admin->print_popup();
}
//-----------------------------------------
// View contact in da pop up innit
//-----------------------------------------
function view_contact()
{
if ($this->ipsclass->input['id'] == "")
{
$this->ipsclass->admin->error("Could not resolve the email ID, please try again");
}
$id = intval($this->ipsclass->input['id']);
$this->ipsclass->DB->cache_add_query( 'warnlogs_view_note', array( 'id' => $id ) );
$this->ipsclass->DB->cache_exec_query();
if ( ! $row = $this->ipsclass->DB->fetch_row() )
{
$this->ipsclass->admin->error("Could not resolve the email ID, please try again ($id)");
}
$type = $row['wlog_contact'] == 'pm' ? "PM" : "EMAIL";
$this->ipsclass->adskin->td_header[] = array( " " , "100%" );
$subject = preg_match( "#(.+?)#is", $row['wlog_contact_content'], $subj );
$content = preg_match( "#(.+?)#is", $row['wlog_contact_content'], $cont );
$this->ipsclass->html .= $this->ipsclass->adskin->start_table( $type.": ".$subj[1] );
$row['date'] = $this->ipsclass->admin->get_date( $row['wlog_date'], 'LONG' );
$this->ipsclass->html .= $this->ipsclass->adskin->add_td_row( array(
"From: {$row['p_name']}
To: {$row['a_name']}
Sent: {$row['date']}
Subject: $subj[1]
$cont[1]
"
) );
$this->ipsclass->html .= $this->ipsclass->adskin->end_table();
$this->ipsclass->admin->print_popup();
}
//-----------------------------------------
// Remove archived files
//-----------------------------------------
function view()
{
$start = intval($this->ipsclass->input['st']) >=0 ? intval($this->ipsclass->input['st']) : 0;
$this->ipsclass->html .= ""; // removed js popwin
$this->ipsclass->admin->page_detail = "Viewing all warn entries on a member";
$this->ipsclass->admin->page_title = "Warn Logs Manager";
if ($this->ipsclass->input['search_string'] == "" and $this->ipsclass->input['mid'])
{
$this->ipsclass->DB->simple_construct( array( 'select' => 'COUNT(wlog_id) as count', 'from' => 'warn_logs', 'where' => "wlog_mid=".intval($this->ipsclass->input['mid']) ) );
$this->ipsclass->DB->simple_exec();
$row = $this->ipsclass->DB->fetch_row();
$row_count = $row['count'];
$query = "&{$this->ipsclass->form_code}&mid={$this->ipsclass->input['mid']}&code=view";
$this->ipsclass->DB->cache_add_query( 'warnlogs_view', array( 'mid' => intval($this->ipsclass->input['mid']), 'start' => $start ) );
$this->ipsclass->DB->cache_exec_query();
}
else
{
$this->ipsclass->input['search_string'] = urldecode($this->ipsclass->input['search_string']);
if ( ($this->ipsclass->input['search_type'] == 'notes') )
{
$dbq = "l.wlog_notes LIKE '%".$this->ipsclass->input['search_string']."%'";
}
else
{
$dbq = "l.wlog_contact_content LIKE '%".$this->ipsclass->input['search_string']."%'";
}
$this->ipsclass->DB->simple_construct( array( 'select' => 'COUNT(l.wlog_id) as count', 'from' => 'warn_logs l', 'where' => $dbq ) );
$this->ipsclass->DB->simple_exec();
$row = $this->ipsclass->DB->fetch_row();
$row_count = $row['count'];
$query = "&{$this->ipsclass->form_code}&code=view&search_type={$this->ipsclass->input['search_type']}&search_string=".urlencode($this->ipsclass->input['search_string']);
$this->ipsclass->DB->cache_add_query( 'warnlogs_view_two', array( 'dbq' => $dbq, 'start' => $start ) );
$this->ipsclass->DB->cache_exec_query();
}
$links = $this->ipsclass->adskin->build_pagelinks( array( 'TOTAL_POSS' => $row_count,
'PER_PAGE' => 30,
'CUR_ST_VAL' => $start,
'L_SINGLE' => "Single Page",
'L_MULTI' => "Pages: ",
'BASE_URL' => $this->ipsclass->base_url.$query,
)
);
$this->ipsclass->admin->page_detail = "You may view warn entries added by your moderators";
$this->ipsclass->admin->page_title = "Warn Logs Manager";
//-----------------------------------------
$this->ipsclass->adskin->td_header[] = array( "Type" , "5%" );
$this->ipsclass->adskin->td_header[] = array( "Member Name" , "15%" );
$this->ipsclass->adskin->td_header[] = array( "Contacted" , "5%" );
$this->ipsclass->adskin->td_header[] = array( "MOD Q" , "10%" );
$this->ipsclass->adskin->td_header[] = array( "SUSP" , "10%" );
$this->ipsclass->adskin->td_header[] = array( "NO POST" , "10%" );
$this->ipsclass->adskin->td_header[] = array( "Date" , "15%" );
$this->ipsclass->adskin->td_header[] = array( "Warned By" , "15%" );
$this->ipsclass->adskin->td_header[] = array( "View Note" , "10%" );
$this->ipsclass->html .= $this->ipsclass->adskin->start_table( "Saved Warn Logs" );
$this->ipsclass->html .= $this->ipsclass->adskin->add_td_basic($links, 'right', 'tablesubheader');
$days = array( 'd' => "Days", 'h' => "Hours" );
if ( $this->ipsclass->DB->get_num_rows() )
{
while ( $row = $this->ipsclass->DB->fetch_row() )
{
$row['wlog_date'] = $this->ipsclass->admin->get_date( $row['wlog_date'], 'LONG' );
$type = ( $row['wlog_type'] == 'pos' ) ? '-' : '+';
$cont = ( $row['wlog_contact'] != 'none' ) ? "View" : ' ';
$mod = preg_match( "#(.+?)#is" , $row['wlog_notes'], $mm );
$post = preg_match( "#(.+?)#is" , $row['wlog_notes'], $pm );
$susp = preg_match( "#(.+?)#is" , $row['wlog_notes'], $sm );
$content = preg_match( "#(.+?)#is", $row['wlog_notes'], $cm );
$content = $cm[1];
$mod = trim($mm[1]);
$post = trim($pm[1]);
$susp = trim($sm[1]);
list($v, $u, $i) = explode(',', $mod);
if ( $i == 1 )
{
$mod = 'INDEF';
}
else if ( $v == "" )
{
$mod = 'None';
}
else
{
$mod = $v.' '.$days[$u];
}
//-----------------------------------------
list($v, $u, $i) = explode(',', $post);
if ( $i == 1 )
{
$post = 'INDEF';
}
else if ( $v == "" )
{
$post = 'None';
}
else
{
$post = $v.' '.$days[$u];
}
list($v, $u) = explode(',', $susp);
if ( $v == "" )
{
$susp = 'None';
}
else
{
$susp = $v.' '.$days[$u];
}
//-----------------------------------------
$this->ipsclass->html .= $this->ipsclass->adskin->add_td_row( array(
"$type",
"{$row['a_name']}",
$cont,
$mod,
$susp,
$post,
"{$row['wlog_date']}",
"{$row['p_name']}",
"View"
) );
}
}
else
{
$this->ipsclass->html .= $this->ipsclass->adskin->add_td_basic("No results");
}
$this->ipsclass->html .= $this->ipsclass->adskin->add_td_basic($links, 'right', 'tablesubheader');
$this->ipsclass->html .= $this->ipsclass->adskin->end_table();
//-----------------------------------------
//-------------------------------
$this->ipsclass->admin->output();
}
//-----------------------------------------
// Remove archived files
//-----------------------------------------
function remove()
{
if ($this->ipsclass->input['mid'] == "")
{
$this->ipsclass->admin->error("You did not select a member ID to remove by!");
}
$this->ipsclass->DB->simple_exec_query( array( 'delete' => 'warn_logs', 'where' => "wlog_mid=".intval($this->ipsclass->input['mid']) ) );
$this->ipsclass->admin->save_log("Removed Warn Logs");
$this->ipsclass->boink_it($this->ipsclass->base_url."&{$this->ipsclass->form_code}");
}
//-----------------------------------------
// SHOW LOGS
//-----------------------------------------
function list_current()
{
$form_array = array();
$this->ipsclass->admin->page_detail = "You may view and remove warn actions performed by your staff.
Note: Removing the logs does not decrease the member's warn level";
$this->ipsclass->admin->page_title = "Warn Logs Manager";
$this->ipsclass->html .= ""; // removed js popwin
//-----------------------------------------
// VIEW LAST 5
//-----------------------------------------
$this->ipsclass->DB->cache_add_query( 'warnlogs_list_current', array() );
$this->ipsclass->DB->cache_exec_query();
$this->ipsclass->adskin->td_header[] = array( "Type" , "5%" );
$this->ipsclass->adskin->td_header[] = array( "Warned Member" , "25%" );
$this->ipsclass->adskin->td_header[] = array( "Contacted?" , "5%" );
$this->ipsclass->adskin->td_header[] = array( "Date" , "25%" );
$this->ipsclass->adskin->td_header[] = array( "Warned By" , "25%" );
$this->ipsclass->html .= $this->ipsclass->adskin->start_table( "Last 10 Warn Entries" );
if ( $this->ipsclass->DB->get_num_rows() )
{
while ( $row = $this->ipsclass->DB->fetch_row() )
{
$row['wlog_date'] = $this->ipsclass->admin->get_date( $row['wlog_date'], 'LONG' );
$type = ( $row['wlog_type'] == 'pos' ) ? '-' : '+';
$cont = ( $row['wlog_contact'] != 'none' ) ? "
" : ' ';
$this->ipsclass->html .= $this->ipsclass->adskin->add_td_row( array(
"$type",
"{$row['a_name']}",
$cont,
"{$row['wlog_date']}",
"{$row['p_name']}",
) );
}
}
else
{
$this->ipsclass->html .= $this->ipsclass->adskin->add_td_basic("No results");
}
$this->ipsclass->html .= $this->ipsclass->adskin->end_table();
//-----------------------------------------
$this->ipsclass->adskin->td_header[] = array( "Member Name" , "30%" );
$this->ipsclass->adskin->td_header[] = array( "Times Warned" , "20%" );
$this->ipsclass->adskin->td_header[] = array( "View all by member" , "20%" );
$this->ipsclass->adskin->td_header[] = array( "Remove all by member" , "30%" );
$this->ipsclass->html .= $this->ipsclass->adskin->start_table( "Saved Warn Logs" );
$this->ipsclass->DB->cache_add_query( 'warnlogs_list_current_two', array() );
$this->ipsclass->DB->cache_exec_query();
while ( $r = $this->ipsclass->DB->fetch_row() )
{
$this->ipsclass->html .= $this->ipsclass->adskin->add_td_row( array( "{$r['members_display_name']}",
"{$r['act_count']}",
"View",
"Remove",
) );
}
$this->ipsclass->html .= $this->ipsclass->adskin->end_table();
//-----------------------------------------
//-------------------------------
$this->ipsclass->html .= $this->ipsclass->adskin->start_form( array( 1 => array( 'code' , 'view' ),
2 => array( 'act' , 'warnlog' ),
4 => array( 'section', $this->ipsclass->section_code ),
) );
$this->ipsclass->adskin->td_header[] = array( " " , "40%" );
$this->ipsclass->adskin->td_header[] = array( " " , "60%" );
$this->ipsclass->html .= $this->ipsclass->adskin->start_table( "Search Warn Logs" );
$form_array = array(
0 => array( 'notes' , 'Entry Notes' ),
1 => array( 'contact', 'Email/PM Sent' ),
);
//-----------------------------------------
$this->ipsclass->html .= $this->ipsclass->adskin->add_td_row( array( "Search for..." ,
$this->ipsclass->adskin->form_input( "search_string")
) );
$this->ipsclass->html .= $this->ipsclass->adskin->add_td_row( array( "Search in..." ,
$this->ipsclass->adskin->form_dropdown( "search_type", $form_array)
) );
$this->ipsclass->html .= $this->ipsclass->adskin->end_form("Search");
$this->ipsclass->html .= $this->ipsclass->adskin->end_table();
//-----------------------------------------
//-------------------------------
$this->ipsclass->admin->output();
}
}
?>