Location: PHPKode > projects > PapyrusBB > PapyrusBB-0.6/include/listTopics.php
<?php
defined('WikyBlog') or die("Not an entry point...");


includeFile('search/all.php');

class forumListing extends query{
	var $objectType = '_forumpost';  //for saving
	var $parent;
	
	//for saving with wikyblog's SavePage.php functions
	var $keywords = '';
	var $flags = '';
	var $dbInfo;
	var $uniqStorage;
	var $inLinks;
	var $file_id;

	
	function forumListing(&$parent){
		global $wbTables,$langA,$page;
		$this->parent = $parent;
		$page->formAction = $parent->uniqLink;

		
		$showList = true;
		if( !empty($page->userCmd) ){
			ob_start();
			switch($page->userCmd){
				
				case 'preview':
					$this->preview();
					$showList = false;
				break;
				
				case 'savetopic':
					if( $this->saveTopic() ){
						break;
					}
					if( $page->ajaxRequest ){
						return;
					}
				case 'newtopic':
					$this->newTopic();
					$showList = false;
				break;
				
				case 'sticky':
					$this->sticky();
				break;
				
				case 'delete':
					$this->delete();
					$showList = false;
				break;
				
				case 'options':
					$this->options();
					$showList = false;
				break;
				case 'active';
					$this->toggleActive();
				break;
				
				case 'confdelete':
					$this->confDelete();
				break;
				
				case wbStrtolower($langA['move']):
				case 'move':
					$this->move();
				break;
				
				case 'uptopic':
					if( $this->upTopic() ){
						break;
					}
					if( $page->ajaxRequest ){
						return;
					}					
				case 'edit':
					$this->edit();
					$showList = false;
				break;
			}
			$page->contentB[$parent->uniqLink] = wb::get_clean();
		}

		if( $showList ){
			$this->getList();
		}
		
			
	}
	
	function getList(){
		global $wbTables,$langA,$page;
		pluginIncludeFile('themes/default/template.php');
		
		$this->overWrite['cmd'] = false;
		$this->overWrite['id'] = false;
		$this->overWrite['how'] = false;
		$this->rowLimit = $this->parent->topics_per_page;
		
		//The Rest
		$this->query = ' SELECT SQL_CALC_FOUND_ROWS ';
		$this->query .= $wbTables['bb_topics'].'.* ';
		$this->query .= ' FROM '.$wbTables['bb_topics'];
		$this->query .= ' WHERE '.$wbTables['bb_topics'].'.`forum_id` = "'.$this->parent->ids['forum'].'" ';
		$this->query .= ' ORDER BY `sticky` DESC, `modified` DESC ';
		$this->searchUrl = $this->parent->uniqLink;
		$this->browse($this->parent->title);
	}
	
	function mysqlFetch(&$result){
		return mysql_fetch_assoc($result);
	}
	function abbrevOutput(&$row,$i){
		forumTemplate::topicDisplay($row,$i);
	}
	
	function displayNumbers(&$from,&$to,&$rowsFound,&$prev,&$next){
		echo '<div style="font-size:85%;text-align:right">&nbsp;';
		if( $this->parent->new_topics ){
			echo wbLinks::local($this->parent->uniqLink.'?cmd=newtopic','new_topic');
			echo ' &nbsp; ';
		}
		echo wbLang::text('RESULTS',$from,$to,$rowsFound);
		echo ' &nbsp; ';
		echo $prev.' &nbsp; '.$next;
		echo '</div>';
	}
		
	function displayPost(&$prev,&$pages,&$next){
		$more = '';
		
		if( $this->parent->new_topics ){
			$more = wbLinks::local($this->parent->uniqLink.'?cmd=newtopic','new_topic');
		}
		parent::displayPost($prev,$pages,$next,'',$more);
		$this->parent->forumFooter();
	}
	
	function displayEmpty(){
		$this->newTopic();
	}
	
	
	////////////////////////////////////////////////////////////////////////////////////////////////
	//
	//		Topic Editing
	//

	
	function preview(){
		global $wbNow,$langA;
		globalFromPost('text');
		
		$row = array();
		$row['formatting'] = $_POST['formatting'];
		$row['poster_ip'] = $_SERVER['REMOTE_ADDR'];
		$row['flags'] = '';
		
		$row['title'] = $_POST['title'];
		$row['sticky'] = '';
		$row['first_post_ip'] = $_SERVER['REMOTE_ADDR'];
		$row['first_post_text'] = $_POST['text'];
		$row['posts'] = 0;
		$row['modified'] = $wbNow;
		$row['created'] = $wbNow;
		$row['active'] = 1;
		
		echo '<h2>'.$langA['preview'].'</h2>';
		pluginIncludeFile('themes/default/template.php');
		$this->abbrevOutput($row,0);
		
		if( isset($_POST['id']) ){
			$this->edit();
		}else{
			$this->newTopic();
		}
	}
	
	
	function checkPost(){
		global $wbTables;
		
			
		
		$id = false;
		if( isset($_POST['id']) ){
			$id = $_POST['id'];
		}elseif( isset($_GET['id']) ){
			$id = $_GET['id'];
		}
		if( !is_numeric($id) ){
			message('INVALID_REQUEST');
			return false;
		}		
		
		$query = 'SELECT '.$wbTables['bb_topics'].'.* ';
		$query .= ' , '.$wbTables['bb_posts'].'.`text` ';
		$query .= ' , '.$wbTables['bb_posts'].'.`formatting` ';
		$query .= ' FROM '.$wbTables['bb_topics'];
		$query .= ' LEFT JOIN '.$wbTables['bb_posts'];
		$query .= ' ON '.$wbTables['bb_topics'].'.`forum_id` = '.$wbTables['bb_posts'].'.`forum_id` ';
		$query .= ' AND '.$wbTables['bb_topics'].'.`file_id` = '.$wbTables['bb_posts'].'.`file_id` ';
		$query .= ' AND '.$wbTables['bb_posts'].'.`id` = 1';
		$query .= ' WHERE '.$wbTables['bb_topics'].'.`forum_id` = "'.$this->parent->ids['forum'].'" ';
		$query .= ' AND '.$wbTables['bb_topics'].'.`file_id` = "'.$id.'" ';
		$query .= ' LIMIT 1 OFFSET 0';
		$result = wbDB::runQuery($query);
		if( mysql_num_rows($result) !== 1){
			message('INVALID_REQUEST');
			return false;
		}
		$row = mysql_fetch_assoc($result);
		
		return $row;
	}

	
	function edit(){
		global $langA,$wbTables;
		
		if( !$this->parent->mod_edit_topics ){
			message('AREA_RESTRICTED');
			return true;
		}
		
		$row = $this->checkPost();
		if( !$row ){
			return false;
		}
		
		
		echo '<input type="hidden" name="cmd" value="uptopic" />';
		echo '<input type="hidden" name="id" value="'.$row['file_id'].'" />';
		if( isset($_POST['id']) ){
			$this->topicForm($langA['edit_topic'],$_POST);
		}else{
			$row['title'] = toDisplay($row['title']);
			$this->topicForm($langA['edit_topic'],$row);
		}
	}
	
	function upTopic(){
		global $wbTables,$page;
		$this->newTopic = false;

		if( !$this->parent->mod_edit_topics ){
			message('AREA_RESTRICTED');
			return true;
		}
		$row = $this->checkPost();
		if( !$row ){
			return false;
		}

		
		
		//new
		$page->userCmd = false;
		$this->file_id = $row['file_id'];
		includeFile('tool/SavePage.php');
		$revisionNum = objectSave::newHistoryRow($this);
		
		
		$instructions = array();
		$instructions['post'] = 1;
		$instructions['action'] = 'edit';
		$instructions['text'] = $row['text'];
		$instructions = serialize($instructions);
		
		if( !objectSave::updateAll($this,$instructions,$revisionNum-1) ){
			return false;
		}
		
		
		//text formatting
		$page->userCmd = false;
		pluginIncludeFile('include/tool/Save.php');
		$bbPostInsert = bbSave::postData();
		
		
		//bb_posts
		$query = 'UPDATE '.$wbTables['bb_posts'];
		$query .= ' SET ';
		$query .= $bbPostInsert;
		$query .= ' , `modified` = `modified` ';
		$query .= ' WHERE ';
		$query .= ' `forum_id` = "'.wbDB::escape($this->parent->ids['forum']).'" ';
		$query .= ' AND `file_id` = "'.wbDB::escape($this->file_id).'" ';
		$query .= ' AND `id` = 1';
		$query .= ' LIMIT 1';
		if( !wbDB::runQuery($query) ){
			message('REQUEST_FAILED');
			return false;
		}
		
		bbSearch::update($this->file_id);
		bbSave::all_links(1);

		
		return true;
	}
	
	function newTopic(){
		global $langA;
		
		if( !$this->parent->new_topics ){
			message('AREA_RESTRICTED');
			return;
		}
		
		$_POST += array('summary'=>$langA['added_topic']);
		echo '<input type="hidden" name="cmd" value="savetopic" />';
		$this->topicForm($langA['new_topic'],$_POST);
	}
	
	////////////////////////////////////////////////////////////////////////////////////////////////
	//
	//		Topic Creation
	//

	function saveTopic(){
		global $wbTables;
		$this->newTopic = true;
		
		if( !$this->parent->new_topics ){
			message('AREA_RESTRICTED');
			return;
		}
		
		if( empty($_POST['title']) ){
			message('EMPTY_TITLE');
			return false;
		}
		$_POST['title'] = htmlspecialchars($_POST['title']);
		if( strlen($_POST['title']) > 60 ){
			message('TITLE_TOO_LONG');
			return false;
		}
		
		if( empty($_POST['text']) ){
			message('EMPTY_TEXT');
			return false;
		}
		
		//flood check
		pluginIncludeFile('include/tool/Save.php');
		$checkCaptcha = false;
		if( $this->parent->use_captcha && function_exists('imagecreate') ){
			$checkCaptcha = true;
		}
		if( !bbSave::checkPoster($this->parent->uniqId,$checkCaptcha) ){
			return false;
		}
		includeFile('tool/SavePage.php');
		
		$username = '';
		$userId = 0;
		if( !empty($_SESSION['username']) ){
			$username = $_SESSION['username'];
			$userId = $_SESSION['user_id'];
		}
		
		//text formatting
		$bbPostInsert = bbSave::postData();
		
		if( !objectSave::newFile($this) ){
			return false;
		}
		
		
		//insert into bb_posts
		$query = ' INSERT INTO '.$wbTables['bb_posts'];
		$query .= ' SET ';
		$query .= $bbPostInsert;
		$query .= ' , `forum_id` = "'. wbDB::escape($this->parent->ids['forum']) .'" ';
		$query .= ' ,`file_id` = "'. wbDB::escape($this->file_id) .'" ';
		$query .= ' , `modified` = NOW() ';
		$query .= ' , `created` = NOW() ';
		$query .= ' , `poster_name` = "'. wbDB::escape($username) .'" ';
		$query .= ' , `poster_id` = "'. wbDB::escape($userId) .'" ';
		$query .= ' , `poster_ip` = "'. wbDB::escape($_SERVER['REMOTE_ADDR']) .'" ';
		if( !wbDB::runQuery($query) ){
			return false;
		}		
		
		//update forums
		$query = ' UPDATE '.$wbTables['bb_forums'];
		$query .= ' SET ';
		$query .= ' `posts` = `posts` + 1';
		$query .= ' , `topics` = `topics` + 1';
		$query .= ' , `last_post_user` = "'. wbDB::escape($username) .'" ';
		$query .= ' , `last_post_ip` = "'. wbDB::escape($_SERVER['REMOTE_ADDR']) .'" ';
		$query .= ' , `modified` = NOW() ';
		$query .= ' WHERE ';
		$query .= $wbTables['bb_forums'].'.`id` = "'. wbDB::escape($this->parent->ids['forum']) .'" ';
		if( !wbDB::runQuery($query) ){
			return false;
		}
		
		bbSave::newPost($this->parent->uniqId);
		bbSave::all_links(1);
		bbSearch::update($this->file_id);
		
		return true;
	}
	
	//save these variables
	function toDB(){
		global $wbNow,$wbTables,$langA;
		
		
		//prep some variables
		$this->dbInfo['dbTable'] = $wbTables['bb_topics'];
		$this->uniqStorage = $this->parent->uniqLink;

		
		//return the info
		$temp = array();
		$temp['forum_id'] = $this->parent->ids['forum'];
		$temp['title'] = toStorage($_POST['title']);
		$temp['first_post_text'] = $this->topicText($_POST['text']);
		$temp['summary'] = htmlspecialchars($_POST['summary']);
		
		if( !$this->newTopic ){
			$temp['modified'] = array($wbTables['bb_topics'].'.`modified`');
			return $temp;
		}
		
		$temp['modified'] = $wbNow;
		$temp['created'] = $wbNow;
		$temp['posts'] = '1';
		
		$temp['first_post_user'] = '';
		$temp['last_post_user'] = '';
		if( !empty($_SESSION['username']) ){
			$temp['first_post_user'] = $_SESSION['username'];
			$temp['last_post_user'] = $_SESSION['username'];
		}
		$temp['first_post_ip'] = $_SERVER['REMOTE_ADDR'];
		$temp['last_post_ip'] = $_SERVER['REMOTE_ADDR'];
		
		
		return $temp;
	}
	
	
	function topicForm($title,&$vars){
		global $langA,$page,$jsNum,$page, $pageOwner;
		$page->css2 = true;
		
		$vars += array('text'=>'','title'=>'','formatting'=>'','summary'=>'','keywords'=>'');
		$page->scripts[] = '/include/js/editing.js?'.$jsNum;
		$page->scripts[] = '/include/js/editingAll.js?'.$jsNum;

		
		includeFile('tool/EditPage.php');
		$formats[] = 'wiki';
		$formats[] = 'none';
		
		echo '<table style="margin:0 auto 0 auto">';
		echo '<tr><td>';
		
		echo '<h2>'.$title.'</h2>';
		
		
		echo '<table cellpadding="5" class="WBeditArea1">';
		echo '<tr>';
			echo '<th style="text-align:right">';
			echo $langA['title'];
			echo ':</th>';
			echo '<td style="text-align:left">';
			//title will already be htmlspeciachar()'d
			echo '<input type="text" name="title" style="width:40em" maxwidth="60" value="'.$vars['title'].'" tabindex="1" onchange="WBe.set(true)" />'; 
			echo '</td>';
			echo '</tr>';
			
		echo '<tr>';
			echo '<th style="text-align:right">';
			echo $langA['message'];
			echo ':</th>';
			echo '<td colspan="2">';
			
			echo getToolbar('text',false);
			
			echo '<textarea rows="20" style="width:40em" name="text" tabindex="2" onchange="WBe.set(true)">';
			echo htmlspecialchars($vars['text']);
			echo '</textarea>';
			echo '</td>';
			echo '</tr>';
			
		echo '<tr>';
			echo '<th style="text-align:right">';
			echo $langA['formatting'];
			echo ':</th>';
			echo '<td style="text-align:left">';
			echo '<select name="formatting" tabindex="4">';
			
			foreach($formats as $format){
				if( $vars['formatting'] == $format ){
					echo '<option value="'.$format.'" selected="selected">'.$langA[$format].'</option>';
				}else{
					echo '<option value="'.$format.'">'.$langA[$format].'</option>';
				}
			}
			
			echo '</select>';
			echo '</td>';
			echo '</tr>';
						
// 		echo '<tr>';
// 			echo '<th style="text-align:right">';
// 			echo $langA['tags'];
// 			echo ':</th>';

// 			//auto-complete keywords
// 			if(empty( $dbObject->keywords ) ){
// 				$temp = '('.wbHtmlspecialchars($langA['DEFAULT_KEYWORD_FIELD']).')';
// 			}else{
// 				$temp = wbStr_replace(',',', ',$dbObject->keywords).',';//put a comma on the end for the javascript
// 			}			
// 			$keyArray = array();
// 			if( !empty($pageOwner['keywords']) ){
// 				foreach($pageOwner['keywords'] as $key => $num){
// 					$keyArray[] = $key;
// 				}
// 			}		
// 			echo '<td style="text-align:left;overflow:hidden;">';
// 				echo '<input type="hidden" name="keyList" value="'.str_replace(array('<','>'),array('&lt;','&gt;'),implode(',',$keyArray)).'" />';
// 				echo '<input onfocus="WBe.create(this,\''.wbHtmlspecialchars($pageOwner['username']).'\')" onkeyup="WBe.show()" onblur="WBe.blur()" type="text" size="50" title="('.wbHtmlspecialchars($langA['DEFAULT_KEYWORD_FIELD']).')" class="WBinputText" maxlength="200" name="keywords" value="'.$temp.'" />';
// 			echo '</td>';
// 			echo '</tr>';
					
		echo '<tr>';
			echo '<th style="text-align:right">';
			echo $langA['summary'];
			echo ':</th>';
			echo '<td>';
			echo '<input type="text" style="width:40em" name="summary" value="'.htmlspecialchars($vars['summary']).'" tabindex="3" />';
			echo '</td>';
			echo '</tr>';

			
		//captcha
		if( $this->parent->use_captcha && function_exists('imagecreate') ){
			pluginIncludeFile('include/tool/Save.php');
			$r = bbSave::captcha($this->parent->uniqId);
			
			echo '<tr>';
			echo '<td>';
			$path = wbLinks::getDir('/include/tool/captcha.php?r='.$r);
			echo '<img src="'.$path.'" alt="captcha" />';
			echo '</td>';
			echo '<td>';
			
			echo '<input type="text" name="captcha" value="" tabindex="5" />';
			echo '</td>';
			echo '</tr>';
		}
						
		echo '</table>';
		
		echo '</td>';
		echo '</tr>';
		echo '<tr><td style="text-align:center">';
		
		echo '<input type="submit" name="cmd" value="'.$langA['preview'].'" tabindex="6" />';
		echo ' &nbsp; ';
		echo '<input type="submit" name="" value="'.$langA['save'].'" tabindex="7" onclick="WBe.set(false)"/>';
		echo ' &nbsp; ';
		echo '<input type="reset" name="cmd" value="'.$langA['reset'].'" tabindex="8" onclick="WBe.set(false)"/>';
		echo ' &nbsp; ';
		echo '<input type="submit" name="cmd" value="'.$langA['cancel'].'" tabindex="9"  onclick="WBe.set(false)"/>';
			
		echo '</td>';
		echo '</tr>';
		echo '</table>';
		
	}
		
	////////////////////////////////////////////////////////////////////////////////////////////////
	//
	//		Misc
	//

	function delete(){
		global $langA,$page;
		$page->css2 = true;

		if( !$this->parent->mod_delete_topics ){
			message('AREA_RESTRICTED');
			return false;
		}
				
		if( !isset($_GET['id']) ){
			message('INVALID_REQUEST');
			return false;
		}
		$id = $_GET['id'];
		if( !is_numeric($id) ){
			message('INVALID_REQUEST');
			return false;
		}
		echo '<input type="hidden" name="id" value="'.$_GET['id'].'" />';
		echo '<table style="margin:2em auto 0 auto" class="WBeditArea1" cellpadding="9">';
		echo '<tr><td style="text-align:center">';
		echo $langA['DELETE_TOPIC'];
		echo '<input type="hidden" name="cmd" value="confdelete" />';
		echo '<br/> &nbsp; <br/>';
		echo '<input type="submit" name="" value="'.$langA['confirm'].'" />';
		echo ' &nbsp; ';
		echo '<input type="submit" name="cmd" value="'.$langA['cancel'].'" />';
		echo '</td></tr>';
		echo '</table>';
		
		return true;
	}
	
	function confDelete(){
		global $wbTables;
		
		if( !$this->parent->mod_delete_topics ){
			message('AREA_RESTRICTED');
			return false;
		}
		
		if( !isset($_POST['id']) ){
			message('INVALID_REQUEST');
			return false;
		}
		$file_id = $_POST['id'];
		if( !is_numeric($file_id) ){
			message('INVALID_REQUEST');
			return false;
		}
		
		//delete from bb_topics
		$query = 'DELETE FROM '.$wbTables['bb_topics'];
		$query .= 'WHERE ';
		$query .= ' `forum_id` = "'.wbDB::escape($this->parent->ids['forum']).'" ';
		$query .= ' AND `file_id` = "'.wbDB::escape($file_id).'" ';
		if( !wbDB::runQuery($query) ){
			message('DELETE_FAILED');
			return false;
		}
		
		//delete from bb_posts
		$query = 'DELETE FROM '.$wbTables['bb_posts'];
		$query .= 'WHERE ';
		$query .= ' `forum_id` = "'.wbDB::escape($this->parent->ids['forum']).'" ';
		$query .= ' AND `file_id` = "'.wbDB::escape($file_id).'" ';
		$deletedPosts = wbDB::runQuery($query,true);
		if( $deletedPosts === false ){
			message('DELETE_FAILED');
			return false;
		}
		
		
		//delete from all_files
		$query = 'DELETE FROM '.$wbTables['all_files'];
		$query .= 'WHERE ';
		$query .= ' `file_id` = "'.wbDB::escape($file_id).'" ';
		wbDB::runQuery($query,true);
		
		//syncronize
		pluginIncludeFile('include/admin/adminSync.php');
		forumSync::syncForum($this->parent->ids['forum']);
	
		return true;
	}
	

	function topicText($text){
		$text = strip_tags($text);
		return substr($text,0,255);
	}
	
	////////////////////////////////////////////////////////////////////////////////////////////////
	//
	//		Topic Options
	//
	
	function sticky(){
		global $wbTables;
		
		if( !$this->parent->mod_sticky ){
			message('AREA_RESTRICTED');
			return false;
		}
		
		if( !isset($_GET['id']) ){
			message('INVALID_REQUEST');
			return false;
		}
		$id = $_GET['id'];
		if( !is_numeric($id) ){
			message('INVALID_REQUEST');
			return false;
		}
		
		//bb_topics
		$query = 'UPDATE '.$wbTables['bb_topics'];
		$query .= ' SET ';
		$query .= ' `modified` = `modified` ';
		if( $_GET['how'] == 'on' ){
			$query .= ' , `sticky` = "1" ';
		}else{
			$query .= ' , `sticky` = "0" ';
		}
		$query .= ' WHERE ';
		$query .= ' `forum_id` = "'.$this->parent->ids['forum'].'" ';
		$query .= ' AND `file_id` = "'.wbDB::escape($id).'" ';
		$query .= ' LIMIT 1';
		if( !wbDB::runQuery($query) ){
			message('REQUEST_FAILED');
			return false;
		}
		message('topic_updated');
	}
	
	function toggleActive(){
		global $wbTables;
		
		if( !$this->parent->mod_options ){
			message('AREA_RESTRICTED');
			return false;
		}
		
		if( !isset($_GET['id']) ){
			message('INVALID_REQUEST');
			return false;
		}
		$id = $_GET['id'];
		if( !is_numeric($id) ){
			message('INVALID_REQUEST');
			return false;
		}
		
		//bb_topics
		$query = 'UPDATE '.$wbTables['bb_topics'];
		$query .= ' SET ';
		$query .= ' `modified` = `modified` ';
		if( $_GET['how'] == 'close' ){
			$query .= ' , `active` = "0" ';
		}else{
			$query .= ' , `active` = "1" ';
		}
		$query .= ' WHERE ';
		$query .= ' `forum_id` = "'.$this->parent->ids['forum'].'" ';
		$query .= ' AND `file_id` = "'.wbDB::escape($id).'" ';
		$query .= ' LIMIT 1';
		if( !wbDB::runQuery($query) ){
			message('REQUEST_FAILED');
			return false;
		}
		message('topic_updated');
	}
	
	function options(){
		global $langA, $wbTables, $page;
		$page->css2 = true;
		
		$row = $this->checkPost();
		if( !$row ){
			return false;
		}
		
		echo '<table style="margin: 1em auto 1em auto">';
		echo '<tr><td style="text-align:center">';
		
		echo '<h3>';
		echo toDisplay($row['title']);
		echo '</h3>';
		
		echo '<table cellpadding="10" class="WBeditArea1">';
		
		//Active
			echo '<tr>';
			echo '<td>';
			echo '<b>';
			echo $langA['active_topic'];
			echo '</b>';
			echo '</td>';
			echo '<td>';
			if( $row['active'] == '1' ){
				echo wbLinks::local($this->parent->uniqLink.'?cmd=active&how=close&id='.$row['file_id'],'close');
			}else{
				echo wbLinks::local($this->parent->uniqLink.'?cmd=active&how=open&id='.$row['file_id'],'open');
			}
			echo '<td>';
			echo '</tr>';
		
		//STICKY
			if( $this->parent->mod_sticky ){
				echo '<tr>';
				echo '<td>';
				echo '<b>';
				echo $langA['sticky'];
				echo '</b>';
				echo '</td>';
				echo '<td>';
				if( $row['sticky'] == '1'){
					echo wbLinks::local($this->parent->uniqLink.'?cmd=sticky&how=off&id='.$row['file_id'],'undo_sticky');
				}else{
					echo wbLinks::local($this->parent->uniqLink.'?cmd=sticky&how=on&id='.$row['file_id'],'make_sticky');
				}
				echo '<td>';
				echo '</tr>';
			}
			
		//Move
			if( $_SESSION['userlevel'] === 5 ){
				echo '<tr>';
				echo '<td>';
				echo '<b>';
				echo $langA['move'];
				echo '</b>';
				echo '</td>';
				echo '<td>';
				
				//Get the forums
// 				$query = ' SELECT `id`, `title`,  ';
// 				$query .= ' FROM '.$wbTables['bb_forums'];
// 				$query .= ' LEFT JOIN '.$wbTables['bb_forums'];
// 				$query .=  ' WHERE `id` != "'.$this->parent->ids['forum'].'" ';
				
				
				$query = 'SELECT '.$wbTables['bb_forums'].'.`id` ';
				$query .= ' ,'.$wbTables['bb_forums'].'.`title` ';
				$query .= ' , '.$wbTables['bb_categories'].'.`title` as `cat_title` ';
				$query .= ' FROM '.$wbTables['bb_forums'];
				$query .= ' LEFT JOIN '.$wbTables['bb_categories'].' USING (`cat_id`) ';
				$query .=  ' WHERE `id` != "'.$this->parent->ids['forum'].'" ';
				$query .= ' ORDER BY `cat_position` , '.$wbTables['bb_forums'].'.`position` ';
				
				
				$result = wbDB::runQuery($query);
				echo '<input type="hidden" name="current" value="'.$row['file_id'].'" />';
				echo '<select name="newforum">';
				$cat = false;
				while($row = mysql_fetch_assoc($result)){
					if( $row['cat_title'] !== $cat ){
						if( $cat !== false ){
							echo '</optgroup>';
						}
						echo '<optgroup label="'.toDisplay($row['cat_title']).'" title="'.toDisplay($row['cat_title']).'">';
					}
					echo '<option value="'.$row['id'].'" >'.toDisplay($row['title']).' ('.$row['id'].')</option>';
					$cat = $row['cat_title'];
				}
				if( $cat !== false ){
					echo '</optgroup>';
				}
				echo '</select>';
				echo ' <input type="submit" name="cmd" value="'.$langA['move'].'" />';
				echo '<td>';
				echo '</tr>';				
				
			}
			
		echo '</table>';
		echo '<input type="submit" name="" value="'.$langA['cancel'].'" />';
		echo '</td></tr>';
		echo '</table>';
		
		
	}
	function move(){
		pluginIncludeFile('include/admin/moveTopic.php');
		moveTopic::move();
	}
	
}
Return current item: PapyrusBB