/**
  * Clear out the mod-queue table appropriately
  *
  * @access	public
  * @param	string		[topic|post] Type of item moved
  * @param	mixed		ID of topic or post, or array of ids
  * @param	boolean		Was content approved?
  * @return	void
  */
 public function clearModQueueTable($type, $typeId, $approved = false)
 {
     //-----------------------------------------
     // Get post class..
     //-----------------------------------------
     require_once IPSLib::getAppDir('forums') . '/sources/classes/post/classPost.php';
     require_once IPSLib::getAppDir('forums') . '/sources/classes/post/classPostForms.php';
     $_postClass = new classPostForms($this->registry);
     //-----------------------------------------
     // Are we operating on one id, or an array
     //-----------------------------------------
     if (is_array($typeId)) {
         $where = "type_id IN(" . implode(',', IPSLib::cleanIntArray($typeId)) . ")";
     } else {
         $where = "type_id=" . intval($typeId);
     }
     //-----------------------------------------
     // Was content deleted or moved to trash forum
     //-----------------------------------------
     if (!$approved) {
         $this->DB->delete('mod_queued_items', "type='{$type}' AND {$where}");
     } else {
         //-----------------------------------------
         // Working with posts?
         //-----------------------------------------
         if ($type == 'post') {
             IPSDebug::fireBug('info', array('type is post'));
             $this->DB->build(array('select' => 'm.id', 'from' => array('mod_queued_items' => 'm'), 'where' => "m.type='{$type}' AND m.{$where}", 'add_join' => array(array('select' => 'p.pid, p.post, p.author_id, p.post_date', 'from' => array('posts' => 'p'), 'where' => 'p.pid=m.type_id', 'type' => 'left'), array('select' => 't.title, t.forum_id', 'from' => array('topics' => 't'), 'where' => 't.tid=p.topic_id', 'type' => 'left'))));
             $outer = $this->DB->execute();
             while ($r = $this->DB->fetch($outer)) {
                 $member = IPSMember::load($r['author_id'], 'extendedProfile,groups');
                 $_postClass->setPublished(true);
                 $_postClass->setAuthor($member);
                 $_postClass->setForumData($this->registry->class_forums->allForums[$r['forum_id']]);
                 $_postClass->incrementUsersPostCount();
                 $_postClass->sendOutTrackedTopicEmails($r['topic_id'], $r['post'], $member['members_display_name'], time() - $this->settings['session_expiration'], $member['member_id']);
                 $this->DB->delete('mod_queued_items', 'id=' . $r['id']);
             }
         } else {
             IPSDebug::fireBug('info', array('type is topic'));
             $this->DB->build(array('select' => 'm.id', 'from' => array('mod_queued_items' => 'm'), 'where' => "m.type='{$type}' AND m.{$where}", 'add_join' => array(array('select' => 't.tid, t.title, t.starter_id, t.forum_id', 'from' => array('topics' => 't'), 'where' => 't.tid=m.type_id', 'type' => 'left'), array('select' => 'p.pid, p.post, p.post_date', 'from' => array('posts' => 'p'), 'where' => 'p.pid=t.topic_firstpost', 'type' => 'left'))));
             $outer = $this->DB->execute();
             while ($r = $this->DB->fetch($outer)) {
                 $member = IPSMember::load($r['starter_id'], 'extendedProfile,groups');
                 $_postClass->setPublished(true);
                 $_postClass->setAuthor($member);
                 $_postClass->setForumData($this->registry->class_forums->allForums[$r['forum_id']]);
                 $_postClass->incrementUsersPostCount();
                 $_postClass->sendOutTrackedForumEmails($r['forum_id'], $r['tid'], $r['title'], $this->registry->class_forums->allForums[$r['forum_id']]['name'], $r['post'], $member['member_id'], $member['members_display_name']);
                 $this->DB->delete('mod_queued_items', 'id=' . $r['id']);
             }
         }
     }
     $this->addModerateLog($this->request['f'], $this->request['t'], $this->request['p'], $this->topic['title'], sprintf($this->lang->words['modqueue_table_clear'], $type, is_array($typeId) ? implode(', ', $typeId) : $typeId));
 }