11unset( $xoopsOption[
'nocommon'] );
13include_once
'../mainfile.php';
15error_reporting( E_ERROR );
19echo
'<h2>wizard/install_updateModules_go.inc</h2>';
21$module_handler =& xoops_gethandler(
'module' );
22$modules =& $module_handler->getObjects(
null,
true );
23foreach ( array_keys( $modules ) as $mid ) {
24 echo
'<h5>' . $modules[ $mid ]->getVar(
'name' ) .
'</h5>';
25 $dirname = $modules[ $mid ]->getVar(
'dirname' );
26 if ( is_dir( XOOPS_ROOT_PATH .
'/modules/' . $dirname ) ) {
27 $modules[ $mid ]->loadInfoAsVar( $dirname,
false );
28 if ( ! $module_handler->insert( $modules[ $mid ] ) ) {
29 echo
'<p>Could not update ' . $modules[ $mid ]->getVar(
'name' ) .
'</p>';
31 $newmid = $modules[ $mid ]->getVar(
'mid' );
33 $msgs[] =
'Module data updated.';
34 $tplfile_handler =& xoops_gethandler(
'tplfile' );
35 $templates = $modules[ $mid ]->getInfo(
'templates' );
36 if (
false !== $templates ) {
37 $msgs[] =
'Generating templates...';
38 foreach ( $templates as $tpl ) {
39 $tpl[
'file'] = trim( $tpl[
'file'] );
40 $tpldata =& xoops_module_gettemplate( $dirname, $tpl[
'file'] );
41 $tplfile =& $tplfile_handler->create();
42 $tplfile->setVar(
'tpl_refid', $newmid );
43 $tplfile->setVar(
'tpl_lastimported', 0 );
44 $tplfile->setVar(
'tpl_lastmodified', time() );
45 if ( preg_match(
"/\.css$/i", $tpl[
'file'] ) ) {
46 $tplfile->setVar(
'tpl_type',
'css' );
48 $tplfile->setVar(
'tpl_type',
'module' );
50 $tplfile->setVar(
'tpl_source', $tpldata,
true );
51 $tplfile->setVar(
'tpl_module', $dirname );
52 $tplfile->setVar(
'tpl_tplset',
'default' );
53 $tplfile->setVar(
'tpl_file', $tpl[
'file'],
true );
54 $tplfile->setVar(
'tpl_desc', $tpl[
'description'],
true );
55 if ( ! $tplfile_handler->insert( $tplfile ) ) {
56 $msgs[] =
' <span style="color:#ff0000;">ERROR: Could not insert template <b>' . $tpl[
'file'] .
'</b> to the database.</span>';
58 $msgs[] =
' Template <b>' . $tpl[
'file'] .
'</b> inserted to the database.';
63 $blocks = $modules[ $mid ]->getInfo(
'blocks' );
64 $msgs[] =
'Rebuilding blocks...';
67 if (
false != $blocks ) {
68 $count = is_countable($blocks) ? count( $blocks ) : 0;
69 include_once( XOOPS_ROOT_PATH .
'/class/xoopsblock.php' );
70 for ( $i = 1; $i <= $count; $i ++ ) {
71 if ( isset( $blocks[ $i ][
'show_func'] ) &&
'' !== $blocks[ $i ][
'show_func'] && isset( $blocks[ $i ][
'file'] ) && (
'' !== $blocks[ $i ][
'file'] ) ) {
72 $editfunc = $blocks[ $i ][
'edit_func'] ??
'';
73 $showfuncs[] = $blocks[ $i ][
'show_func'];
74 $funcfiles[] = $blocks[ $i ][
'file'];
76 if ( ( isset( $blocks[ $i ][
'template'] ) && (
'' !== trim( $blocks[ $i ][
'template'] ) ) ) ) {
77 $content =& xoops_module_gettemplate( $dirname, $blocks[ $i ][
'template'],
true );
78 $template = $blocks[ $i ][
'template'];
84 if ( isset( $blocks[ $i ][
'options'] ) && ( $blocks[ $i ][
'options'] !==
'' ) ) {
85 $options = $blocks[ $i ][
'options'];
87 $sql =
'SELECT bid, name FROM ' . $xoopsDB->prefix(
'newblocks' ) .
' WHERE mid=' . $mid .
' AND func_num=' . $i;
88 $fresult = $xoopsDB->query( $sql );
90 while ( $fblock = $xoopsDB->fetchArray( $fresult ) ) {
93 . $xoopsDB->prefix(
'newblocks' ) .
" SET name='" . addslashes( $blocks[ $i ][
'name'] ) .
"', title='" . addslashes( $blocks[ $i ][
'name'] ) .
"', dirname='" . addslashes( $dirname ) .
"', func_file='" . addslashes( $blocks[ $i ][
'file'] ) .
"', show_func='" . addslashes( $blocks[ $i ][
'show_func'] ) .
"', template='" . addslashes( $template ) .
"', edit_func='" . addslashes( $editfunc ) .
"', options='" . addslashes( $options ) .
"', content='', template='" . $template .
"', last_modified=" . time() .
' WHERE bid='
95 $result = $xoopsDB->query( $sql );
97 $msgs[] =
' ERROR: Could not update ' . $fblock[
'name'];
99 $msgs[] =
' Block <b>' . $fblock[
'name'] .
'</b> updated. Block ID: <b>' . $fblock[
'bid'] .
'</b>';
100 if (
'' != $template ) {
101 $tplfile =& $tplfile_handler->create();
102 $tplfile->setVar(
'tpl_refid', $fblock[
'bid'] );
103 $tplfile->setVar(
'tpl_source', $content,
true );
104 $tplfile->setVar(
'tpl_tplset',
'default' );
105 $tplfile->setVar(
'tpl_file', $blocks[ $i ][
'template'] );
106 $tplfile->setVar(
'tpl_module', $dirname );
107 $tplfile->setVar(
'tpl_type',
'block' );
108 $tplfile->setVar(
'tpl_desc', $blocks[ $i ][
'description'],
true );
109 $tplfile->setVar(
'tpl_lastimported', 0 );
110 $tplfile->setVar(
'tpl_lastmodified', time() );
111 if ( ! $tplfile_handler->insert( $tplfile ) ) {
112 $msgs[] =
' <span style="color:#ff0000;">ERROR: Could not insert template <b>' . $blocks[ $i ][
'template'] .
'</b> to the database.</span>';
114 $msgs[] =
' Template <b>' . $blocks[ $i ][
'template'] .
'</b> inserted to the database.';
119 if ( 0 === $fcount ) {
120 $newbid = $xoopsDB->genId( $xoopsDB->prefix(
'newblocks' ) .
'_bid_seq' );
121 $block_name = addslashes( $blocks[ $i ][
'name'] );
122 $sql =
'INSERT INTO '
123 . $xoopsDB->prefix(
'newblocks' ) .
' (bid, mid, func_num, options, name, title, content, side, weight, visible, block_type, isactive, dirname, func_file, show_func, edit_func, template, last_modified) VALUES ('
126 . $i .
",'" . addslashes( $options ) .
"','" . $block_name .
"', '" . $block_name .
"', '', 0, 0, 0, 'M', 1, '" . addslashes( $dirname ) .
"', '" . addslashes( $blocks[ $i ][
'file'] ) .
"', '" . addslashes( $blocks[ $i ][
'show_func'] ) .
"', '" . addslashes( $editfunc ) .
"', '" . $template .
"', " . time() .
')';
127 $result = $xoopsDB->query( $sql );
129 $msgs[] =
' ERROR: Could not create ' . $blocks[ $i ][
'name'];
131 if ( empty( $newbid ) ) {
132 $newbid = $xoopsDB->getInsertId();
134 if (
'' !== $template ) {
135 $tplfile =& $tplfile_handler->create();
136 $tplfile->setVar(
'tpl_module', $dirname );
137 $tplfile->setVar(
'tpl_refid', $newbid );
138 $tplfile->setVar(
'tpl_source', $content,
true );
139 $tplfile->setVar(
'tpl_tplset',
'default' );
140 $tplfile->setVar(
'tpl_file', $blocks[ $i ][
'template'],
true );
141 $tplfile->setVar(
'tpl_type',
'block' );
142 $tplfile->setVar(
'tpl_lastimported', 0 );
143 $tplfile->setVar(
'tpl_lastmodified', time() );
144 $tplfile->setVar(
'tpl_desc', $blocks[ $i ][
'description'],
true );
145 if ( ! $tplfile_handler->insert( $tplfile ) ) {
146 $msgs[] =
' <span style="color:#ff0000;">ERROR: Could not insert template <b>' . $blocks[ $i ][
'template'] .
'</b> to the database.</span>';
148 $msgs[] =
' Template <b>' . $blocks[ $i ][
'template'] .
'</b> inserted to the database.';
151 $msgs[] =
' Block <b>' . $blocks[ $i ][
'name'] .
'</b> created. Block ID: <b>' . $newbid .
'</b>';
157 $block_arr = XoopsBlock::sGetByModule( $mid );
158 foreach ( $block_arr as $block ) {
159 if ( ! in_array( $block->getVar(
'show_func' ), $showfuncs,
true ) || ! in_array( $block->getVar(
'func_file' ), $funcfiles,
true ) ) {
160 $sql = sprintf(
'DELETE FROM %s WHERE bid = %u', $xoopsDB->prefix(
'newblocks' ), $block->getVar(
'bid' ) );
161 if ( ! $xoopsDB->query( $sql ) ) {
162 $msgs[] =
' <span style="color:#ff0000;">ERROR: Could not delete block <b>' . $block->getVar(
'name' ) .
'</b>. Block ID: <b>' . $block->getVar(
'bid' ) .
'</b></span>';
164 $msgs[] =
' Block <b>' . $block->getVar(
'name' ) .
' deleted. Block ID: <b>' . $block->getVar(
'bid' ) .
'</b>';
169 $configs = $modules[ $mid ]->getInfo(
'config' );
170 if (
false !== $configs ) {
171 if ( 0 !== $modules[ $mid ]->getVar(
'hascomments' ) ) {
173 include_once( XOOPS_ROOT_PATH .
'/include/comment_constants.php' );
175 $configs[] = [
'name' =>
'com_rule',
176 'title' =>
'_CM_COMRULES',
178 'formtype' =>
'select',
179 'valuetype' =>
'int',
181 'options' => [
'_CM_COMAPPROVEALL' => XOOPS_COMMENT_APPROVEALL,
182 '_CM_COMAPPROVEUSER' => XOOPS_COMMENT_APPROVEUSER,
183 '_CM_COMAPPROVEADMIN' => XOOPS_COMMENT_APPROVEADMIN
186 $configs[] = [
'name' =>
'com_anonpost',
187 'title' =>
'_CM_COMANONPOST',
189 'formtype' =>
'yesno',
190 'valuetype' =>
'int',
195 if ( 0 != $modules[ $mid ]->getVar(
'hascomments' ) ) {
198 include_once( XOOPS_ROOT_PATH .
'/include/comment_constants.php' );
200 $configs[] = [
'name' =>
'com_rule',
201 'title' =>
'_CM_COMRULES',
203 'formtype' =>
'select',
204 'valuetype' =>
'int',
206 'options' => [
'_CM_COMAPPROVEALL' => XOOPS_COMMENT_APPROVEALL,
207 '_CM_COMAPPROVEUSER' => XOOPS_COMMENT_APPROVEUSER,
208 '_CM_COMAPPROVEADMIN' => XOOPS_COMMENT_APPROVEADMIN
211 $configs[] = [
'name' =>
'com_anonpost',
212 'title' =>
'_CM_COMANONPOST',
214 'formtype' =>
'yesno',
215 'valuetype' =>
'int',
221 if ( 0 !== $modules[ $mid ]->getVar(
'hasnotification' ) ) {
222 if ( empty( $configs ) ) {
225 include_once( XOOPS_ROOT_PATH .
'/include/notification_constants.php' );
226 $configs[] = [
'name' =>
'notification_enabled',
227 'title' =>
'_NOT_CONFIG_ENABLED',
228 'description' =>
'_NOT_CONFIG_ENABLEDDSC',
229 'formtype' =>
'select',
230 'valuetype' =>
'int',
231 'default' => XOOPS_NOTIFICATION_ENABLEBOTH,
232 'options' => $options
236 if (
false != $configs ) {
237 $msgs[] =
'Adding module config data...';
238 $config_handler =& xoops_gethandler(
'config' );
240 foreach ( $configs as $config ) {
241 $confobj =& $config_handler->createConfig();
242 $confobj->setVar(
'conf_modid', $newmid );
243 $confobj->setVar(
'conf_catid', 0 );
244 $confobj->setVar(
'conf_name', $config[
'name'] );
245 $confobj->setVar(
'conf_title', $config[
'title'],
true );
246 $confobj->setVar(
'conf_desc', $config[
'description'],
true );
247 $confobj->setVar(
'conf_formtype', $config[
'formtype'] );
248 $confobj->setVar(
'conf_valuetype', $config[
'valuetype'] );
249 $confobj->setVar(
'conf_value', $config[
'default'],
true );
250 $confobj->setVar(
'conf_order', $order );
252 if ( isset( $config[
'options'] ) && is_array( $config[
'options'] ) ) {
253 foreach ( $config[
'options'] as $key => $value ) {
254 $confop =& $config_handler->createConfigOption();
255 $confop->setVar(
'confop_name', $key,
true );
256 $confop->setVar(
'confop_value', $value,
true );
257 $confobj->setConfOptions( $confop );
258 $confop_msgs .=
'<br> Config option added. Name: <b>' . $key .
'</b> Value: <b>' . $value .
'</b>';
263 if (
false !== $config_handler->insertConfig( $confobj ) ) {
264 $msgs[] =
' Config <b>' . $config[
'name'] .
'</b> added to the database.' . $confop_msgs;
266 $msgs[] =
' <span style="color:#ff0000;">ERROR: Could not insert config <b>' . $config[
'name'] .
'</b> to the database.</span>';
272 foreach ( $msgs as $msg ) {
273 echo
'<code>' . $msg .
'</code><br>';
277 include_once
'./class/dbmanager.php';
280 $sql =
'SELECT bid, side FROM ' . $dbm->prefix(
'newblocks' );
281 $result = $dbm->query( $sql );
283 while ( $myrow = $dbm->fetchArray( $result ) ) {
284 if ( 0 === $myrow[
'side'] ) {
285 $dbm->insert(
'block_module_link',
' VALUES (' . $myrow[
'bid'] .
', 0)' );
287 $dbm->insert(
'block_module_link',
' VALUES (' . $myrow[
'bid'] .
', -1)' );
296$title = _INSTALL_L142;
297$content =
"<table width='80%' align='center'><tr><td align='left'>\n";
298$content .= ob_get_contents();
299$content .=
"</td></tr></table>\n";
302$b_next = [
'updateComments', _INSTALL_L14 ];
304include
'./install_tpl.php';