Version 3.3.4
This commit is contained in:
1 parent
78706903a2
commit
fb6b5baabc
2206 files changed
+409828
-382984
No files matched your search
@@ -1,180 +1,192 @@
|
||||
<?php
|
||||
/**
|
||||
* @file permadelete.php Deletes posts and topics marked for deletion after specified number of days
|
||||
*~TERABYTE_DOC_READY~
|
||||
* $Copyright: (c) 2001 - 2011 Invision Power Services, Inc.$
|
||||
* $License: This is NULLED!
|
||||
* $Author: bfarber $
|
||||
* @since -
|
||||
* $LastChangedDate: 2011-09-16 17:49:58 -0400 (Fri, 16 Sep 2011) $
|
||||
* @version v3.2.3
|
||||
* $Revision: 9505 $
|
||||
*/
|
||||
|
||||
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
|
||||
* @brief Task to send out the daily digest emails
|
||||
*
|
||||
*/
|
||||
class task_item
|
||||
{
|
||||
/**
|
||||
* Object that stores the parent task manager class
|
||||
*
|
||||
* @var $class
|
||||
*/
|
||||
protected $class;
|
||||
|
||||
/**
|
||||
* Array that stores the task data
|
||||
*
|
||||
* @var $task
|
||||
*/
|
||||
protected $task = array();
|
||||
|
||||
/**
|
||||
* Registry Object Shortcuts
|
||||
*
|
||||
* @var $registry
|
||||
* @var $DB
|
||||
* @var $settings
|
||||
* @var $lang
|
||||
*/
|
||||
protected $registry;
|
||||
protected $DB;
|
||||
protected $settings;
|
||||
protected $lang;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param object $registry Registry object
|
||||
* @param object $class Task manager class object
|
||||
* @param array $task Array with the task data
|
||||
* @return @e void
|
||||
*/
|
||||
public function __construct( ipsRegistry $registry, $class, $task )
|
||||
{
|
||||
/* Make registry objects */
|
||||
$this->registry = $registry;
|
||||
$this->DB = $this->registry->DB();
|
||||
$this->settings =& $this->registry->fetchSettings();
|
||||
$this->cache = $this->registry->cache();
|
||||
$this->lang = $this->registry->getClass('class_localization');
|
||||
|
||||
$this->class = $class;
|
||||
$this->task = $task;
|
||||
}
|
||||
|
||||
/**
|
||||
* Run this task
|
||||
*
|
||||
* @return @e void
|
||||
*/
|
||||
public function runTask()
|
||||
{
|
||||
$this->registry->getClass('class_localization')->loadLanguageFile( array( 'public_global' ), 'core' );
|
||||
$this->registry->getClass('class_localization')->loadLanguageFile( array( 'public_mod' ), 'forums' );
|
||||
|
||||
//-----------------------------------------
|
||||
// Figure out how long
|
||||
//-----------------------------------------
|
||||
|
||||
$_days = $this->settings['days_to_keep_deletions'] > 0 ? intval($this->settings['days_to_keep_deletions']) : 365;
|
||||
$_ts = time() - ( $_days * 86400 );
|
||||
$posts = 0; // Number of removed posts
|
||||
$topics = 0; // Number of removed topics
|
||||
$forums = array();
|
||||
|
||||
//-----------------------------------------
|
||||
// Moderator library
|
||||
//-----------------------------------------
|
||||
|
||||
$classToLoad = IPSLib::loadLibrary( IPSLib::getAppDir( 'forums' ) . '/sources/classes/moderate.php', 'moderatorLibrary', 'forums' );
|
||||
$moderatorLibrary = new $classToLoad( $this->registry );
|
||||
|
||||
//-----------------------------------------
|
||||
// Get topics
|
||||
//-----------------------------------------
|
||||
|
||||
$this->DB->build( array( 'select' => '*', 'from' => 'topics', 'where' => $this->registry->getClass('class_forums')->fetchTopicHiddenQuery( array( 'pdelete', 'oktoremove' ) ) . ' AND tdelete_time < ' . $_ts ) );
|
||||
$outer = $this->DB->execute();
|
||||
|
||||
while( $r = $this->DB->fetch($outer) )
|
||||
{
|
||||
$forums[ $r['forum_id'] ] = $r['forum_id'];
|
||||
|
||||
$moderatorLibrary->init( $this->registry->getClass('class_forums')->allForums[ $r['forum_id'] ], $r );
|
||||
$moderatorLibrary->topicDeleteFromDB( $r['tid'], true );
|
||||
$moderatorLibrary->clearModQueueTable( 'topic', $r['tid'] );
|
||||
$moderatorLibrary->addModerateLog( $r['forum_id'], $r['tid'], '', $r['title'], $this->lang->words['acp_deleted_a_topic'] );
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Get posts
|
||||
//-----------------------------------------
|
||||
|
||||
$_ids = array();
|
||||
|
||||
$this->DB->build( array(
|
||||
'select' => 'p.*',
|
||||
'from' => array( 'posts' => 'p' ),
|
||||
'where' => $this->registry->getClass('class_forums')->fetchPostHiddenQuery( array( 'pdelete', 'oktoremove' ), 'p.' ) . ' AND pdelete_time < ' . $_ts,
|
||||
'add_join' => array(
|
||||
array(
|
||||
'select' => 't.*',
|
||||
'from' => array( 'topics' => 't' ),
|
||||
'where' => 't.tid=p.topic_id',
|
||||
'type' => 'left',
|
||||
)
|
||||
)
|
||||
) );
|
||||
$outer = $this->DB->execute();
|
||||
|
||||
while( $r = $this->DB->fetch($outer) )
|
||||
{
|
||||
$forums[ $r['forum_id'] ] = $r['forum_id'];
|
||||
|
||||
$moderatorLibrary->init( $this->registry->getClass('class_forums')->allForums[ $r['forum_id'] ], $r );
|
||||
$moderatorLibrary->postDeleteFromDb( $r['pid'], true );
|
||||
$moderatorLibrary->clearModQueueTable( 'post', $r['pid'] );
|
||||
|
||||
$_ids[] = $r['pid'];
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Rebuild forums and stats
|
||||
//-----------------------------------------
|
||||
|
||||
if( count($forums) )
|
||||
{
|
||||
foreach( $forums as $forum )
|
||||
{
|
||||
$moderatorLibrary->forumRecount( $forum );
|
||||
}
|
||||
|
||||
$this->cache->rebuildCache( 'stats', 'global' );
|
||||
}
|
||||
|
||||
$moderatorLibrary->addModerateLog( "", "", "", implode( ',', $_ids ), sprintf( $this->lang->words['multi_post_delete'], implode( ', ', $_ids ) ) );
|
||||
|
||||
//-----------------------------------------
|
||||
// Log to log table - modify but dont delete
|
||||
//-----------------------------------------
|
||||
|
||||
$this->class->appendTaskLog( $this->task, sprintf( $this->lang->words['task_permadelete'], $posts, $topics ) );
|
||||
|
||||
//-----------------------------------------
|
||||
// Unlock Task: DO NOT MODIFY!
|
||||
//-----------------------------------------
|
||||
|
||||
$this->class->unlockTask( $this->task );
|
||||
}
|
||||
<?php
|
||||
/**
|
||||
* @file permadelete.php Deletes posts and topics marked for deletion after specified number of days
|
||||
*~TERABYTE_DOC_READY~
|
||||
* $Copyright: (c) 2001 - 2011 Invision Power Services, Inc.$
|
||||
* $License: http://www.invisionpower.com/company/standards.php#license$
|
||||
* $Author: AndyMillne $
|
||||
* @since -
|
||||
* $LastChangedDate: 2012-07-02 10:20:47 -0400 (Mon, 02 Jul 2012) $
|
||||
* @version v3.3.4
|
||||
* $Revision: 11019 $
|
||||
*/
|
||||
|
||||
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
|
||||
* @brief Task to send out the daily digest emails
|
||||
*
|
||||
*/
|
||||
class task_item
|
||||
{
|
||||
/**
|
||||
* Object that stores the parent task manager class
|
||||
*
|
||||
* @var $class
|
||||
*/
|
||||
protected $class;
|
||||
|
||||
/**
|
||||
* Array that stores the task data
|
||||
*
|
||||
* @var $task
|
||||
*/
|
||||
protected $task = array();
|
||||
|
||||
/**
|
||||
* Registry Object Shortcuts
|
||||
*
|
||||
* @var $registry
|
||||
* @var $DB
|
||||
* @var $settings
|
||||
* @var $lang
|
||||
*/
|
||||
protected $registry;
|
||||
protected $DB;
|
||||
protected $settings;
|
||||
protected $lang;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param object $registry Registry object
|
||||
* @param object $class Task manager class object
|
||||
* @param array $task Array with the task data
|
||||
* @return @e void
|
||||
*/
|
||||
public function __construct( ipsRegistry $registry, $class, $task )
|
||||
{
|
||||
/* Make registry objects */
|
||||
$this->registry = $registry;
|
||||
$this->DB = $this->registry->DB();
|
||||
$this->settings =& $this->registry->fetchSettings();
|
||||
$this->cache = $this->registry->cache();
|
||||
$this->lang = $this->registry->getClass('class_localization');
|
||||
|
||||
$this->class = $class;
|
||||
$this->task = $task;
|
||||
}
|
||||
|
||||
/**
|
||||
* Run this task
|
||||
*
|
||||
* @return @e void
|
||||
*/
|
||||
public function runTask()
|
||||
{
|
||||
$this->registry->getClass('class_localization')->loadLanguageFile( array( 'public_global' ), 'core' );
|
||||
$this->registry->getClass('class_localization')->loadLanguageFile( array( 'public_mod' ), 'forums' );
|
||||
|
||||
//-----------------------------------------
|
||||
// Figure out how long
|
||||
//-----------------------------------------
|
||||
|
||||
$_days = $this->settings['days_to_keep_deletions'] > 0 ? intval($this->settings['days_to_keep_deletions']) : 365;
|
||||
$_ts = time() - ( $_days * 86400 );
|
||||
$posts = 0; // Number of removed posts
|
||||
$topics = 0; // Number of removed topics
|
||||
$forums = array();
|
||||
|
||||
//-----------------------------------------
|
||||
// Moderator library
|
||||
//-----------------------------------------
|
||||
|
||||
$classToLoad = IPSLib::loadLibrary( IPSLib::getAppDir( 'forums' ) . '/sources/classes/moderate.php', 'moderatorLibrary', 'forums' );
|
||||
$moderatorLibrary = new $classToLoad( $this->registry );
|
||||
|
||||
//-----------------------------------------
|
||||
// Get topics
|
||||
//-----------------------------------------
|
||||
|
||||
$this->DB->build( array( 'select' => '*',
|
||||
'from' => 'topics',
|
||||
'where' => $this->registry->getClass('class_forums')->fetchTopicHiddenQuery( array( 'pdelete', 'oktoremove' ) ) . ' AND tdelete_time < ' . $_ts,
|
||||
'limit' => array( 0, 500 ) ) );
|
||||
|
||||
$outer = $this->DB->execute();
|
||||
|
||||
while( $r = $this->DB->fetch($outer) )
|
||||
{
|
||||
$topics++;
|
||||
$forums[ $r['forum_id'] ] = $r['forum_id'];
|
||||
|
||||
$moderatorLibrary->init( $this->registry->getClass('class_forums')->allForums[ $r['forum_id'] ], $r );
|
||||
$moderatorLibrary->topicDeleteFromDB( $r['tid'], true );
|
||||
$moderatorLibrary->clearModQueueTable( 'topic', $r['tid'] );
|
||||
$moderatorLibrary->addModerateLog( $r['forum_id'], $r['tid'], '', $r['title'], $this->lang->words['acp_deleted_a_topic'] );
|
||||
|
||||
// Do we have a linked topic to remove?
|
||||
$linked_topic = $this->DB->buildAndFetch( array( 'select' => 'tid, forum_id', 'from' => 'topics', 'where' => "state='link' AND moved_to='" . $r['tid'] . '&' . $r['forum_id'] . "'" ) );
|
||||
|
||||
if ( $linked_topic )
|
||||
{
|
||||
$this->DB->delete( 'topics', "tid=" . $linked_topic['tid'] );
|
||||
$forums[ $linked_topic['forum_id'] ] = $linked_topic['forum_id'];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Get posts
|
||||
//-----------------------------------------
|
||||
|
||||
$_ids = array();
|
||||
|
||||
$this->DB->build( array(
|
||||
'select' => 'p.*',
|
||||
'from' => array( 'posts' => 'p' ),
|
||||
'where' => $this->registry->getClass('class_forums')->fetchPostHiddenQuery( array( 'pdelete', 'oktoremove' ), 'p.' ) . ' AND pdelete_time < ' . $_ts,
|
||||
'limit' => array( 0, 500 ),
|
||||
'add_join' => array( array( 'select' => 't.*',
|
||||
'from' => array( 'topics' => 't' ),
|
||||
'where' => 't.tid=p.topic_id',
|
||||
'type' => 'left' ) ) ) );
|
||||
$outer = $this->DB->execute();
|
||||
|
||||
while( $r = $this->DB->fetch($outer) )
|
||||
{
|
||||
$posts++;
|
||||
$forums[ $r['forum_id'] ] = $r['forum_id'];
|
||||
|
||||
$moderatorLibrary->init( $this->registry->getClass('class_forums')->allForums[ $r['forum_id'] ], $r );
|
||||
$moderatorLibrary->postDeleteFromDb( $r['pid'], true );
|
||||
$moderatorLibrary->clearModQueueTable( 'post', $r['pid'] );
|
||||
|
||||
$_ids[] = $r['pid'];
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Rebuild forums and stats
|
||||
//-----------------------------------------
|
||||
|
||||
if( count($forums) )
|
||||
{
|
||||
foreach( $forums as $forum )
|
||||
{
|
||||
$moderatorLibrary->forumRecount( $forum );
|
||||
}
|
||||
|
||||
$this->cache->rebuildCache( 'stats', 'global' );
|
||||
}
|
||||
|
||||
$moderatorLibrary->addModerateLog( "", "", "", implode( ',', $_ids ), sprintf( $this->lang->words['multi_post_delete'], implode( ', ', $_ids ) ) );
|
||||
|
||||
//-----------------------------------------
|
||||
// Log to log table - modify but dont delete
|
||||
//-----------------------------------------
|
||||
|
||||
$this->class->appendTaskLog( $this->task, sprintf( $this->lang->words['task_permadelete'], $posts, $topics ) );
|
||||
|
||||
//-----------------------------------------
|
||||
// Unlock Task: DO NOT MODIFY!
|
||||
//-----------------------------------------
|
||||
|
||||
$this->class->unlockTask( $this->task );
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user