function xoops_module_update_smartsection($module) { // Load SmartDbUpdater from the SmartObject Framework if present $smartdbupdater = XOOPS_ROOT_PATH . "/modules/smartsection/class/smartdbupdater.php"; include_once $smartdbupdater; $dbupdater = new SmartobjectDbupdater(); ob_start(); echo "<code>" . _SDU_UPDATE_UPDATING_DATABASE . "<br />"; // Adding partial_view field $table = new SmartDbTable('smartsection_items'); if (!$table->fieldExists('partial_view')) { $table->addNewField('partial_view', "varchar(255) NOT NULL default ''"); } else { $table->addAlteredField('partial_view', "varchar(255) NOT NULL default ''"); } if (!$dbupdater->updateTable($table)) { /** * @todo trap the errors */ } unset($table); /** * Check for items with categoryid=0 */ @($smartsection_item_handler = xoops_getmodulehandler('item', 'smartsection')); @($smartsection_category_handler = xoops_getmodulehandler('category', 'smartsection')); if ($smartsection_item_handler) { //find a valid categoryid $categoriesObj = $smartsection_category_handler->getCategories(1, 0, 0, 'weight', 'ASC', false); if (count($categoriesObj) > 0) { $categoryid = $categoriesObj[0]->getVar('categoryid'); $criteria = new CriteriaCompo(); $criteria->add(new Criteria('categoryid', 0)); $smartsection_item_handler->updateAll('categoryid', $categoryid, $criteria); echo " Cleaning up items for with categoryid=0<br />"; } } // Adding item_tag field in smartsection_items $table = new SmartDbTable('smartsection_items'); if (!$table->fieldExists('item_tag')) { $table->addNewField('item_tag', "TEXT NOT NULL"); } if ($table->fieldExists('tags')) { $table->addDropedField('tags'); } if (!$dbupdater->updateTable($table)) { /** * @todo trap the errors */ } unset($table); echo "</code>"; $feedback = ob_get_clean(); if (method_exists($module, "setMessage")) { $module->setMessage($feedback); } else { echo $feedback; } return true; }
function xoops_module_update_smartobject($module) { ob_start(); $dbVersion = smart_GetMeta('version', 'smartobject'); if (!$dbVersion) { $dbVersion = 0; } $dbupdater = new SmartobjectDbupdater(); echo "<code>" . _SDU_UPDATE_UPDATING_DATABASE . "<br />"; // db migrate version = 1 $newDbVersion = 1; if ($dbVersion < $newDbVersion) { echo "Database migrate to version " . $newDbVersion . "<br />"; // Create table smartobject_link $table = new SmartDbTable('smartobject_link'); if (!$table->exists()) { $table->setStructure("CREATE TABLE %s (\n\t\t\t `linkid` int(11) NOT NULL auto_increment,\n\t\t\t `from_uid` int(11) NOT NULL default '0',\n\t\t\t `from_email` varchar(255) NOT NULL default '',\n\t\t\t `from_name` varchar(255) NOT NULL default '',\n\t\t\t `to_uid` int(11) NOT NULL default '0',\n\t\t\t `to_email` varchar(255) NOT NULL default '',\n\t\t\t `to_name` varchar(255) NOT NULL default '',\n\t\t\t `link` varchar(255) NOT NULL default '',\n\t\t\t `subject` varchar(255) NOT NULL default '',\n\t\t\t `body` TEXT NOT NULL,\n\t\t\t `mid` int(11) NOT NULL default '0',\n\t\t\t `mid_name` varchar(255) NOT NULL default '',\n\n\t\t\t PRIMARY KEY (`linkid`)\n\t\t\t) TYPE=MyISAM COMMENT='SmartObject by The SmartFactory <www.smartfactory.ca>' AUTO_INCREMENT=1 ;"); if (!$dbupdater->updateTable($table)) { /** * @todo trap the errors */ } } unset($table); $table = new SmartDbTable('smartobject_link'); if (!$table->fieldExists('date')) { $table->addNewField('date', "int(11) NOT NULL default '0'"); if (!$dbupdater->updateTable($table)) { /** * @todo trap the errors */ } } unset($table); // Create table smartobject_tag $table = new SmartDbTable('smartobject_tag'); if (!$table->exists()) { $table->setStructure("CREATE TABLE %s (\n\t\t `tagid` int(11) NOT NULL auto_increment,\n\t\t\t `name` varchar(255) NOT NULL default '',\n\t\t\t `description` TEXT NOT NULL,\n\t\t\t PRIMARY KEY (`id`)\n\t\t\t) TYPE=MyISAM COMMENT='SmartObject by The SmartFactory <www.smartfactory.ca>' AUTO_INCREMENT=1 ;"); if (!$dbupdater->updateTable($table)) { /** * @todo trap the errors */ } } // Create table smartobject_tag_text $table = new SmartDbTable('smartobject_tag_text'); if (!$table->exists()) { $table->setStructure("CREATE TABLE %s (\n\t\t\t `tagid` int(11) NOT NULL default 0,\n\t\t\t `language` varchar(255) NOT NULL default '',\n\t\t\t `value` TEXT NOT NULL,\n\t\t\t PRIMARY KEY (`id`, `language`)\n\t\t\t) TYPE=MyISAM COMMENT='SmartObject by The SmartFactory <www.smartfactory.ca>' AUTO_INCREMENT=1 ;"); if (!$dbupdater->updateTable($table)) { /** * @todo trap the errors */ } } // Create table smartobject_adsense $table = new SmartDbTable('smartobject_adsense'); if (!$table->exists()) { $table->setStructure("\n `adsenseid` int(11) NOT NULL auto_increment,\n `format` VARCHAR(100) NOT NULL,\n `description` TEXT NOT NULL,\n `style` TEXT NOT NULL,\n `border_color` varchar(6) NOT NULL default '',\n `background_color` varchar(6) NOT NULL default '',\n `link_color` varchar(6) NOT NULL default '',\n `url_color` varchar(6) NOT NULL default '',\n `text_color` varchar(6) NOT NULL default '',\n `client_id` varchar(100) NOT NULL default '',\n `tag` varchar(50) NOT NULL default '',\n PRIMARY KEY (`adsenseid`)\n\t\t\t"); } if (!$dbupdater->updateTable($table)) { /** * @todo trap the errors */ } } // db migrate version = 2 $newDbVersion = 2; if ($dbVersion < $newDbVersion) { echo "Database migrate to version " . $newDbVersion . "<br />"; // Create table smartobject_adsense $table = new SmartDbTable('smartobject_rating'); if (!$table->exists()) { $table->setStructure("\n `ratingid` int(11) NOT NULL auto_increment,\n `dirname` VARCHAR(255) NOT NULL,\n `item` VARCHAR(255) NOT NULL,\n `itemid` int(11) NOT NULL,\n `uid` int(11) NOT NULL,\n `rate` int(1) NOT NULL,\n `date` int(11) NOT NULL,\n PRIMARY KEY (`ratingid`),\n UNIQUE (`dirname`, `item`, `itemid`, `uid`)\n\t\t\t"); } if (!$dbupdater->updateTable($table)) { /** * @todo trap the errors */ } // Create table smartobject_adsense $table = new SmartDbTable('smartobject_currency'); $table->setData("2, 'EUR', 'Euro', '€', 0.65, 0"); $table->setData("3, 'USD', 'American dollar', '\$', 0.9, 0"); $table->setData("1, 'CAD', 'Canadian dollar', '\$', 1, 1"); if (!$dbupdater->updateTable($table)) { /** * @todo trap the errors */ } } // db migrate version = 3 $newDbVersion = 3; if ($dbVersion < $newDbVersion) { echo "Database migrate to version " . $newDbVersion . "<br />"; // Create table smartobject_adsense $table = new SmartDbTable('smartobject_customtag'); if (!$table->exists()) { $table->setStructure("\n\t\t\t `customtagid` int(11) NOT NULL auto_increment,\n\t\t\t `name` VARCHAR(255) NOT NULL,\n\t\t\t `description` TEXT NOT NULL,\n\t\t\t `content` TEXT NOT NULL,\n\t\t\t `language` TEXT NOT NULL,\n\t\t\t PRIMARY KEY (`customtagid`)\n\t\t\t"); } if (!$dbupdater->updateTable($table)) { /** * @todo trap the errors */ } } // db migrate version = 4 $newDbVersion = 4; if ($dbVersion < $newDbVersion) { echo "Database migrate to version " . $newDbVersion . "<br />"; // Create table smartobject_adsense $table = new SmartDbTable('smartobject_currency'); if (!$table->exists()) { $table->setStructure("\n\t\t\t `currencyid` int(11) NOT NULL auto_increment,\n\t\t\t `iso4217` VARCHAR(5) NOT NULL,\n\t\t\t `name` VARCHAR(255) NOT NULL,\n\t\t\t `symbol` VARCHAR(1) NOT NULL,\n\t\t\t `rate` float NOT NULL,\n\t\t\t `default_currency` int(1) NOT NULL,\n\t\t\t PRIMARY KEY (`currencyid`)\n\t\t\t"); } if (!$dbupdater->updateTable($table)) { /** * @todo trap the errors */ } } // db migrate version = 6 $newDbVersion = 6; if ($dbVersion < $newDbVersion) { echo "Database migrate to version " . $newDbVersion . "<br />"; } $newDbVersion = 7; if ($dbVersion < $newDbVersion) { echo "Database migrate to version " . $newDbVersion . "<br />"; // Create table smartobject_link $table = new SmartDbTable('smartobject_file'); if (!$table->exists()) { $table->setStructure("\n\t\t\t `fileid` int(11) NOT NULL auto_increment,\n\t\t\t `caption` varchar(255) collate latin1_general_ci NOT NULL,\n\t\t\t `url` varchar(255) collate latin1_general_ci NOT NULL,\n\t\t\t `description` text collate latin1_general_ci NOT NULL,\n\t\t\t PRIMARY KEY (`fileid`)\n\t\t\t"); if (!$dbupdater->updateTable($table)) { /** * @todo trap the errors */ } } unset($table); $table = new SmartDbTable('smartobject_urllink'); if (!$table->exists()) { $table->setStructure("\n\t\t\t `urllinkid` int(11) NOT NULL auto_increment,\n\t\t\t `caption` varchar(255) collate latin1_general_ci NOT NULL,\n\t\t\t `url` varchar(255) collate latin1_general_ci NOT NULL,\n\t\t\t `description` text collate latin1_general_ci NOT NULL,\n\t\t\t `target` varchar(10) collate latin1_general_ci NOT NULL,\n \t\t\t PRIMARY KEY (`urllinkid`)\n\t\t\t"); if (!$dbupdater->updateTable($table)) { /** * @todo trap the errors */ } } unset($table); } echo "</code>"; $feedback = ob_get_clean(); if (method_exists($module, "setMessage")) { $module->setMessage($feedback); } else { echo $feedback; } smart_SetMeta("version", $newDbVersion, "smartobject"); //Set meta version to current return true; }
function xoops_module_update_smartfaq($module) { // Load SmartDbUpdater from the SmartObject Framework if present $smartdbupdater = XOOPS_ROOT_PATH . "/modules/smartobject/class/smartdbupdater.php"; if (!file_exists($smartdbupdater)) { $smartdbupdater = XOOPS_ROOT_PATH . "/modules/smartfaq/class/smartdbupdater.php"; } include_once $smartdbupdater; $dbupdater = new SmartobjectDbupdater(); ob_start(); echo "<code>" . _SDU_UPDATE_UPDATING_DATABASE . "<br />"; // Adding partialview field $table = new SmartDbTable('smartfaq_faq'); if (!$table->fieldExists('partialview')) { $table->addNewField('partialview', "tinyint(1) NOT NULL default '0'"); } // Changing categoryid type to int(11) $table->addAlteredField('categoryid', "int(11) NOT NULL default '0'", false); if (!$dbupdater->updateTable($table)) { /** * @todo trap the errors */ } unset($table); // Editing smartfaq_categories table $table = new SmartDbTable('smartfaq_categories'); // Changing categoryid type to int(11) $table->addAlteredField('categoryid', "int(11) NOT NULL default '0'", false); // Changing parentid type to int(11) $table->addAlteredField('parentid', "int(11) NOT NULL default '0'", false); if (!$dbupdater->updateTable($table)) { /** * @todo trap the errors */ } unset($table); // Editing smartfaq_answers table $table = new SmartDbTable('smartfaq_answers'); // Changing categoryid type to int(11) $table->addAlteredField('answerid', "int(11) NOT NULL default '0'", false); // Changing parentid type to int(11) $table->addAlteredField('faqid', "int(11) NOT NULL default '0'", false); if (!$dbupdater->updateTable($table)) { /** * @todo trap the errors */ } unset($table); /** * Check for items with categoryid=0 */ include_once XOOPS_ROOT_PATH . "/modules/smartfaq/include/functions.php"; $smartfaq_faq_handler = $answer_handler =& sf_gethandler('faq'); $smartfaq_category_handler = $answer_handler =& sf_gethandler('category'); //find a valid categoryid $categoriesObj = $smartfaq_category_handler->getCategories(1, 0, 0, 'weight', 'ASC', false); if (count($categoriesObj) > 0) { $categoryid = $categoriesObj[0]->getVar('categoryid'); $criteria = new CriteriaCompo(); $criteria->add(new Criteria('categoryid', 0)); $smartfaq_faq_handler->updateAll('categoryid', $categoryid, $criteria); echo " Cleaning up questions with categoryid=0<br />"; } echo "</code>"; $feedback = ob_get_clean(); if (method_exists($module, "setMessage")) { $module->setMessage($feedback); } else { echo $feedback; } return true; }