/**
  * 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));
 }
 /**
  * Save the topic title edits
  *
  * @access	private
  * @return	void		[Outputs to screen]
  */
 private function _doEdit()
 {
     $this->_resetModerator($this->topic['forum_id']);
     $this->_genericPermissionCheck('edit_topic');
     if (trim($this->request['TopicTitle']) == "") {
         $this->_showError('mod_no_topic_title', 10399);
     }
     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);
     $this->request['TopicTitle'] = $_postClass->cleanTopicTitle($this->request['TopicTitle']);
     $this->request['TopicTitle'] = trim(IPSText::getTextClass('bbcode')->stripBadWords($this->request['TopicTitle']));
     $this->request['TopicDesc'] = trim(IPSText::getTextClass('bbcode')->stripBadWords($this->request['TopicDesc']));
     $this->request['TopicDesc'] = IPSText::mbsubstr($this->request['TopicDesc'], 0, 70);
     $title_seo = IPSText::makeSeoTitle($this->request['TopicTitle']);
     $this->DB->update('topics', array('title' => $this->request['TopicTitle'], 'description' => $this->request['TopicDesc'], 'title_seo' => $title_seo), 'tid=' . $this->topic['tid']);
     $this->modLibrary->forumRecount($this->forum['id']);
     $this->_addModeratorLog(sprintf($this->lang->words['acp_edit_title'], $this->topic['tid'], $this->topic['title'], $topic_title));
     $this->registry->output->redirectScreen($this->lang->words['p_edited'], $this->settings['base_url'] . "showtopic=" . $this->topic['tid']);
 }