diff options
| author | bitweaver.org <bitweaver@users.sourceforge.net> | 2005-06-19 06:12:45 +0000 |
|---|---|---|
| committer | bitweaver.org <bitweaver@users.sourceforge.net> | 2005-06-19 06:12:45 +0000 |
| commit | 850713ed26ff34d8fe37feed30bb94de4adc957c (patch) | |
| tree | 7ceb5eaad8a84eb8796fd2d53ed62f17052acc35 /admin | |
| download | wiki-850713ed26ff34d8fe37feed30bb94de4adc957c.tar.gz wiki-850713ed26ff34d8fe37feed30bb94de4adc957c.tar.bz2 wiki-850713ed26ff34d8fe37feed30bb94de4adc957c.zip | |
IMPORT TikiPro CLYDE FINAL
Diffstat (limited to 'admin')
| -rw-r--r-- | admin/admin_external_wikis.php | 81 | ||||
| -rw-r--r-- | admin/admin_wiki_inc.php | 385 | ||||
| -rw-r--r-- | admin/import_phpwiki.php | 159 | ||||
| -rw-r--r-- | admin/index.php | 4 | ||||
| -rw-r--r-- | admin/schema_inc.php | 228 | ||||
| -rw-r--r-- | admin/upgrade_inc.php | 234 |
6 files changed, 1091 insertions, 0 deletions
diff --git a/admin/admin_external_wikis.php b/admin/admin_external_wikis.php new file mode 100644 index 0000000..e7510d3 --- /dev/null +++ b/admin/admin_external_wikis.php @@ -0,0 +1,81 @@ +<?php +// $Header: /cvsroot/bitweaver/_bit_wiki/admin/admin_external_wikis.php,v 1.1 2005/06/19 06:12:45 bitweaver Exp $ +// Copyright (c) 2002-2003, Luis Argerich, Garland Foster, Eduardo Polidor, et. al. +// 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' ); +include_once( KERNEL_PKG_PATH.'admin_lib.php' ); +if (!$gBitUser->isAdmin()) { + $smarty->assign('msg', tra("You dont have permission to use this feature")); + $gBitSystem->display( 'error.tpl' ); + die; +} +if (!isset($_REQUEST["extwiki_id"])) { + $_REQUEST["extwiki_id"] = 0; +} +$smarty->assign('extwiki_id', $_REQUEST["extwiki_id"]); +if ($_REQUEST["extwiki_id"]) { + $info = $adminlib->get_extwiki($_REQUEST["extwiki_id"]); +} else { + $info = array(); + $info["extwiki"] = ''; + $info['name'] = ''; +} +$smarty->assign('info', $info); +if (isset($_REQUEST["remove"])) { + + $adminlib->remove_extwiki($_REQUEST["remove"]); +} +if (isset($_REQUEST["save"])) { + + $adminlib->replace_extwiki($_REQUEST["extwiki_id"], $_REQUEST["extwiki"], $_REQUEST['name']); + $info = array(); + $info["extwiki"] = ''; + $info['name'] = ''; + $smarty->assign('info', $info); + $smarty->assign('name', ''); +} +if (empty( $_REQUEST["sort_mode"] )) { + $sort_mode = 'received_date_desc'; +} else { + $sort_mode = $_REQUEST["sort_mode"]; +} +$smarty->assign_by_ref('sort_mode', $sort_mode); +if (!isset($_REQUEST["offset"])) { + $offset = 0; +} else { + $offset = $_REQUEST["offset"]; +} +if (isset($_REQUEST['page'])) { + $page = &$_REQUEST['page']; + $offset = ($page - 1) * $maxRecords; +} +$smarty->assign_by_ref('offset', $offset); +if (isset($_REQUEST["find"])) { + $find = $_REQUEST["find"]; +} else { + $find = ''; +} +$smarty->assign_by_ref('find', $find); + +$channels = $adminlib->list_extwiki($offset, $maxRecords, $sort_mode, $find); +$cant_pages = ceil($channels["cant"] / $maxRecords); +$smarty->assign_by_ref('cant_pages', $cant_pages); +$smarty->assign('actual_page', 1 + ($offset / $maxRecords)); +if ($channels["cant"] > ($offset + $maxRecords)) { + $smarty->assign('next_offset', $offset + $maxRecords); +} else { + $smarty->assign('next_offset', -1); +} +// If offset is > 0 then prev_offset +if ($offset > 0) { + $smarty->assign('prev_offset', $offset - $maxRecords); +} else { + $smarty->assign('prev_offset', -1); +} +$smarty->assign_by_ref('channels', $channels["data"]); + +// Display the template +$gBitSystem->display( 'bitpackage:wiki/admin_external_wikis.tpl'); +?>
\ No newline at end of file diff --git a/admin/admin_wiki_inc.php b/admin/admin_wiki_inc.php new file mode 100644 index 0000000..7412f1a --- /dev/null +++ b/admin/admin_wiki_inc.php @@ -0,0 +1,385 @@ +<?php +// $Header: /cvsroot/bitweaver/_bit_wiki/admin/admin_wiki_inc.php,v 1.1 2005/06/19 06:12:45 bitweaver Exp $ +// Copyright (c) 2002-2003, Luis Argerich, Garland Foster, Eduardo Polidor, et. al. +// 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. + +// FIXME: including wikilib is NOT the way to fix this. +require_once( WIKI_PKG_PATH.'BitPage.php' ); + +$formWikiLists = array( + "wiki_list_name" => array( + 'label' => 'Name', + 'note' => 'Name of the wikipage.', + ), + "wiki_list_hits" => array( + 'label' => 'Hits', + 'note' => 'How often the page has been viewed.', + ), + "wiki_list_lastmodif" => array( + 'label' => 'Last modification date', + 'note' => 'Date of the last modification of a page.', + ), + "wiki_list_creator" => array( + 'label' => 'Creator', + 'note' => 'Name of the creator of a page.', + ), + "wiki_list_user" => array( + 'label' => 'User', + 'note' => 'Last user to modify the page.', + ), + "wiki_list_lastver" => array( + 'label' => 'Last version number', + 'note' => 'Shows the currently active version number.', + ), + "wiki_list_comment" => array( + 'label' => 'Comment', + 'note' => 'Display the comment added on the last commit.', + ), + "wiki_list_status" => array( + 'label' => 'Status', + 'note' => 'Displays wether the page is locked or open for modifications.', + ), + "wiki_list_versions" => array( + 'label' => 'Versions', + 'note' => 'Display the number of available versions of a page.', + ), + "wiki_list_links" => array( + 'label' => 'Links', + 'note' => 'Displays the number of links within a page.', + ), + "wiki_list_backlinks" => array( + 'label' => 'Backlinks', + 'note' => 'Number of pages that link to a page.', + ), + "wiki_list_format_guid" => array( + 'label' => 'Format GUID', + 'note' => 'Display the format GUID the page was saved in.', + ), + "wiki_list_size" => array( + 'label' => 'Size', + 'note' => 'Size of page in bytes.', + ), +); +$smarty->assign( 'formWikiLists',$formWikiLists ); + +if (isset($_REQUEST["wikilistconf"])) { + + foreach( $formWikiLists as $item => $data ) { + simple_set_toggle( $item ); + } +} + +$formWikiFeatures = array( + "feature_backlinks" => array( + 'label' => 'Backlinks', + 'note' => 'Display a dropdown list of pages that link to a page.', + ), + "feature_likePages" => array( + 'label' => 'Like Pages', + 'note' => 'Display a list of pages that have a common word in the names.', + ), + "feature_history" => array( + 'label' => 'History', + 'note' => 'Allow access to the page\'s history.', + ), + "feature_listPages" => array( + 'label' => 'List Pages', + 'note' => 'Allow access to a listing of all wikipages.', + ), + "feature_wiki_attachments" => array( + 'label' => 'Attachments', + 'note' => 'Allow the attachment of files to a wikipage.', + ), + "feature_wiki_comments" => array( + 'label' => 'Comments', + 'note' => 'Allow the addition of user comments at the end of every wikipage.', + ), + "feature_dump" => array( + 'label' => 'Dump', + 'note' => 'Allow the creation of a dump of a page.', + ), + "feature_sandbox" => array( + 'label' => 'Sandbox', + 'note' => 'The Sandbox is a wikipage that can be modified by any user to practise the wiki syntax. This page has no history nor is the contents searchable.', + ), + "feature_wiki_undo" => array( + 'label' => 'Undo', + 'note' => '???', + ), + "feature_wiki_templates" => array( + 'label' => 'Use templates', + 'note' => 'Allow the usage of templates.', + ), + "feature_wiki_rankings" => array( + 'label' => 'Rankings', + 'note' => 'Creates a ranking system based on the number of times a page is accessed.', + ), + "feature_wiki_usrlock" => array( + 'label' => 'Users can lock pages', + 'note' => 'Users who have the right permissions can lock pages preventing changes by other users.', + ), + "wiki_creator_admin" => array( + 'label' => 'Page creators are admin of their pages', + 'note' => 'Users who create a page, have all permissions regarding that particular page.', + ), + "feature_wiki_url_import" => array( + 'label' => 'Allow URL Import', + 'note' => 'Allow urls to be imported and saved to the wiki.', + ), + "feature_wiki_icache" => array( + 'label' => 'Individual WikiPage Cache', + 'note' => 'Allow individual cache settings for wikipages.', + ), +); + +$smarty->assign( 'formWikiFeatures',$formWikiFeatures ); +if (isset($_REQUEST["wikifeatures"])) { + + foreach( $formWikiFeatures as $item => $data ) { + simple_set_toggle( $item,'wiki' ); + } + if (isset($_REQUEST["feature_warn_on_edit"]) && $_REQUEST["feature_warn_on_edit"] == "y") { + $gBitSystem->storePreference("feature_warn_on_edit", 'y'); + $smarty->assign("feature_warn_on_edit", 'y'); + } else { + $gBitSystem->storePreference("feature_warn_on_edit", 'n'); + $smarty->assign("feature_warn_on_edit", 'n'); + } + $gBitSystem->storePreference("warn_on_edit_time", $_REQUEST["warn_on_edit_time"]); + $smarty->assign('warn_on_edit_time', $_REQUEST["warn_on_edit_time"]); + $gBitSystem->storePreference('wiki_cache', $_REQUEST["wiki_cache"]); + $smarty->assign('wiki_cache', $_REQUEST["wiki_cache"]); + + $smarty->assign('dump_url', $wikilib->getStorageUrl( "dump/$bitdomain" )); + /* + if(isset($_REQUEST["feature_wiki_notepad"]) && $_REQUEST["feature_wiki_notepad"]=="y") { + $gBitSystem->storePreference("feature_wiki_notepad",'y'); + $smarty->assign("feature_wiki_notepad",'y'); + } else { + $gBitSystem->storePreference("feature_wiki_notepad",'n'); + $smarty->assign("feature_wiki_notepad",'n'); + } + */ + /* not sure if the following are still required */ + $gBitSystem->storePreference('feature_wiki_tables', $_REQUEST['feature_wiki_tables']); + $smarty->assign('feature_wiki_tables', $_REQUEST['feature_wiki_tables']); + if (isset($_REQUEST["feature_userVersions"]) && $_REQUEST["feature_userVersions"] == "y") { + $gBitSystem->storePreference("feature_userVersions", 'y'); + $smarty->assign("feature_userVersions", 'y'); + } else { + $gBitSystem->storePreference("feature_userVersions", 'n'); + $smarty->assign("feature_userVersions", 'n'); + } +} +$formWikiInOut = array( + "feature_wiki_monosp" => array( + 'label' => 'Automonospaced text', + 'note' => 'When adding a space at the beginning of a line, the given line uses a monospace font.', + ), + "wiki_spellcheck" => array( + 'label' => 'Spellchecking', + 'note' => 'Allow the usage of a spellchecking facility.', + ), + "feature_wikiwords" => array( + 'label' => 'WikiWords', + 'note' => 'Automagically change words with CamelCaps or under_scores to links to internal wiki pages.', + ), + "feature_wiki_plurals" => array( + 'label' => 'Link plural WikiWords to their singular form', + 'note' => 'If you use WikiWords as page name in a text, it will be linked to WikiWord.', + ), + "feature_page_title" => array( + 'label' => 'Page Title', + 'note' => 'Display the page title at the top of every wikipage.', + ), + "feature_wiki_description" => array( + 'label' => 'Description', + 'note' => 'Display a brief page description just below the title of the page.', + ), + "feature_wiki_footnotes" => array( + 'label' => 'Footnotes', + 'note' => 'Allow the addition of footnotes to wikipages.', + ), + "wiki_uses_slides" => array( + 'label' => 'Use Slideshows', + 'note' => 'If a wikipage is plit into a number of pages, this can be viewed as a slideshow, without menus or excess data on the page. can be useful for presentations and the like.', + ), + "wiki_uses_s5" => array( + 'label' => 'Use S5 Slideshows', + 'note' => 'Any WikiPage can be turned into a full featured slideshow. Slides are separated at every H1 heading ( ! - wiki syntax ) and can be viewed using Firefox ( requires javascript ) or Opera ( need to press F11 to start the show ). Further information can be found at <a href="http://www.meyerweb.com/eric/tools/s5/">S5</a>', + ), + "feature_wiki_multiprint" => array( + 'label' => 'Print Multiple Pages', + 'note' => 'Allow joining of pages for printing purposes.', + ), +); +$smarty->assign( 'formWikiInOut',$formWikiInOut ); + +if (isset($_REQUEST["wikiinout"])) { + + foreach( $formWikiInOut as $item => $data ) { + simple_set_toggle( $item,'wiki' ); + } +} + +$formWikiBooks = array( + "feature_wiki_books" => array( + 'label' => 'WikiBooks', + 'note' => 'Allow the creation and use of WikiBooks - hierarchial collections of wiki pages', + ), + "wikibook_show_path" => array( + 'label' => 'Show book path', + 'note' => 'If this settings is enabled, the path pointing to the currently viewed page will be displayed at the top of the page.<br />Alternatively, you can turn on the module "<a href="'.KERNEL_PKG_URL.'admin/index.php?page=layout">liberty -> structure navigation</a>".', + ), + "wikibook_show_navigation" => array( + 'label' => 'Show book navigation links', + 'note' => 'Book navigation links allow you to navigate books more easily providing the following links:<br /><strong>previous | parent page | next</strong>.<br />Alternatively, you can turn on the module "<a href="'.KERNEL_PKG_URL.'admin/index.php?page=layout">liberty -> structure navigation</a>".', + ), + "wikibook_use_icons" => array( + 'label' => 'Use navigation icons instead of words', + 'note' => 'This option will remove the names of the navigation controls and replace them with appropriate icons for navigation. This can be useful if you feel that navigation is too cluttered when showing that many words.', + ), +); +$smarty->assign( 'formWikiBooks',$formWikiBooks ); + +if (isset($_REQUEST["wikibooks"])) { + + foreach( $formWikiBooks as $item => $data ) { + simple_set_toggle( $item,'wiki' ); + } +} + +$formWikiWatch = array( + "wiki_watch_author" => array( + 'label' => 'Page author watch', + 'note' => 'Automatically set a watch for the author of a page.', + ), + "wiki_watch_editor" => array( + 'label' => 'Page editor watch', + 'note' => 'Automatically set a watch for the editor of a page.', + ), + "wiki_watch_comments" => array( + 'label' => 'Comment watch', + 'note' => 'Allow watching of comments (who knows if this works).', + ), +); +$smarty->assign( 'formWikiWatch',$formWikiWatch ); + +if (isset($_REQUEST["wikiwatch"])) { + + foreach( $formWikiWatch as $item => $data ) { + simple_set_toggle( $item,'wiki' ); + } +} + +if (isset($_REQUEST["dump"])) { + + include (UTIL_PKG_PATH."tar.class.php"); + error_reporting (E_ERROR | E_WARNING); + $wikilib->dumpPages(); +} +if (isset($_REQUEST["createtag"])) { + + // Check existance + if ($adminlib->tag_exists($_REQUEST["tagname"])) { + $smarty->assign('msg', tra("Tag already exists")); + $gBitSystem->display( 'error.tpl' ); + die; + } + $adminlib->create_tag($_REQUEST["tagname"]); +} +if (isset($_REQUEST["restoretag"])) { + + // Check existance + if (!$adminlib->tag_exists($_REQUEST["restagname"])) { + $smarty->assign('msg', tra("Tag not found")); + $gBitSystem->display( 'error.tpl' ); + die; + } + $adminlib->restore_tag($_REQUEST["restagname"]); +} +if (isset($_REQUEST["removetag"])) { + + // Check existance + $adminlib->remove_tag($_REQUEST["remtagname"]); +} +if (isset($_REQUEST["wikiprefs"])) { + + if (isset($_REQUEST["wiki_comments_per_page"])) { + $gBitSystem->storePreference("wiki_comments_per_page", $_REQUEST["wiki_comments_per_page"]); + $smarty->assign('wiki_comments_per_page', $_REQUEST["wiki_comments_per_page"]); + } + if (isset($_REQUEST["wiki_comments_default_ordering"])) { + $gBitSystem->storePreference("wiki_comments_default_ordering", $_REQUEST["wiki_comments_default_ordering"]); + $smarty->assign('wiki_comments_default_ordering', $_REQUEST["wiki_comments_default_ordering"]); + } +} + +if (isset($_REQUEST["setwikihome"])) { + + $gBitSystem->storePreference('wikiHomePage', $_REQUEST["wikiHomePage"]); + $smarty->assign('wikiHomePage', $_REQUEST["wikiHomePage"]); +} +if (isset($_REQUEST["wikidiscussprefs"])) { + + if (isset($_REQUEST["feature_wiki_discuss"])) { + $gBitSystem->storePreference('feature_wiki_discuss', 'y'); + $smarty->assign('feature_wiki_discuss', 'y'); + } else { + $gBitSystem->storePreference("feature_wiki_discuss", 'n'); + $smarty->assign('feature_wiki_discuss', 'n'); + } + if (isset($_REQUEST["wiki_forum"])) { + $gBitSystem->storePreference('wiki_forum', $_REQUEST["wiki_forum"]); + $smarty->assign('wiki_forum', $_REQUEST["wiki_forum"]); + $wiki_forum_id = $gBitSystem->getOne("select `forumID` from `tiki_forums` where `name`='" . $_REQUEST["wiki_forum"] . "'"); + $gBitSystem->storePreference('wiki_forum_id', $wiki_forum_id); + $smarty->assign('wiki_forum_id', $wiki_forum_id); + } +} +if (isset($_REQUEST["setwikiregex"])) { + + $gBitSystem->storePreference('wiki_page_regex', $_REQUEST["wiki_page_regex"]); + $smarty->assign( 'wiki_page_regex', $_REQUEST["wiki_page_regex"] ); +} else { + $smarty->assign( 'wiki_page_regex', $gBitSystem->getPreference( 'wiki_page_regex', 'strict' ) ); +} +if (isset($_REQUEST["wikisetprefs"])) { + + if (isset($_REQUEST["maxVersions"])) { + $gBitSystem->storePreference("maxVersions", $_REQUEST["maxVersions"]); + } + if (isset($_REQUEST["keep_versions"])) { + $gBitSystem->storePreference("keep_versions", $_REQUEST["keep_versions"]); + $smarty->assign('keep_versions', $_REQUEST["keep_versions"]); + } +} +if (isset($_REQUEST["wikisetcopyright"])) { + + simple_set_toggle( 'wiki_feature_copyrights','wiki' ); + if (isset($_REQUEST["wikiLicensePage"])) { + $gBitSystem->storePreference("wikiLicensePage", $_REQUEST["wikiLicensePage"]); + $smarty->assign('wikiLicensePage', $_REQUEST["wikiLicensePage"]); + } + if (isset($_REQUEST["wikiSubmitNotice"])) { + $gBitSystem->storePreference("wikiSubmitNotice", $_REQUEST["wikiSubmitNotice"]); + $smarty->assign('wikiSubmitNotice', $_REQUEST["wikiSubmitNotice"]); + } +} +if ( $gBitSystem->isPackageActive( 'tiki_forums' ) ) { + $commentslib = new Comments(); + $all_forums = $commentslib->list_forums(0, -1, 'name_asc', ''); + $smarty->assign_by_ref("all_forums", $all_forums["data"]); +} +$tags = $adminlib->get_tags(); +$smarty->assign_by_ref("tags", $tags); +$smarty->assign("maxVersions", $gBitSystem->getPreference("maxVersions", 0)); +$smarty->assign("keep_versions", $gBitSystem->getPreference("keep_versions", 1)); + +$smarty->assign("wiki_feature_copyrights", $gBitSystem->getPreference("wiki_feature_copyrights")); +$smarty->assign('wikiLicensePage', $gBitSystem->getPreference("wikiLicensePage")); +$smarty->assign('wikiSubmitNotice', $gBitSystem->getPreference("wikiSubmitNotice")); + + +?> diff --git a/admin/import_phpwiki.php b/admin/import_phpwiki.php new file mode 100644 index 0000000..6724e96 --- /dev/null +++ b/admin/import_phpwiki.php @@ -0,0 +1,159 @@ +<?php +// $Header: /cvsroot/bitweaver/_bit_wiki/admin/Attic/import_phpwiki.php,v 1.1 2005/06/19 06:12:45 bitweaver Exp $ +// Copyright (c) 2002-2003, Luis Argerich, Garland Foster, Eduardo Polidor, et. al. +// 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. +require_once( '../../bit_setup_inc.php' ); +if (!$gBitUser->isAdmin()) { + $smarty->assign('msg', tra("You dont have permission to use this feature")); + $gBitSystem->display( 'error.tpl' ); + die; +} +require (WEBMAIL_PKG_PATH."mimeDecode.php"); +function parse_output(&$obj, &$parts, $i) { + if (!empty($obj->parts)) { + for ($i = 0; $i < count($obj->parts); $i++) + parse_output($obj->parts[$i], $parts, $i); + } else { + $ctype = $obj->ctype_primary . '/' . $obj->ctype_secondary; + switch ($ctype) { + case 'application/x-phpwiki': + $aux["body"] = $obj->body; + $ccc = $obj->headers["content-type"]; + $items = split(';', $ccc); + foreach ($items as $item) { + $portions = split('=', $item); + if (isset($portions[0]) && isset($portions[1])) { + $aux[trim($portions[0])] = trim($portions[1]); + } + } + $parts[] = $aux; + break; + case 'application/x-bitweaver': + $aux["body"] = $obj->body; + $ccc = $obj->headers["content-type"]; + $items = split(';', $ccc); + foreach ($items as $item) { + $portions = split('=', $item); + if (isset($portions[0]) && isset($portions[1])) { + $aux[trim($portions[0])] = trim($portions[1]); + } + } + $parts[] = $aux; + break; + } + } +} +function compare_import_versions($a1, $a2) { + return $a1["version"] - $a2["version"]; +} +$smarty->assign('result', 'y'); +if (isset($_REQUEST["import"])) { + + $path = $_REQUEST["path"]; + $h = opendir("$path/"); + $lines = array(); + while (false !== $file = readdir($h)) { + if (is_file("$path/$file")) { + $fp = fopen("$path/$file", "r"); + $full = fread($fp, filesize("$path/$file")); + //$full=htmlspecialchars($full); + fclose ($fp); + $params = array( + 'input' => $full, + 'crlf' => "\r\n", + 'include_bodies' => TRUE, + 'decode_headers' => TRUE, + 'decode_bodies' => TRUE + ); + $output = Mail_mimeDecode::decode($params); + parse_output($output, $parts, 0); + usort($parts, 'compare_import_versions'); + $last_part = ''; + $last_part_ver = 0; + foreach ($parts as $part) { + if ($part["version"] > $last_part_ver) { + $last_part_ver = $part["version"]; + $last_part = $part["body"]; + } + if (isset($part["pagename"])) { + // PHPWiki footnotes get handled by refusing to + // convert [[...] at all; the latest gBitSystem.php + // will render [[foo] as [foo], no link. So the + // (?<!\[) scattered here is to handle [[...] stuff. + // -rlpowell + // Fixing [description|URL] format of PHPWiki. + // -rlpowell + $part["body"] = preg_replace("/(?<!\[)\[([^\[\|\]]+)\|(http:[^\]\|\]]+)\]/", + "[$2|$1]", $part["body"]); + // Parse the body replacing links to Tiki links + $part["body"] = preg_replace("/ (http:\/\/[^ ]+) /", " [$1] ", $part["body"]); + // I have great difficulty imagining why someone + // thought this was right. It's not. It turns + // external links into image links that point + // nowhere. -rlpowell + // $part["body"] = preg_replace("/\[(http:\/\/[^\]]+)\]/", "{img src=$1}", $part["body"]); + // The (?!http:) below should really include other URL + // forms, but that would get complicated very quickly. + // -rlpowell + $part["body"] = preg_replace("/(?<!\[)\[((?!http:|\[)[^\|\]]+)\]/", "(($1))", $part["body"]); + $part["body"] = preg_replace("/(?<!\[)\[((?!http:|\[)[^\|]+)\|([^\]]+)\]/", "(($2|$1))", $part["body"]); + // %%% makes a linebreak in PHPWiki. -rlpowell + $part["body"] = str_replace("%%%", "", $part["body"]); + // ! and !!! need to be switched, annoyingly enough. + // This is a bit non-trivial. -rlpowell + $part["body"] = preg_replace("/\n\!([^\!])/", "\n&!!!&$1", $part["body"]); + $part["body"] = preg_replace("/\n\!\!\!([^\!])/", "\n!$1", $part["body"]); + $part["body"] = str_replace("\n&!!!&", "\n!!!", $part["body"]); + $pagename = urldecode($part["pagename"]); + $version = urldecode($part["version"]); + $author = urldecode($part["author"]); + $lastmodified = $part["lastmodified"]; + if (isset($part["description"])) { + $description = $part["description"]; + } else { + $description = ''; + } + $authorid = urldecode($part["author_id"]); + if (isset($part["hits"])) { + $hits = urldecode($part["hits"]); + } else { + $hits = 0; + } + $ex = substr($part["body"], 0, 25); + //print(strlen($part["body"])); + $msg = ''; + if ($_REQUEST["remo"] == 'y') { + $wikilib->remove_all_versions($pagename, ''); + } + if ($wikilib->pageExists($pagename)) { + if ($_REQUEST["crunch"] == 'n') { + $msg = '<b>' . tra('page not added (Exists)'). '</b>'; + } else { + $msg = '<b>' . tra('overwriting old page'). '</b>'; + $wikilib->update_page($pagename, $part["body"], + tra('updated by the phpwiki import process'), $author, + $authorid, $description); + } + } else { + $msg = tra('page created'); + $wikilib->create_page($pagename, $hits, $part["body"], $lastmodified, + tra('created from phpwiki import'), $author, $authorid, $description); + } + $aux["page"] = $pagename; + $aux["version"] = $version; + $aux["part"] = $ex; + $aux["msg"] = $msg; + $lines[] = $aux; + } + } + unset ($parts); + } + } + closedir ($h); + $smarty->assign('lines', $lines); + $smarty->assign('result', 'y'); +} + +$gBitSystem->display( 'bitpackage:wiki/import_phpwiki.tpl'); +?> diff --git a/admin/index.php b/admin/index.php new file mode 100644 index 0000000..80f6d40 --- /dev/null +++ b/admin/index.php @@ -0,0 +1,4 @@ +<?php + // This is not a package. + header ("location: ../index.php"); +?>
\ No newline at end of file diff --git a/admin/schema_inc.php b/admin/schema_inc.php new file mode 100644 index 0000000..c7299d7 --- /dev/null +++ b/admin/schema_inc.php @@ -0,0 +1,228 @@ +<?php + +$tables = array( + +'tiki_actionlog' => " + page_id I4 NOTNULL, + user_id I4 NOTNULL, + action C(255) NOTNULL, + last_modified I8, + title C(160), + ip C(15), + comment C(200) +", + +'tiki_copyrights' => " + copyright_id I4 AUTO PRIMARY, + page_id I4 NOTNULL, + title C(200), + year I8, + authors C(200), + copyright_order I8, + user_id I4 +", + +'tiki_history' => " + page_id I4 PRIMARY, + version I4 PRIMARY, + last_modified I8 NOTNULL, + format_guid C(16) NOTNULL, + description C(200), + user_id C(40), + ip C(15), + comment C(200), + data X + CONSTRAINTS ', CONSTRAINT `tiki_history_page_ref` FOREIGN KEY (`page_id`) REFERENCES `".BIT_DB_PREFIX."tiki_pages`( `page_id` )' +", + +'tiki_links' => " + from_content_id I4 PRIMARY, + to_content_id I4 PRIMARY +", + +'tiki_page_footnotes' => " + user_id C(40) PRIMARY, + page_id I4 NOTNULL, + data X +", + +'tiki_pages' => " + page_id I4 PRIMARY, + content_id I4 NOTNULL, + version I4 NOTNULL, + page_size I4 DEFAULT 0, + description C(200), + comment C(200), + flag C(1), + points I4, + votes I4, + cache X, + wiki_cache I8, + cache_timestamp I8, + page_rank N(4,3) +", + +'tiki_received_pages' => " + received_page_id I4 AUTO PRIMARY, + title C(160) NOTNULL, + data X, + description C(200), + comment C(200), + received_from_site C(200), + received_from_user C(200), + received_date I8 +", + +'tiki_tags' => " + page_id I4 PRIMARY, + tag_name C(80) PRIMARY, + title C(160), + user_id I4 NOTNULL, + hits I4, + description C(200), + data X, + last_modified I8, + comment C(200), + version I4 NOTNULL, + ip C(15), + flag C(1) +", + +'tiki_semaphores' => " + sem_name C(250) PRIMARY, + user_id I4 NOTNULL, + created I8 +", + +'tiki_extwiki' => " + extwiki_id I4 AUTO PRIMARY, + name C(200) NOTNULL, + extwiki C(255) +" + +); + +global $gBitInstaller; + +$gBitInstaller->makePackageHomeable(WIKI_PKG_NAME); + +foreach( array_keys( $tables ) AS $tableName ) { + $gBitInstaller->registerSchemaTable( WIKI_PKG_DIR, $tableName, $tables[$tableName] ); +} + +$gBitInstaller->registerPackageInfo( WIKI_PKG_NAME, array( + 'description' => "A wiki is 'the simplest online database that could possibly work.' No HTML or programming knowledge is needed to contribute to a wiki.", + 'license' => '<a href="http://www.gnu.org/licenses/licenses.html#LGPL">LGPL</a>', + 'version' => '0.1', + 'state' => 'experimental', + 'dependencies' => '', +) ); + +// ### Indexes +$indices = array ( + 'tiki_pages_content_idx' => array( 'table' => 'tiki_pages', 'cols' => 'content_id', 'opts' => 'UNIQUE' ), + 'tiki_pages_page_rank_idx' => array( 'table' => 'tiki_pages', 'cols' => 'page_rank', 'opts' => NULL ), + 'tiki_page_footnotes_page_idx' => array( 'table' => 'tiki_page_footnotes', 'cols' => 'page_id', 'opts' => NULL ) +); +$gBitInstaller->registerSchemaIndexes( WIKI_PKG_DIR, $indices ); + +// ### Sequences +$sequences = array ( + 'tiki_pages_page_id_seq' => array( 'start' => 1 ) +); +$gBitInstaller->registerSchemaSequences( WIKI_PKG_DIR, $sequences ); + + +// ### Default UserPermissions +$gBitInstaller->registerUserPermissions( WIKI_PKG_NAME, array( + array('bit_p_edit_dynvar', 'Can edit dynamic variables', 'editors', WIKI_PKG_NAME), + array('bit_p_edit', 'Can edit pages', 'registered', WIKI_PKG_NAME), + array('bit_p_view', 'Can view page/pages', 'basic', WIKI_PKG_NAME), + array('bit_p_remove', 'Can remove', 'editors', WIKI_PKG_NAME), + array('bit_p_rollback', 'Can rollback pages', 'editors', WIKI_PKG_NAME), + array('bit_p_admin_wiki', 'Can admin the wiki', 'editors', WIKI_PKG_NAME), + array('bit_p_wiki_admin_attachments', 'Can admin attachments to wiki pages', 'editors', WIKI_PKG_NAME), + array('bit_p_wiki_view_attachments', 'Can view wiki attachments and download', 'registered', WIKI_PKG_NAME), + array('bit_p_upload_picture', 'Can upload pictures to wiki pages', 'registered', WIKI_PKG_NAME), + array('bit_p_minor', 'Can save as minor edit', 'registered', WIKI_PKG_NAME), + array('bit_p_rename', 'Can rename pages', 'editors', WIKI_PKG_NAME), + array('bit_p_lock', 'Can lock pages', 'editors', WIKI_PKG_NAME), + + array('bit_p_edit_books', 'Can create and edit books', 'registered', WIKI_PKG_NAME), + array('bit_p_admin_books', 'Can administer books', 'editors', WIKI_PKG_NAME), + array('bit_p_edit_copyrights', 'Can edit copyright notices', 'registered', WIKI_PKG_NAME) +) ); + +// ### Default Preferences +$gBitInstaller->registerPreferences( WIKI_PKG_NAME, array( + array(WIKI_PKG_NAME, 'anonCanEdit','n'), + array(WIKI_PKG_NAME, 'feature_autolinks','y'), + array(WIKI_PKG_NAME, 'feature_backlinks','y'), + array(WIKI_PKG_NAME, 'feature_dump','y'), + array(WIKI_PKG_NAME, 'feature_history','y'), + array(WIKI_PKG_NAME, 'feature_lastChanges','y'), + array(WIKI_PKG_NAME, 'feature_likePages','y'), + array(WIKI_PKG_NAME, 'feature_listPages','y'), + array(WIKI_PKG_NAME, 'feature_page_title','y'), + array(WIKI_PKG_NAME, 'feature_ranking','n'), + array(WIKI_PKG_NAME, 'feature_sandbox','y'), + array(WIKI_PKG_NAME, 'feature_warn_on_edit','n'), + array(WIKI_PKG_NAME, 'feature_wiki','y'), + array(WIKI_PKG_NAME, 'feature_wiki_attachments','y'), + array(WIKI_PKG_NAME, 'feature_wiki_books','y'), + array(WIKI_PKG_NAME, 'feature_wiki_comments','n'), + array(WIKI_PKG_NAME, 'feature_wiki_description','y'), + array(WIKI_PKG_NAME, 'feature_wiki_discuss','n'), + array(WIKI_PKG_NAME, 'feature_wiki_footnotes','n'), + array(WIKI_PKG_NAME, 'feature_wiki_icache','n'), + array(WIKI_PKG_NAME, 'feature_wiki_monosp','n'), + array(WIKI_PKG_NAME, 'feature_wiki_multiprint','n'), + array(WIKI_PKG_NAME, 'feature_wiki_notepad','n'), + array(WIKI_PKG_NAME, 'feature_wiki_generate_pdf',''), + array(WIKI_PKG_NAME, 'feature_wiki_pictures','y'), + array(WIKI_PKG_NAME, 'feature_wiki_plurals','y'), + array(WIKI_PKG_NAME, 'feature_wiki_rankings','y'), + array(WIKI_PKG_NAME, 'feature_wiki_tables','new'), + array(WIKI_PKG_NAME, 'feature_wiki_templates','n'), + array(WIKI_PKG_NAME, 'feature_wiki_undo','n'), + array(WIKI_PKG_NAME, 'feature_wiki_usrlock','n'), + array(WIKI_PKG_NAME, 'feature_wikiwords','y'), + array(WIKI_PKG_NAME, 'keep_versions','1'), + array(WIKI_PKG_NAME, 'maxVersions','0'), + array(WIKI_PKG_NAME, 'w_use_db','y'), + array(WIKI_PKG_NAME, 'w_use_dir',''), + array(WIKI_PKG_NAME, 'warn_on_edit_time','2'), + array(WIKI_PKG_NAME, 'wiki_bot_bar','n'), + array(WIKI_PKG_NAME, 'wiki_cache','0'), + array(WIKI_PKG_NAME, 'wiki_comments_default_ordering','points_desc'), + array(WIKI_PKG_NAME, 'wiki_comments_per_page','10'), + array(WIKI_PKG_NAME, 'wiki_creator_admin','n'), + array(WIKI_PKG_NAME, 'wiki_feature_copyrights','n'), + array(WIKI_PKG_NAME, 'wiki_forum',''), + array(WIKI_PKG_NAME, 'wiki_forum_id',''), + array(WIKI_PKG_NAME, 'wiki_left_column','y'), + array(WIKI_PKG_NAME, 'wiki_list_backlinks','y'), + array(WIKI_PKG_NAME, 'wiki_list_comment','y'), + array(WIKI_PKG_NAME, 'wiki_list_creator','y'), + array(WIKI_PKG_NAME, 'wiki_list_hits','y'), + array(WIKI_PKG_NAME, 'wiki_list_lastmodif','y'), + array(WIKI_PKG_NAME, 'wiki_list_lastver','y'), + array(WIKI_PKG_NAME, 'wiki_list_links','y'), + array(WIKI_PKG_NAME, 'wiki_list_name','y'), + array(WIKI_PKG_NAME, 'wiki_list_size','y'), + array(WIKI_PKG_NAME, 'wiki_list_status','y'), + array(WIKI_PKG_NAME, 'wiki_list_user','y'), + array(WIKI_PKG_NAME, 'wiki_list_versions','y'), + array(WIKI_PKG_NAME, 'wiki_page_regex','strict'), + array(WIKI_PKG_NAME, 'wiki_right_column','y'), + array(WIKI_PKG_NAME, 'wiki_spellcheck','n'), + array(WIKI_PKG_NAME, 'wiki_top_bar','n'), + array(WIKI_PKG_NAME, 'wiki_uses_slides','n'), + array(WIKI_PKG_NAME, 'wikibook_show_path','y'), + array(WIKI_PKG_NAME, 'wikibook_show_navigation','y'), + array(WIKI_PKG_NAME, 'wikiHomePage','Welcome'), + array(WIKI_PKG_NAME, 'wikiLicensePage',''), + array(WIKI_PKG_NAME, 'wikiSubmitNotice',''), +) ); + +?> diff --git a/admin/upgrade_inc.php b/admin/upgrade_inc.php new file mode 100644 index 0000000..8e22628 --- /dev/null +++ b/admin/upgrade_inc.php @@ -0,0 +1,234 @@ +<?php + +global $gBitSystem, $gUpgradeFrom, $gUpgradeTo; + +$upgrades = array( + +'BONNIE' => array( + 'CLYDE' => array( + +// STEP 0 +array( 'QUERY' => + array( 'MYSQL' => array( + "ALTER TABLE `".BIT_DB_PREFIX."tiki_history` DROP PRIMARY KEY", + "ALTER TABLE `".BIT_DB_PREFIX."tiki_links` DROP PRIMARY KEY", + )), +), + +// STEP 1 +array( 'DATADICT' => array( +array( 'RENAMECOLUMN' => array( + 'tiki_pages' => array( '`pageRank`' => '`page_rank` N(4,3)' ), + 'tiki_received_pages' => array( '`receivedPageId`' => '`received_page_id` I4 AUTO', +// '`pageName`' => '`page_name`' , + '`receivedFromSite`' => '`received_from_site` C(200)' , + '`receivedFromUser`' => '`received_from_user` C(200)' , + '`receivedDate`' => '`received_date` I8' , + ), + 'tiki_actionlog' => array( '`lastModif`' => '`last_modified` I8' ), + 'tiki_history' => array( '`lastModif`' => '`last_modified` I8' ), + 'tiki_copyrights' => array( // '`userName`' => '`user_name` C(200)', + '`copyrightId`' => '`copyright_id` I4 AUTO' ), + 'tiki_extwiki' => array( '`extwikiId`' => '`extwiki_id` I4 AUTO' ), + 'tiki_semaphores' => array( '`semName`' => '`sem_name` C(250)', + '`timestamp`' => '`created` I8' ), + 'tiki_tags' => array( '`tagName`' => '`tag_name` C(80)', + '`pageName`' => '`page_name` C(160)', + '`lastModif`' => '`last_modified` I8' ), +)), +array( 'ALTER' => array( + 'tiki_pages' => array( + 'content_id' => array( '`content_id`', 'I4' ), // , 'NOTNULL' ), + ), + 'tiki_page_footnotes' => array( + 'user_id' => array( '`user_id`', 'I4' ), // , 'NOTNULL' ), + 'page_id' => array( '`page_id`', 'I4' ), // , 'NOTNULL' ), + ), + 'tiki_actionlog' => array( + 'user_id' => array( '`user_id`', 'I4' ), // , 'NOTNULL' ), + 'page_id' => array( '`page_id`', 'I4' ), // , 'NOTNULL' ), + ), + 'tiki_history' => array( + 'page_id' => array( '`page_id`', 'I4' ), // , 'NOTNULL' ), + 'user_id' => array( '`user_id`', 'I4' ), // , 'NOTNULL' ), + 'format_guid' => array( 'format_guid', 'VARCHAR(16)' ), // , 'NOTNULL' ), + ), + 'tiki_links' => array( + 'from_content_id' => array( '`from_content_id`', 'I4' ), // , 'NOTNULL' ), + 'to_content_id' => array( '`to_content_id`', 'I4' ), // , 'NOTNULL' ), + ), + 'tiki_semaphores' => array( + 'user_id' => array( '`user_id`', 'I4' ), // , 'NOTNULL' ), + ), +)), +)), + +// STEP 3 +array( 'PHP' => ' + global $gBitSystem; + require_once( WIKI_PKG_PATH."BitPage.php" ); + $max = $gBitSystem->GetOne( "SELECT MAX(`page_id`) FROM `'.BIT_DB_PREFIX.'tiki_pages`" ); + $gBitSystem->mDb->mDb->CreateSequence( "tiki_pages_page_id_seq", $max + 1 ); + $query = "SELECT uu.`user_id`, uu2.`user_id` AS modifier_user_id, tp.`lastModif` AS created, tp.`lastModif` AS `last_modified`, tp.`data`, tp.`pageName` AS `title`, tp.`ip`, tp.`hits` + FROM `'.BIT_DB_PREFIX.'tiki_pages` tp INNER JOIN `'.BIT_DB_PREFIX.'users_users` uu ON( tp.`creator`=uu.`login` ) INNER JOIN `'.BIT_DB_PREFIX.'users_users` uu2 ON( tp.`user`=uu2.`login` )"; + if( $rs = $gBitSystem->query( $query ) ) { + while( !$rs->EOF ) { + $conId = $gBitSystem->mDb->mDb->GenID( "tiki_content_id_seq" ); + $rs->fields["content_id"] = $conId; + $rs->fields["content_type_guid"] = BITPAGE_CONTENT_TYPE_GUID; + $rs->fields["format_guid"] = PLUGIN_GUID_TIKIWIKI; + $gBitSystem->mDb->associateInsert( "tiki_content", $rs->fields ); + $gBitSystem->query( "UPDATE `'.BIT_DB_PREFIX.'tiki_pages` SET `content_id`=? WHERE `pageName`=?", array( $conId, $rs->fields["title"] ) ); + if( $w_use_dir = $gBitSystem->getPreference("w_use_dir") ) { + $page = new BitPage( NULL, $conId ); + if( $page->load() && $rs2 = $gBitSystem->query( "SELECT * FROM `'.BIT_DB_PREFIX.'tiki_wiki_attachments` twa INNER JOIN `'.BIT_DB_PREFIX.'users_users` uu ON( twa.`user`=uu.`login` ) WHERE twa.`page`=?", array( $rs->fields["title"] ) ) ) { + while( !$rs2->EOF ) { + $info = $rs2->fields; + $storeHash["modifier_user_id"] = $rs->fields["modifier_user_id"]; + $storeHash["upload"]["user_id"] = (!empty($info["user_id"]) ? $info["user_id"] : ROOT_USER_ID); + $storeHash["upload"]["name"] = $info["filename"]; + $storeHash["upload"]["type"] = $info["filetype"]; + $storeHash["upload"]["size"] = filesize( $w_use_dir.$info["path"] ); + $storeHash["upload"]["tmp_name"] = $w_use_dir.$info["path"]; + if( $page->store( $storeHash ) ) { + $gBitSystem->query( "DELETE FROM `'.BIT_DB_PREFIX.'tiki_wiki_attachments` WHERE `page`=?", array( $rs->fields["title"] ) ); + } + unset( $storeHash ); + $rs2->MoveNext(); + } + } + if( !empty( $page->mErrors ) ) { +vd( $page->mErrors ); + } + } + $rs->MoveNext(); + } + } +' ), + + +// STEP 4 +array( 'QUERY' => + array( 'SQL92' => array( +// "UPDATE `".BIT_DB_PREFIX."tiki_pages SET `modifier_user_id`=-1 WHERE `modifier_user_id` IS NULL", + "UPDATE `".BIT_DB_PREFIX."tiki_history` SET `page_id`= (SELECT `page_id` FROM `".BIT_DB_PREFIX."tiki_pages` tp WHERE tp.`pageName`=`".BIT_DB_PREFIX."tiki_history`.`pageName`)", + "UPDATE `".BIT_DB_PREFIX."tiki_history` SET `user_id`=(SELECT `user_id` FROM `".BIT_DB_PREFIX."users_users` WHERE `".BIT_DB_PREFIX."users_users`.`login`=`".BIT_DB_PREFIX."tiki_history`.`user`)", + "UPDATE `".BIT_DB_PREFIX."tiki_history` SET `user_id`=".ROOT_USER_ID." WHERE `user_id` IS NULL", + "UPDATE `".BIT_DB_PREFIX."tiki_structures` SET `content_id`= (SELECT `content_id` FROM `".BIT_DB_PREFIX."tiki_pages` tp WHERE tp.`page_id`=`".BIT_DB_PREFIX."tiki_structures`.`page_id`)", + "UPDATE `".BIT_DB_PREFIX."tiki_semaphores` SET `user_id`=(SELECT `user_id` FROM `".BIT_DB_PREFIX."users_users` WHERE `".BIT_DB_PREFIX."users_users`.`login`=`".BIT_DB_PREFIX."tiki_semaphores`.`user`)", + "UPDATE `".BIT_DB_PREFIX."tiki_semaphores` SET `user_id`=(SELECT `user_id` FROM `".BIT_DB_PREFIX."users_users` WHERE `".BIT_DB_PREFIX."users_users`.`login`=`".BIT_DB_PREFIX."tiki_semaphores`.`user`)", + "UPDATE `".BIT_DB_PREFIX."tiki_page_footnotes` SET `page_id`= (SELECT `page_id` FROM `".BIT_DB_PREFIX."tiki_pages` tp WHERE tp.`pageName`=`".BIT_DB_PREFIX."tiki_page_footnotes`.`pageName`)", + "UPDATE `".BIT_DB_PREFIX."tiki_page_footnotes` SET `user_id`=(SELECT `user_id` FROM `".BIT_DB_PREFIX."users_users` WHERE `".BIT_DB_PREFIX."users_users`.`login`=`".BIT_DB_PREFIX."tiki_page_footnotes`.`user`)", + "UPDATE `".BIT_DB_PREFIX."tiki_page_footnotes` SET `user_id`=".ROOT_USER_ID." WHERE `user_id` IS NULL", + "UPDATE `".BIT_DB_PREFIX."tiki_actionlog` SET `page_id`= (SELECT `page_id` FROM `".BIT_DB_PREFIX."tiki_pages` tp WHERE tp.`pageName`=`".BIT_DB_PREFIX."tiki_actionlog`.`pageName`)", + "UPDATE `".BIT_DB_PREFIX."tiki_actionlog` SET `user_id`=(SELECT `user_id` FROM `".BIT_DB_PREFIX."users_users` WHERE `".BIT_DB_PREFIX."users_users`.`login`=`".BIT_DB_PREFIX."tiki_actionlog`.`user`)", + "UPDATE `".BIT_DB_PREFIX."tiki_actionlog` SET `user_id`=".ROOT_USER_ID." WHERE `user_id` IS NULL", + "UPDATE `".BIT_DB_PREFIX."tiki_links` SET `from_content_id`= (SELECT `content_id` FROM `".BIT_DB_PREFIX."tiki_pages` tp WHERE tp.`pageName`=`".BIT_DB_PREFIX."tiki_links`.`fromPage`)", + "UPDATE `".BIT_DB_PREFIX."tiki_links` SET `to_content_id`= (SELECT `content_id` FROM `".BIT_DB_PREFIX."tiki_pages` tp WHERE tp.`pageName`=`".BIT_DB_PREFIX."tiki_links`.`toPage`)", + "UPDATE users_permissions SET perm_name='bit_p_edit_books', perm_desc='Can create and edit books' WHERE perm_name='bit_p_edit_structures'", + + "INSERT INTO `".BIT_DB_PREFIX."users_grouppermissions` (`group_id`, `perm_name`) VALUES (2,'bit_p_edit_books')", + "UPDATE `".BIT_DB_PREFIX."tiki_preferences` SET `name`='feature_wiki_generate_pdf' WHERE name='feature_wiki_pdf'", + "INSERT INTO `".BIT_DB_PREFIX."tiki_preferences` (`name`, `value`, `package`) VALUES( 'feature_page_title', 'y', 'wiki' )", + "INSERT INTO `".BIT_DB_PREFIX."tiki_preferences` (`name`, `value`, `package`) VALUES( 'package_wiki', 'y', 'wiki' )", + + // Update versions that are out of whack so tiki_pages.versions>tiki_history.version + "UPDATE `".BIT_DB_PREFIX."tiki_pages` SET `version`=(SELECT th.`version`+1 FROM `".BIT_DB_PREFIX."tiki_history` th WHERE th.`page_id`=`".BIT_DB_PREFIX."tiki_pages`.`page_id` AND `".BIT_DB_PREFIX."tiki_pages`.`version`=th.`version`) WHERE `page_id` IN (SELECT `page_id` FROM `".BIT_DB_PREFIX."tiki_history` th WHERE th.`version`=`".BIT_DB_PREFIX."tiki_pages`.`version` AND th.`page_id`=`".BIT_DB_PREFIX."tiki_pages`.`page_id`)", + + // should go into users, but has to go here do to wiki needing user changes first + "UPDATE tiki_content SET content_type_guid='bituser' WHERE title like 'UserPage%'", + "UPDATE `".BIT_DB_PREFIX."users_users` SET `content_id`=(SELECT `content_id` FROM `".BIT_DB_PREFIX."tiki_content` WHERE `content_type_guid`='bituser' AND `user_id`=`".BIT_DB_PREFIX."users_users`.`user_id`)", + + // update comments on user pages + "UPDATE `".BIT_DB_PREFIX."tiki_comments` SET `objectType`='".BITUSER_CONTENT_TYPE_GUID."' WHERE `objectType`='wiki page' AND `object` LIKE 'UserPage%'", + "UPDATE `".BIT_DB_PREFIX."tiki_comments` SET `parent_id`=(SELECT `content_id` FROM `".BIT_DB_PREFIX."tiki_content` WHERE `content_type_guid`='".BITUSER_CONTENT_TYPE_GUID."' AND `title`=`".BIT_DB_PREFIX."tiki_comments`.`object` ) WHERE `parent_id`=0 AND `objectType`='".BITUSER_CONTENT_TYPE_GUID."'", + + // update comments on wiki pages + "UPDATE `".BIT_DB_PREFIX."tiki_comments` SET `objectType`='".BITPAGE_CONTENT_TYPE_GUID."' WHERE `objectType`='wiki page'", + "UPDATE `".BIT_DB_PREFIX."tiki_comments` SET `parent_id`=(SELECT `content_id` FROM `".BIT_DB_PREFIX."tiki_content` WHERE `content_type_guid`='".BITPAGE_CONTENT_TYPE_GUID."' AND `title`=`".BIT_DB_PREFIX."tiki_comments`.`object` ) WHERE `parent_id`=0 AND `objectType`='".BITPAGE_CONTENT_TYPE_GUID."'", + + "INSERT INTO `".BIT_DB_PREFIX."tiki_preferences` (`name`, `value`, `package`) VALUES( 'feature_wiki_books', 'y', 'wiki' )", + "INSERT INTO `".BIT_DB_PREFIX."tiki_preferences` (`name`, `value`, `package`) VALUES( 'feature_history', 'y', 'wiki' )", + "INSERT INTO `".BIT_DB_PREFIX."tiki_preferences` (`name`, `value`, `package`) VALUES( 'feature_listPages', 'y', 'wiki' )", + + "UPDATE `".BIT_DB_PREFIX."tiki_categorized_objects` SET `object_type`='".BITPAGE_CONTENT_TYPE_GUID."', `object_id`=(SELECT tc.`content_id` FROM `".BIT_DB_PREFIX."tiki_content` tc WHERE tc.`title`=`".BIT_DB_PREFIX."tiki_categorized_objects`.`objId` AND `".BIT_DB_PREFIX."tiki_categorized_objects`.`object_type`='wiki page')", + + + ), +)), + +/* +array( 'sql92' => array( + +"ALTER TABLE `".BIT_DB_PREFIX."tiki_wiki_attachments` RENAME COLUMN `attId` TO att_id", +"ALTER TABLE `".BIT_DB_PREFIX."tiki_wiki_attachments ADD user_id INT", +"UPDATE `".BIT_DB_PREFIX."tiki_wiki_attachments SET user_id=(SELECT user_id FROM users_users WHERE `user`=login)", +"UPDATE `".BIT_DB_PREFIX."tiki_wiki_attachments SET user_id=1 WHERE user_id IS NULL", +"ALTER TABLE `".BIT_DB_PREFIX."tiki_wiki_attachments ALTER user_id SET NOT NULL", +"ALTER TABLE `".BIT_DB_PREFIX."tiki_wiki_attachments DROP `user`", +"ALTER TABLE `".BIT_DB_PREFIX."tiki_wiki_attachments ADD page_id INT", +"UPDATE `".BIT_DB_PREFIX."tiki_wiki_attachments SET page_id=(SELECT page_id FROM tiki_pages WHERE `page_name`=`page`)", +"ALTER TABLE `".BIT_DB_PREFIX."tiki_wiki_attachments ALTER page_id SET NOT NULL", +"ALTER TABLE `".BIT_DB_PREFIX."tiki_wiki_attachments DROP `page`", + +*/ + +// STEP 5 +array( 'PHP' => ' + require_once( LIBERTY_PKG_PATH."LibertyStructure.php" ); + require_once( WIKI_PKG_PATH."BitBook.php" ); + $query = "SELECT `structure_id`, `content_id` FROM `".BIT_DB_PREFIX."tiki_structures` WHERE `parent_id` IS NULL OR `parent_id`=0"; + $roots = $gBitSystem->GetAssoc( $query ); + $s = new LibertyStructure(); + foreach( $roots AS $rootId=>$contentId ) { + $gBitSystem->query( "UPDATE `".BIT_DB_PREFIX."tiki_structures` SET `root_structure_id`=? WHERE `structure_id`=?", array( $rootId, $rootId ) ); + $gBitSystem->query( "UPDATE `".BIT_DB_PREFIX."tiki_content` SET `content_type_guid`=? WHERE `content_id`=?", array( BITBOOK_CONTENT_TYPE_GUID, $contentId ) ); + $toc = $s->build_subtree_toc( $rootId ); + $s->setTreeRoot( $rootId, $toc ); + } + +' ), + + +// STEP 6 +array( 'DATADICT' => array( + array( 'DROPCOLUMN' => array( + 'tiki_pages' => array( '`lastModif`', '`data`', '`pageName`', '`ip`', '`hits`', '`user`' ), + 'tiki_semaphores' => array( '`user`' ), + 'tiki_page_footnotes' => array( '`user`', '`pageName`' ), + 'tiki_actionlog' => array( '`user`', '`pageName`' ), + 'tiki_history' => array( '`user`', '`pageName`' ), + 'tiki_links' => array( '`fromPage`', '`toPage`' ), + 'tiki_structures' => array( '`page_id`' ), + )), +)), + +// STEP 7 +array( 'DATADICT' => array( +array( 'CREATEINDEX' => array( + 'tiki_actlog_page_idx' => array( 'tiki_actionlog', '`page_id`', array() ), + 'tiki_footnotes_page_idx' => array( 'tiki_page_footnotes', '`page_id`', array() ), + 'tiki_footnotes_user_idx' => array( 'tiki_page_footnotes', '`user_id`', array() ), + 'tiki_footnotes_up_idx' => array( 'tiki_page_footnotes', '`user_id`,`page_id`', array( 'UNIQUE' ) ), + 'tiki_history_page_idx' => array( 'tiki_history', '`page_id`', array() ), + 'tiki_history_pv_idx' => array( 'tiki_history', '`page_id`,`version`', array( 'UNIQUE' ) ), + 'tiki_links_from_idx' => array( 'tiki_links', '`from_content_id`', array() ), + 'tiki_links_to_idx' => array( 'tiki_links', '`to_content_id`', array() ), + 'tiki_links_ft_idx' => array( 'tiki_links', '`from_content_id`,`to_content_id`', array( 'UNIQUE' ) ), + 'tiki_pages_content_idx' => array( 'tiki_pages', '`content_id`', array( 'UNIQUE' ) ), + 'tiki_sema_user_idx' => array( 'tiki_semaphores', '`user_id`', array() ), + )), +)), + + + ) +) + +); + +if( isset( $upgrades[$gUpgradeFrom][$gUpgradeTo] ) ) { + $gBitSystem->registerUpgrade( WIKI_PKG_NAME, $upgrades[$gUpgradeFrom][$gUpgradeTo] ); +} + + +?> |
