rendered paste body<?php
// doalltopics.php
// Scott Oldford
// scott@essentialcoding.com
// Created for IPB 2.2
if ( ! defined( 'IN_IPB' ) )
{
print "<h1>Incorrect access</h1>You cannot access this file directly. If you have recently upgraded, make sure you upgraded all the relevant files.";
exit();
}
class task_item
{
var $class = "";
var $root_path = "";
var $task = "";
/*-------------------------------------------------------------------------*/
// Our 'auto_run' function
// ADD CODE HERE
/*-------------------------------------------------------------------------*/
function run_task()
{
$this->doIt();
$this->class->append_task_log( $this->task, 'Added all Selected Members to Subscription' );
//-----------------------------------------
// Unlock Task: DO NOT MODIFY!
//-----------------------------------------
$this->class->unlock_task( $this->task );
}
/*-------------------------------------------------------------------------*/
// register_class
// LEAVE ALONE
/*-------------------------------------------------------------------------*/
function register_class(&$class)
{
$this->class = $class;
$this->ipsclass =& $class->ipsclass;
$this->root_path = $this->class->root_path;
}
/*-------------------------------------------------------------------------*/
// pass_task
// LEAVE ALONE
/*-------------------------------------------------------------------------*/
function pass_task( $this_task )
{
$this->task = $this_task;
}
function doIt() {
$this->ipsclass->DB->simple_construct( array( 'select' => '*',
'from' => 'members',
'where' => "allTrack = '1'"
) );
$result = $this->ipsclass->DB->simple_exec();
while($row = $this->ipsclass->DB->fetch_row($result)) {
foreach($this->ipsclass->cache['forum_cache'] as $key => $value) {
$this->ipsclass->DB->simple_construct( array( 'select' => '*',
'from' => 'forum_tracker',
'where' => "member_id = '".$row['id']."' AND forum_id = '".$value['id']."'"
) );
$worked = $this->ipsclass->DB->simple_exec();
$worked = $this->ipsclass->DB->fetch_row();
if(!@$worked) {
$insert = array();
$insert['member_id'] = $row['id'];
$insert['forum_id'] = $value['id'];
$insert['start_date'] = time();
$insert['last_sent'] = 0;
$insert['forum_track_type'] = "immediate";
$result = $this->ipsclass->DB->do_insert("forum_tracker", $insert);
}
}
$this->ipsclass->DB->simple_construct( array( 'select' => '*',
'from' => 'topics'
) );
$result2 = $this->ipsclass->DB->simple_exec();
while($row2 = $this->ipsclass->DB->fetch_row($result2)) {
$this->ipsclass->DB->simple_construct( array( 'select' => '*',
'from' => 'tracker',
'where' => "member_id = '".$row['id']."' AND topic_id = '".$row2['tid']."'"
) );
$worked = $this->ipsclass->DB->simple_exec();
$worked = $this->ipsclass->DB->fetch_row();
if(!@$worked) {
$insert = array();
$insert['member_id'] = $row['id'];
$insert['topic_id'] = $row2['tid'];
$insert['start_date'] = time();
$insert['last_sent'] = 0;
$insert['topic_track_type'] = "immediate";
$result = $this->ipsclass->DB->do_insert("tracker", $insert);
}
}
}
$this->ipsclass->DB->simple_construct( array( 'select' => '*',
'from' => 'members',
'where' => "allTrack = '0'"
) );
$result = $this->ipsclass->DB->simple_exec();
while($row = $this->ipsclass->DB->fetch_row($result)) {
foreach($this->ipsclass->cache['forum_cache'] as $key => $value) {
$this->ipsclass->DB->simple_delete("forum_tracker", "member_id = '".$row['id']."' AND forum_id = '".$value['id']."'");
$this->ipsclass->DB->simple_exec();
}
$this->ipsclass->DB->simple_construct( array( 'select' => '*',
'from' => 'topics'
) );
$result2 = $this->ipsclass->DB->simple_exec();
while($row2 = $this->ipsclass->DB->fetch_row($result2)) {
$this->ipsclass->DB->simple_delete("tracker", "member_id = '".$row['id']."' AND topic_id = '".$row2['id']."'");
$this->ipsclass->DB->simple_exec();
}
}
}
}
?>