From: <vo...@us...> - 2012-01-10 08:37:31
|
Revision: 8693 http://xoops.svn.sourceforge.net/xoops/?rev=8693&view=rev Author: voltan1 Date: 2012-01-10 08:37:21 +0000 (Tue, 10 Jan 2012) Log Message: ----------- Add update script from old news module. it not complated Modified Paths: -------------- XoopsModules/fmcontent/branches/news/admin/action.module.php XoopsModules/fmcontent/branches/news/xoops_version.php Added Paths: ----------- XoopsModules/fmcontent/branches/news/include/functions_install.php XoopsModules/fmcontent/branches/news/include/functions_uninstall.php XoopsModules/fmcontent/branches/news/include/functions_update.php Modified: XoopsModules/fmcontent/branches/news/admin/action.module.php =================================================================== --- XoopsModules/fmcontent/branches/news/admin/action.module.php 2012-01-10 05:41:35 UTC (rev 8692) +++ XoopsModules/fmcontent/branches/news/admin/action.module.php 2012-01-10 08:37:21 UTC (rev 8693) @@ -19,153 +19,10 @@ * @version $Id$ */ -function xoops_module_pre_install_news($module) { - - $db = $GLOBALS["xoopsDB"]; - $error = false; - - /* - if (substr(XOOPS_VERSION, 0, 9) < "XOOPS 2.5") { - $module->setErrors("The module only works for XOOPS 2.5+"); - return false; - } - */ - $sqlfile = array('mysql' => 'sql/mysql.sql'); - - $modsDirname = 'news'; - $indexFile = XOOPS_ROOT_PATH . "/uploads/index.html"; - $blankFile = XOOPS_ROOT_PATH . "/uploads/blank.gif"; - - //Creation du fichier creator dans uploads - $module_uploads = XOOPS_ROOT_PATH . "/uploads/news"; - if (!is_dir($module_uploads)) { - mkdir($module_uploads, 0777); - chmod($module_uploads, 0777); - copy($indexFile, XOOPS_ROOT_PATH . "/uploads/" . $modsDirname . "/index.html"); - } - //Creation du fichier price dans uploads - $module_uploads = XOOPS_ROOT_PATH . "/uploads/" . $modsDirname . "/image"; - if (!is_dir($module_uploads)) { - mkdir($module_uploads, 0777); - chmod($module_uploads, 0777); - copy($indexFile, XOOPS_ROOT_PATH . "/uploads/" . $modsDirname . "/image/index.html"); - copy($blankFile, XOOPS_ROOT_PATH . "/uploads/" . $modsDirname . "/image/blank.gif"); - } - - //Creation du fichier price dans uploads - $module_uploads = XOOPS_ROOT_PATH . "/uploads/" . $modsDirname . "/image/original"; - if (!is_dir($module_uploads)) { - mkdir($module_uploads, 0777); - chmod($module_uploads, 0777); - copy($indexFile, XOOPS_ROOT_PATH . "/uploads/" . $modsDirname . "/image/original/index.html"); - copy($blankFile, XOOPS_ROOT_PATH . "/uploads/" . $modsDirname . "/image/original/blank.gif"); - } - - //Creation du fichier price dans uploads - $module_uploads = XOOPS_ROOT_PATH . "/uploads/" . $modsDirname . "/image/medium"; - if (!is_dir($module_uploads)) { - mkdir($module_uploads, 0777); - chmod($module_uploads, 0777); - copy($indexFile, XOOPS_ROOT_PATH . "/uploads/" . $modsDirname . "/image/medium/index.html"); - copy($blankFile, XOOPS_ROOT_PATH . "/uploads/" . $modsDirname . "/image/medium/blank.gif"); - } - - //Creation du fichier price dans uploads - $module_uploads = XOOPS_ROOT_PATH . "/uploads/" . $modsDirname . "/image/thumb"; - if (!is_dir($module_uploads)) { - mkdir($module_uploads, 0777); - chmod($module_uploads, 0777); - copy($indexFile, XOOPS_ROOT_PATH . "/uploads/" . $modsDirname . "/image/thumb/index.html"); - copy($blankFile, XOOPS_ROOT_PATH . "/uploads/" . $modsDirname . "/image/thumb/blank.gif"); - } - - //Creation du fichier price dans uploads - $module_uploads = XOOPS_ROOT_PATH . "/uploads/" . $modsDirname . "/file"; - if (!is_dir($module_uploads)) { - mkdir($module_uploads, 0777); - chmod($module_uploads, 0777); - copy($indexFile, XOOPS_ROOT_PATH . "/uploads/" . $modsDirname . "/file/index.html"); - copy($blankFile, XOOPS_ROOT_PATH . "/uploads/" . $modsDirname . "/file/blank.gif"); - } - - if (is_array($sqlfile) && !empty($sqlfile[XOOPS_DB_TYPE])) { - $sql_file_path = XOOPS_ROOT_PATH . "/modules/" . $modsDirname . "/" . $sqlfile[XOOPS_DB_TYPE]; - - if (!file_exists($sql_file_path)) { - $module->setErrors("<p>" . sprintf(_NEWS_MI_SQL_NOT_FOUND, "<strong>{$sql_file_path}</strong>")); - $error = true; - } else { - $msgs[] = "<p>" . sprintf(_NEWS_MI_SQL_FOUND, "<strong>{$sql_file_path}</strong>") . "<br />" . _NEWS_MI_CREATE_TABLES; - require_once $GLOBALS['xoops']->path('/class/database/sqlutility.php'); - $sql_query = fread(fopen($sql_file_path, 'r'), filesize($sql_file_path)); - $sql_query = trim($sql_query); - SqlUtility::splitMySqlFile($pieces, $sql_query); - $created_tables = array(); - foreach ($pieces as $piece) { - // [0] contains the prefixed query - // [4] contains unprefixed table name - $prefixed_query = SqlUtility::prefixQuery($piece, $db->prefix()); - if (!$prefixed_query) { - $module->setErrors("<p>" . sprintf(_NEWS_MI_SQL_NOT_VALID, "<strong>" . $piece . "</strong>")); - $error = true; - break; - } - - if (!isset($reservedTables)) { - $reservedTables = array(); - } - // check if the table name is reserved - if (!in_array($prefixed_query[4], $reservedTables)) { - // not reserved, so try to create one - if (!$db->query($prefixed_query[0])) { - $errs[] = $db->error(); - $error = true; - break; - } else { - if (!in_array($prefixed_query[4], $created_tables)) { - $msgs[] = " " . sprintf(_NEWS_MI_TABLE_CREATED, "<strong>" . $db->prefix($prefixed_query[4]) . "</strong>"); - $created_tables[] = $prefixed_query[4]; - } else { - $msgs[] = " " . sprintf(_NEWS_MI_INSERT_DATA, "<strong>" . $db->prefix($prefixed_query[4]) . "</strong>"); - } - } - } else { - // the table name is reserved, so halt the installation - $module->setErrors(" " . sprintf(_NEWS_MI_TABLE_RESERVED, "<strong>" . $prefixed_query[4] . "</strong>")); - $error = true; - break; - } - } - // if there was an error, delete the tables created so far, so the next installation will not fail - if ($error == true) { - foreach ($created_tables as $ct) { - $db->query("DROP TABLE " . $db->prefix($ct)); - } - return false; - } - } - return true; - } - return false; -} -function xoops_module_update_news($module, $version) { -} -function xoops_module_uninstall_news($module) { - $db =& $GLOBALS["xoopsDB"]; - - $created_tables = array(0 => 'news_story', 1 => 'news_topic' , 2 => 'news_file'); - - foreach ($created_tables as $ct) { - $db->query("DROP TABLE " . $db->prefix($ct)); - } - return true; - -} - ?> \ No newline at end of file Added: XoopsModules/fmcontent/branches/news/include/functions_install.php =================================================================== --- XoopsModules/fmcontent/branches/news/include/functions_install.php (rev 0) +++ XoopsModules/fmcontent/branches/news/include/functions_install.php 2012-01-10 08:37:21 UTC (rev 8693) @@ -0,0 +1,155 @@ +<?php +/* + You may not change or alter any portion of this comment or credits + of supporting developers from this source code or any supporting source code + which is considered copyrighted (c) material of the original comment or credit authors. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +*/ + +/** + * News action script file + * + * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/ + * @license http://www.fsf.org/copyleft/gpl.html GNU public license + * @author Andricq Nicolas (AKA MusS) + * @author Hossein Azizabadi (AKA Voltan) + * @version $Id$ + */ + +function xoops_module_pre_install_news($module) { + + + $db = $GLOBALS["xoopsDB"]; + $error = false; + + /* + if (substr(XOOPS_VERSION, 0, 9) < "XOOPS 2.5") { + $module->setErrors("The module only works for XOOPS 2.5+"); + return false; + } + */ + $sqlfile = array('mysql' => 'sql/mysql.sql'); + + $modsDirname = basename(dirname(dirname(__FILE__))); + $indexFile = XOOPS_ROOT_PATH . "/uploads/index.html"; + $blankFile = XOOPS_ROOT_PATH . "/uploads/blank.gif"; + + //Creation du fichier creator dans uploads + $module_uploads = XOOPS_ROOT_PATH . "/uploads/news"; + if (!is_dir($module_uploads)) { + mkdir($module_uploads, 0777); + chmod($module_uploads, 0777); + copy($indexFile, XOOPS_ROOT_PATH . "/uploads/" . $modsDirname . "/index.html"); + } + + //Creation du fichier price dans uploads + $module_uploads = XOOPS_ROOT_PATH . "/uploads/" . $modsDirname . "/image"; + if (!is_dir($module_uploads)) { + mkdir($module_uploads, 0777); + chmod($module_uploads, 0777); + copy($indexFile, XOOPS_ROOT_PATH . "/uploads/" . $modsDirname . "/image/index.html"); + copy($blankFile, XOOPS_ROOT_PATH . "/uploads/" . $modsDirname . "/image/blank.gif"); + } + + //Creation du fichier price dans uploads + $module_uploads = XOOPS_ROOT_PATH . "/uploads/" . $modsDirname . "/image/original"; + if (!is_dir($module_uploads)) { + mkdir($module_uploads, 0777); + chmod($module_uploads, 0777); + copy($indexFile, XOOPS_ROOT_PATH . "/uploads/" . $modsDirname . "/image/original/index.html"); + copy($blankFile, XOOPS_ROOT_PATH . "/uploads/" . $modsDirname . "/image/original/blank.gif"); + } + + //Creation du fichier price dans uploads + $module_uploads = XOOPS_ROOT_PATH . "/uploads/" . $modsDirname . "/image/medium"; + if (!is_dir($module_uploads)) { + mkdir($module_uploads, 0777); + chmod($module_uploads, 0777); + copy($indexFile, XOOPS_ROOT_PATH . "/uploads/" . $modsDirname . "/image/medium/index.html"); + copy($blankFile, XOOPS_ROOT_PATH . "/uploads/" . $modsDirname . "/image/medium/blank.gif"); + } + + //Creation du fichier price dans uploads + $module_uploads = XOOPS_ROOT_PATH . "/uploads/" . $modsDirname . "/image/thumb"; + if (!is_dir($module_uploads)) { + mkdir($module_uploads, 0777); + chmod($module_uploads, 0777); + copy($indexFile, XOOPS_ROOT_PATH . "/uploads/" . $modsDirname . "/image/thumb/index.html"); + copy($blankFile, XOOPS_ROOT_PATH . "/uploads/" . $modsDirname . "/image/thumb/blank.gif"); + } + + //Creation du fichier price dans uploads + $module_uploads = XOOPS_ROOT_PATH . "/uploads/" . $modsDirname . "/file"; + if (!is_dir($module_uploads)) { + mkdir($module_uploads, 0777); + chmod($module_uploads, 0777); + copy($indexFile, XOOPS_ROOT_PATH . "/uploads/" . $modsDirname . "/file/index.html"); + copy($blankFile, XOOPS_ROOT_PATH . "/uploads/" . $modsDirname . "/file/blank.gif"); + } + + if (is_array($sqlfile) && !empty($sqlfile[XOOPS_DB_TYPE])) { + $sql_file_path = XOOPS_ROOT_PATH . "/modules/" . $modsDirname . "/" . $sqlfile[XOOPS_DB_TYPE]; + + if (!file_exists($sql_file_path)) { + $module->setErrors("<p>" . sprintf(_NEWS_MI_SQL_NOT_FOUND, "<strong>{$sql_file_path}</strong>")); + $error = true; + } else { + $msgs[] = "<p>" . sprintf(_NEWS_MI_SQL_FOUND, "<strong>{$sql_file_path}</strong>") . "<br />" . _NEWS_MI_CREATE_TABLES; + + require_once $GLOBALS['xoops']->path('/class/database/sqlutility.php'); + $sql_query = fread(fopen($sql_file_path, 'r'), filesize($sql_file_path)); + $sql_query = trim($sql_query); + SqlUtility::splitMySqlFile($pieces, $sql_query); + $created_tables = array(); + foreach ($pieces as $piece) { + // [0] contains the prefixed query + // [4] contains unprefixed table name + $prefixed_query = SqlUtility::prefixQuery($piece, $db->prefix()); + if (!$prefixed_query) { + $module->setErrors("<p>" . sprintf(_NEWS_MI_SQL_NOT_VALID, "<strong>" . $piece . "</strong>")); + $error = true; + break; + } + + if (!isset($reservedTables)) { + $reservedTables = array(); + } + // check if the table name is reserved + if (!in_array($prefixed_query[4], $reservedTables)) { + // not reserved, so try to create one + if (!$db->query($prefixed_query[0])) { + $errs[] = $db->error(); + $error = true; + break; + } else { + if (!in_array($prefixed_query[4], $created_tables)) { + $msgs[] = " " . sprintf(_NEWS_MI_TABLE_CREATED, "<strong>" . $db->prefix($prefixed_query[4]) . "</strong>"); + $created_tables[] = $prefixed_query[4]; + } else { + $msgs[] = " " . sprintf(_NEWS_MI_INSERT_DATA, "<strong>" . $db->prefix($prefixed_query[4]) . "</strong>"); + } + } + } else { + // the table name is reserved, so halt the installation + $module->setErrors(" " . sprintf(_NEWS_MI_TABLE_RESERVED, "<strong>" . $prefixed_query[4] . "</strong>")); + $error = true; + break; + } + } + // if there was an error, delete the tables created so far, so the next installation will not fail + if ($error == true) { + foreach ($created_tables as $ct) { + $db->query("DROP TABLE " . $db->prefix($ct)); + } + return false; + } + } + return true; + } + return false; +} + +?> \ No newline at end of file Added: XoopsModules/fmcontent/branches/news/include/functions_uninstall.php =================================================================== --- XoopsModules/fmcontent/branches/news/include/functions_uninstall.php (rev 0) +++ XoopsModules/fmcontent/branches/news/include/functions_uninstall.php 2012-01-10 08:37:21 UTC (rev 8693) @@ -0,0 +1,34 @@ +<?php +/* + You may not change or alter any portion of this comment or credits + of supporting developers from this source code or any supporting source code + which is considered copyrighted (c) material of the original comment or credit authors. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +*/ + +/** + * News action script file + * + * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/ + * @license http://www.fsf.org/copyleft/gpl.html GNU public license + * @author Andricq Nicolas (AKA MusS) + * @author Hossein Azizabadi (AKA Voltan) + * @version $Id$ + */ + +function xoops_module_uninstall_news($module) { + $db =& $GLOBALS["xoopsDB"]; + + $created_tables = array(0 => 'news_story', 1 => 'news_topic' , 2 => 'news_file'); + + foreach ($created_tables as $ct) { + $db->query("DROP TABLE " . $db->prefix($ct)); + } + return true; + +} + +?> \ No newline at end of file Added: XoopsModules/fmcontent/branches/news/include/functions_update.php =================================================================== --- XoopsModules/fmcontent/branches/news/include/functions_update.php (rev 0) +++ XoopsModules/fmcontent/branches/news/include/functions_update.php 2012-01-10 08:37:21 UTC (rev 8693) @@ -0,0 +1,317 @@ +<?php +/* + You may not change or alter any portion of this comment or credits + of supporting developers from this source code or any supporting source code + which is considered copyrighted (c) material of the original comment or credit authors. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +*/ + +/** + * News action script file + * + * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/ + * @license http://www.fsf.org/copyleft/gpl.html GNU public license + * @author Hossein Azizabadi (AKA Voltan) + * @version $Id$ + */ + +/** + * This function work just for update version 1.68 ( or 1.66 ) to version 1.8 and upper. + * If your version is under 1.68 ( or 1.66 ) please frist update your old version to 1.68. + */ +function xoops_module_update_news($module, $version) { + + $modsDirname = basename(dirname(dirname(__FILE__))); + if($modsDirname != 'news') { + return false; + } + + $indexFile = XOOPS_ROOT_PATH . "/uploads/index.html"; + $blankFile = XOOPS_ROOT_PATH . "/uploads/blank.gif"; + + //Creation du fichier creator dans uploads + $module_uploads = XOOPS_ROOT_PATH . "/uploads/news"; + if (!is_dir($module_uploads)) { + mkdir($module_uploads, 0777); + chmod($module_uploads, 0777); + copy($indexFile, XOOPS_ROOT_PATH . "/uploads/" . $modsDirname . "/index.html"); + } + + //Creation du fichier price dans uploads + $module_uploads = XOOPS_ROOT_PATH . "/uploads/" . $modsDirname . "/image"; + if (!is_dir($module_uploads)) { + mkdir($module_uploads, 0777); + chmod($module_uploads, 0777); + copy($indexFile, XOOPS_ROOT_PATH . "/uploads/" . $modsDirname . "/image/index.html"); + copy($blankFile, XOOPS_ROOT_PATH . "/uploads/" . $modsDirname . "/image/blank.gif"); + } + + //Creation du fichier price dans uploads + $module_uploads = XOOPS_ROOT_PATH . "/uploads/" . $modsDirname . "/image/original"; + if (!is_dir($module_uploads)) { + mkdir($module_uploads, 0777); + chmod($module_uploads, 0777); + copy($indexFile, XOOPS_ROOT_PATH . "/uploads/" . $modsDirname . "/image/original/index.html"); + copy($blankFile, XOOPS_ROOT_PATH . "/uploads/" . $modsDirname . "/image/original/blank.gif"); + } + + //Creation du fichier price dans uploads + $module_uploads = XOOPS_ROOT_PATH . "/uploads/" . $modsDirname . "/image/medium"; + if (!is_dir($module_uploads)) { + mkdir($module_uploads, 0777); + chmod($module_uploads, 0777); + copy($indexFile, XOOPS_ROOT_PATH . "/uploads/" . $modsDirname . "/image/medium/index.html"); + copy($blankFile, XOOPS_ROOT_PATH . "/uploads/" . $modsDirname . "/image/medium/blank.gif"); + } + + //Creation du fichier price dans uploads + $module_uploads = XOOPS_ROOT_PATH . "/uploads/" . $modsDirname . "/image/thumb"; + if (!is_dir($module_uploads)) { + mkdir($module_uploads, 0777); + chmod($module_uploads, 0777); + copy($indexFile, XOOPS_ROOT_PATH . "/uploads/" . $modsDirname . "/image/thumb/index.html"); + copy($blankFile, XOOPS_ROOT_PATH . "/uploads/" . $modsDirname . "/image/thumb/blank.gif"); + } + + //Creation du fichier price dans uploads + $module_uploads = XOOPS_ROOT_PATH . "/uploads/" . $modsDirname . "/file"; + if (!is_dir($module_uploads)) { + mkdir($module_uploads, 0777); + chmod($module_uploads, 0777); + copy($indexFile, XOOPS_ROOT_PATH . "/uploads/" . $modsDirname . "/file/index.html"); + copy($blankFile, XOOPS_ROOT_PATH . "/uploads/" . $modsDirname . "/file/blank.gif"); + } + + $db = $GLOBALS["xoopsDB"]; + $error = false; + + include_once XOOPS_ROOT_PATH . '/modules/news/include/functions.php'; + include_once XOOPS_ROOT_PATH . '/modules/news/class/perm.php'; + include_once XOOPS_ROOT_PATH . '/modules/news/class/utils.php'; + include_once XOOPS_ROOT_PATH . '/class/template.php'; + include_once XOOPS_ROOT_PATH . '/class/xoopstree.php'; + + + + if(!NewsUtils::News_TableExists($db->prefix('news_story'))) + { + $sql = "CREATE TABLE " . $db->prefix('news_story') . " ( + `story_id` int(10) NOT NULL auto_increment, + `story_title` varchar(255) NOT NULL, + `story_subtitle` varchar(255) NOT NULL, + `story_titleview` tinyint(1) NOT NULL default '1', + `story_topic` int(11) NOT NULL, + `story_type` varchar(25) NOT NULL, + `story_short` text NOT NULL, + `story_text` text NOT NULL, + `story_link` varchar(255) NOT NULL, + `story_words` varchar(255) NOT NULL, + `story_desc` varchar(255) NOT NULL, + `story_alias` varchar(255) NOT NULL, + `story_important` tinyint(1) NOT NULL, + `story_default` tinyint(1) NOT NULL, + `story_status` tinyint(1) NOT NULL, + `story_create` int (10) NOT NULL default '0', + `story_update` int (10) NOT NULL default '0', + `story_publish` int (10) NOT NULL default '0', + `story_expire` int (10) NOT NULL default '0', + `story_uid` int(11) NOT NULL, + `story_author` varchar(255) NOT NULL, + `story_source` varchar(255) NOT NULL, + `story_groups` varchar(255) NOT NULL, + `story_order` int(11) NOT NULL, + `story_next` int(11) NOT NULL default '0', + `story_prev` int(11) NOT NULL default '0', + `story_modid` int(11) NOT NULL, + `story_hits` int(11) NOT NULL, + `story_img` varchar(255) NOT NULL, + `story_comments` int(11) unsigned NOT NULL default '0', + `story_file` tinyint(3) NOT NULL, + `dohtml` tinyint(1) NOT NULL, + `dobr` tinyint(1) NOT NULL, + `doimage` tinyint(1) NOT NULL, + `dosmiley` tinyint(1) NOT NULL, + `doxcode` tinyint(1) NOT NULL, + PRIMARY KEY (`story_id`), + KEY `idxstoriestopic` (`story_topic`), + KEY `story_title` (`story_title`), + KEY `story_create` (`story_create`), + FULLTEXT KEY `search` (`story_title`,`story_short`,`story_text`,`story_subtitle`) + ) ENGINE=MyISAM;"; + if (!$db->queryF($sql)) { + echo 'd2'; + return false; + } + } + + if(!NewsUtils::News_TableExists($db->prefix('news_topic'))) + { + $sql = "CREATE TABLE " . $db->prefix('news_topic') . " ( + `topic_id` int (11) unsigned NOT NULL auto_increment, + `topic_pid` int (5) unsigned NOT NULL , + `topic_title` varchar (255) NOT NULL , + `topic_desc` text NOT NULL , + `topic_img` varchar (255) NOT NULL , + `topic_weight` int (5) NOT NULL , + `topic_showtype` tinyint (4) NOT NULL , + `topic_perpage` tinyint (4) NOT NULL , + `topic_columns` tinyint (4) NOT NULL , + `topic_submitter` int (10) NOT NULL default '0', + `topic_date_created` int (10) NOT NULL default '0', + `topic_date_update` int (10) NOT NULL default '0', + `topic_asmenu` tinyint (1) NOT NULL default '1', + `topic_online` tinyint (1) NOT NULL default '1', + `topic_modid` int(11) NOT NULL, + `topic_showtopic` tinyint (1) NOT NULL default '0', + `topic_showauthor` tinyint (1) NOT NULL default '1', + `topic_showdate` tinyint (1) NOT NULL default '1', + `topic_showpdf` tinyint (1) NOT NULL default '1', + `topic_showprint` tinyint (1) NOT NULL default '1', + `topic_showmail` tinyint (1) NOT NULL default '1', + `topic_shownav` tinyint (1) NOT NULL default '1', + `topic_showhits` tinyint (1) NOT NULL default '1', + `topic_showcoms` tinyint (1) NOT NULL default '1', + `topic_alias` varchar(255) NOT NULL, + `topic_homepage` tinyint (4) NOT NULL , + `topic_show` tinyint (1) NOT NULL default '1', + PRIMARY KEY (`topic_id`,`topic_modid`), + UNIQUE KEY `file_id` (`topic_id`,`topic_modid`) + ) ENGINE=MyISAM;"; + if (!$db->queryF($sql)) { + echo 'd3'; + return false; + } + } + + if(!NewsUtils::News_TableExists($db->prefix('news_file'))) + { + $sql = "CREATE TABLE " . $db->prefix('news_file') . " ( + `file_id` int (11) unsigned NOT NULL auto_increment, + `file_modid` int(11) NOT NULL, + `file_title` varchar (255) NOT NULL , + `file_name` varchar (255) NOT NULL , + `file_content` int(11) NOT NULL, + `file_date` int(10) NOT NULL default '0', + `file_type` varchar(64) NOT NULL default '', + `file_status` tinyint(1) NOT NULL, + `file_hits` int(11) NOT NULL, + PRIMARY KEY (`file_id`,`file_modid`), + UNIQUE KEY `file_id` (`file_id`,`file_modid`) + ) ENGINE=MyISAM;"; + if (!$db->queryF($sql)) { + echo 'd4'; + return false; + } + } + + //load needed handler + $module_handler = xoops_gethandler('module'); + $comment_handler = xoops_gethandler('comment'); + $notification_handler = xoops_gethandler('notification'); + $topic_handler = xoops_getmodulehandler('topic', 'news'); + $story_handler = xoops_getmodulehandler('story', 'news'); + $file_handler = xoops_getmodulehandler('file', 'news'); + $newsModule = $module_handler->getByDirname('news'); + $news_mid = $newsModule->getVar('mid'); + + $old_topics = $db->prefix('topics'); + $old_articles = $db->prefix('stories'); + $old_files = $db->prefix('stories_files'); + $old_rating = $db->prefix('stories_votedata'); + + $new_news_topics = array(); + $mytree = new XoopsTree($old_topics,'topic_id','topic_pid'); + $old_topics = $mytree->getChildTreeArray(0,'topic_id'); + + // start + foreach($old_topics as $topic) { + + $topicobj = $topic_handler->create (); + $topicobj->setVar ( 'topic_id', $topic['topic_id'] ); + $topicobj->setVar ( 'topic_pid', $topic['topic_pid'] ); + $topicobj->setVar ( 'topic_title', $topic['topic_title'] ); + $topicobj->setVar ( 'topic_img', $topic['topic_imgurl'] ); + $topicobj->setVar ( 'topic_desc', $topic['topic_description'] ); + $topicobj->setVar ( 'topic_modid', $news_mid); + $topicobj->setVar ( 'topic_alias', NewsUtils::News_AliasFilter($topic['topic_title'])); + + if (! $topic_handler->insert ( $topicobj )) { + return false; + } + + $result = $db->query('SELECT * FROM '.$old_articles.' WHERE topicid = '.$topic['topic_id'].' ORDER BY created'); + + while ( $article = $db->fetchArray($result) ) { + + $storyobj = $story_handler->create (); + $storyobj->setVar ( 'story_id', $article['storyid']); + $storyobj->setVar ( 'story_title', $article['title']); + $storyobj->setVar ( 'story_titleview', '1' ); + $storyobj->setVar ( 'story_topic', $article['topicid']); + $storyobj->setVar ( 'story_type', 'news' ); + $storyobj->setVar ( 'story_short', $article['hometext']); + $storyobj->setVar ( 'story_text', $article['bodytext']); + $storyobj->setVar ( 'story_words', $article['keywords']); + $storyobj->setVar ( 'story_desc', $article['description']); + $storyobj->setVar ( 'story_alias', NewsUtils::News_AliasFilter($article['title'])); + $storyobj->setVar ( 'story_status', '1'); + $storyobj->setVar ( 'story_create', $article['created']); + $storyobj->setVar ( 'story_update', $article['created']); + $storyobj->setVar ( 'story_publish', $article['published']); + $storyobj->setVar ( 'story_expire', $article['expired']); + $storyobj->setVar ( 'story_uid', $article['uid']); + $storyobj->setVar ( 'story_groups', '1 2 3'); + $storyobj->setVar ( 'story_modid', $news_mid ); + $storyobj->setVar ( 'story_hits', $article['counter']); + $storyobj->setVar ( 'story_img', $article['picture']); + $storyobj->setVar ( 'story_comments', $article['comments']); + $storyobj->setVar ( 'dohtml', $article['nohtml']); + //$storyobj->setVar ( 'dobr', $article['']); + //$storyobj->setVar ( 'doimage', $article['']); + $storyobj->setVar ( 'dosmiley', $article['nosmiley']); + //$storyobj->setVar ( 'doxcode', $article['']); + + if (! $story_handler->insert ( $storyobj )) { + return false; + } + + // The files + $result4 = $db->query('SELECT * FROM '.$old_files.' WHERE storyid='.$article['storyid']); + while ( $file = $db->fetchArray($result4) ) { + $fileobj = $file_handler->create (); + $fileobj->setVar ( 'file_id', $file['fileid']); + $fileobj->setVar ( 'file_modid', $news_mid); + $fileobj->setVar ( 'file_title', $file['filerealname']); + $fileobj->setVar ( 'file_name', $file['downloadname']); + $fileobj->setVar ( 'file_content', $file['storyid']); + $fileobj->setVar ( 'file_date', $file['date']); + $fileobj->setVar ( 'file_type', $file['mimetype']); + $fileobj->setVar ( 'file_status', '1'); + $fileobj->setVar ( 'file_hits', $file['counter']); + + if (! $file_handler->insert ( $fileobj )) { + return false; + } + } + + // The comments + $comments = $comment_handler->getByItemId($news_mid, $article['storyid'], 'ASC'); + if(is_array($comments) && count($comments)>0) { + foreach($comments as $onecomment) { + $onecomment->setNew(); + $onecomment->setVar('com_modid',$news_mid); + $onecomment->setVar('com_itemid',$article['storyid']); + $comment_handler->insert($onecomment); + } + } + unset($comments); + } + + } + // end +} + +?> \ No newline at end of file Modified: XoopsModules/fmcontent/branches/news/xoops_version.php =================================================================== --- XoopsModules/fmcontent/branches/news/xoops_version.php 2012-01-10 05:41:35 UTC (rev 8692) +++ XoopsModules/fmcontent/branches/news/xoops_version.php 2012-01-10 08:37:21 UTC (rev 8693) @@ -44,9 +44,9 @@ 'adminindex' => 'admin/index.php', 'adminmenu' => 'admin/menu.php', // Modules scripts - 'onInstall' => 'admin/action.module.php', - 'onUpdate' => 'admin/action.module.php', - 'onUninstall' => 'admin/action.module.php', + 'onInstall' => 'include/functions_install.php', + 'onUpdate' => 'include/functions_update.php', + 'onUninstall' => 'include/functions_uninstall.php', // Main menu 'hasMain' => 1, // Recherche This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |