From 0f435a0c74b3b73c8339cab3390fe44a24bf4b91 Mon Sep 17 00:00:00 2001 From: mcfly Date: Thu, 18 Dec 2008 22:03:45 +0000 Subject: [PATCH] Beginning of forum update routine --- e107_plugins/forum/forum_update.php | 119 ++++++++++++++++++++++ e107_plugins/forum/forum_update_check.php | 36 +++++++ 2 files changed, 155 insertions(+) create mode 100644 e107_plugins/forum/forum_update.php create mode 100644 e107_plugins/forum/forum_update_check.php diff --git a/e107_plugins/forum/forum_update.php b/e107_plugins/forum/forum_update.php new file mode 100644 index 000000000..fc6fff62f --- /dev/null +++ b/e107_plugins/forum/forum_update.php @@ -0,0 +1,119 @@ +updateInfo['skip_attach'])) +{ + $f->checkAttachmentDirs(); + if(isset($f->error['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; + } +} + + +//print_a($f->error); + +class forumUpgrade +{ + var $newVersion = '2.0'; + var $error = array(); + var $updateInfo; + + function forumUpgrade() + { + $this->getUpdateInfo(); + } + + + function checkAttachmentDirs() + { + $dirs = array( + e_PLUGIN.'forum/attachments/', + e_PLUGIN.'forum/attachments/thumb' + ); + + foreach($dirs as $dir) + { + if(!file_exists($dir)) + { + if(!mkdir($dir)) + { + $this->error['attach'][] = "Directory '{$dir}' does not exist and I was unable to create it"; + } + } + else + { + if(is_writable($dir)) + { + $this->error['attach'][] = "Directory '{$dir}' exits, but it now writeable"; + } + } + } + } + + function getUpdateInfo() + { + $e107 = e107::getInstance(); + if($e107->sql->db_Select('generic', '*', "gen_type = 'forumUpgrade'")) + { + $row = $e107->sql->db_Fetch(MYSQL_ASSOC); + $this->updateInfo = unserialize($row['gen_chardata']); + } + else + { + $qry = "INSERT INTO `#generic` (gen_type) VALUES ('forumUpgrade')"; + $e107->sql->db_Select_gen($qry); + $this->updateInfo = array(); + } + } + + function setUpdateInfo() + { + $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); + } + + function setNewVersion() + { + global $sql; + $sql->db_Update('plugin',"plugin_version = '{$this->newVersion}' WHERE plugin_name='Forum'"); + return "Forum Version updated to version: {$this->newVersion}
"; + } + +} +?> \ No newline at end of file diff --git a/e107_plugins/forum/forum_update_check.php b/e107_plugins/forum/forum_update_check.php new file mode 100644 index 000000000..e4e116706 --- /dev/null +++ b/e107_plugins/forum/forum_update_check.php @@ -0,0 +1,36 @@ +