diff options
| author | Hash9 <hash9@users.sourceforge.net> | 2006-07-12 17:00:33 +0000 |
|---|---|---|
| committer | Hash9 <hash9@users.sourceforge.net> | 2006-07-12 17:00:33 +0000 |
| commit | 08bf61461f4a7138f2a9fa1721ee80691032d32b (patch) | |
| tree | 3caaac62ed46d8feb56c19fd2adac24c49a330b0 | |
| parent | 89324a0abef2594c09965cb0e3166e3e7121b596 (diff) | |
| download | boards-08bf61461f4a7138f2a9fa1721ee80691032d32b.tar.gz boards-08bf61461f4a7138f2a9fa1721ee80691032d32b.tar.bz2 boards-08bf61461f4a7138f2a9fa1721ee80691032d32b.zip | |
allow content to be assigned to boards and get some extra data for the queries, also get more templates for comments from liberty
| -rw-r--r-- | BitBoard.php | 424 | ||||
| -rw-r--r-- | BitBoardForum.php | 167 | ||||
| -rw-r--r-- | BitBoardTopic.php | 127 | ||||
| -rw-r--r-- | admin/schema_inc.php | 11 | ||||
| -rw-r--r-- | ajax.php | 7 | ||||
| -rw-r--r-- | assign.php | 50 | ||||
| -rw-r--r-- | board.php | 8 | ||||
| -rw-r--r-- | edit.php | 71 | ||||
| -rwxr-xr-x | icons/db_update.png | bin | 0 -> 1867 bytes | |||
| -rw-r--r-- | index.php | 4 | ||||
| -rw-r--r-- | lookup_inc.php | 15 | ||||
| -rw-r--r-- | post.php | 7 | ||||
| -rw-r--r-- | templates/ajax.tpl | 2 | ||||
| -rw-r--r-- | templates/board.tpl | 17 | ||||
| -rw-r--r-- | templates/board_assign.tpl | 59 | ||||
| -rw-r--r-- | templates/board_edit.tpl | 86 | ||||
| -rw-r--r-- | templates/comment_post.tpl | 8 | ||||
| -rw-r--r-- | templates/menu_bitboards.tpl | 6 | ||||
| -rw-r--r-- | templates/post.tpl | 95 | ||||
| -rw-r--r-- | templates/topic.tpl | 47 | ||||
| -rw-r--r-- | templates/topic_move.tpl | 4 | ||||
| -rw-r--r-- | topic.php | 15 | ||||
| -rw-r--r-- | topic_move.php | 5 |
23 files changed, 954 insertions, 281 deletions
diff --git a/BitBoard.php b/BitBoard.php index f10bdef..3b3936e 100644 --- a/BitBoard.php +++ b/BitBoard.php @@ -1,72 +1,364 @@ <?php /** -* $Header: /cvsroot/bitweaver/_bit_boards/BitBoard.php,v 1.1 2006/06/28 15:45:26 spiderr Exp $ -* $Id: BitBoard.php,v 1.1 2006/06/28 15:45:26 spiderr Exp $ +* $Header: /cvsroot/bitweaver/_bit_boards/BitBoard.php,v 1.2 2006/07/12 16:57:33 hash9 Exp $ +* $Id: BitBoard.php,v 1.2 2006/07/12 16:57:33 hash9 Exp $ */ /** -* BitBoardBoard class to illustrate best practices when creating a new bitweaver package that +* BitBoard class to illustrate best practices when creating a new bitweaver package that * builds on core bitweaver functionality, such as the Liberty CMS engine * * @date created 2004/8/15 * @author spider <spider@steelsun.com> -* @version $Revision: 1.1 $ $Date: 2006/06/28 15:45:26 $ $Author: spiderr $ -* @class BitBoardBoard +* @version $Revision: 1.2 $ $Date: 2006/07/12 16:57:33 $ $Author: hash9 $ +* @class BitBoard */ require_once( LIBERTY_PKG_PATH.'LibertyAttachable.php' ); +/** +* This is used to uniquely identify the object +*/ +define( 'BITFORUM_CONTENT_TYPE_GUID', 'bitforum' ); + class BitBoard extends LibertyAttachable { + /** + * Primary key for our mythical BitBoard class object & table + * @public + */ + var $mBitBoardId; /** * During initialisation, be sure to call our base constructors **/ - function BitBoard() { + function BitBoard( $pBitBoardId=NULL, $pContentId=NULL ) { LibertyAttachable::LibertyAttachable(); + $this->mBitBoardId = $pBitBoardId; + $this->mContentId = $pContentId; + $this->mContentTypeGuid = BITFORUM_CONTENT_TYPE_GUID; + $this->registerContentType( BITFORUM_CONTENT_TYPE_GUID, array( + 'content_type_guid' => BITFORUM_CONTENT_TYPE_GUID, + 'content_description' => 'Forum Board', + 'handler_class' => 'BitBoard', + 'handler_package' => 'bitboards', + 'handler_file' => 'BitBoard.php', + 'maintainer_url' => 'http://www.bitweaver.org' + ) ); } - function loadContent($contentId) { - global $gBitDb; - global $gBitUser; - //var_dump($GLOBALS); - if( LibertyContent::verifyId( $contentId ) ) { + /** + * Load the data from the database + * @param pParamHash be sure to pass by reference in case we need to make modifcations to the hash + **/ + function load() { + if( $this->verifyId( $this->mBitBoardId ) || $this->verifyId( $this->mContentId ) ) { // LibertyContent::load()assumes you have joined already, and will not execute any sql! // This is a significant performance optimization + $lookupColumn = $this->verifyId( $this->mBitBoardId ) ? 'board_id' : 'content_id'; $bindVars = array(); $selectSql = $joinSql = $whereSql = ''; - array_push( $bindVars, $contentId ); - $gBitUser->getServicesSql( 'content_load_sql_function', $selectSql, $joinSql, $whereSql, $bindVars ); + array_push( $bindVars, $lookupId = @BitBase::verifyId( $this->mBitBoardId ) ? $this->mBitBoardId : $this->mContentId ); + $this->getServicesSql( 'content_load_sql_function', $selectSql, $joinSql, $whereSql, $bindVars ); - $query = "SELECT lc.*, uue.`login` AS modifier_user, uue.`real_name` AS modifier_real_name, uuc.`login` AS creator_user, uuc.`real_name` AS creator_real_name $selectSql - FROM `".BIT_DB_PREFIX."liberty_content` lc $joinSql - LEFT JOIN `".BIT_DB_PREFIX."users_users` uue ON( uue.`user_id` = lc.`modifier_user_id` ) - LEFT JOIN `".BIT_DB_PREFIX."users_users` uuc ON( uuc.`user_id` = lc.`user_id` ) - WHERE lc.`content_id`=? $whereSql"; - $result = $gBitDb->query( $query, $bindVars ); + $query = "SELECT s.*, lc.*, " . + "uue.`login` AS modifier_user, uue.`real_name` AS modifier_real_name, " . + "uuc.`login` AS creator_user, uuc.`real_name` AS creator_real_name " . + "$selectSql " . + "FROM `".BIT_DB_PREFIX."forum_board` s " . + "INNER JOIN `".BIT_DB_PREFIX."liberty_content` lc ON( lc.`content_id` = s.`content_id` ) $joinSql" . + "LEFT JOIN `".BIT_DB_PREFIX."users_users` uue ON( uue.`user_id` = lc.`modifier_user_id` )" . + "LEFT JOIN `".BIT_DB_PREFIX."users_users` uuc ON( uuc.`user_id` = lc.`user_id` )" . + "WHERE s.`$lookupColumn`=? $whereSql"; + $result = $this->mDb->query( $query, $bindVars ); - $ret = array(); if( $result && $result->numRows() ) { - $ret = $result->fields; + $this->mInfo = $result->fields; + $this->mContentId = $result->fields['content_id']; + $this->mBitBoardId = $result->fields['board_id']; + + $this->mInfo['creator'] =( isset( $result->fields['creator_real_name'] )? $result->fields['creator_real_name'] : $result->fields['creator_user'] ); + $this->mInfo['editor'] =( isset( $result->fields['modifier_real_name'] )? $result->fields['modifier_real_name'] : $result->fields['modifier_user'] ); + $this->mInfo['display_url'] = $this->getDisplayUrl(); + $this->mInfo['parsed_data'] = $this->parseData(); + + LibertyAttachable::load(); + } + } + return( count( $this->mInfo ) ); + } + + /** + * Any method named Store inherently implies data will be written to the database + * @param pParamHash be sure to pass by reference in case we need to make modifcations to the hash + * This is the ONLY method that should be called in order to store( create or update )an bitforum! + * It is very smart and will figure out what to do for you. It should be considered a black box. + * + * @param array pParams hash of values that will be used to store the page + * + * @return bool TRUE on success, FALSE if store could not occur. If FALSE, $this->mErrors will have reason why + * + * @access public + **/ + function store( &$pParamHash ) { + if( $this->verify( $pParamHash )&& LibertyAttachable::store( $pParamHash ) ) { + $table = BIT_DB_PREFIX."forum_board"; + $this->mDb->StartTrans(); + if( $this->mBitBoardId ) { + $locId = array( "board_id" => $pParamHash['board_id'] ); + $result = $this->mDb->associateUpdate( $table, $pParamHash['bitforum_store'], $locId ); + } else { + $pParamHash['bitforum_store']['content_id'] = $pParamHash['content_id']; + if( @$this->verifyId( $pParamHash['board_id'] ) ) { + // if pParamHash['board_id'] is set, some is requesting a particular board_id. Use with caution! + $pParamHash['bitforum_store']['board_id'] = $pParamHash['board_id']; + } else { + $pParamHash['bitforum_store']['board_id'] = $this->mDb->GenID( 'forum_board_id_seq' ); + } + $this->mBitBoardId = $pParamHash['bitforum_store']['board_id']; + + $result = $this->mDb->associateInsert( $table, $pParamHash['bitforum_store'] ); + $result = $this->mDb->associateInsert( BIT_DB_PREFIX."forum_map",array('board_content_id'=>$pParamHash['bitforum_store']['content_id'],'topic_content_id'=>$pParamHash['bitforum_store']['content_id'])); + } + + + $this->mDb->CompleteTrans(); + $this->load(); + } + return( count( $this->mErrors )== 0 ); + } + + /** + * Make sure the data is safe to store + * @param pParamHash be sure to pass by reference in case we need to make modifcations to the hash + * This function is responsible for data integrity and validation before any operations are performed with the $pParamHash + * NOTE: This is a PRIVATE METHOD!!!! do not call outside this class, under penalty of death! + * + * @param array pParams reference to hash of values that will be used to store the page, they will be modified where necessary + * + * @return bool TRUE on success, FALSE if verify failed. If FALSE, $this->mErrors will have reason why + * + * @access private + **/ + function verify( &$pParamHash ) { + // make sure we're all loaded up of we have a mBitBoardId + if( $this->verifyId( $this->mBitBoardId ) && empty( $this->mInfo ) ) { + $this->load(); + } + + if( @$this->verifyId( $this->mInfo['content_id'] ) ) { + $pParamHash['content_id'] = $this->mInfo['content_id']; + } + + // It is possible a derived class set this to something different + if( @$this->verifyId( $pParamHash['content_type_guid'] ) ) { + $pParamHash['content_type_guid'] = $this->mContentTypeGuid; + } + + if( @$this->verifyId( $pParamHash['content_id'] ) ) { + $pParamHash['bitforum_store']['content_id'] = $pParamHash['content_id']; + } + + // check some lengths, if too long, then truncate + if( $this->isValid() && !empty( $this->mInfo['description'] ) && empty( $pParamHash['description'] ) ) { + // someone has deleted the description, we need to null it out + $pParamHash['bitforum_store']['description'] = ''; + } else if( empty( $pParamHash['description'] ) ) { + unset( $pParamHash['description'] ); + } else { + $pParamHash['bitforum_store']['description'] = substr( $pParamHash['description'], 0, 200 ); + } + + if( !empty( $pParamHash['data'] ) ) { + $pParamHash['edit'] = $pParamHash['data']; + } + + // check for name issues, first truncate length if too long + if( !empty( $pParamHash['title'] ) ) { + if( empty( $this->mBitBoardId ) ) { + if( empty( $pParamHash['title'] ) ) { + $this->mErrors['title'] = 'You must enter a name for this page.'; + } else { + $pParamHash['content_store']['title'] = substr( $pParamHash['title'], 0, 160 ); + } + } else { + $pParamHash['content_store']['title'] =( isset( $pParamHash['title'] ) )? substr( $pParamHash['title'], 0, 160 ): ''; + } + } else if( empty( $pParamHash['title'] ) ) { + // no name specified + $this->mErrors['title'] = 'You must specify a name'; + } + + return( count( $this->mErrors )== 0 ); + } + + /** + * This function removes a bitforum entry + **/ + function expunge() { + $ret = FALSE; + if( $this->isValid() ) { + $this->mDb->StartTrans(); + $query = "DELETE FROM `".BIT_DB_PREFIX."forum_map` WHERE `board_content_id` = ?"; + $result = $this->mDb->query( $query, array( $this->mContentId ) ); + $query = "DELETE FROM `".BIT_DB_PREFIX."forum_board` WHERE `content_id` = ?"; + $result = $this->mDb->query( $query, array( $this->mContentId ) ); + if( LibertyAttachable::expunge() ) { + $ret = TRUE; + $this->mDb->CompleteTrans(); + } else { + $this->mDb->RollbackTrans(); + } + } + return $ret; + } + + /** + * Make sure bitforum is loaded and valid + **/ + function isValid() { + return( $this->verifyId( $this->mBitBoardId ) ); + } - $ret['creator'] =( isset( $result->fields['creator_real_name'] )? $result->fields['creator_real_name'] : $result->fields['creator_user'] ); - $ret['editor'] =( isset( $result->fields['modifier_real_name'] )? $result->fields['modifier_real_name'] : $result->fields['modifier_user'] ); - $ret['display_url'] = BIT_ROOT_URL."index.php?content_id=$contentId"; + function getAllMap() { + $b = new BitBoard(); + $listHash = array(); + $l = $b->getList($listHash); + $ret = array(); + foreach ($l as $k => $boardd) { + $board = new BitBoard($boardd['board_id']); + $board->mInfo=$boardd; + $ret['map'][$k]=$boardd; + $ret['map'][$k]['map'] = $board->getMap(); + $ret['map'][$k]['integrity'] = $board->verifyIntegrity(); + } + $ret['umap'] = $b->getUnMapped(); + return $ret; + } + + function getUnMapped() { + global $gBitSystem; + $ret = NULL; + $sql = "SELECT + lc.`title`, + lc.`content_id`, + lct.`content_description`, + ( SELECT count(*) + FROM `".BIT_DB_PREFIX."liberty_comments` lcom + WHERE lcom.`root_id`=lcom.`parent_id` AND lcom.`root_id`=lc.`content_id` + ) AS thread_count + FROM `".BIT_DB_PREFIX."liberty_content` lc + INNER JOIN `".BIT_DB_PREFIX."liberty_content_types` lct ON (lc.`content_type_guid`=lct.`content_type_guid`) + WHERE lc.`content_id` NOT IN ( + SELECT lc.`content_id` AS content_id + FROM `".BIT_DB_PREFIX."forum_board` b + INNER JOIN `".BIT_DB_PREFIX."liberty_content` blc ON (blc.`content_id`=b.`content_id`) + INNER JOIN `".BIT_DB_PREFIX."forum_map` map ON (map.`board_content_id`= blc.`content_id`) + INNER JOIN `".BIT_DB_PREFIX."liberty_content` lc ON (lc.`content_id`=map.`topic_content_id`) + ) + AND lc.`content_type_guid` != 'pigeonholes' + AND lc.`content_type_guid` != 'bitforum' + AND lc.`content_type_guid` != 'bitcomment' + AND lc.`title` != '' + ORDER BY lc.`content_type_guid`, lc.`title` + "; + $rs = $this->mDb->query( $sql ); + while( $row = $rs->fetchRow() ) { + $ret[$row['content_id']] = $row; + } + return $ret; + } + + function addContent($content_id) { + if (@BitBase::verifyId($content_id)) { + $data = array( + 'board_content_id'=>$this->mContentId, + 'topic_content_id'=>$content_id, + ); + $this->mDb->associateInsert( BIT_DB_PREFIX."forum_map",$data); + } + } + + function removeContent($content_id) { + if (@BitBase::verifyId($content_id) && @BitBase::verifyId($this->mContentId)) { + $sql = "DELETE FROM `".BIT_DB_PREFIX."forum_map` WHERE `board_content_id` = ? AND `topic_content_id` = ?"; + $result = $this->mDb->query( $sql, array( $this->mContentId,$content_id ) ); + } + } + + function verifyIntegrity() { + global $gBitSystem; + $ret = false; + if( $this->isValid() ) { + $sql = "SELECT + COUNT(*) + FROM `".BIT_DB_PREFIX."forum_board` b + INNER JOIN `".BIT_DB_PREFIX."forum_map` map ON (map.`board_content_id`= b.`content_id`) + WHERE b.`board_id`=? AND map.`board_content_id` = map.`topic_content_id` + "; + $count = $this->mDb->getOne( $sql, array( $this->mBitBoardId )); + return ($count==1); + } + return $ret; + } + + function fixContentMap() { + if( $this->isValid() && @BitBase::verifyId($this->mContentId)) { + $this->removeContent($this->mContentId); + $this->addContent($this->mContentId); + } + } + + function lookupMapRev($content_id) { + global $gBitDb; + $ret = NULL; + if (@BitBase::verifyId($content_id)) { + $sql = "SELECT `board_content_id` FROM `".BIT_DB_PREFIX."forum_map` map WHERE map.`topic_content_id`=?"; + $ret = $gBitDb->getOne( $sql, array( $content_id )); + } + return $ret; + } + + function getMap() { + global $gBitSystem; + $ret = NULL; + if( $this->isValid() ) { + $sql = "SELECT + lc.`title` AS t_title, + lc.`content_id` AS t_content_id, + blc.`title` AS b_title, + blc.`content_id` AS b_content_id, + b.`board_id` AS b_board_id, + ( SELECT count(*) + FROM `".BIT_DB_PREFIX."liberty_comments` lcom + WHERE lcom.`root_id`=lcom.`parent_id` AND lcom.`root_id`=lc.`content_id` + ) AS thread_count, + ((blc.`content_id`- lc.`content_id)*(blc.`content_id`- lc.`content_id)) AS order_key + FROM `".BIT_DB_PREFIX."forum_board` b + INNER JOIN `".BIT_DB_PREFIX."liberty_content` blc ON (blc.`content_id`=b.`content_id`) + INNER JOIN `".BIT_DB_PREFIX."forum_map` map ON (map.`board_content_id`= blc.`content_id`) + INNER JOIN `".BIT_DB_PREFIX."liberty_content` lc ON (lc.`content_id`=map.`topic_content_id`) + WHERE b.`board_id`=? AND map.`board_content_id`!=map.`topic_content_id` + ORDER BY order_key + "; + $rs = $this->mDb->query( $sql, array( $this->mBitBoardId )); + while( $row = $rs->fetchRow() ) { + $ret[$row['t_content_id']] = $row; } } - return( $ret ); + return $ret; } /** * This function generates a list of records from the liberty_content database for use in a list page **/ - function getFullList( &$pParamHash ) { + function getList( &$pParamHash ) { global $gBitSystem, $gBitUser; - $BIT_DB_PREFIX=BIT_DB_PREFIX; // this makes sure parameters used later on are set - LibertyAttachable::prepGetList( $pParamHash ); + LibertyContent::prepGetList( $pParamHash ); $selectSql = $joinSql = $whereSql = ''; $bindVars = array(); + array_push( $bindVars, $this->mContentTypeGuid ); $this->getServicesSql( 'content_list_sql_function', $selectSql, $joinSql, $whereSql, $bindVars ); // this will set $find, $sort_mode, $max_records and $offset @@ -82,75 +374,41 @@ class BitBoard extends LibertyAttachable { $bindVars[] = '%' . strtoupper( $find ). '%'; } - if (empty($pParamHash['ct'])) { - $query= "SELECT DISTINCT lcom.`root_id` AS root_id, lc.`content_id` AS content_id, lc.`title` AS title, lc.`content_type_guid` AS content_type_guid, - ( SELECT count(*) FROM `".BIT_DB_PREFIX."liberty_comments` slcom WHERE slcom.`root_id`=slcom.`parent_id` AND slcom.`root_id`=lc.`content_id` ) AS post_count - $selectSql - FROM ".BIT_DB_PREFIX."liberty_content lc - INNER JOIN ".BIT_DB_PREFIX."liberty_comments lcom ON( lc.`content_id`=lcom.`root_id` ) - $joinSql - WHERE TRUE $whereSql - "; - - $query_cant= "SELECT COUNT(DISTINCT lcom.root_id) - FROM ".BIT_DB_PREFIX."liberty_content lc - INNER JOIN ".BIT_DB_PREFIX."liberty_comments lcom ON( lc.content_id=lcom.root_id ) - $joinSql - WHERE TRUE $whereSql - "; - } else { - $whereSql .= " AND lc.`content_type_guid`= '{$pParamHash['ct']}'"; - $query= "SELECT lc.`content_id` AS content_id, lc.`title` AS title, lc.`content_type_guid` AS content_type_guid, - ( SELECT count(*) FROM `".BIT_DB_PREFIX."liberty_comments` lcom WHERE lcom.`root_id`=lcom.`parent_id` AND lcom.`root_id`=lc.`content_id` ) AS post_count - $selectSql - FROM ".BIT_DB_PREFIX."liberty_content lc - $joinSql - WHERE TRUE $whereSql - "; - - $query_cant= "SELECT COUNT(*) - FROM ".BIT_DB_PREFIX."liberty_content lc - $joinSql - WHERE TRUE $whereSql - "; - } + $query = "SELECT ts.*, lc.`content_id`, lc.`title`, lc.`data`, + ( SELECT count(*) + FROM `".BIT_DB_PREFIX."forum_map` AS map + INNER JOIN `".BIT_DB_PREFIX."liberty_comments` lcom ON (map.`topic_content_id` = lcom.`root_id`) + WHERE lcom.`root_id`=lcom.`parent_id` AND map.`board_content_id`=lc.`content_id` + ) AS post_count + $selectSql + FROM `".BIT_DB_PREFIX."forum_board` ts INNER JOIN `".BIT_DB_PREFIX."liberty_content` lc ON( lc.`content_id` = ts.`content_id` ) $joinSql + WHERE lc.`content_type_guid` = ? $whereSql + ORDER BY ".$this->mDb->convert_sortmode( $sort_mode ); + $query_cant = "select count(*) + FROM `".BIT_DB_PREFIX."forum_board` ts INNER JOIN `".BIT_DB_PREFIX."liberty_content` lc ON( lc.`content_id` = ts.`content_id` ) $joinSql + WHERE lc.`content_type_guid` = ? $whereSql"; $result = $this->mDb->query( $query, $bindVars, $max_records, $offset ); $ret = array(); while( $res = $result->fetchRow() ) { - $res['url']= BITBOARDS_PKG_URL."index.php?c={$res['content_id']}"; + $res['url']= BITBOARDS_PKG_URL."index.php?b={$res['board_id']}"; $ret[] = $res; } $pParamHash["cant"] = $this->mDb->getOne( $query_cant, $bindVars ); - // add all pagination info to pParamHash - LibertyAttachable::postGetList( $pParamHash ); - return $ret; - } - function getForumBoardSelectList() { - global $gBitDb; - $query = "SELECT lc.`content_id` as content_id, lc.`title` as title, lct.`content_description` AS description, - ( SELECT count(*) FROM `".BIT_DB_PREFIX."liberty_comments` slcom WHERE slcom.`root_id`=slcom.`parent_id` AND slcom.`root_id`=lc.`content_id ) AS post_count - FROM `".BIT_DB_PREFIX."liberty_content` lc - INNER JOIN `".BIT_DB_PREFIX."liberty_content_types` lct ON( lc.`content_type_guid` = lct.`content_type_guid` ) - WHERE lc.`content_type_guid`!='bitcomment' - ORDER BY lc.`content_type_guid` ASC"; - - $result = $gBitDb->query( $query); - $ret = array(); - while( $res = $result->fetchRow() ) { - $ret[] = $res; - } + // add all pagination info to pParamHash + LibertyContent::postGetList( $pParamHash ); return $ret; } /** - * Generates the URL to the bitboard page + * Generates the URL to the bitforum page + * @param pExistsHash the hash that was returned by LibertyContent::pageExists * @return the link to display the page. */ - function getForumDisplayUrl(&$lcontent) { + function getDisplayUrl() { $ret = NULL; - if( @$lcontent->verifyId( $lcontent->mContentId ) ) { - $ret = BITBOARDS_PKG_URL."index.php?c=".$lcontent->mContentId; + if( @$this->verifyId( $this->mBitBoardId ) ) { + $ret = BITBOARDS_PKG_URL."index.php?b=".$this->mBitBoardId; } return $ret; } diff --git a/BitBoardForum.php b/BitBoardForum.php new file mode 100644 index 0000000..25609b9 --- /dev/null +++ b/BitBoardForum.php @@ -0,0 +1,167 @@ +<?php +/** +* $Header: /cvsroot/bitweaver/_bit_boards/Attic/BitBoardForum.php,v 1.1 2006/07/12 17:00:32 hash9 Exp $ +* $Id: BitBoardForum.php,v 1.1 2006/07/12 17:00:32 hash9 Exp $ +*/ + +/** +* BitBoardBoard class to illustrate best practices when creating a new bitweaver package that +* builds on core bitweaver functionality, such as the Liberty CMS engine +* +* @date created 2004/8/15 +* @author spider <spider@steelsun.com> +* @version $Revision: 1.1 $ $Date: 2006/07/12 17:00:32 $ $Author: hash9 $ +* @class BitBoardBoard +*/ + +require_once( LIBERTY_PKG_PATH.'LibertyAttachable.php' ); + +class BitBoardForum extends LibertyAttachable { + + /** + * During initialisation, be sure to call our base constructors + **/ + function BitBoardForum() { + LibertyAttachable::LibertyAttachable(); + } + + function loadContent($contentId) { + global $gBitDb; + global $gBitUser; + //var_dump($GLOBALS); + if( LibertyContent::verifyId( $contentId ) ) { + // LibertyContent::load()assumes you have joined already, and will not execute any sql! + // This is a significant performance optimization + $bindVars = array(); + $selectSql = $joinSql = $whereSql = ''; + array_push( $bindVars, $contentId ); + $gBitUser->getServicesSql( 'content_load_sql_function', $selectSql, $joinSql, $whereSql, $bindVars ); + + $query = "SELECT lc.*, uue.`login` AS modifier_user, uue.`real_name` AS modifier_real_name, uuc.`login` AS creator_user, uuc.`real_name` AS creator_real_name $selectSql + FROM `".BIT_DB_PREFIX."liberty_content` lc $joinSql + LEFT JOIN `".BIT_DB_PREFIX."users_users` uue ON( uue.`user_id` = lc.`modifier_user_id` ) + LEFT JOIN `".BIT_DB_PREFIX."users_users` uuc ON( uuc.`user_id` = lc.`user_id` ) + WHERE lc.`content_id`=? $whereSql"; + $result = $gBitDb->query( $query, $bindVars ); + + $ret = array(); + if( $result && $result->numRows() ) { + $ret = $result->fields; + + $ret['creator'] =( isset( $result->fields['creator_real_name'] )? $result->fields['creator_real_name'] : $result->fields['creator_user'] ); + $ret['editor'] =( isset( $result->fields['modifier_real_name'] )? $result->fields['modifier_real_name'] : $result->fields['modifier_user'] ); + $ret['display_url'] = BIT_ROOT_URL."index.php?content_id=$contentId"; + } + } + return( $ret ); + } + + /** + * This function generates a list of records from the liberty_content database for use in a list page + **/ + function getFullList( &$pParamHash ) { + global $gBitSystem, $gBitUser; + $BIT_DB_PREFIX=BIT_DB_PREFIX; + // this makes sure parameters used later on are set + LibertyAttachable::prepGetList( $pParamHash ); + + $selectSql = $joinSql = $whereSql = ''; + $bindVars = array(); + $this->getServicesSql( 'content_list_sql_function', $selectSql, $joinSql, $whereSql, $bindVars ); + + // this will set $find, $sort_mode, $max_records and $offset + extract( $pParamHash ); + + if( is_array( $find ) ) { + // you can use an array of pages + $whereSql .= " AND lc.`title` IN( ".implode( ',',array_fill( 0,count( $find ),'?' ) )." )"; + $bindVars = array_merge ( $bindVars, $find ); + } elseif( is_string( $find ) ) { + // or a string + $whereSql .= " AND UPPER( lc.`title` )like ? "; + $bindVars[] = '%' . strtoupper( $find ). '%'; + } + + if (empty($pParamHash['ct'])) { + $query= "SELECT DISTINCT lcom.`root_id` AS root_id, lc.`content_id` AS content_id, lc.`title` AS title, lc.`content_type_guid` AS content_type_guid, + ( SELECT count(*) FROM `".BIT_DB_PREFIX."liberty_comments` slcom WHERE slcom.`root_id`=slcom.`parent_id` AND slcom.`root_id`=lc.`content_id` ) AS post_count + $selectSql + FROM ".BIT_DB_PREFIX."liberty_content lc + INNER JOIN ".BIT_DB_PREFIX."liberty_comments lcom ON( lc.`content_id`=lcom.`root_id` ) + $joinSql + WHERE TRUE $whereSql + "; + + $query_cant= "SELECT COUNT(DISTINCT lcom.root_id) + FROM ".BIT_DB_PREFIX."liberty_content lc + INNER JOIN ".BIT_DB_PREFIX."liberty_comments lcom ON( lc.content_id=lcom.root_id ) + $joinSql + WHERE TRUE $whereSql + "; + } else { + $whereSql .= " AND lc.`content_type_guid`= '{$pParamHash['ct']}'"; + $query= "SELECT lc.`content_id` AS content_id, lc.`title` AS title, lc.`content_type_guid` AS content_type_guid, + ( SELECT count(*) FROM `".BIT_DB_PREFIX."liberty_comments` lcom WHERE lcom.`root_id`=lcom.`parent_id` AND lcom.`root_id`=lc.`content_id` ) AS post_count + $selectSql + FROM ".BIT_DB_PREFIX."liberty_content lc + $joinSql + WHERE TRUE $whereSql + "; + + $query_cant= "SELECT COUNT(*) + FROM ".BIT_DB_PREFIX."liberty_content lc + $joinSql + WHERE TRUE $whereSql + "; + } + $result = $this->mDb->query( $query, $bindVars, $max_records, $offset ); + $ret = array(); + while( $res = $result->fetchRow() ) { + $res['url']= BITBOARDS_PKG_URL."index.php?c={$res['content_id']}"; + $ret[] = $res; + } + $pParamHash["cant"] = $this->mDb->getOne( $query_cant, $bindVars ); + // add all pagination info to pParamHash + LibertyAttachable::postGetList( $pParamHash ); + return $ret; + } + + function getForumBoardSelectList() { + global $gBitDb; + $query = "SELECT lc.`content_id` as content_id, lc.`title` as title, + ( SELECT count(*) + FROM `".BIT_DB_PREFIX."forum_map` AS map + INNER JOIN `".BIT_DB_PREFIX."liberty_comments` lcom ON (map.`topic_content_id` = lcom.`root_id`) + WHERE lcom.`root_id`=lcom.`parent_id` AND map.`board_content_id`=lc.`content_id` + ) AS post_count + FROM `".BIT_DB_PREFIX."forum_board` b + INNER JOIN `".BIT_DB_PREFIX."liberty_content` lc ON( lc.`content_id` = b.`content_id` ) + ORDER BY lc.`title` ASC"; + + $result = $gBitDb->query( $query); + $ret = array(); + while( $res = $result->fetchRow() ) { + $ret[] = $res; + } + return $ret; + } + + /** + * Generates the URL to the bitboard page + * @return the link to display the page. + */ + function getForumDisplayUrl(&$lcontent) { + global $gBitDb; + $ret = NULL; + if( @$lcontent->verifyId( $lcontent->mContentId ) ) { + if ($lcontent->mInfo['content_type_guid']=='bitforum') { + $bId = $gBitDb->getOne("SELECT `board_id` FROM `".BIT_DB_PREFIX."forum_board` s WHERE s.`content_id`=?",array($lcontent->mContentId)); + $ret = BITBOARDS_PKG_URL."index.php?b=$bId"; + } else { + $ret = BITBOARDS_PKG_URL."index.php?c=".$lcontent->mContentId; + } + } + return $ret; + } +} +?> diff --git a/BitBoardTopic.php b/BitBoardTopic.php index 1406e92..8f0a004 100644 --- a/BitBoardTopic.php +++ b/BitBoardTopic.php @@ -1,7 +1,7 @@ <?php /** -* $Header: /cvsroot/bitweaver/_bit_boards/BitBoardTopic.php,v 1.3 2006/07/06 19:44:26 hash9 Exp $ -* $Id: BitBoardTopic.php,v 1.3 2006/07/06 19:44:26 hash9 Exp $ +* $Header: /cvsroot/bitweaver/_bit_boards/BitBoardTopic.php,v 1.4 2006/07/12 16:57:33 hash9 Exp $ +* $Id: BitBoardTopic.php,v 1.4 2006/07/12 16:57:33 hash9 Exp $ */ /** @@ -10,7 +10,7 @@ * * @date created 2004/8/15 * @author spider <spider@steelsun.com> -* @version $Revision: 1.3 $ $Date: 2006/07/06 19:44:26 $ $Author: hash9 $ +* @version $Revision: 1.4 $ $Date: 2006/07/12 16:57:33 $ $Author: hash9 $ * @class BitBoardTopic */ @@ -20,7 +20,7 @@ require_once( BITBOARDS_PKG_PATH.'BitBoardPost.php' ); /** * This is used to uniquely identify the object */ -define( 'BitBoardTopic_CONTENT_TYPE_GUID', 'BitForumTopic' ); +define( 'BitBoardTopic_CONTENT_TYPE_GUID', 'BitBoardTopic' ); class BitBoardTopic extends LibertyAttachable { /** @@ -83,11 +83,14 @@ SELECT lcom.`root_id` AS th_root_id, lcom.`root_id` AS content_id, - lc.`content_type_guid` AS content_type_guid + lc.`content_type_guid` AS content_type_guid, + + map.`board_content_id` AS board_content_id $selectSql FROM `${BIT_DB_PREFIX}liberty_comments` AS lcom INNER JOIN `${BIT_DB_PREFIX}liberty_content` AS lc ON( lc.`content_id` = lcom.`content_id` ) + INNER JOIN `${BIT_DB_PREFIX}forum_map` map ON (map.`topic_content_id`=lcom.`root_id` ) LEFT JOIN `${BIT_DB_PREFIX}forum_thread` th ON (th.`parent_id`=lcom.`comment_id`) LEFT JOIN `${BIT_DB_PREFIX}forum_post` AS post ON(post.`comment_id`=lcom.`comment_id`) $joinSql @@ -238,11 +241,14 @@ WHERE $bindVars[] = '%' . strtoupper( $find ). '%'; } - if(!empty($pParamHash['c'])) { - $whereSql .= " AND lcom.`root_id` = ". $pParamHash['c'] ; + if(!empty($pParamHash['b'])) { + $joinSql .= " INNER JOIN `${BIT_DB_PREFIX}forum_map` AS map ON (map.`topic_content_id` = lcom.`root_id`)"; + $joinSql .= " INNER JOIN `${BIT_DB_PREFIX}forum_board` AS b ON (b.`content_id` = map.`board_content_id`)"; + $whereSql .= " AND b.`board_id` = ". $pParamHash['b'] ; } + if (!($gBitUser->hasPermission('p_bitboards_edit') || $gBitUser->hasPermission('p_bitboards_post_edit'))) { /*$whereSql .= " AND ((post.`approved` = TRUE) OR (lc.`user_id` >= 0))"; $selectSql = " 0 AS unreg";*/ @@ -270,8 +276,8 @@ WHERE post.`unreg_uname` AS first_unreg_uname, unreg DESC, */ - $query = <<<SQL -SELECT + + $query = "SELECT lc.`user_id` AS flc_user_id, lc.`created` AS flc_created, lc.`last_modified` AS flc_last_modified, @@ -291,7 +297,14 @@ SELECT lcom.`root_id` AS th_root_id, lcom.`root_id` AS content_id, - lc.`content_type_guid` AS content_type_guid + lc.`content_type_guid` AS content_type_guid, + + ( + SELECT COUNT(*) + FROM `".BIT_DB_PREFIX."liberty_comments` s_lcom + INNER JOIN `".BIT_DB_PREFIX."liberty_content` s_lc ON (s_lcom.`content_id` = s_lc.`content_id`) + WHERE SUBSTRING(s_lcom.`thread_forward_sequence`,1,10) LIKE SUBSTRING(lcom.`thread_forward_sequence`,1,10) + ) AS post_count $selectSql FROM `${BIT_DB_PREFIX}liberty_comments` AS lcom @@ -307,9 +320,8 @@ ORDER BY th_moved ASC, th_deleted ASC, lc.created DESC -SQL; - $query_cant = <<<SQL -SELECT count(*) +"; + $query_cant = "SELECT count(*) FROM `${BIT_DB_PREFIX}liberty_comments` AS lcom INNER JOIN `${BIT_DB_PREFIX}liberty_content` AS lc ON( lc.`content_id` = lcom.`content_id` ) LEFT JOIN `${BIT_DB_PREFIX}forum_thread` th ON (th.`parent_id`=lcom.`comment_id`) @@ -317,8 +329,7 @@ LEFT JOIN `${BIT_DB_PREFIX}forum_post` AS post ON (post.`comment_id` = lcom.`com $joinSql WHERE lcom.`root_id`=lcom.`parent_id` - $whereSql -SQL; + $whereSql"; $result = $this->mDb->query( $query, $bindVars, $max_records, $offset ); $ret = array(); while( $res = $result->fetchRow() ) { @@ -327,6 +338,8 @@ SQL; } else { $res['url']=BITBOARDS_PKG_URL."index.php?t=".$res['th_thread_id']; } + $llc_data = BitBoardTopic::getLastPost($res); + $res = array_merge($res,$llc_data); $res['flip']=BitBoardTopic::getFlipFlop($res); $ret[] = $res; } @@ -334,52 +347,62 @@ SQL; // add all pagination info to pParamHash LibertyAttachable::postGetList( $pParamHash ); return $ret; -} + } -/** + function getLastPost($data) { + $BIT_DB_PREFIX = BIT_DB_PREFIX; + $query="SELECT MAX(lc.`last_modified`) AS llc_last_modified, MAX(lc.`user_id`) AS llc_user_id + FROM `".BIT_DB_PREFIX."liberty_comments` lcom + INNER JOIN `".BIT_DB_PREFIX."liberty_content` lc ON (lcom.`content_id` = lc.`content_id`) + WHERE SUBSTRING(lcom.`thread_forward_sequence`,1,10) LIKE '".sprintf("%09d.",$data['th_thread_id'])."%'"; + $result = $this->mDb->getRow( $query); + return $result; + } + + /** * Generates the URL to the bitboard page * @param pExistsHash the hash that was returned by LibertyAttachable::pageExists * @return the link to display the page. */ -function getDisplayUrl() { - $ret = NULL; - if( @$this->verifyId( $this->mRootId ) ) { - $res['url']=BITBOARDS_PKG_URL."index.php?c=".$this->mContentId; + function getDisplayUrl() { + $ret = NULL; + if( @$this->verifyId( $this->mRootId ) ) { + $res['url']=BITBOARDS_PKG_URL."index.php?c=".$this->mContentId; + } + return $ret; } - return $ret; -} -function isLocked($thread_id=false) { - global $gBitSystem; - if (!$thread_id) { - $thread_id = $this->mRootId; + function isLocked($thread_id=false) { + global $gBitSystem; + if (!$thread_id) { + $thread_id = $this->mRootId; + } + return $gBitSystem->mDb->getOne("SELECT `locked` FROM `".BIT_DB_PREFIX."forum_thread` WHERE `parent_id` = $thread_id"); } - return $gBitSystem->mDb->getOne("SELECT `locked` FROM `".BIT_DB_PREFIX."forum_thread` WHERE `parent_id` = $thread_id"); -} -function getFlipFlop($arr=false) { - if(! $arr) { - $arr = $this->mInfo; - } - global $gBitSmarty; - $flip['locked']['state']=$arr['th_locked']; - $flip['locked']['req']=2; - $flip['locked']['id']=$arr['th_thread_id']; - $flip['locked']['idname']='t'; - $flip['locked']['up']='locked'; - $flip['locked']['upname']='Thread Locked'; - $flip['locked']['down']='unlocked'; - $flip['locked']['downname']='Thread Unlocked'; + function getFlipFlop($arr=false) { + if(! $arr) { + $arr = $this->mInfo; + } + global $gBitSmarty; + $flip['locked']['state']=$arr['th_locked']; + $flip['locked']['req']=2; + $flip['locked']['id']=$arr['th_thread_id']; + $flip['locked']['idname']='t'; + $flip['locked']['up']='locked'; + $flip['locked']['upname']='Thread Locked'; + $flip['locked']['down']='unlocked'; + $flip['locked']['downname']='Thread Unlocked'; - $flip['sticky']['state']=$arr['th_sticky']; - $flip['sticky']['req']=3; - $flip['sticky']['id']=$arr['th_thread_id']; - $flip['sticky']['idname']='t'; - $flip['sticky']['up']='idea'; - $flip['sticky']['upname']='Sticky Thread'; - $flip['sticky']['down']='agt_uninstall-product'; - $flip['sticky']['downname']='Non Sticky Thread'; - return $flip; -} + $flip['sticky']['state']=$arr['th_sticky']; + $flip['sticky']['req']=3; + $flip['sticky']['id']=$arr['th_thread_id']; + $flip['sticky']['idname']='t'; + $flip['sticky']['up']='idea'; + $flip['sticky']['upname']='Sticky Thread'; + $flip['sticky']['down']='agt_uninstall-product'; + $flip['sticky']['downname']='Non Sticky Thread'; + return $flip; + } } ?> diff --git a/admin/schema_inc.php b/admin/schema_inc.php index dc0dddb..fe40699 100644 --- a/admin/schema_inc.php +++ b/admin/schema_inc.php @@ -15,6 +15,16 @@ $tables = array( deleted I1 NOTNULL DEFAULT(0), sticky I1 NOTNULL DEFAULT(0) ", + 'forum_board' => " + board_id I4 PRIMARY, + content_id I4 NOTNULL + ", + 'forum_map' => " + board_content_id I4 NOTNULL, + topic_content_id I4 PRIMARY + CONSTRAINT ', CONSTRAINT `bitforums_topics_forum_ref` FOREIGN KEY (`board_content_id`) REFERENCES `".BIT_DB_PREFIX."liberty_content` (`content_id`) + , CONSTRAINT `bitforums_topics_related_ref` FOREIGN KEY (`topic_content_id`) REFERENCES `".BIT_DB_PREFIX."liberty_content` (`content_id`)' + " ); global $gBitInstaller; @@ -38,6 +48,7 @@ $gBitInstaller->registerSchemaIndexes( BITBOARDS_PKG_NAME, $indices ); // ### Sequences $sequences = array ( + 'forum_board_id_seq' => array( 'start' => 1 ), 'bitboards_id_seq' => array( 'start' => 1 ), 'bitboards_topic_id_seq' => array( 'start' => 1 ), ); @@ -1,9 +1,9 @@ <?php /** * AJAX Function Call Stuff - * + * * reqs: - * 1 - list all boards + * 1 - list all boards * 2 - switch lock state on a given thread * 3 - switch sticky state on a given thread */ @@ -13,6 +13,7 @@ require_once( '../bit_setup_inc.php' ); require_once( BITBOARDS_PKG_PATH.'BitBoardTopic.php' ); require_once( BITBOARDS_PKG_PATH.'BitBoardPost.php' ); require_once( BITBOARDS_PKG_PATH.'BitBoard.php' ); +require_once( BITBOARDS_PKG_PATH.'BitBoardForum.php' ); // Is package installed and enabled $gBitSystem->verifyPackage( 'bitboards' ); @@ -86,7 +87,7 @@ set_error_handler("ajax_nice_error"); switch ($_GET['req']) { case 1: - $board = new BitBoard(); + $board = new BitBoardForum(); $boardList=$board->getForumBoardSelectList(); $gBitSmarty->assign_by_ref('boardList',$boardList); $gBitSmarty->display('bitpackage:bitboards/ajax.tpl'); diff --git a/assign.php b/assign.php new file mode 100644 index 0000000..fe597a4 --- /dev/null +++ b/assign.php @@ -0,0 +1,50 @@ +<?php +// $Header: /cvsroot/bitweaver/_bit_boards/assign.php,v 1.1 2006/07/12 17:00:32 hash9 Exp $ +// Copyright (c) 2004 bitweaver BitBoard +// All Rights Reserved. See copyright.txt for details and a complete list of authors. +// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details. + +// Initialization +require_once( '../bit_setup_inc.php' ); + +// Is package installed and enabled +$gBitSystem->verifyPackage( 'bitboards' ); + +// Now check permissions to access this page +$gBitSystem->verifyPermission('p_bitboards_edit' ); + +require_once(BITBOARDS_PKG_PATH.'lookup_inc.php' ); + +if (!empty($_REQUEST['remove'])) { + foreach ($_REQUEST['remove'] as $board_id => $content_ids) { + $b = new BitBoard($board_id); + $b->load(); + foreach ($content_ids as $content_id => $remove) { + if ($remove) { + $b->removeContent($content_id); + } + } + } +} +if (!empty($_REQUEST['assign'])) { + foreach ($_REQUEST['assign'] as $board_id => $content_ids) { + $b = new BitBoard($board_id); + $b->load(); + foreach ($content_ids as $content_id) { + $b->addContent($content_id); + } + } +} +if (!empty($_REQUEST['integrity'])) { + $board_id = $_REQUEST['integrity']; + $b = new BitBoard($board_id); + $b->load(); + $b->fixContentMap(); +} + +$data = BitBoard::getAllMap(); +$gBitSmarty->assign_by_ref('data',$data); + +// Display the template +$gBitSystem->display( 'bitpackage:bitboards/board_assign.tpl', tra('Assign content to Board') ); +?>
\ No newline at end of file @@ -1,5 +1,5 @@ <?php -// $Header: /cvsroot/bitweaver/_bit_boards/Attic/board.php,v 1.3 2006/07/06 19:44:26 hash9 Exp $ +// $Header: /cvsroot/bitweaver/_bit_boards/Attic/board.php,v 1.4 2006/07/12 16:57:33 hash9 Exp $ // Copyright (c) 2004 bitweaver Messageboards // All Rights Reserved. See copyright.txt for details and a complete list of authors. // Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details. @@ -50,11 +50,11 @@ if( isset( $_REQUEST["submit_mult"] ) && isset( $_REQUEST["checked"] ) && $_REQU // create new bitboard object $boards = new BitBoard(); -$boardsList = $boards->getFullList( $_REQUEST ); +$boardsList = $boards->getList( $_REQUEST ); $gBitSmarty->assign_by_ref( 'boardsList', $boardsList ); -if (!empty($_REQUEST['content_type_guid'])) { +/*if (!empty($_REQUEST['content_type_guid'])) { $gBitSmarty->assign_by_ref( 'cType', $gLibertySystem->mContentTypes[$_REQUEST['content_type_guid']] ); -} +}*/ // getList() has now placed all the pagination information in $_REQUEST['listInfo'] $gBitSmarty->assign_by_ref( 'listInfo', $_REQUEST['listInfo'] ); diff --git a/edit.php b/edit.php new file mode 100644 index 0000000..4e5f759 --- /dev/null +++ b/edit.php @@ -0,0 +1,71 @@ +<?php +// $Header: /cvsroot/bitweaver/_bit_boards/edit.php,v 1.1 2006/07/12 17:00:32 hash9 Exp $ +// Copyright (c) 2004 bitweaver BitBoard +// All Rights Reserved. See copyright.txt for details and a complete list of authors. +// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details. + +// Initialization +require_once( '../bit_setup_inc.php' ); + +// Is package installed and enabled +$gBitSystem->verifyPackage( 'bitboards' ); + +// Now check permissions to access this page +$gBitSystem->verifyPermission('p_bitboards_edit' ); + +if( isset( $_REQUEST['bitforum']['board_id'] ) ) { + $_REQUEST['b'] = $_REQUEST['bitforum']['board_id']; +} + +require_once(BITBOARDS_PKG_PATH.'lookup_inc.php' ); + +if( isset( $_REQUEST['bitforum']["title"] ) ) { + $gContent->mInfo["title"] = $_REQUEST['bitforum']["title"]; +} + +if( isset( $_REQUEST['bitforum']["description"] ) ) { + $gContent->mInfo["description"] = $_REQUEST['bitforum']["description"]; +} + +if( isset( $_REQUEST["format_guid"] ) ) { + $gContent->mInfo['format_guid'] = $_REQUEST["format_guid"]; +} + +if( isset( $_REQUEST['bitforum']["edit"] ) ) { + $gContent->mInfo["data"] = $_REQUEST['bitforum']["edit"]; + $gContent->mInfo['parsed_data'] = $gContent->parseData(); +} + +// If we are in preview mode then preview it! +if( isset( $_REQUEST["preview"] ) ) { + $gBitSmarty->assign('preview', 'y'); + $gContent->invokeServices( 'content_preview_function' ); +} else { + $gContent->invokeServices( 'content_edit_function' ); +} + +// Pro +// Check if the page has changed +if( !empty( $_REQUEST["save_bitforum"] ) ) { + // Check if all Request values are delivered, and if not, set them + // to avoid error messages. This can happen if some features are + // disabled + if( $gContent->store( $_REQUEST['bitforum'] ) ) { + header( "Location: ".$gContent->getDisplayUrl() ); + die; + } else { + $gBitSmarty->assign_by_ref( 'errors', $gContent->mErrors ); + } +} + +// Configure quicktags list +if( $gBitSystem->isPackageActive( 'quicktags' ) ) { + include_once( QUICKTAGS_PKG_PATH.'quicktags_inc.php' ); +} + +// WYSIWYG and Quicktag variable +$gBitSmarty->assign( 'textarea_id', 'editbitforum' ); + +// Display the template +$gBitSystem->display( 'bitpackage:bitboards/board_edit.tpl', tra('Board') ); +?> diff --git a/icons/db_update.png b/icons/db_update.png Binary files differnew file mode 100755 index 0000000..013e94d --- /dev/null +++ b/icons/db_update.png @@ -1,5 +1,5 @@ <?php -// $Header: /cvsroot/bitweaver/_bit_boards/index.php,v 1.1 2006/06/28 15:45:26 spiderr Exp $ +// $Header: /cvsroot/bitweaver/_bit_boards/index.php,v 1.2 2006/07/12 16:57:33 hash9 Exp $ // Copyright (c) 2004 bitweaver Messageboards // All Rights Reserved. See copyright.txt for details and a complete list of authors. // Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details. @@ -11,7 +11,7 @@ require_once( BITBOARDS_PKG_PATH.'BitBoard.php' ); if (!empty($_REQUEST['t'])) { require( BITBOARDS_PKG_PATH.'post.php' ); -} elseif (!empty($_REQUEST['c'])) { +} elseif (!empty($_REQUEST['b'])) { require( BITBOARDS_PKG_PATH.'topic.php' ); } else { require( BITBOARDS_PKG_PATH.'board.php' ); diff --git a/lookup_inc.php b/lookup_inc.php index 881d91d..44eb513 100644 --- a/lookup_inc.php +++ b/lookup_inc.php @@ -1,20 +1,23 @@ <?php - require_once( BITBOARDS_PKG_PATH.'BitBoardTopic.php'); require_once( BITBOARDS_PKG_PATH.'BitBoardPost.php' ); - -// if p supplied, use that +require_once( BITBOARDS_PKG_PATH.'BitBoard.php' ); +// if t supplied, use that if( @BitBase::verifyId( $_REQUEST['t'] ) ) { $gContent = new BitBoardTopic( $_REQUEST['t'] ); - - // if t supplied, use that +// if p supplied, use that } elseif( @BitBase::verifyId( $_REQUEST['p'] ) ) { $gContent = new BitBoardPost( $_REQUEST['p'] ); +} elseif( @BitBase::verifyId( $_REQUEST['b'] ) ) { + + $gContent = new BitBoard( $_REQUEST['b'] ); } elseif (isset($_REQUEST['p'])) { $gContent = new BitBoardPost(); // otherwise create new object -} else { +} elseif (isset($_REQUEST['t'])) { $gContent = new BitBoardTopic(); +} else { + $gContent = new BitBoard(); } $gContent->load(); @@ -1,6 +1,7 @@ <?php require_once( '../bit_setup_inc.php' ); require_once( BITBOARDS_PKG_PATH.'BitBoardPost.php' ); +require_once( BITBOARDS_PKG_PATH.'BitBoardForum.php' ); require_once( BITBOARDS_PKG_PATH.'BitBoard.php' ); if (!empty($_REQUEST['action'])) { @@ -37,11 +38,7 @@ if (empty($thread->mInfo['th_root_id'])) { $gBitSystem->fatalError(tra( "Invalid thread selection." ) ); } -$board = new LibertyContent(); -$board->mContentId=$thread->mInfo['th_root_id']; -$board->mInfo['content_id']=$thread->mInfo['th_root_id']; -$board->mInfo=BitBoard::loadContent($thread->mInfo['th_root_id']); -$board->mInfo['display_url']=BitBoard::getForumDisplayUrl($board); +$board = new BitBoard(null,$thread->mInfo['board_content_id']); $board->load(); $gBitSmarty->assign_by_ref( 'board', $board ); diff --git a/templates/ajax.tpl b/templates/ajax.tpl index c1b88b8..6989e77 100644 --- a/templates/ajax.tpl +++ b/templates/ajax.tpl @@ -1,6 +1,6 @@ {strip} <option value="">Select a Board</option> {foreach from=$boardList item=board} - <option value="{$board.content_id}"> {$board.title} ({$board.post_count}) ({$board.description})</option> + <option value="{$board.content_id}"> {$board.title} [{$board.post_count}]</option> {/foreach} {/strip}
\ No newline at end of file diff --git a/templates/board.tpl b/templates/board.tpl index b4fcdc8..ab081ad 100644 --- a/templates/board.tpl +++ b/templates/board.tpl @@ -1,16 +1,15 @@ -{* $Header: /cvsroot/bitweaver/_bit_boards/templates/Attic/board.tpl,v 1.2 2006/07/06 19:44:26 hash9 Exp $ *} +{* $Header: /cvsroot/bitweaver/_bit_boards/templates/Attic/board.tpl,v 1.3 2006/07/12 16:57:33 hash9 Exp $ *} {strip} <div class="floaticon">{bithelp}</div> <div class="listing bitboard"> <div class="header"> - <h1>{$cType.content_description|escape|default:"Forum Group"}s</h1> + <h1>Forums</h1> </div> <div class="body"> - {minifind sort_mode=$sort_mode category_id=$smarty.request.category_id} + {minifind sort_mode=$sort_mode b=$smarty.request.b} {form id="checkform"} - <input type="hidden" name="category_id" value="{$smarty.request.category_id}" /> <input type="hidden" name="offset" value="{$control.offset|escape}" /> <input type="hidden" name="sort_mode" value="{$control.sort_mode|escape}" /> @@ -24,10 +23,10 @@ {assign var=board_title value="(Content $board_title)"} {/if} <tr class="mb-row-{cycle values="even,odd"}{if $board.unreg > 0}-unapproved{/if}"> - <td width="1px"> - + {*<td width="1px"> + <a href="{$smarty.const.BIT_ROOT_URL}index.php?content_id={$board.content_id|escape:"url"}" title="Show: $board_title">{biticon ipackage=liberty iname="view" iexplain="Show: $board_title"}</a> - </td> + </td>*} <td><a href="{$board.url}" title="{$board_title}">{$board_title}</a></td> {* {if $gBitUser->hasPermission('p_bitboards_edit') || $gBitUser->hasPermission('p_bitboards_post_edit')} @@ -40,7 +39,7 @@ {/if} *} <td style="text-align:right; color: blue;">{if $board.post_count > 0}{$board.post_count} Threads</a>{/if}</td> - + </tr> {foreachelse} <tr class="norecords"><td colspan="16"> @@ -69,7 +68,7 @@ *} {/form} - {pagination} + {pagination b=$smarty.request.b} </div><!-- end .body --> </div><!-- end .admin --> {/strip} diff --git a/templates/board_assign.tpl b/templates/board_assign.tpl new file mode 100644 index 0000000..4574d20 --- /dev/null +++ b/templates/board_assign.tpl @@ -0,0 +1,59 @@ +<div class="floaticon">{bithelp}</div> + +<div class="admin bitforum"> + <div class="header"> + <h1> + {tr}Assign Content to Boards{/tr} + </h1> + </div> + <div class="body"> + {jstabs tab=$smarty.request.tab} + {foreach item=board from=$data.map name='board_loop'} + {capture assign=title} + <span style="font-size: 1.3em;"> + {if ! $board.integrity} + <img src="{$smarty.const.LIBERTY_PKG_URL}/icons/warning.png" alt="Integrity Check Failed" title="Integrity Check Failed" class="icon" /> + {/if} + {$board.title} + </span> + {/capture} + {jstab title=$title} + {form legend="<a href=\"`$board.url`\">`$board.title`</a>"} + <input type="hidden" name="tab" value="{$smarty.foreach.board_loop.iteration-1}" /> + {if ! $board.integrity} + <div class="floaticon"> + <a href="{$smarty.const.BITBOARDS_PKG_URL}assign.php?tab={$smarty.foreach.board_loop.iteration-1}&integrity={$board.board_id}"> + {biticon ipackage=bitboards iname="db_update" iexplain="Fix Integrity"} + </a> + </div> + {formfeedback warning="Integrity Check Failed"} + {/if} + <table cellpadding="2" cellspacing="2"> + {foreach item=mapping from=$board.map} + <tr> + <td width="1"><a title="{tr}Remove from board{/tr}" href="{$smarty.const.BITBOARDS_PKG_URL}assign.php?tab={$smarty.foreach.board_loop.iteration-1}&remove[{$board.board_id}][{$mapping.t_content_id}]=1">{biticon ipackage=liberty iname="delete" iexplain="Remove from board"}</a></td> + <td width="1"><input type="checkbox" name="remove[{$board.board_id}][{$mapping.t_content_id}]" value="1" /></td> + <td width="1" style="font-style: italic; color: blue;">{$mapping.thread_count}</td> + <td>{$mapping.t_title}</td> + </tr> + {/foreach} + <tr> + <td></td> + <td colspan="4"> + <select name="assign[{$board.board_id}][]"> + {foreach item=umapping from=$data.umap} + <option value="{$umapping.content_id}">{$umapping.title} ({$umapping.content_description}) [{$umapping.thread_count}]</option> + {/foreach} + </select> + </td> + </tr> + <tr> + <td colspan="4" style="text-align: center;"><input type="submit" value="Add" name="action" /> <input type="submit" value="Remove" name="action" /></td> + </tr> + </table> + {/form} + {/jstab} + {/foreach} + {/jstabs} + </div><!-- end .body --> +</div><!-- end .bitforum -->
\ No newline at end of file diff --git a/templates/board_edit.tpl b/templates/board_edit.tpl new file mode 100644 index 0000000..37ecdcd --- /dev/null +++ b/templates/board_edit.tpl @@ -0,0 +1,86 @@ +{* $Header: /cvsroot/bitweaver/_bit_boards/templates/board_edit.tpl,v 1.1 2006/07/12 17:00:33 hash9 Exp $ *} +{strip} +<div class="floaticon">{bithelp}</div> + +<div class="admin bitforum"> + {if $preview} + <h2>Preview {$gContent->mInfo.title|escape}</h2> + <div class="preview"> + {include file="bitpackage:liberty/services_inc.tpl" serviceLocation='nav' serviceHash=$gContent->mInfo} + <div class="display bitforum"> + <div class="header"> + <h1>{$gContent->mInfo.title|escape|default:"Board"}</h1> + </div><!-- end .header --> + <div class="body"> + <div class="content"> + {$gContent->mInfo.parsed_data} + </div><!-- end .content --> + </div><!-- end .body --> + </div><!-- end .bitforum --> + {include file="bitpackage:liberty/services_inc.tpl" serviceLocation='view' serviceHash=$gContent->mInfo} + </div> + {/if} + + <div class="header"> + <h1> + {if $gContent->isValid()} + {tr}{tr}Edit{/tr} {$gContent->getTitle()|escape}{/tr} + {else} + {tr}Create New Board{/tr} + {/if} + </h1> + </div> + + <div class="body"> + {jstabs} + {if $gContent->isValid()} + {assign var='leg' value=$gContent->getTitle()|escape} + {assign var='leg' value="Edit Board: $leg"} + {else} + {assign var='leg' value='Create Board'} + {/if} + {jstab title=$leg} + {form enctype="multipart/form-data" id="editbitforumform"} + {legend legend=$leg} + <input type="hidden" name="bitforum[board_id]" value="{$gContent->mInfo.board_id}" /> + + <div class="row"> + {formlabel label="Title" for="title"} + {forminput} + <input type="text" size="60" maxlength="200" name="bitforum[title]" id="title" value="{$gContent->mInfo.title|escape}" /> + {/forminput} + </div> + + {include file="bitpackage:liberty/edit_format.tpl"} + + {if $gBitSystem->isFeatureActive('package_smileys')} + {include file="bitpackage:smileys/smileys_full.tpl"} + {/if} + + {if $gBitSystem->isFeatureActive('package_quicktags')} + {include file="bitpackage:quicktags/quicktags_full.tpl"} + {/if} + + <div class="row"> + {forminput} + <textarea {spellchecker} id="{$textarea_id}" name="bitforum[edit]" rows="{$smarty.cookies.rows|default:10}" cols="50">{$gContent->mInfo.data|escape:html}</textarea> + {/forminput} + </div> + + {* any simple service edit options *} + {include file="bitpackage:liberty/edit_services_inc.tpl serviceFile=content_edit_mini_tpl} + + <div class="row submit"> + <input type="submit" name="preview" value="{tr}Preview{/tr}" /> + <input type="submit" name="save_bitforum" value="{tr}Save{/tr}" /> + </div> + {/legend} + {/form} + {/jstab} + {* any service edit template tabs *} + {include file="bitpackage:liberty/edit_services_inc.tpl serviceFile=content_edit_tab_tpl} + {/jstabs} + </div><!-- end .body --> +</div><!-- end .bitforum --> + +{/strip} diff --git a/templates/comment_post.tpl b/templates/comment_post.tpl index d3d14e7..2798c12 100644 --- a/templates/comment_post.tpl +++ b/templates/comment_post.tpl @@ -1,3 +1,4 @@ +{if $smarty.request.post_comment_request} {strip} <br /> <div class="display comment"> @@ -35,7 +36,7 @@ {*assign var=gContent value=$commentpost*} {*include file="bitpackage:liberty/edit_format.tpl"*} - + {assign var=textarea_id value="commentpost"} {if $gBitSystem->isPackageActive( 'smileys' )} {include file="bitpackage:smileys/smileys_full.tpl"} @@ -44,7 +45,7 @@ {if $gBitSystem->isPackageActive( 'quicktags' )} {include file="bitpackage:quicktags/quicktags_full.tpl" formId="commentpost"} {/if} - + <div class="row"> {formlabel label="Comment" for="commentpost"} {forminput} @@ -62,8 +63,9 @@ {/if} {/form} - + {libertypagination hash=$commentsPgnHash} </div><!-- end .body --> </div><!-- end .comment --> {/strip} +{/if}
\ No newline at end of file diff --git a/templates/menu_bitboards.tpl b/templates/menu_bitboards.tpl index 39401d7..16e2983 100644 --- a/templates/menu_bitboards.tpl +++ b/templates/menu_bitboards.tpl @@ -1,7 +1,11 @@ {strip} <ul> {if $gBitUser->hasPermission( 'p_bitboards_read')} - <li><a class="item" href="{$smarty.const.BITBOARDS_PKG_URL}index.php">{tr}BitBoard Home{/tr}</a></li> + <li><a class="item" href="{$smarty.const.BITBOARDS_PKG_URL}index.php">{tr}Boards Home{/tr}</a></li> + {/if} + {if $gBitUser->hasPermission( 'p_bitboards_edit')} + <li><a class="item" href="{$smarty.const.BITBOARDS_PKG_URL}edit.php">{tr}Create new Board{/tr}</a></li> + <li><a class="item" href="{$smarty.const.BITBOARDS_PKG_URL}assign.php">{tr}Assign content to Board{/tr}</a></li> {/if} </ul> {/strip} diff --git a/templates/post.tpl b/templates/post.tpl index 11cba4e..e426438 100644 --- a/templates/post.tpl +++ b/templates/post.tpl @@ -1,44 +1,5 @@ -{* $Header: /cvsroot/bitweaver/_bit_boards/templates/Attic/post.tpl,v 1.3 2006/07/06 19:44:26 hash9 Exp $ *} +{* $Header: /cvsroot/bitweaver/_bit_boards/templates/Attic/post.tpl,v 1.4 2006/07/12 16:57:33 hash9 Exp $ *} {strip} - {if $comments and $gBitSystem->isFeatureActive('comments_display_option_bar')} - {form action="`$comments_return_url`#editcomments"} - <input type="hidden" name="post_comment_reply_id" value="{$post_comment_reply_id}" /> - <input type="hidden" name="post_comment_id" value="{$post_comment_id}" /> - <table class="optionbar"> - <caption>{tr}Comments Filter{/tr}</caption> - <tr> - <td> - <label for="comments-maxcomm">{tr}Messages{/tr} </label> - <select name="comments_maxComments" id="comments-maxcomm"> - {* 1 comment selection is used for directly displaying a single comment via a URL *} - <option value="1" {if $maxComments eq 1}selected="selected"{/if}>1</option> - <option value="5" {if $maxComments eq 5}selected="selected"{/if}>5</option> - <option value="10" {if $maxComments eq 10}selected="selected"{/if}>10</option> - <option value="20" {if $maxComments eq 20}selected="selected"{/if}>20</option> - <option value="50" {if $maxComments eq 50}selected="selected"{/if}>50</option> - <option value="100" {if $maxComments eq 100}selected="selected"{/if}>100</option> - <option value="999999" {if $maxComments eq 999999}selected="selected"{/if}>All</option> - </select> - </td> - <td> - <label for="comments-style">{tr}Style{/tr} </label> - <select name="comments_style" id="comments-style"> - <option value="flat" {if $comments_style eq "flat"}selected="selected"{/if}>Flat</option> - <option value="threaded" {if $comments_style eq "threaded"}selected="selected"{/if}>Threaded</option> - </select> - </td> - <td> - <label for="comments-sort">{tr}Sort{/tr} </label> - <select name="comments_sort_mode" id="comments-sort"> - <option value="commentDate_desc" {if $comments_sort_mode eq "commentDate_desc"}selected="selected"{/if}>Newest first</option> - <option value="commentDate_asc" {if $comments_sort_mode eq "commentDate_asc"}selected="selected"{/if}>Oldest first</option> - </select> - </td> - <td style="text-align:right"><input type="submit" name="comments_setOptions" value="set" /></td> - </tr> - </table> - {/form} - {/if} <div class="floaticon"> {assign var=flip value=$thread->getFlipFlop()} {assign var=flip_name value="locked"} @@ -51,50 +12,28 @@ <div class="listing bitboard"> <div class="header"> <h1>{$thread->mInfo.flc_title|escape}</h1> - <span style="text-align: right; width: 100%;">Back to <a href="{$board->mInfo.display_url}">{$board->mInfo.title|escape}</a></span> + Back to <a href="{$board->mInfo.display_url}">{$board->mInfo.title|escape}</a> </div> <div class="body"> + {include file="bitpackage:liberty/comments_display_option_bar.tpl"} {minifind sort_mode=$sort_mode thread_id=$smarty.request.thread_id} - {form id="checkform"} - <input type="hidden" name="thread_id" value="{$smarty.request.thread_id}" /> - <input type="hidden" name="offset" value="{$control.offset|escape}" /> - <input type="hidden" name="sort_mode" value="{$control.sort_mode|escape}" /> + <table class="mb-table"> + {foreach item=comment from=$comments} + <tr class="mb-row-{cycle values="even,odd"}{if $post->mInfo.deleted==1}-deleted{else}{if $post->mInfo.user_id<0 and $post->mInfo.approved==0}-unapproved{/if}{/if}"> + {displaycomment comment=$comment template=$comment_template} + </tr> + {foreachelse} + <tr class="norecords"><td colspan="16"> + {tr}No posts found{/tr} + </td></tr> + {/foreach} + </table> + <p style="text-align: right;"><a title="{tr}Post on this thread{/tr}" href="{$comments_return_url}&post_comment_request=1#editcomments">{tr}Post on this thread{/tr} {biticon ipackage=bitboard iname="mail_new" iexplain="Post on this thread"}</a></p> - <table class="mb-table"> - {foreach item=comment from=$comments} - <tr class="mb-row-{cycle values="even,odd"}{if $post->mInfo.deleted==1}-deleted{else}{if $post->mInfo.user_id<0 and $post->mInfo.approved==0}-unapproved{/if}{/if}"> - {displaycomment comment=$comment template=$comment_template} - </tr> - {foreachelse} - <tr class="norecords"><td colspan="16"> - {tr}No records found{/tr} - </td></tr> - {/foreach} - </table> - <p style="text-align: right;"><a title="{tr}Post on this thread{/tr}" href="{$comments_return_url}&post_comment_request=1#editcomments">{tr}Post on this thread{/tr} {biticon ipackage=bitboard iname="mail_new" iexplain="Post on this thread"}</a></p> - {if $gBitUser->hasPermission( 'p_bitboards_remove' )} - <div style="text-align:right;"> - <script type="text/javascript">/* <![CDATA[ check / uncheck all */ - document.write("<label for=\"switcher\">{tr}Select All{/tr}</label> "); - document.write("<input name=\"switcher\" id=\"switcher\" type=\"checkbox\" onclick=\"switchCheckboxes(this.form.id,'checked[]','switcher')\" /><br />"); - /* ]]> */</script> - - <select name="submit_mult" onchange="this.form.submit();"> - <option value="" selected="selected">{tr}with checked{/tr}:</option> - {if $gBitUser->hasPermission( 'p_bitboards_remove' )} - <option value="remove_bitboards">{tr}remove{/tr}</option> - {/if} - </select> - - <noscript><div><input type="submit" value="{tr}Submit{/tr}" /></div></noscript> - </div> - {/if} - {/form} - - {pagination} + {libertypagination hash=$comments} </div><!-- end .body --> </div><!-- end .admin --> - {include file="bitpackage:bitboards/comment_post.tpl"} + {include file="bitpackage:liberty/comments_post_inc.tpl" post_title="Post" hide=1} {/strip} diff --git a/templates/topic.tpl b/templates/topic.tpl index 9db5c46..1496608 100644 --- a/templates/topic.tpl +++ b/templates/topic.tpl @@ -1,20 +1,33 @@ -{* $Header: /cvsroot/bitweaver/_bit_boards/templates/Attic/topic.tpl,v 1.3 2006/07/06 19:44:26 hash9 Exp $ *} +{* $Header: /cvsroot/bitweaver/_bit_boards/templates/Attic/topic.tpl,v 1.4 2006/07/12 16:57:33 hash9 Exp $ *} {strip} <div class="listing bitboard"> + <div class="floaticon"> + {if $print_page ne 'y'} + {if $gBitUser->hasPermission( 'p_bitforum_edit' )} + <a title="{tr}Remove this bitforum{/tr}" href="{$smarty.const.BITBOARDS_PKG_URL}edit.php?b={$board->mInfo.board_id}">{biticon ipackage=liberty iname="edit" iexplain="Edit BitForum"}</a> + {/if} + {if $gBitUser->hasPermission( 'p_bitforum_remove' )} + <a title="{tr}Remove this bitforum{/tr}" href="{$smarty.const.BITBOARDS_PKG_URL}remove.php?b={$board->mInfo.board_id}">{biticon ipackage=liberty iname="delete" iexplain="Remove BitForum"}</a> + {/if} + {/if}<!-- end print_page --> + </div><!-- end .floaticon --> <div class="header"> - <h1>{$board->mInfo.title|escape|default:"Forum Topic"}</h1> + <h1>{$board->mInfo.title|escape|default:"Forum Topic"} <a id='content_1' href="{$comments_return_url}&show={if empty($smarty.request.show)}1{else}0{/if}" onclick="{literal}if (this.innerHTML=='-') { document.getElementById('content_div').style.display='none'; this.innerHTML='+'; } else { document.getElementById('content_div').style.display='block'; this.innerHTML='-'; } return false;{/literal}">{if empty($smarty.request.show)}+{else}-{/if}</a></h1> <div class="date"> - {tr}Posted by{/tr}: {displayname user=$board->mInfo.creator_user user_id=$board->mInfo.creator_user_id real_name=$board->mInfo.creator_real_name} on {$board->getField('created')|bit_short_datetime} + {tr}Created by{/tr}: {displayname user=$board->mInfo.creator_user user_id=$board->mInfo.creator_user_id real_name=$board->mInfo.creator_real_name} on {$board->getField('created')|bit_short_datetime} {if $board->getField('last_modified') != $board->getField('created')} - <br/>{tr}Edited by{/tr}: {displayname user=$board->mInfo.modifier_user user_id=$board->mInfo.modifier_user_id real_name=$board->mInfo.modifier_real_name}, {$board->getField('last_modified')|bit_short_datetime} + {tr}Edited by{/tr}: {displayname user=$board->mInfo.modifier_user user_id=$board->mInfo.modifier_user_id real_name=$board->mInfo.modifier_real_name}, {$board->getField('last_modified')|bit_short_datetime} {/if} </div> - - <span style="text-align: right; width: 100%;">Back to <a href="{$cat_url}">{$board->mInfo.content_type.content_description}s</a></span> + + Back to <a href="{$cat_url}">{$board->mInfo.content_type.content_description}s</a> </div> <div class="body"> + <div id="content_div" class="content" style="text-align: right; {if empty($smarty.request.show)}display: none;{/if}"> + {$board->mInfo.parsed_data} + </div><!-- end .content --> <p style="text-align: right; margin: 0px; padding: 0px;"><a title="{tr}Start a new thread{/tr}" href="{$comments_return_url}&post_comment_request=1#editcomments">{tr}Start a new thread{/tr} {biticon ipackage=bitboard iname="mail_new" iexplain="Start a new thread"}</a></p> {minifind sort_mode=$sort_mode board_id=$smarty.request.board_id} {form id="checkform"} @@ -23,17 +36,6 @@ <input type="hidden" name="sort_mode" value="{$control.sort_mode|escape}" /> <table class="mb-table"> - {*<tr> - <th>{smartlink ititle="Title" isort=flc_title iurl=$request.url offset=$control.offset}</th> - <th>{smartlink ititle="Started By" isort=flc_user_id offset=$control.offset}</th> - <th>{smartlink ititle="Started" isort=flc_created offset=$control.offset}</th> - <th>{smartlink ititle="Last Update By" isort=llc_user_id offset=$control.offset}</th> - <th>{smartlink ititle="Last Update" isort=llc_created offset=$control.offset}</th> - {if $gBitUser->hasPermission( 'p_bitboards_remove' )} - <th>{tr}Actions{/tr}</th> - {/if} - </tr>*} - {foreach item=thread from=$threadList} <tr class="mb-row-{cycle values="even,odd"} {if $thread.first_deleted==1 or $thread.th_deleted==1} @@ -64,7 +66,8 @@ {/if} </td> <td> - <a href="{$thread.url}" title="{$thread.flc_title}">{$thread.flc_title|escape}</a>, started by {if $thread.flc_user_id < 0}{$thread.first_unreg_uname|escape}{else}{displayname user_id=$thread.flc_user_id}{/if} {$thread.flc_created|reltime|escape}{if $thread.post_count > 1}, with {$thread.post_count|escape} posts, last update by {if $thread.flc_user_id < 0}{$thread.first_unreg_uname|escape}{else}{displayname user_id=$thread.flc_user_id}{/if} {$thread.llc_last_modified|reltime|escape}{/if}. + <a href="{$thread.url}" title="{$thread.flc_title}|default:"[Thread `$thread.th_thread_id`]"|escape">{$thread.flc_title|default:"[Thread `$thread.th_thread_id`]"|escape}</a>, started by {if $thread.flc_user_id < 0}{$thread.first_unreg_uname|escape}{else}{displayname user_id=$thread.flc_user_id}{/if} {$thread.flc_created|reltime|escape}{if $thread.post_count > 1}, with {$thread.post_count|escape} posts, + last update by {if $thread.llc_user_id < 0}{$thread.first_unreg_uname|escape}{else}{displayname user_id=$thread.llc_user_id}{/if} {$thread.llc_last_modified|reltime|escape}{/if} </td> {if $gBitUser->hasPermission('p_bitboards_edit') || $gBitUser->hasPermission('p_bitboards_post_edit')} <td style="text-align:right;">{if $thread.unreg > 0}<a style="color: blue;" href="{$smarty.const.BITBOARDS_PKG_URL}index.php?board_id={$thread.th_board_id|escape:"url"}&thread_id={$thread.th_thread_id|escape:"url"}" title="{$thread.flc_title}">{$thread.unreg} Unregistered Posts</a>{/if}</td> @@ -74,7 +77,7 @@ {if $gBitUser->hasPermission( 'p_bitboards_edit' )} {*smartlink ititle="Edit" ifile="edit.php" ibiticon="liberty/edit" board_id=$thread.board_id*} <a onclick=" - document.getElementById('move_block_{$thread.th_thread_id|escape:"url"}').style['display']='inline'; + document.getElementById('move_block_{$thread.th_thread_id|escape:"url"}').style['display']='inline'; var url = '{$smarty.const.BITBOARDS_PKG_URL}ajax.php?req=1&seq=' + new Date().getTime(); var element = 'move_{$thread.th_thread_id|escape:"url"}'; var params = null; @@ -86,7 +89,7 @@ {/literal} this.oldonclick=this.onclick; this.onclick=new Function(' - document.getElementById(\'move_block_{$thread.th_thread_id|escape:"url"}\').style[\'display\']=\'none\'; + document.getElementById(\'move_block_{$thread.th_thread_id|escape:"url"}\').style[\'display\']=\'none\'; document.getElementById(\'move_{$thread.th_thread_id|escape:"url"}\').innerHTML=\'\'; this.onclick=this.oldonclick; return false; @@ -133,8 +136,8 @@ </div> {/if} {/form} - {pagination} + {pagination b=$smarty.request.b} </div><!-- end .body --> </div><!-- end .admin --> -{include file="bitpackage:bitboards/comment_post.tpl"} +{include file="bitpackage:liberty/comments_post_inc.tpl" post_title="Post" hide=1} {/strip} diff --git a/templates/topic_move.tpl b/templates/topic_move.tpl index 26b80ce..680a584 100644 --- a/templates/topic_move.tpl +++ b/templates/topic_move.tpl @@ -1,4 +1,4 @@ -{* $Header: /cvsroot/bitweaver/_bit_boards/templates/topic_move.tpl,v 1.1 2006/06/28 15:45:26 spiderr Exp $ *} +{* $Header: /cvsroot/bitweaver/_bit_boards/templates/topic_move.tpl,v 1.2 2006/07/12 16:57:33 hash9 Exp $ *} {strip} <div class="floaticon">{bithelp}</div> @@ -17,7 +17,7 @@ {forminput} <select name="target" id="target"> {section name=ix loop=$boards} - <option value="{$boards[ix].content_id|escape}">{$boards[ix].title|escape|truncate:20:"...":true} ({$boards[ix].post_count|escape}) ({$boards[ix].description|escape|truncate:20:"...":true})</option> + <option value="{$boards[ix].content_id|escape}">{$boards[ix].title|escape|truncate:20:"...":true} [{$boards[ix].post_count|escape}]</option> {sectionelse} <option>{tr}No records found{/tr}</option> {/section} @@ -1,5 +1,5 @@ <?php -// $Header: /cvsroot/bitweaver/_bit_boards/Attic/topic.php,v 1.3 2006/07/06 19:44:26 hash9 Exp $ +// $Header: /cvsroot/bitweaver/_bit_boards/Attic/topic.php,v 1.4 2006/07/12 16:57:33 hash9 Exp $ // Copyright (c) 2004 bitweaver Messageboards // All Rights Reserved. See copyright.txt for details and a complete list of authors. // Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details. @@ -7,6 +7,7 @@ require_once( '../bit_setup_inc.php' ); require_once( BITBOARDS_PKG_PATH.'BitBoardTopic.php' ); require_once( BITBOARDS_PKG_PATH.'BitBoardPost.php' ); +require_once( BITBOARDS_PKG_PATH.'BitBoardForum.php' ); require_once( BITBOARDS_PKG_PATH.'BitBoard.php' ); $gBitSmarty->assign( 'loadAjax', TRUE ); @@ -35,8 +36,8 @@ if (isset($_REQUEST["locked"]) || isset($_REQUEST["sticky"])) { trigger_error(var_export($gContent->mErrors,true )); } die(); -} elseif (empty($_REQUEST['c'])) { - $gBitSystem->fatalError("Content id not given"); +} elseif (empty($_REQUEST['b'])) { + $gBitSystem->fatalError("board id not given"); } @@ -74,15 +75,13 @@ if( isset( $_REQUEST["submit_mult"] ) && isset( $_REQUEST["checked"] ) && $_REQU } } } -$board = new LibertyContent(); -$board->mInfo=BitBoard::loadContent($_REQUEST['c']); -$board->mContentId=$_REQUEST['c']; + +$board = new BitBoard($_REQUEST['b']); $board->load(); -$board->mInfo['content_type']=$gLibertySystem->mContentTypes[$board->mInfo['content_type_guid']]; $gContent = $board; $commentsParentId=$board->mContentId; -$comments_return_url= BITBOARDS_PKG_URL."index.php?c=".urlencode($board->mContentId); +$comments_return_url= BITBOARDS_PKG_URL."index.php?b=".urlencode($board->mBitBoardId); require_once (LIBERTY_PKG_PATH.'comments_inc.php'); diff --git a/topic_move.php b/topic_move.php index 4d34ba8..c67a358 100644 --- a/topic_move.php +++ b/topic_move.php @@ -2,6 +2,7 @@ require_once( '../bit_setup_inc.php' ); require_once( BITBOARDS_PKG_PATH.'BitBoard.php' ); +require_once( BITBOARDS_PKG_PATH.'BitBoardForum.php' ); // Is package installed and enabled $gBitSystem->verifyPackage( 'bitboards' ); @@ -47,9 +48,9 @@ if( isset( $_REQUEST["target"] ) ) { $gBitSystem->confirmDialog( $formHash,$msgHash ); } -$board = new BitBoard(); +$board = new BitBoardForum(); $gBitSmarty->assign_by_ref('boards', $board->getForumBoardSelectList()); -require_once( BITBOARDS_PKG_PATH .'lookup_bittopic_inc.php' ); +require_once( BITBOARDS_PKG_PATH .'lookup_inc.php' ); $gBitSystem->display( 'bitpackage:bitboards/topic_move.tpl', tra('Category') ); ?>
\ No newline at end of file |
