diff --git a/e107_plugins/forum/forum_sql.php b/e107_plugins/forum/forum_sql.php index 7097b5ced..7db2d6076 100644 --- a/e107_plugins/forum/forum_sql.php +++ b/e107_plugins/forum/forum_sql.php @@ -38,7 +38,7 @@ CREATE TABLE forum_thread ( `thread_options` text, PRIMARY KEY (`thread_id`), KEY `thread_forum_id` (`thread_forum_id`), - KEY `thread_s` (`thread_s`), + KEY `thread_sticky` (`thread_sticky`), KEY `thread_lastpost` (`thread_lastpost`) ) Type=MyISAM AUTO_INCREMENT=1 ; diff --git a/e107_plugins/forum/forum_update.php b/e107_plugins/forum/forum_update.php index fc6fff62f..8cd0da74c 100644 --- a/e107_plugins/forum/forum_update.php +++ b/e107_plugins/forum/forum_update.php @@ -11,40 +11,138 @@ | GNU General Public License (http://gnu.org). | | $Source: /cvs_backup/e107_0.8/e107_plugins/forum/forum_update.php,v $ -| $Revision: 1.3 $ -| $Date: 2008-12-18 22:03:45 $ +| $Revision: 1.4 $ +| $Date: 2008-12-19 21:56:37 $ | $Author: mcfly_e107 $ +----------------------------------------------------------------------------+ */ -if (!defined('e107_INIT')) { exit; } +if(defined('e_PAGE') && e_PAGE == 'e107_update.php') +{ + echo " + + "; + exit; +} +$eplug_admin = true; +require_once('../../class2.php'); +if (!getperms('P')) +{ + header('location:'.e_BASE.'index.php'); + exit; +} require_once(e_PLUGIN.'forum/forum_class.php'); +require_once(e_ADMIN.'auth.php'); $forum = new e107forum; $timestart = microtime(); $f = new forumUpgrade; $e107 = e107::getInstance(); -//Check attachment dir permissions -if(!isset($f->updateInfo['skip_attach'])) +if(isset($_POST) && count($_POST)) { - $f->checkAttachmentDirs(); - if(isset($f->error['attach'])) + if(isset($_POST['skip_attach'])) { - $errorText = " - The following errors have occured. These issues must be resolved if you ever want to enable attachment or image uploading in your forums.
If you do not ever plan on enabling this setting in your forum, you may click the 'skip' button

- "; - foreach($f->error['attach'] as $e) - { - $errorText .= '** '.$e.'
'; - } - $e107->ns->tablerender('Attachment directory error', $errorText); - require(e_ADMIN.'footer.php'); - exit; + $f->updateInfo['skip_attach'] = 1; + $f->updateInfo['currentStep'] = 2; + $f->setUpdateInfo(); + } + + var_dump($_POST); + if(isset($_POST['nextStep'])) + { + $tmp = array_keys($_POST['nextStep']); + $f->updateInfo['currentStep'] = $tmp[0]; + $f->setUpdateInfo(); } } + + +$currentStep = (isset($f->updateInfo['currentStep']) ? $f->updateInfo['currentStep'] : 1); +$stepParms = (isset($stepParms) ? $stepParms : ''); + +if(function_exists('step'.$currentStep)) +{ + call_user_func('step'.$currentStep, $stepParms); +} + + +require(e_ADMIN.'footer.php'); +exit; + + +function step1() +{ + global $f; + $e107 = e107::getInstance(); + //Check attachment dir permissions + if(!isset($f->updateInfo['skip_attach'])) + { + $f->checkAttachmentDirs(); + if(isset($f->error['attach'])) + { + $text = " +

ERROR:

+ The following errors have occured. These issues must be resolved if you ever want to enable attachment or image uploading in your forums.
If you do not ever plan on enabling this setting in your forum, you may click the 'skip' button

+ "; + foreach($f->error['attach'] as $e) + { + $errorText .= '** '.$e.'
'; + } + $text .= " +
+
+ +     + +
+ "; + } + else + { + $text = "Attachment and attachment/thumb directories are writable +

+
+ +
+ "; + } + $e107->ns->tablerender('Attachment directory permissions', $text); + } +} + +function step2() +{ + $e107 = e107::getInstance(); + if(!isset($_POST['create_tables'])) + { + $text = " + This step will create the new forum_thread, forum_post, and forum_attach tables. It will also create a forum_new table that will become the 'real' forum table once the data from the current table is migrated. +

+
+ +
+ "; + $e107->ns->tablerender('Step 2: Forum table creation', $text); + return; + } + + if($sql = file_get_contents(e_PLUGIN.'forum/forum_sql.php')) + { + echo $sql; + } + else + { + echo 'failed'; + } + + +} + //print_a($f->error); class forumUpgrade @@ -77,9 +175,9 @@ class forumUpgrade } else { - if(is_writable($dir)) + if(!is_writable($dir)) { - $this->error['attach'][] = "Directory '{$dir}' exits, but it now writeable"; + $this->error['attach'][] = "Directory '{$dir}' exits, but is not writeable"; } } } @@ -103,6 +201,7 @@ class forumUpgrade function setUpdateInfo() { + $e107 = e107::getInstance(); $info = mysql_real_escape_string(serialize($this->updateInfo)); $qry = "UPDATE `#generic` Set gen_chardata = '{$info}' WHERE gen_type = 'forumUpgrade'"; $e107->sql->db_Select_gen($qry); @@ -110,10 +209,57 @@ class forumUpgrade function setNewVersion() { - global $sql; - $sql->db_Update('plugin',"plugin_version = '{$this->newVersion}' WHERE plugin_name='Forum'"); + $e107 = e107::getInstance(); + $e107->sql->db_Update('plugin',"plugin_version = '{$this->newVersion}' WHERE plugin_name='Forum'"); return "Forum Version updated to version: {$this->newVersion}
"; } } + +function forum_update_adminmenu() +{ + global $currentStep; + + $var[1]['text'] = 'Step 1 - Permissions'; + $var[1]['link'] = '#'; + + $var[2]['text'] = 'Step 2 - Create new tables'; + $var[2]['link'] = '#'; + + $var[3]['text'] = 'Step 3 - Create extended fields'; + $var[3]['link'] = '#'; + + $var[4]['text'] = 'Step 4 - Move user data'; + $var[4]['link'] = '#'; + + $var[5]['text'] = 'Step 5 - Migrate forum configuration'; + $var[5]['link'] = '#'; + + $var[6]['text'] = 'Step 6 - Migrate threads/replies'; + $var[6]['link'] = '#'; + + $var[7]['text'] = 'Step 7 - Calc counts/lastpost data'; + $var[7]['link'] = '#'; + + $var[8]['text'] = 'Step 8 - Migrate any poll information'; + $var[8]['link'] = '#'; + + $var[9]['text'] = 'Step 9 - Migrate any attachments'; + $var[9]['link'] = '#'; + + $var[10]['text'] = 'Step 10 - Migrate any attachments'; + $var[10]['link'] = '#'; + + $var[11]['text'] = 'Step 11 - Delete old forum data'; + $var[11]['link'] = '#'; + + + for($i=1; $i < $currentStep; $i++) + { + $var[$i]['text'] = "{$var[$i]['text']}"; + } + + show_admin_menu('Forum Upgrade', $currentStep, $var); +} + ?> \ No newline at end of file