11 define(
'RMCLOCATION',
'modules');
12 include_once
'../../include/cp_header.php';
21 include_once XOOPS_ROOT_PATH.
'/kernel/module.php';
23 $db = XoopsDatabaseFactory::getDatabaseConnection();
25 $sql =
"SELECT * FROM ".$db->prefix(
"modules").
" ORDER BY `name`";
30 $mod =
new XoopsModule();
31 $mod->assignVars($row);
34 if (file_exists(XOOPS_ROOT_PATH.
'/modules/'.
$mod->getVar(
'dirname').
'/class/'.strtolower(
$mod->getVar(
'dirname').
'controller').
'.php')){
35 include_once XOOPS_ROOT_PATH.
'/modules/'.
$mod->getVar(
'dirname').
'/class/'.strtolower(
$mod->getVar(
'dirname').
'controller').
'.php';
36 $class = ucfirst(
$mod->getVar(
'dirname')).
'Controller';
38 if (method_exists($class,
'get_main_link')){
39 $main_link = $class->get_main_link();
42 if (
$mod->getVar(
'hasmain')){
43 $main_link = XOOPS_URL.
'/modules/'.
$mod->dirname();
51 if (
$mod->getVar(
'hasmain')){
52 $main_link = XOOPS_URL.
'/modules/'.
$mod->dirname();
60 $admin_link =
$mod->getVar(
'hasadmin') ? XOOPS_URL.
'/modules/'.
$mod->dirname().
'/'.
$mod->getInfo(
'adminindex') :
'';
63 'id' =>
$mod->getVar(
'mid'),
64 'name' =>
$mod->getVar(
'name'),
65 'realname' =>
$mod->getInfo(
'name'),
67 'description' =>
$mod->getInfo(
'description'),
68 'icon' => XOOPS_URL.
'/modules/'.
$mod->getVar(
'dirname').
'/'.(
$mod->getInfo(
'icon48') ?
$mod->getInfo(
'icon48') :
$mod->getInfo(
'image')),
69 'image' => XOOPS_URL.
'/modules/'.
$mod->getVar(
'dirname').
'/'.
$mod->getInfo(
'image'),
71 'admin_link' => $admin_link,
72 'updated' => formatTimestamp(
$mod->getVar(
'last_update'),
's'),
73 'author' =>
$mod->getInfo(
'author'),
74 'author_mail' =>
$mod->getInfo(
'authormail'),
75 'author_web' =>
$mod->getInfo(
'authorweb'),
76 'author_url' =>
$mod->getInfo(
'authorurl'),
77 'license' =>
$mod->getInfo(
'license'),
78 'dirname' =>
$mod->getInfo(
'dirname'),
79 'active' =>
$mod->getVar(
'isactive'),
80 'help' =>
$mod->getInfo(
'help')
87 require_once XOOPS_ROOT_PATH .
"/class/xoopslists.php";
88 $dirlist = XoopsLists::getModulesList();
89 $available_mods = array();
90 $module_handler = xoops_gethandler(
'module');
91 foreach ($dirlist as
$file) {
95 $module =& $module_handler->create();
96 if (!$module->loadInfo($file,
false)) {
99 $available_mods[] = $module;
105 $available_mods =
RMEvents::get()->run_event(
'rmcommon.available.modules', $available_mods);
107 $GLOBALS[
'available_mods'] = $available_mods;
110 RMTemplate::get()->assign(
'xoops_pagetitle',
__(
'Modules Management',
'rmcommon'));
112 RMTemplate::get()->add_local_script(
'modules.js',
'rmcommon',
'include');
113 RMTemplate::get()->set_help(
'http://www.redmexico.com.mx/docs/common-utilities/uso-de-common-utilities/standalone/1/#administrador-de-modulos');
115 include
RMTemplate::get()->get_template(
'rmc_modules.php',
'module',
'rmcommon');
128 if (
$dir==
'' || !file_exists(XOOPS_ROOT_PATH.
'/modules/'.
$dir.
'/xoops_version.php')){
129 redirectMsg(
'modules.php',
__(
'Specified module is not valid!',
'rmcommon'), 1);
133 $module_handler = xoops_gethandler(
'module');
135 if ($module = $module_handler->getByDirname(
$dir)){
136 redirectMsg(
'modules.php', sprintf(
__(
'%s is already installed!',
'rmcommon'), $module->name()), 1);
140 $module =& $module_handler->create();
141 if (!$module->loadInfo(
$dir,
false)) {
142 redirectMsg(
'modules.php',
__(
'Sepecified module is not a valid Xoops Module!',
'rmcommon'), 1);
146 $module =
RMEvents::get()->run_event(
'rmcommon.preinstall.module', $module);
148 RMTEmplate::get()->add_script(
'include/js/modules.js');
153 include
RMTemplate::get()->get_template(
'rmc_mod_preinstall.php',
'module',
'rmcommon');
164 if (!$xoopsSecurity->check()){
165 redirectMsg(
'modules.php?action=install&dir='.$module,
__(
'Sorry, this operation could not be completed!',
'rmcommon'), 1);
169 $module_handler = xoops_gethandler(
'module');
171 if ($module = $module_handler->getByDirname(
$mod)){
172 redirectMsg(
'modules.php', sprintf(
__(
'%s is already installed!',
'rmcommon'), $module->name()), 1);
176 $file = XOOPS_ROOT_PATH.
'/modules/system/language/'.$xoopsConfig[
'language'].
'/admin/modulesadmin.php';
177 if (file_exists(
$file)){
180 include_once str_replace($xoopsConfig[
'language'],
'english',
$file);
183 $file = XOOPS_ROOT_PATH.
'/modules/system/language/'.$xoopsConfig[
'language'].
'/admin/admin.php';
184 if (file_exists(
$file)){
187 include_once str_replace($xoopsConfig[
'language'],
'english',
$file);
191 include_once XOOPS_ROOT_PATH.
'/modules/system/admin/modulesadmin/modulesadmin.php';
195 $module_log = xoops_module_install(
$mod);
197 $module_log =
RMEvents::get()->run_event(
'rmcommon.module.installed', $module_log,
$mod);
203 $module = $module_handler->getByDirname(
$mod);
204 $log_title = sprintf(
__(
'Installation log for %s',
'rmcommon'), $module ? $module->name() :
$mod);
206 include
RMTemplate::get()->get_template(
'rmc_mod_log.php',
'module',
'rmcommon');
218 if (!$xoopsSecurity->check()){
219 redirectMsg(
'modules.php',
__(
'Sorry, this operation could not be completed!',
'rmcommon'), 1);
223 $module_handler = xoops_gethandler(
'module');
225 if (!$module_handler->getByDirname(
$mod)){
226 redirectMsg(
'modules.php', sprintf(
__(
'Module %s is not installed yet!',
'rmcommon'),
$mod), 1);
230 $file = XOOPS_ROOT_PATH.
'/modules/system/language/'.$xoopsConfig[
'language'].
'/admin/modulesadmin.php';
231 if (file_exists(
$file)){
234 include_once str_replace($xoopsConfig[
'language'],
'english',
$file);
237 include_once XOOPS_ROOT_PATH.
'/modules/system/admin/modulesadmin/modulesadmin.php';
241 $module_log = xoops_module_uninstall(
$mod);
243 $module_log =
RMEvents::get()->run_event(
'rmcommon.module.uninstalled', $module_log,
$mod);
249 $module =
new XoopsModule();
250 $module->loadInfo(
$mod,
false);
251 $log_title = sprintf(
__(
'Uninstall log for %s',
'rmcommon'), $module ? $module->getInfo(
'name') :
$mod);
253 include
RMTemplate::get()->get_template(
'rmc_mod_log.php',
'module',
'rmcommon');
263 $dirname = trim($dirname);
264 $module_handler =& xoops_gethandler(
'module');
265 $module =& $module_handler->getByDirname($dirname);
267 $prev_version = $module->getVar(
'version');
268 include_once XOOPS_ROOT_PATH.
'/class/template.php';
269 $xoopsTpl =
new XoopsTpl();
270 $xoopsTpl->clearCache($dirname);
273 $temp_name = $module->getVar(
'name');
274 $module->loadInfoAsVar($dirname);
275 $module->setVar(
'name', $temp_name);
278 if (!$module_handler->insert($module)) {
279 $log .= sprintf(
__(
'Could not update %s',
'rmcommon'), $module->getVar(
'name'));
281 $newmid = $module->getVar(
'mid');
283 $msgs[] = sprintf(
__(
'Updating module %s',
'rmcommon'), $module->getVar(
'name'));
284 $tplfile_handler =& xoops_gethandler(
'tplfile');
285 $deltpl = $tplfile_handler->find(
'default',
'module', $module->getVar(
'mid'));
287 if (is_array($deltpl)) {
289 $dcount = count($deltpl);
290 for (
$i = 0;
$i < $dcount;
$i++) {
291 if (!$tplfile_handler->delete($deltpl[
$i])) {
292 $delng[] = $deltpl[
$i]->getVar(
'tpl_file');
296 $templates = $module->getInfo(
'templates');
297 if ($templates !=
false) {
298 $msgs[] =
__(
'Updating templates...',
'rmcommon');
299 foreach ($templates as
$tpl) {
300 $tpl[
'file'] = trim($tpl[
'file']);
301 if (!in_array($tpl[
'file'], $delng)) {
302 $tpldata =& xoops_module_gettemplate($dirname, $tpl[
'file']);
303 $tplfile =& $tplfile_handler->create();
304 $tplfile->setVar(
'tpl_refid', $newmid);
305 $tplfile->setVar(
'tpl_lastimported', 0);
306 $tplfile->setVar(
'tpl_lastmodified', time());
307 if (preg_match(
"/\.css$/i", $tpl[
'file'])) {
308 $tplfile->setVar(
'tpl_type',
'css');
310 $tplfile->setVar(
'tpl_type',
'module');
312 $tplfile->setVar(
'tpl_source', $tpldata,
true);
313 $tplfile->setVar(
'tpl_module', $dirname);
314 $tplfile->setVar(
'tpl_tplset',
'default');
315 $tplfile->setVar(
'tpl_file', $tpl[
'file'],
true);
316 $tplfile->setVar(
'tpl_desc', $tpl[
'description'],
true);
317 if (!$tplfile_handler->insert($tplfile)) {
318 $msgs[] =
' <span style="color:#ff0000;">'.sprintf(
__(
'Template %s could not be inserted!',
'rmcommon'),
"<strong>".$tpl[
'file'].
"</strong>").
'</span>';
320 $newid = $tplfile->getVar(
'tpl_id');
321 $msgs[] =
' '.sprintf(
__(
'Template %s inserted to the database.',
'rmcommon'),
"<strong>".$tpl[
'file'].
"</strong>");
322 if ($xoopsConfig[
'template_set'] ==
'default') {
323 if (!xoops_template_touch($newid)) {
324 $msgs[] =
' <span style="color:#ff0000;">'.sprintf(
__(
'ERROR: Could not recompile template %s',
'rmcommon'),
"<strong>".$tpl[
'file'].
"</strong>").
'</span>';
326 $msgs[] =
' <span>'.sprintf(
__(
'Template %s recompiled',
'rmcommon'),
"<strong>".$tpl[
'file'].
"</strong>").
'</span>';
332 $msgs[] =
' <span style="color:#ff0000;">'.sprintf(
__(
'ERROR: Could not delete old template %s. Aborting update of this file.',
'rmcommon'),
"<strong>".$tpl[
'file'].
"</strong>").
'</span>';
336 $blocks = $module->getInfo(
'blocks');
337 $msgs[] =
__(
'Rebuilding blocks...',
'rmcommon');
338 if ($blocks !=
false) {
339 $showfuncs = array();
340 $funcfiles = array();
341 foreach ($blocks as
$i => $block) {
342 if (isset($block[
'show_func']) && $block[
'show_func'] !=
'' && isset($block[
'file']) && $block[
'file'] !=
'') {
343 $editfunc = isset($block[
'edit_func']) ? $block[
'edit_func'] :
'';
344 $showfuncs[] = $block[
'show_func'];
345 $funcfiles[] = $block[
'file'];
347 if ((isset($block[
'template']) && trim($block[
'template']) !=
'')) {
348 $content = xoops_module_gettemplate($dirname, $block[
'template'],
'blocks');
354 $template = $block[
'template'];
357 if (!empty($block[
'options'])) {
360 $sql =
"SELECT bid, name FROM ".$xoopsDB->prefix(
'newblocks').
" WHERE mid=".$module->getVar(
'mid').
" AND func_num=".
$i.
" AND show_func='".addslashes($block[
'show_func']).
"' AND func_file='".addslashes($block[
'file']).
"'";
361 $fresult = $xoopsDB->query(
$sql);
363 while ($fblock = $xoopsDB->fetchArray($fresult)) {
365 $sql =
"UPDATE ".$xoopsDB->prefix(
"newblocks").
" SET name='".addslashes($block[
'name']).
"', edit_func='".addslashes($editfunc).
"', content='', template='".$template.
"', last_modified=".time().
" WHERE bid=".$fblock[
'bid'];
368 $msgs[] =
" ".sprintf(
__(
'ERROR: Could not update %s'), $fblock[
'name']);
370 $msgs[] =
" ".sprintf(
__(
'Block %s updated.',
'rmcommon'), $fblock[
'name']).sprintf(
__(
'Block ID: %s',
'rmcommon'),
"<strong>".$fblock[
'bid'].
"</strong>");
371 if ($template !=
'') {
372 $tplfile = $tplfile_handler->find(
'default',
'block', $fblock[
'bid']);
373 if (count($tplfile) == 0) {
374 $tplfile_new =& $tplfile_handler->create();
375 $tplfile_new->setVar(
'tpl_module', $dirname);
376 $tplfile_new->setVar(
'tpl_refid', $fblock[
'bid']);
377 $tplfile_new->setVar(
'tpl_tplset',
'default');
378 $tplfile_new->setVar(
'tpl_file', $block[
'template'],
true);
379 $tplfile_new->setVar(
'tpl_type',
'block');
381 $tplfile_new = $tplfile[0];
383 $tplfile_new->setVar(
'tpl_source',
$content,
true);
384 $tplfile_new->setVar(
'tpl_desc', $block[
'description'],
true);
385 $tplfile_new->setVar(
'tpl_lastmodified', time());
386 $tplfile_new->setVar(
'tpl_lastimported', 0);
387 if (!$tplfile_handler->insert($tplfile_new)) {
388 $msgs[] =
' <span style="color:#ff0000;">'.sprintf(
__(
'ERROR: Could not update %s template.',
'rmcommon'),
"<strong>".$block[
'template'].
"</strong>").
'</span>';
390 $msgs[] =
" ".sprintf(
__(
'Template %s updated.',
'rmcommon'),
"<strong>".$block[
'template'].
"</strong>");
391 if ($xoopsConfig[
'template_set'] ==
'default') {
392 if (!xoops_template_touch($tplfile_new->getVar(
'tpl_id'))) {
393 $msgs[] =
' <span style="color:#ff0000;">'.sprintf(
__(
'ERROR: Could not recompile template %s',
'rmcommon'),
"<strong>".$block[
'template'].
"</strong>").
'</span>';
395 $msgs[] =
" ".sprintf(
__(
'Template %s recompiled',
'rmcommon'),
"<strong>".$block[
'template'].
"</strong>");
404 $newbid = $xoopsDB->genId($xoopsDB->prefix(
'newblocks').
'_bid_seq');
405 $block_name = addslashes($block[
'name']);
406 $block_type = ($module->getVar(
'dirname') ==
'system') ?
'S' :
'M';
407 $sql =
"INSERT INTO ".$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 (".$newbid.
", ".$module->getVar(
'mid').
", ".
$i.
",'".addslashes(
$options).
"','".$block_name.
"', '".$block_name.
"', '', 0, 0, 0, '{$block_type}', 1, '".addslashes($dirname).
"', '".addslashes($block[
'file']).
"', '".addslashes($block[
'show_func']).
"', '".addslashes($editfunc).
"', '".$template.
"', ".time().
")";
410 $msgs[] =
' '.sprintf(_(
'ERROR: Could not create %s',
'rmcommon'), $block[
'name']);$log .=
$sql;
412 if (empty($newbid)) {
413 $newbid = $xoopsDB->getInsertId();
415 if ($module->getInfo(
'hasMain')) {
416 $groups = array(XOOPS_GROUP_ADMIN, XOOPS_GROUP_USERS, XOOPS_GROUP_ANONYMOUS);
418 $groups = array(XOOPS_GROUP_ADMIN);
420 $gperm_handler =& xoops_gethandler(
'groupperm');
421 foreach ($groups as $mygroup) {
422 $bperm =& $gperm_handler->create();
423 $bperm->setVar(
'gperm_groupid', $mygroup);
424 $bperm->setVar(
'gperm_itemid', $newbid);
425 $bperm->setVar(
'gperm_name',
'block_read');
426 $bperm->setVar(
'gperm_modid', 1);
427 if (!$gperm_handler->insert($bperm)) {
428 $msgs[] =
' <span style="color:#ff0000;">'.__(
'ERROR: Could not add block access right',
'rmcommon') .
' '.sprintf(
__(
"Block ID: %s",
'rmcommon'),
"<strong>".$newbid.
"</strong>").
' '.sprintf(
__(
'Group ID: %s',
'rmcommon'),
"<strong>".$mygroup.
"</strong>").
'</span>';
430 $msgs[] =
' '.__(
'Added block access right',
'rmcommon').
' ' . sprintf(
__(
"Block ID: %s",
'rmcommon'),
"<strong>".$newbid.
"</strong>") .
' ' . sprintf(
__(
'Group ID: %s',
'rmcommon'),
"<strong>".$mygroup.
"</strong>");
434 if ($template !=
'') {
435 $tplfile =& $tplfile_handler->create();
436 $tplfile->setVar(
'tpl_module', $dirname);
437 $tplfile->setVar(
'tpl_refid', $newbid);
438 $tplfile->setVar(
'tpl_source',
$content,
true);
439 $tplfile->setVar(
'tpl_tplset',
'default');
440 $tplfile->setVar(
'tpl_file', $block[
'template'],
true);
441 $tplfile->setVar(
'tpl_type',
'block');
442 $tplfile->setVar(
'tpl_lastimported', 0);
443 $tplfile->setVar(
'tpl_lastmodified', time());
444 $tplfile->setVar(
'tpl_desc', $block[
'description'],
true);
445 if (!$tplfile_handler->insert($tplfile)) {
446 $msgs[] =
' <span style="color:#ff0000;">'.sprintf(
__(
'ERROR: Could not insert template %s to the database.',
'rmcommon'),
"<strong>".$block[
'template'].
"</strong>").
'</span>';
448 $newid = $tplfile->getVar(
'tpl_id');
449 $msgs[] =
' '.sprintf(
__(
'Template %s added to the database',
'rmcommon'),
"<strong>".$block[
'template'].
"</strong>");
450 if ($xoopsConfig[
'template_set'] ==
'default') {
451 if (!xoops_template_touch($newid)) {
452 $msgs[] =
' <span style="color:#ff0000;">'.sprintf(
__(
'ERROR: Template %s recompile failed',
'rmcommon'),
"<strong>".$block[
'template'].
"</strong>").
'</span>';
454 $msgs[] =
' '.sprintf(
__(
'Template %s recompiled',
'rmcommon'),
"<strong>".$block[
'template'].
"</strong>");
459 $msgs[] =
' '.sprintf(
__(
'Block %s created',
'rmcommon'),
"<strong>".$block[
'name'].
"</strong>").sprintf(
__(
"Block ID: %s",
'rmcommon'),
"<strong>".$newbid.
"</strong>");
460 $sql =
'INSERT INTO '.$xoopsDB->prefix(
'block_module_link').
' (block_id, module_id) VALUES ('.$newbid.
', -1)';
461 $xoopsDB->query(
$sql);
466 $block_arr = XoopsBlock::getByModule($module->getVar(
'mid'));
467 foreach ($block_arr as $block) {
468 if (!in_array($block->getVar(
'show_func'), $showfuncs) || !in_array($block->getVar(
'func_file'), $funcfiles)) {
469 $sql = sprintf(
"DELETE FROM %s WHERE bid = %u", $xoopsDB->prefix(
'newblocks'), $block->getVar(
'bid'));
470 if(!$xoopsDB->query(
$sql)) {
471 $msgs[] =
' <span style="color:#ff0000;">'.sprintf(
__(
'ERROR: Could not delete block %s',
'rmcommon'),
"<strong>".$block->getVar(
'name').
"</strong>").sprintf(
__(
"Block ID: %s",
'rmcommon'),
"<strong>".$block->getVar(
'bid').
"</strong>").
'</span>';
473 $msgs[] =
' Block <strong>'.$block->getVar(
'name').
' deleted. Block ID: <strong>'.$block->getVar(
'bid').
'</strong>';
474 if ($block->getVar(
'template') !=
'') {
475 $tplfiles = $tplfile_handler->find(null,
'block', $block->getVar(
'bid'));
476 if (is_array($tplfiles)) {
477 $btcount = count($tplfiles);
478 for ($k = 0; $k < $btcount; $k++) {
479 if (!$tplfile_handler->delete($tplfiles[$k])) {
480 $msgs[] =
' <span style="color:#ff0000;">'.__(
'ERROR: Could not remove deprecated block template.',
'rmcommon').
'(ID: <strong>'.$tplfiles[$k]->getVar(
'tpl_id').
'</strong>)</span>';
482 $msgs[] =
' '.sprintf(
__(
'Block template %s deprecated',
'rmcommon'),
"<strong>".$tplfiles[$k]->getVar(
'tpl_file').
"</strong>");
493 $xoopsTpl->setCompileId();
496 $config_handler =& xoops_gethandler(
'config');
497 $configs = $config_handler->getConfigs(
new Criteria(
'conf_modid', $module->getVar(
'mid')));
498 $confcount = count($configs);
499 $config_delng = array();
500 if ($confcount > 0) {
501 $msgs[] =
__(
'Deleting module config options...',
'rmcommon');
502 for (
$i = 0;
$i < $confcount;
$i++) {
503 if (!$config_handler->deleteConfig($configs[
$i])) {
504 $msgs[] =
' <span style="color:#ff0000;">'.__(
'ERROR: Could not delete config data from the database',
'rmcommon'). sprintf(
__(
'Config ID: %s',
'rmcommon'),
"<strong>".$configs[$i]->getvar(
'conf_id').
"</strong>").
'</span>';
506 $config_delng[] = $configs[
$i]->getvar(
'conf_name');
508 $config_old[$configs[
$i]->getvar(
'conf_name')][
'value'] = $configs[
$i]->getvar(
'conf_value',
'N');
509 $config_old[$configs[
$i]->getvar(
'conf_name')][
'formtype'] = $configs[
$i]->getvar(
'conf_formtype');
510 $config_old[$configs[
$i]->getvar(
'conf_name')][
'valuetype'] = $configs[
$i]->getvar(
'conf_valuetype');
511 $msgs[] =
" ".__(
'Config data deleted from the database.',
'rmcommon').
' ' . sprintf(
__(
'Config ID: %s',
'rmcommon'),
"<strong>".$configs[$i]->getVar(
'conf_id').
"</strong>");
517 $configs = $module->getInfo(
'config');
519 if ($configs !=
false) {
520 if ($module->getVar(
'hascomments') != 0) {
521 include_once(XOOPS_ROOT_PATH.
'/include/comment_constants.php');
522 array_push($configs, array(
'name' =>
'com_rule',
'title' =>
'_CM_COMRULES',
'description' =>
'',
'formtype' =>
'select',
'valuetype' =>
'int',
'default' => 1,
'options' => array(
'_CM_COMNOCOM' => XOOPS_COMMENT_APPROVENONE,
'_CM_COMAPPROVEALL' => XOOPS_COMMENT_APPROVEALL,
'_CM_COMAPPROVEUSER' => XOOPS_COMMENT_APPROVEUSER,
'_CM_COMAPPROVEADMIN' => XOOPS_COMMENT_APPROVEADMIN)));
523 array_push($configs, array(
'name' =>
'com_anonpost',
'title' =>
'_CM_COMANONPOST',
'description' =>
'',
'formtype' =>
'yesno',
'valuetype' =>
'int',
'default' => 0));
526 if ($module->getVar(
'hascomments') != 0) {
528 include_once(XOOPS_ROOT_PATH.
'/include/comment_constants.php');
529 $configs[] = array(
'name' =>
'com_rule',
'title' =>
'_CM_COMRULES',
'description' =>
'',
'formtype' =>
'select',
'valuetype' =>
'int',
'default' => 1,
'options' => array(
'_CM_COMNOCOM' => XOOPS_COMMENT_APPROVENONE,
'_CM_COMAPPROVEALL' => XOOPS_COMMENT_APPROVEALL,
'_CM_COMAPPROVEUSER' => XOOPS_COMMENT_APPROVEUSER,
'_CM_COMAPPROVEADMIN' => XOOPS_COMMENT_APPROVEADMIN));
530 $configs[] = array(
'name' =>
'com_anonpost',
'title' =>
'_CM_COMANONPOST',
'description' =>
'',
'formtype' =>
'yesno',
'valuetype' =>
'int',
'default' => 0);
534 if ($module->getVar(
'hasnotification') != 0) {
535 if (empty($configs)) {
539 include_once XOOPS_ROOT_PATH .
'/include/notification_constants.php';
540 include_once XOOPS_ROOT_PATH .
'/include/notification_functions.php';
542 $options[
'_NOT_CONFIG_DISABLE'] = XOOPS_NOTIFICATION_DISABLE;
543 $options[
'_NOT_CONFIG_ENABLEBLOCK'] = XOOPS_NOTIFICATION_ENABLEBLOCK;
544 $options[
'_NOT_CONFIG_ENABLEINLINE'] = XOOPS_NOTIFICATION_ENABLEINLINE;
545 $options[
'_NOT_CONFIG_ENABLEBOTH'] = XOOPS_NOTIFICATION_ENABLEBOTH;
548 $configs[] = array (
'name' =>
'notification_enabled',
'title' =>
'_NOT_CONFIG_ENABLE',
'description' =>
'_NOT_CONFIG_ENABLEDSC',
'formtype' =>
'select',
'valuetype' =>
'int',
'default' => XOOPS_NOTIFICATION_ENABLEBOTH,
'options'=>
$options);
553 $categories =& notificationCategoryInfo(
'',$module->getVar(
'mid'));
555 $events =& notificationEvents ($category[
'name'],
false, $module->getVar(
'mid'));
556 foreach ($events as $event) {
557 if (!empty($event[
'invisible'])) {
560 $option_name = $category[
'title'] .
' : ' . $event[
'title'];
561 $option_value = $category[
'name'] .
'-' . $event[
'name'];
562 $options[$option_name] = $option_value;
566 $configs[] = array (
'name' =>
'notification_events',
'title' =>
'_NOT_CONFIG_EVENTS',
'description' =>
'_NOT_CONFIG_EVENTSDSC',
'formtype' =>
'select_multi',
'valuetype' =>
'array',
'default' => array_values(
$options),
'options' =>
$options);
569 if ($configs !=
false) {
570 $msgs[] =
'Adding module config data...';
571 $config_handler =& xoops_gethandler(
'config');
573 foreach ($configs as $config) {
575 if (!in_array($config[
'name'], $config_delng)) {
576 $confobj =& $config_handler->createConfig();
577 $confobj->setVar(
'conf_modid', $newmid);
578 $confobj->setVar(
'conf_catid', 0);
579 $confobj->setVar(
'conf_name', $config[
'name']);
580 $confobj->setVar(
'conf_title', $config[
'title'],
true);
581 $confobj->setVar(
'conf_desc', $config[
'description'],
true);
582 $confobj->setVar(
'conf_formtype', $config[
'formtype']);
583 $confobj->setVar(
'conf_valuetype', $config[
'valuetype']);
584 if (isset($config_old[$config[
'name']][
'value']) && $config_old[$config[
'name']][
'formtype'] == $config[
'formtype'] && $config_old[$config[
'name']][
'valuetype'] == $config[
'valuetype']) {
587 $confobj->setVar(
'conf_value', $config_old[$config[
'name']][
'value'],
true);
589 $confobj->setConfValueForInput($config[
'default'],
true);
593 $confobj->setVar(
'conf_order', $order);
595 if (isset($config[
'options']) && is_array($config[
'options'])) {
596 foreach ($config[
'options'] as $key => $value) {
597 $confop =& $config_handler->createConfigOption();
598 $confop->setVar(
'confop_name', $key,
true);
599 $confop->setVar(
'confop_value', $value,
true);
600 $confobj->setConfOptions($confop);
601 $confop_msgs .=
'<br /> ' .
__(
'Config option added',
'rmcommon') .
' ' .
__(
'Name:',
'rmcommon') .
' <strong>' . ( defined($key) ? constant($key) : $key ) .
'</strong> ' .
__(
'Value:',
'rmcommon') .
' <strong>' . $value .
'</strong> ';
606 if (
false != $config_handler->insertConfig($confobj)) {
608 $msgs[] =
" ".sprintf(
__(
'Config %s added to the database',
'rmcommon'),
"<strong>" . $config[
'name'] .
"</strong>") . $confop_msgs;
610 $msgs[] =
' <span style="color:#ff0000;">' . sprintf(
__(
'ERROR: Could not insert config %s to the database.',
'rmcommon'),
"<strong>" . $config[
'name'] .
"</strong>") .
'</span>';
619 $update_script = $module->getInfo(
'onUpdate');
620 if (
false != $update_script && trim($update_script) !=
'') {
621 include_once XOOPS_ROOT_PATH.
'/modules/'.$dirname.
'/'.trim($update_script);
622 if (function_exists(
'xoops_module_update_'.$dirname)) {
623 $func =
'xoops_module_update_'.$dirname;
624 if (!$func($module, $prev_version)) {
625 $msgs[] =
"<p>".sprintf(
__(
'Failed to execute %s',
'rmcommon'), $func).
"</p>";
627 $msgs[] =
"<p>".sprintf(
__(
'%s executed successfully.',
'rmcommon'),
"<strong>".$func.
"</strong>").
"</p>";
632 foreach ($msgs as $msg) {
633 $log .= $msg.
'<br />';
635 $log .=
"<p>".sprintf(
__(
'Module %s updated successfully!',
'rmcommon'),
"<strong>".$module->getVar(
'name').
"</strong>").
"</p>";
639 xoops_load(
"cpanel",
"system");
640 XoopsSystemCpanel::flush();
653 if (!$xoopsSecurity->check()){
654 redirectMsg(
'modules.php',
__(
'Sorry, this operation could not be completed!',
'rmcommon'), 1);
658 $module_handler = xoops_gethandler(
'module');
659 $module = $module_handler->getByDirname(
$mod);
662 redirectMsg(
'modules.php', sprintf(
__(
'Module %s is not installed yet!',
'rmcommon'),
$mod), 1);
666 $file = XOOPS_ROOT_PATH.
'/modules/system/language/'.$xoopsConfig[
'language'].
'/admin/modulesadmin.php';
667 if (file_exists(
$file)){
670 include_once str_replace($xoopsConfig[
'language'],
'english',
$file);
673 include_once XOOPS_ROOT_PATH.
'/modules/system/admin/modulesadmin/modulesadmin.php';
675 RMEvents::get()->run_event(
'rmcommon.updating.module', $module);
679 $module_log =
RMEvents::get()->run_event(
'rmcommon.module.updated', $module_log, $module_log);
685 $log_title = sprintf(
__(
'Update log for %s',
'rmcommon'), $module ? $module->getInfo(
'name') :
$mod);
687 include
RMTemplate::get()->get_template(
'rmc_mod_log.php',
'module',
'rmcommon');
699 if (!$xoopsSecurity->check()){
700 redirectMsg(
'modules.php',
__(
'Sorry, this operation could not be completed!',
'rmcommon'), 1);
704 $module_handler = xoops_gethandler(
'module');
706 if (!$module = $module_handler->getByDirname(
$mod)){
707 redirectMsg(
'modules.php', sprintf(
__(
'Module %s is not installed yet!',
'rmcommon'),
$mod), 1);
711 RMEvents::get()->run_event(
'rmcommon.disabling.module', $module);
713 $db = XoopsDatabaseFactory::getDatabaseConnection();
714 $sql =
"UPDATE ".$db->prefix(
"modules").
" SET isactive='$enable' WHERE dirname='$mod'";
716 redirectMsg(
'modules.php', sprintf(
__(
'Module %s could not be disabled!',
'rmcommon'),
$mod), 1);
720 RMEvents::get()->run_event(
'rmcommon.module.disabled', $module);
722 redirectMsg(
"modules.php", sprintf(
__(
'Module %s successfully disabled!',
'rmcommon'), $module->name()), 0);
730 $xoopsLogger->activated =
false;
732 if (!$xoopsSecurity->check(
true,
rmc_server_var($_POST,
'token',
''))){
733 echo
__(
"Sorry, you don't have access to this page",
'rmcommon');
734 echo
"<br /><a href='javascript:;' onclick='location.reload();'>".__(
'Click here to refresh',
'rmcommon').
"</a>";
738 $db = XoopsDatabaseFactory::getDatabaseConnection();
739 $sql =
"SELECT * FROM ".$db->prefix(
"modules").
" ORDER BY `name`";
747 require_once XOOPS_ROOT_PATH .
"/class/xoopslists.php";
748 $dirlist = XoopsLists::getModulesList();
749 $available_mods = array();
750 $module_handler = xoops_gethandler(
'module');
751 foreach ($dirlist as
$file) {
755 $module =& $module_handler->create();
756 if (!$module->loadInfo($file,
false)) {
759 $available_mods[] = $module;
765 unset($module_handler);
774 $nav->target_url(
'javascript:;" onclick="load_page({PAGE_NUM});');
777 $available_mods =
RMEvents::get()->run_event(
'rmcommon.available.modules', $available_mods);
780 if ($end>count($available_mods)) $end = count($available_mods);
784 <div
class=
"rmc_widget_content_reduced rmc_modules_widget">
785 <img
id=
"img-load" src=
"images/loading.gif" style=
"display: none; margin: 15px auto;" />
786 <div
id=
"mods-widget-container">
787 <?php
for(
$i=
$start;$i<$end;$i++): ?>
788 <?php
$mod = $available_mods[
$i]; ?>
789 <div
class=
"<?php echo tpl_cycle("even,
odd"); ?>">
790 <a
href=
"modules.php?action=install&dir=<?php echo $mod->getInfo('dirname'); ?>" class=
"rmc_mod_img" style=
"background: url(<?php echo XOOPS_URL; ?>/modules/<?php echo $mod->getInfo('dirname'); ?>/<?php echo $mod->getInfo('image'); ?>) no-repeat center;"><span> </span></a>
791 <strong><a href=
"modules.php?action=install&dir=<?php echo $mod->getInfo('dirname'); ?>"><?php echo $mod->getInfo(
'name'); ?></a></strong>
792 <span
class=
"rmc_available_options">
793 <a href=
"modules.php?action=install&dir=<?php echo $mod->getInfo('dirname'); ?>"><?php
_e(
'Install',
'rmcommon'); ?></a> |
794 <a href=
"javascript:;" onclick=
"show_module_info('<?php echo $mod->getInfo('dirname'); ?>');"><?php
_e(
'More info',
'rmcommon'); ?></a>
796 <span
class=
"rmc_mod_info" id=
"mod-<?php echo $mod->getInfo('dirname'); ?>">
797 <?php
_e(
'Version:',
'rmcommon'); ?>
798 <?php
if($mod->getInfo(
'rmnative')): ?>
801 <?php echo $mod->getInfo(
'version'); ?>
802 <?php
endif; ?><br />
803 <?php
_e(
'Author:',
'rmcommon'); ?> <?php echo substr(strip_tags($mod->getInfo(
'author')), 0, 12); ?>
806 <input type=
"hidden" id=
"token" value=
"<?php echo $xoopsSecurity->createToken(); ?>" />
808 <?php
$nav->display(
false); ?>
812 $ret = ob_get_clean();
821 $xoopsLogger->activated =
false;
823 if (!$xoopsSecurity->check()){
827 'message' =>
__(
'You can not rename modules. Session token not valid!',
'rmcommon').
' '.
rmc_server_var($_POST,
'token')
830 echo json_encode(
$ret);
838 if (
$id<=0 || $name==
''){
841 'message' =>
__(
'Data provided is not valid',
'rmcommon'),
842 'token' => $xoopsSecurity->createToken()
845 echo json_encode(
$ret);
849 $db = XoopsDatabaseFactory::getDatabaseConnection();
850 $sql =
"UPDATE ".$db->prefix(
"modules").
" SET `name`='$name' WHERE mid='$id'";
854 'message' =>
__(
'Module name could not be changed!',
'rmcommon').
'\n'.
$db->error(),
855 'token' => $xoopsSecurity->createToken()
858 echo json_encode(
$ret);
864 'message'=>
__(
'Module name changed successfully!',
'rmcommon'),
865 'token'=>$xoopsSecurity->createToken(),
869 echo json_encode(
$ret);
884 case 'uninstall_module':
887 case 'update_module':
890 case 'disable_module':
893 case 'enable_module':
903 $_REQUEST[
'action'] =
'';