Minahito
minah****@users*****
2006年 1月 30日 (月) 20:38:12 JST
Index: xoops2jp/html/install/makedata.php diff -u xoops2jp/html/install/makedata.php:1.2.8.1 xoops2jp/html/install/makedata.php:1.2.8.2 --- xoops2jp/html/install/makedata.php:1.2.8.1 Wed Oct 19 02:20:37 2005 +++ xoops2jp/html/install/makedata.php Mon Jan 30 20:38:11 2006 @@ -1,5 +1,5 @@ <?php -// $Id: makedata.php,v 1.2.8.1 2005/10/18 17:20:37 minahito Exp $ +// $Id: makedata.php,v 1.2.8.2 2006/01/30 11:38:11 minahito Exp $ // ------------------------------------------------------------------------ // // XOOPS - PHP Content Management System // // Copyright (c) 2000 XOOPS.org // @@ -89,78 +89,7 @@ // default theme $time = time(); - $dbm->insert('tplset', " VALUES (1, 'default', 'XOOPS Default Template Set', '', ".$time.")"); - - // system modules - - if ( file_exists('../modules/system/language/'.$language.'/modinfo.php') ) { - include '../modules/system/language/'.$language.'/modinfo.php'; - } else { - include '../modules/system/language/english/modinfo.php'; - $language = 'english'; - } - - $modversion = array(); - include_once '../modules/system/xoops_version.php'; - $time = time(); - - // RMV-NOTIFY (updated for extra column in table) - $dbm->insert("modules", " VALUES (1, '"._MI_SYSTEM_NAME."', 100, ".$time.", 0, 1, 'system', 0, 1, 0, 0, 0, 0)"); - - foreach ($modversion['templates'] as $tplfile) { - if ($fp = fopen('../modules/system/templates/'.$tplfile['file'], 'r')) { - $newtplid = $dbm->insert('tplfile', " VALUES (0, 1, 'system', 'default', '".addslashes($tplfile['file'])."', '".addslashes($tplfile['description'])."', ".$time.", ".$time.", 'module')"); - //$newtplid = $xoopsDB->getInsertId(); - $tplsource = fread($fp, filesize('../modules/system/templates/'.$tplfile['file'])); - fclose($fp); - $dbm->insert('tplsource', " (tpl_id, tpl_source) VALUES (".$newtplid.", '".addslashes($tplsource)."')"); - } - } - - foreach ($modversion['blocks'] as $func_num => $newblock) { - if ($fp = fopen('../modules/system/templates/blocks/'.$newblock['template'], 'r')) { - if (in_array($newblock['template'], array('system_block_user.html', 'system_block_login.html', 'system_block_mainmenu.html'))) { - $visible = 1; - } else { - $visible = 0; - } - $options = !isset($newblock['options']) ? '' : trim($newblock['options']); - $edit_func = !isset($newblock['edit_func']) ? '' : trim($newblock['edit_func']); - $newbid = $dbm->insert('newblocks', " VALUES (0, 1, ".$func_num.", '".addslashes($options)."', '".addslashes($newblock['name'])."', '".addslashes($newblock['name'])."', '', 0, 0, ".$visible.", 'S', 'H', 1, 'system', '".addslashes($newblock['file'])."', '".addslashes($newblock['show_func'])."', '".addslashes($edit_func)."', '".addslashes($newblock['template'])."', 0, ".$time.")"); - //$newbid = $xoopsDB->getInsertId(); - $newtplid = $dbm->insert('tplfile', " VALUES (0, ".$newbid.", 'system', 'default', '".addslashes($newblock['template'])."', '".addslashes($newblock['description'])."', ".$time.", ".$time.", 'block')"); - //$newtplid = $xoopsDB->getInsertId(); - $tplsource = fread($fp, filesize('../modules/system/templates/blocks/'.$newblock['template'])); - fclose($fp); - $dbm->insert('tplsource', " (tpl_id, tpl_source) VALUES (".$newtplid.", '".addslashes($tplsource)."')"); - $dbm->insert("group_permission", " VALUES (0, ".$gruops['XOOPS_GROUP_ADMIN'].", ".$newbid.", 1, 'block_read')"); - //$dbm->insert("group_permission", " VALUES (0, ".$gruops['XOOPS_GROUP_ADMIN'].", ".$newbid.", 'xoops_blockadmiin')"); - $dbm->insert("group_permission", " VALUES (0, ".$gruops['XOOPS_GROUP_USERS'].", ".$newbid.", 1, 'block_read')"); - $dbm->insert("group_permission", " VALUES (0, ".$gruops['XOOPS_GROUP_ANONYMOUS'].", ".$newbid.", 1, 'block_read')"); - } - } - - // data for table 'users' - - $temp = md5($adminpass); - $regdate = time(); - //$dbadminname= addslashes($adminname); - // RMV-NOTIFY (updated for extra columns in user table) - $dbm->insert('users', " VALUES (1,'','".addslashes($adminname)."','".addslashes($adminmail)."','".XOOPS_URL."/','blank.gif','".$regdate."','','','',1,'','','','','".$temp."',0,0,7,5,'default','0.0',".time().",'thread',0,1,0,'','','',0)"); - - - // data for table 'block_module_link' - - $sql = 'SELECT bid, side FROM '.$dbm->prefix('newblocks'); - $result = $dbm->query($sql); - - while ($myrow = $dbm->fetchArray($result)) { - if ($myrow['side'] == 0) { - $dbm->insert("block_module_link", " VALUES (".$myrow['bid'].", 0)"); - } else { - $dbm->insert("block_module_link", " VALUES (".$myrow['bid'].", -1)"); - } - } + $dbm->insert('tplset', " VALUES (1, 'default', 'XOOPS Cube Default Template Set', '', ".$time.")"); // data for table 'config' @@ -238,10 +167,168 @@ // RMV-NOTIFY... Need to specify which user is sender of notification PM $dbm->insert('config', " VALUES (73,0,6,'fromuid','_MD_AM_MAILFROMUID','1','_MD_AM_MAILFROMUIDDESC','user','int',3)"); + // install modules + installModule($dbm, 1, "system", _MI_SYSTEM_NAME, $language, $gruops); + + installModule($dbm, 2, "base", _MI_BASE_NAME, $language, $gruops, true); + $dbm->insert("group_permission", " VALUES (0, ".$gruops['XOOPS_GROUP_ADMIN'].", 2, 1, 'module_admin')"); + + installModule($dbm, 3, "legacyRender", _MI_LEGACYRENDER_NAME, $language, $gruops, true); + $dbm->insert("group_permission", " VALUES (0, ".$gruops['XOOPS_GROUP_ADMIN'].", 3, 1, 'module_admin')"); + + installModule($dbm, 4, "user", _MI_USER_NAME, $language, $gruops, true); + $dbm->insert("group_permission", " VALUES (0, ".$gruops['XOOPS_GROUP_ADMIN'].", 4, 1, 'module_admin')"); + $dbm->insert("group_permission", " VALUES (0, ".$gruops['XOOPS_GROUP_ADMIN'].", 4, 1, 'module_read')"); + $dbm->insert("group_permission", " VALUES (0, ".$gruops['XOOPS_GROUP_USERS'].", 4, 1, 'module_read')"); + $dbm->insert("group_permission", " VALUES (0, ".$gruops['XOOPS_GROUP_ANONYMOUS'].", 4, 1, 'module_read')"); + + installModule($dbm, 5, "pm", _MI_PM_NAME, $language, $gruops, true); + $dbm->insert("group_permission", " VALUES (0, ".$gruops['XOOPS_GROUP_ADMIN'].", 5, 1, 'module_admin')"); + $dbm->insert("group_permission", " VALUES (0, ".$gruops['XOOPS_GROUP_ADMIN'].", 5, 1, 'module_read')"); + $dbm->insert("group_permission", " VALUES (0, ".$gruops['XOOPS_GROUP_USERS'].", 5, 1, 'module_read')"); + + installModule($dbm, 6, "stdCache", _MI_STDCACHE_NAME, $language, $gruops, true); + $dbm->insert("group_permission", " VALUES (0, ".$gruops['XOOPS_GROUP_ADMIN'].", 6, 1, 'module_admin')"); + + // data for table 'users' + + $temp = md5($adminpass); + $regdate = time(); + //$dbadminname= addslashes($adminname); + // RMV-NOTIFY (updated for extra columns in user table) + $dbm->insert('users', " VALUES (1,'','".addslashes($adminname)."','".addslashes($adminmail)."','".XOOPS_URL."/','blank.gif','".$regdate."','','','',1,'','','','','".$temp."',0,0,7,5,'default','0.0',".time().",'thread',0,1,0,'','','',0)"); + + + // data for table 'block_module_link' + + $sql = 'SELECT bid, side FROM '.$dbm->prefix('newblocks'); + $result = $dbm->query($sql); + + while ($myrow = $dbm->fetchArray($result)) { + if ($myrow['side'] == 0) { + $dbm->insert("block_module_link", " VALUES (".$myrow['bid'].", 0)"); + } else { + $dbm->insert("block_module_link", " VALUES (".$myrow['bid'].", -1)"); + } + } return $gruops; } +/** + * + * Install module by module's name, language and specified mid. + * + * @param $dbm object Database manager instance + * @param $mid int module's ID + * @param $module string module's name + * @param $language string language + * @param $grops array hash map + */ +function installModule(&$dbm, $mid, $module, $module_name, $language = 'english', &$groups) { + if ( file_exists("../modules/${module}/language/${language}/modinfo.php") ) { + include "../modules/${module}/language/${language}/modinfo.php"; + } else { + include "../modules/${module}/language/english/modinfo.php"; + $language = 'english'; + } + $modversion = array(); + require_once "../modules/${module}/xoops_version.php"; + $time = time(); + + // RMV-NOTIFY (updated for extra column in table) + $dbm->insert("modules", " VALUES (${mid}, '" . constant($module_name) . "', 100, ".$time.", 0, 1, '${module}', 0, 1, 0, 0, 0, 0)"); + + if (is_array($modversion['templates']) && count($modversion['templates']) > 0) { + foreach ($modversion['templates'] as $tplfile) { + if ($fp = fopen("../modules/${module}/templates/".$tplfile['file'], 'r')) { + $newtplid = $dbm->insert('tplfile', " VALUES (0, ${mid}, '${module}', 'default', '".addslashes($tplfile['file'])."', '".addslashes($tplfile['description'])."', ".$time.", ".$time.", 'module')"); + //$newtplid = $xoopsDB->getInsertId(); + if (filesize("../modules/${module}/templates/".$tplfile['file']) > 0) { + $tplsource = fread($fp, filesize("../modules/${module}/templates/".$tplfile['file'])); + } + else { + $tplsource = ""; + } + fclose($fp); + $dbm->insert('tplsource', " (tpl_id, tpl_source) VALUES (".$newtplid.", '".addslashes($tplsource)."')"); + } + } + } + + if (is_array($modversion['blocks']) && count($modversion['blocks']) > 0) { + foreach ($modversion['blocks'] as $func_num => $newblock) { + if ($fp = fopen("../modules/${module}/templates/blocks/".$newblock['template'], 'r')) { + // + // The following checking is dependence on the structure of system module. + // + if (in_array($newblock['template'], array('system_block_user.html', 'system_block_login.html', 'system_block_mainmenu.html'))) { + $visible = 1; + } else { + $visible = 0; + } + $options = !isset($newblock['options']) ? '' : trim($newblock['options']); + $edit_func = !isset($newblock['edit_func']) ? '' : trim($newblock['edit_func']); + $newbid = $dbm->insert('newblocks', " VALUES (0, ${mid}, ".$func_num.", '".addslashes($options)."', '".addslashes($newblock['name'])."', '".addslashes($newblock['name'])."', '', 0, 0, ".$visible.", 'S', 'H', 1, '${module}', '".addslashes($newblock['file'])."', '".addslashes($newblock['show_func'])."', '".addslashes($edit_func)."', '".addslashes($newblock['template'])."', 0, ".$time.")"); + //$newbid = $xoopsDB->getInsertId(); + $newtplid = $dbm->insert('tplfile', " VALUES (0, ".$newbid.", '${module}', 'default', '".addslashes($newblock['template'])."', '".addslashes($newblock['description'])."', ".$time.", ".$time.", 'block')"); + //$newtplid = $xoopsDB->getInsertId(); + if (filesize("../modules/${module}/templates/blocks/".$newblock['template']) > 0) { + $tplsource = fread($fp, filesize("../modules/${module}/templates/blocks/".$newblock['template'])); + } + else { + $tplsource = ""; + } + fclose($fp); + $dbm->insert('tplsource', " (tpl_id, tpl_source) VALUES (".$newtplid.", '".addslashes($tplsource)."')"); + + $dbm->insert("group_permission", " VALUES (0, ".$groups['XOOPS_GROUP_ADMIN'].", ".$newbid.", 1, 'block_read')"); + //$dbm->insert("group_permission", " VALUES (0, ".$gruops['XOOPS_GROUP_ADMIN'].", ".$newbid.", 'xoops_blockadmiin')"); + $dbm->insert("group_permission", " VALUES (0, ".$groups['XOOPS_GROUP_USERS'].", ".$newbid.", 1, 'block_read')"); + $dbm->insert("group_permission", " VALUES (0, ".$groups['XOOPS_GROUP_ANONYMOUS'].", ".$newbid.", 1, 'block_read')"); + } + } + } + + // + // Install preferences + // + if (isset($modversion['config'])) { + require_once "../mainfile.php"; + require_once "../include/common.php"; + + global $xoopsDB; + + $configHandler =& new XoopsConfigHandler($xoopsDB); + + $count = 0; + foreach ($modversion['config'] as $configInfo) { + // + // TODO We have to sanitize. + // + $name = $configInfo['name']; + $title = $configInfo['title']; + $desc = $configInfo['description']; + $formtype = $configInfo['formtype']; + $valuetype = $configInfo['valuetype']; + $default = $configInfo['default']; + + if ($valuetype == "array") { + $default = serialize(explode('|', trim($default))); + } + + $conf_id = $dbm->insert("config", " VALUES (0, ${mid}, 0, '${name}', '${title}', '${default}', '${desc}', '${formtype}', '${valuetype}', ${count})"); + + if (isset($configInfo['options']) && is_array($configInfo['options'])) { + foreach ($configInfo['options'] as $key => $value) { + $dbm->insert("configoption", " VALUES (0, '${key}', '${value}', ${conf_id})"); + } + } + + $count++; + } + } +} ?>