diff options
| author | Christian Fowler <spider@viovio.com> | 2006-02-07 01:19:19 +0000 |
|---|---|---|
| committer | Christian Fowler <spider@viovio.com> | 2006-02-07 01:19:19 +0000 |
| commit | 2e181f9e06e17e527031043216124da80afa3630 (patch) | |
| tree | 2f31b2cd56f628cc44e76784e07ce26c998b151c | |
| parent | 3c7738bde4f7fa9d7074c42ef6e4fde1b12724b3 (diff) | |
| download | wiki-2e181f9e06e17e527031043216124da80afa3630.tar.gz wiki-2e181f9e06e17e527031043216124da80afa3630.tar.bz2 wiki-2e181f9e06e17e527031043216124da80afa3630.zip | |
finish move of content versioning to liberty_content - had to move version column to Liberty as well.
| -rw-r--r-- | BitPage.php | 211 | ||||
| -rw-r--r-- | admin/schema_inc.php | 1 | ||||
| -rw-r--r-- | lookup_page_inc.php | 8 | ||||
| -rw-r--r-- | page_history.php | 10 |
4 files changed, 18 insertions, 212 deletions
diff --git a/BitPage.php b/BitPage.php index bf80cfc..8c427a2 100644 --- a/BitPage.php +++ b/BitPage.php @@ -1,11 +1,11 @@ <?php /** - * @version $Header: /cvsroot/bitweaver/_bit_wiki/BitPage.php,v 1.30 2006/02/06 22:56:52 squareing Exp $ + * @version $Header: /cvsroot/bitweaver/_bit_wiki/BitPage.php,v 1.31 2006/02/07 01:19:19 spiderr Exp $ * @package wiki * * @author spider <spider@steelsun.com> * - * @version $Revision: 1.30 $ $Date: 2006/02/06 22:56:52 $ $Author: squareing $ + * @version $Revision: 1.31 $ $Date: 2006/02/07 01:19:19 $ $Author: spiderr $ * * Copyright (c) 2004 bitweaver.org * Copyright (c) 2003 tikwiki.org @@ -13,7 +13,7 @@ * 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 * - * $Id: BitPage.php,v 1.30 2006/02/06 22:56:52 squareing Exp $ + * $Id: BitPage.php,v 1.31 2006/02/07 01:19:19 spiderr Exp $ */ /** @@ -120,15 +120,6 @@ class BitPage extends LibertyAttachable { $table = BIT_DB_PREFIX."wiki_pages"; if( $this->verifyId( $this->mPageId ) ) { $this->invalidateCache(); - if( !empty( $pParamHash['force_history'] ) || ( empty( $pParamHash['minor'] ) && !empty( $this->mInfo['version'] ) && $pParamHash['field_changed'] )) { - if( $this->mPageName != 'SandBox' && empty( $pParamHash['has_no_history'] ) ) { - $query = "insert into `".BIT_DB_PREFIX."liberty_content_history`( `page_id`, `version`, `last_modified`, `user_id`, `ip`, `comment`, `data`, `description`, `format_guid`) values(?,?,?,?,?,?,?,?,?)"; - $result = $this->mDb->query( $query, array( $this->mPageId, (int)$this->mInfo['version'], (int)$this->mInfo['last_modified'] , $this->mInfo['modifier_user_id'], $this->mInfo['ip'], $this->mInfo['comment'], $this->mInfo['data'], $this->mInfo['description'], $this->mInfo['format_guid'] ) ); - } - $action = "Created"; - $mailEvents = 'wiki_page_changes'; - } - $locId = array ( "name" => "page_id", "value" => $this->mPageId ); $result = $this->mDb->associateUpdate( $table, $pParamHash['page_store'], $locId ); @@ -284,12 +275,6 @@ class BitPage extends LibertyAttachable { } } - if( !$this->verifyId( $this->mPageId ) ) { - $pParamHash['page_store']['version'] = 1; - } else { - $pParamHash['page_store']['version'] = $this->mInfo['version'] + 1; - } - return( count( $this->mErrors ) == 0 ); } @@ -361,31 +346,6 @@ class BitPage extends LibertyAttachable { return( $this->setLock( NULL, $pModUserId ) ); } - /** - * Removes last version of the page (from pages) if theres some - * version in the liberty_content_history then the last version becomes the actual version - */ - function removeLastVersion( $comment = '' ) { - if( $this->verifyId( $this->mPageId ) ) { - global $gBitSystem; - $this->invalidateCache(); - $query = "select * from `".BIT_DB_PREFIX."liberty_content_history` where `page_id`=? order by ".$this->mDb->convert_sortmode("last_modified_desc"); - $result = $this->mDb->query($query, array( $this->mPageId ) ); - if ($result->numRows()) { - // We have a version - $res = $result->fetchRow(); - $this->rollbackVersion( $res["version"] ); - $this->expungeVersion( $res["version"] ); - } else { - $this->remove_all_versions($page); - } - $action = "Removed last version"; - $t = $gBitSystem->getUTCTime(); - $query = "insert into `".BIT_DB_PREFIX."wiki_action_log`( `action`, `page_id`, `last_modified`, `user_id`, `ip`, `comment`) values( ?, ?, ?, ?, ?, ?)"; - $result = $this->mDb->query($query, array( $action, $this->mPageId, $t, ROOT_USER_ID, $_SERVER["REMOTE_ADDR"], $comment ) ); - } - } - // ********* Footnote functions for the wiki ********** // /** * Store footnote @@ -513,65 +473,6 @@ class BitPage extends LibertyAttachable { } - // ********* History functions for the wiki ********** // - /** - * Get count of the number of historic records for the page - * @return count - */ - function getHistoryCount() { - $ret = NULL; - if( $this->isValid() ) { - $query = "SELECT COUNT(*) AS `count` - FROM `".BIT_DB_PREFIX."liberty_content_history` - WHERE `page_id` = ?"; - $rs = $this->mDb->query($query, array($this->mPageId)); - $ret = $rs->fields['count']; - } - return $ret; - } - - /** - * Get complete set of historical data in order to display a given wiki page version - * @param pExistsHash the hash that was returned by LibertyContent::pageExists - * @return array of mInfo data - */ - function getHistory( $pVersion=NULL, $pUserId=NULL, $pOffset = 0, $max_records = -1 ) { - $ret = NULL; - if( $this->isValid() ) { - global $gBitSystem; - $versionSql = ''; - if( @BitBase::verifyId( $pUserId ) ) { - $bindVars = array( $pUserId ); - $whereSql = ' th.`user_id`=? '; - } else { - $bindVars = array( $this->mPageId ); - $whereSql = ' th.`page_id`=? '; - } - if( !empty( $pVersion ) ) { - array_push( $bindVars, $pVersion ); - $versionSql = ' AND th.`version`=? '; - } - $query = "SELECT lc.`title`, th.*, - uue.`login` AS modifier_user, uue.`real_name` AS modifier_real_name, - uuc.`login` AS creator_user, uuc.`real_name` AS creator_real_name - FROM `".BIT_DB_PREFIX."liberty_content_history` th INNER JOIN `".BIT_DB_PREFIX."wiki_pages` tp ON (tp.`page_id` = th.`page_id`) INNER JOIN `".BIT_DB_PREFIX."liberty_content` lc ON (lc.`content_id` = tp.`content_id`) - LEFT JOIN `".BIT_DB_PREFIX."users_users` uue ON (uue.`user_id` = th.`user_id`) - LEFT JOIN `".BIT_DB_PREFIX."users_users` uuc ON (uuc.`user_id` = lc.`user_id`) - WHERE $whereSql $versionSql order by th.`version` desc"; - - $result = $this->mDb->query( $query, $bindVars, $max_records, $pOffset ); - $ret = array(); - while( !$result->EOF ) { - $aux = $result->fields; - $aux['creator'] = (isset( $aux['creator_real_name'] ) ? $aux['creator_real_name'] : $aux['creator_user'] ); - $aux['editor'] = (isset( $aux['modifier_real_name'] ) ? $aux['modifier_real_name'] : $aux['modifier_user'] ); - array_push( $ret, $aux ); - $result->MoveNext(); - } - } - return $ret; - } - /** * Roll back to a specific version of a page * @param pVersion Version number to roll back to @@ -580,109 +481,15 @@ class BitPage extends LibertyAttachable { */ function rollbackVersion( $pVersion, $comment = '' ) { $ret = FALSE; - if( $this->isValid() ) { - global $gBitUser,$gBitSystem; - $this->mDb->StartTrans(); - // JHT - cache invalidation appears to be handled by store function - so don't need to do it here - $query = "select *, `user_id` AS modifier_user_id, `data` AS `edit` from `".BIT_DB_PREFIX."liberty_content_history` where `page_id`=? and `version`=?"; - $result = $this->mDb->query($query,array( $this->mPageId, $pVersion ) ); - if( $result->numRows() ) { - $res = $result->fetchRow(); - $res['comment'] = 'Rollback to version '.$pVersion.' by '.$gBitUser->getDisplayName(); - // JHT 2005-06-19_15:22:18 - // set ['force_history'] to - // make sure we don't destory current content without leaving a copy in history - // if rollback can destroy the current page version, it can be used - // maliciously - $res['force_history'] = 1; - // JHT 2005-10-16_22:21:10 - // title must be set or store fails - // we use current page name - $res['title'] = $this->mPageName; - if( $this->store( $res ) ) { - $action = "Changed actual version to $pVersion"; - $t = $gBitSystem->getUTCTime(); - $query = "insert into `".BIT_DB_PREFIX."wiki_action_log`(`action`,`page_id`,`last_modified`,`user_id`,`ip`,`comment`) values(?,?,?,?,?,?)"; - $result = $this->mDb->query($query,array($action,$this->mPageId,$t,ROOT_USER_ID,$_SERVER["REMOTE_ADDR"],$comment)); - $ret = TRUE; - } - $this->mDb->CompleteTrans(); - } else { - $this->mDb->RollbackTrans(); - } - } - return $ret; - } - - /** - * Removes a specific version of a page - * @param pVersion Version number to roll back to - * @param comment Comment text to be added to the action log - * @return TRUE if completed successfully - */ - function expungeVersion( $pVersion=NULL, $comment = '' ) { - $ret = FALSE; - if( $this->isValid() ) { - $this->mDb->StartTrans(); - $bindVars = array( $this->mPageId ); - $versionSql = ''; - if( $pVersion ) { - $versionSql = " and `version`=? "; - array_push( $bindVars, $pVersion ); - } - $hasRows = $this->mDb->getOne( "SELECT COUNT(`version`) FROM `".BIT_DB_PREFIX."liberty_content_history` WHERE `page_id`=? $versionSql ", $bindVars ); - $query = "delete from `".BIT_DB_PREFIX."liberty_content_history` where `page_id`=? $versionSql "; - $result = $this->mDb->query( $query, $bindVars ); - if( $hasRows ) { - global $gBitSystem; - $action = "Removed version $pVersion"; - $t = $gBitSystem->getUTCTime(); - $query = "insert into `".BIT_DB_PREFIX."wiki_action_log`(`action`,`page_id`,`last_modified`,`user_id`,`ip`,`comment`) values(?,?,?,?,?,?)"; - $result = $this->mDb->query($query,array($action,$this->mPageId,$t,ROOT_USER_ID,$_SERVER["REMOTE_ADDR"],$comment)); - $ret = TRUE; - } - $this->mDb->CompleteTrans(); - } - return $ret; - } - -/* - // Returns information about a specific version of a page - function get_version($page_id, $version) { - $query = "SELECT th.*, lc.`title` - FROM `".BIT_DB_PREFIX."liberty_content_history` th INNER JOIN `".BIT_DB_PREFIX."wiki_pages` tp ON (tp.`page_id` = th.`page_id`) INNER JOIN `".BIT_DB_PREFIX."liberty_content` lc ON (lc.`content_id` = tp.`content_id`) - WHERE th.`page_id`=? and th.`version`=? "; - $result = $this->mDb->query($query,array($page_id,$version)); - $res = $result->fetchRow(); - return $res; - } - // Returns all the versions for this page - // without the data itself - function get_page_history($pageId) { - global $gBitSystem; - $query = "SELECT lc.`title`, th.*, - uue.`login` AS modifier_user, uue.`real_name` AS modifier_real_name, uue.`user_id` AS modifier_user_id, - uuc.`login` AS creator_user, uuc.`real_name` AS creator_real_name, uuc.`user_id` AS creator_user_id - - FROM `".BIT_DB_PREFIX."liberty_content_history` th INNER JOIN `".BIT_DB_PREFIX."wiki_pages` tp ON (tp.`page_id` = th.`page_id`) INNER JOIN `".BIT_DB_PREFIX."liberty_content` lc ON (lc.`content_id` = tp.`content_id`) - INNER JOIN `".BIT_DB_PREFIX."users_users` uue ON (uue.`user_id` = th.`user_id`) - INNER JOIN `".BIT_DB_PREFIX."users_users` uuc ON (uuc.`user_id` = lc.`user_id`) - WHERE th.`page_id` = ? - ORDER BY th.`version` desc"; - - $result = $this->mDb->query($query,array($pageId)); - $ret = array(); - while ($res = $result->fetchRow()) { - $aux = $res; - $aux['creator'] = (isset( $res['creator_real_name'] ) ? $res['creator_real_name'] : $res['creator_user'] ); - $aux['editor'] = (isset( $res['modifier_real_name'] ) ? $res['modifier_real_name'] : $res['modifier_user'] ); - $aux["last_modified"] = $res["last_modified"]; - //$aux["percent"] = levenshtein($res["data"],$actual); - $ret[] = $aux; + if( parent::rollbackVersion( $pVersion, $comment ) ) { + $action = "Changed actual version to $pVersion"; + $t = $gBitSystem->getUTCTime(); + $query = "insert into `".BIT_DB_PREFIX."wiki_action_log`(`action`,`page_id`,`last_modified`,`user_id`,`ip`,`comment`) values(?,?,?,?,?,?)"; + $result = $this->mDb->query($query,array($action,$this->mPageId,$t,ROOT_USER_ID,$_SERVER["REMOTE_ADDR"],$comment)); + $ret = TRUE; } return $ret; } -*/ /** * Methods to cache and handle the cached version of wiki pages diff --git a/admin/schema_inc.php b/admin/schema_inc.php index 3d5aea6..295f3c4 100644 --- a/admin/schema_inc.php +++ b/admin/schema_inc.php @@ -21,7 +21,6 @@ $tables = array( 'wiki_pages' => " page_id I4 PRIMARY, content_id I4 NOTNULL, - version I4 NOTNULL, page_size I4 DEFAULT 0, description C(200), comment C(200), diff --git a/lookup_page_inc.php b/lookup_page_inc.php index d2c8557..113638c 100644 --- a/lookup_page_inc.php +++ b/lookup_page_inc.php @@ -1,6 +1,6 @@ <?php /** - * $Header: /cvsroot/bitweaver/_bit_wiki/lookup_page_inc.php,v 1.9 2006/02/06 22:56:52 squareing Exp $ + * $Header: /cvsroot/bitweaver/_bit_wiki/lookup_page_inc.php,v 1.10 2006/02/07 01:19:19 spiderr Exp $ * * Copyright (c) 2004 bitweaver.org * Copyright (c) 2003 tikwiki.org @@ -8,7 +8,7 @@ * 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 * - * $Id: lookup_page_inc.php,v 1.9 2006/02/06 22:56:52 squareing Exp $ + * $Id: lookup_page_inc.php,v 1.10 2006/02/07 01:19:19 spiderr Exp $ * @package wiki * @subpackage functions */ @@ -22,7 +22,7 @@ include_once( LIBERTY_PKG_PATH.'lookup_content_inc.php' ); // if we already have a gContent, we assume someone else created it for us, and has properly loaded everything up. -// if( empty( $gContent ) || !is_object( $gContent ) || !$gContent->isValid() ) { + if( empty( $gContent ) || !is_object( $gContent ) ) { $gContent = new BitPage( @BitBase::verifyId( $_REQUEST['page_id'] ) ? $_REQUEST['page_id'] : NULL, @BitBase::verifyId( $_REQUEST['content_id'] ) ? $_REQUEST['content_id'] : NULL ); $loadPage = (!empty( $_REQUEST['page'] ) ? $_REQUEST['page'] : NULL); @@ -46,7 +46,7 @@ if( !$gContent->load() && $loadPage ) { $gContent->mInfo['title'] = $loadPage; } -// } + } // we weren't passed a structure, but maybe this page belongs to one. let's check... if( empty( $gStructure ) ) { diff --git a/page_history.php b/page_history.php index 92e9b6f..43faf1f 100644 --- a/page_history.php +++ b/page_history.php @@ -1,6 +1,6 @@ <?php /** - * $Header: /cvsroot/bitweaver/_bit_wiki/page_history.php,v 1.7 2006/02/06 22:56:52 squareing Exp $ + * $Header: /cvsroot/bitweaver/_bit_wiki/page_history.php,v 1.8 2006/02/07 01:19:19 spiderr Exp $ * * Copyright (c) 2004 bitweaver.org * Copyright (c) 2003 tikwiki.org @@ -8,7 +8,7 @@ * 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 * - * $Id: page_history.php,v 1.7 2006/02/06 22:56:52 squareing Exp $ + * $Id: page_history.php,v 1.8 2006/02/07 01:19:19 spiderr Exp $ * @package wiki * @subpackage functions */ @@ -86,14 +86,14 @@ if (isset($_REQUEST["delete"]) && isset($_REQUEST["hist"])) { // pagination stuff $gBitSmarty->assign( 'page', $page = !empty( $_REQUEST['page'] ) ? $_REQUEST['page'] : 1 ); -$offset = ( $page - 1 ) * $gBitSystem->mPrefs['max_records']; -$history = $gContent->getHistory( NULL, NULL, $offset, $gBitSystem->mPrefs['max_records'] ); +$offset = ( $page - 1 ) * $gBitSystem->getPreference( 'max_records' ); +$history = $gContent->getHistory( NULL, NULL, $offset, $gBitSystem->getPreference( 'max_records' ) ); $gBitSmarty->assign_by_ref( 'history', $history ); //vd($gContent->getHistoryCount()); // calculate page number -$numPages = ceil( $gContent->getHistoryCount() / $gBitSystem->mPrefs['max_records'] ); +$numPages = ceil( $gContent->getHistoryCount() / $gBitSystem->getPreference('max_records', 20) ); $gBitSmarty->assign( 'numPages', $numPages ); |
