123 $root =& XCube_Root::getSingleton();
124 $root->mLanguageManager->loadModinfoMessageCatalog($dirname);
125 $filepath = XOOPS_MODULE_PATH .
"/{$dirname}/xoops_version.php";
127 if (file_exists($filepath)) {
132 if (isset($info[
'legacy_installer']) && is_array($info[
'legacy_installer']) && isset($info[
'legacy_installer'][$mode])) {
133 $updateInfo = $info[
'legacy_installer'][$mode];
135 $className = $updateInfo[
'class'];
137 $filePath = $updateInfo[
'filepath'] ?? XOOPS_MODULE_PATH .
"/{$dirname}/admin/class/{$className}.class.php";
138 $namespace = $updateInfo[
'namespace'] ?? ucfirst($dirname);
140 if (
null != $namespace) {
141 $className =
"{$namespace}_{$className}";
144 if (!XC_CLASS_EXISTS($className) && file_exists($filePath)) {
145 require_once $filePath;
148 if (XC_CLASS_EXISTS($className)) {
149 $installer =
new $className();
154 $installer =
new $defaultClassName();
175 $sqlfileInfo =& $module->getInfo(
'sqlfile');
176 $dirname = $module->getVar(
'dirname');
177 $dbType = (isset($sqlfileInfo[XOOPS_DB_TYPE]) || !isset($dbTypeAliases[XOOPS_DB_TYPE]))? XOOPS_DB_TYPE : $dbTypeAliases[XOOPS_DB_TYPE];
179 if (!isset($sqlfileInfo[$dbType])) {
183 $sqlfile = $sqlfileInfo[$dbType];
184 $sqlfilepath = XOOPS_MODULE_PATH .
"/{$dirname}/{$sqlfile}";
186 if (isset($module->modinfo[
'cube_style']) &&
true == $module->modinfo[
'cube_style']) {
187 require_once XOOPS_MODULE_PATH .
'/legacy/admin/class/Legacy_SQLScanner.class.php';
189 $scanner->setDB_PREFIX(XOOPS_DB_PREFIX);
190 $scanner->setDirname($module->get(
'dirname'));
192 if (!$scanner->loadFile($sqlfilepath)) {
198 $sqls = $scanner->getSQL();
200 $root =& XCube_Root::getSingleton();
201 $db =& $root->mController->getDB();
206 foreach ($sqls as $sql) {
207 if (!$db->query($sql)) {
208 $log->addError($db->error());
213 $log->addReport(_AD_LEGACY_MESSAGE_DATABASE_SETUP_FINISHED);
215 require_once XOOPS_ROOT_PATH.
'/class/database/sqlutility.php';
217 $reservedTables = [
'avatar',
'avatar_users_link',
'block_module_link',
'xoopscomments',
'config',
'configcategory',
'configoption',
'image',
'imagebody',
'imagecategory',
'imgset',
'imgset_tplset_link',
'imgsetimg',
'groups',
'groups_users_link',
'group_permission',
'online',
'bannerclient',
'banner',
'bannerfinish',
'priv_msgs',
'ranks',
'session',
'smiles',
'users',
'newblocks',
'modules',
'tplfile',
'tplset',
'tplsource',
'xoopsnotifications'];
219 $root =& XCube_Root::getSingleton();
220 $db =& $root->mController->mDB;
222 $sql_query = fread(fopen($sqlfilepath,
'r'), filesize($sqlfilepath));
223 $sql_query = trim($sql_query);
224 SqlUtility::splitMySqlFile($pieces, $sql_query);
225 $created_tables = [];
226 foreach ($pieces as $piece) {
229 $prefixed_query = SqlUtility::prefixQuery($piece, $db->prefix());
230 if (!$prefixed_query) {
231 $log->addError(
"{$piece} is not a valid SQL!");
236 if (!in_array($prefixed_query[4], $reservedTables)) {
238 if (!$db->query($prefixed_query[0])) {
239 $log->addError($db->error());
242 if (!in_array($prefixed_query[4], $created_tables)) {
243 $log->addReport(
' Table ' . $db->prefix($prefixed_query[4]) .
' created.');
244 $created_tables[] = $prefixed_query[4];
246 $log->addReport(
' Data inserted to table ' . $db->prefix($prefixed_query[4]));
251 $log->addError($prefixed_query[4] .
' is a reserved table!');
278 $templates = $module->getInfo(
'templates');
279 if (
false != $templates) {
280 foreach ($templates as $template) {
305 $tplHandler =& xoops_gethandler(
'tplfile');
307 $fileName = trim($template[
'file']);
310 if (
false == $tpldata) {
317 $tplfile =& $tplHandler->create();
318 $tplfile->setVar(
'tpl_refid', $module->getVar(
'mid'));
319 $tplfile->setVar(
'tpl_lastimported', 0);
320 $tplfile->setVar(
'tpl_lastmodified', time());
322 if (preg_match(
"/\.css$/i", $fileName)) {
323 $tplfile->setVar(
'tpl_type',
'css');
325 $tplfile->setVar(
'tpl_type',
'module');
328 $tplfile->setVar(
'tpl_source', $tpldata,
true);
329 $tplfile->setVar(
'tpl_module', $module->getVar(
'dirname'));
330 $tplfile->setVar(
'tpl_tplset',
'default');
331 $tplfile->setVar(
'tpl_file', $fileName,
true);
333 $description = $template[
'description'] ??
'';
334 $tplfile->setVar(
'tpl_desc', $description,
true);
336 if ($tplHandler->insert($tplfile)) {
369 $tplHandler =& xoops_gethandler(
'tplfile');
370 $delTemplates =
null;
372 $delTemplates =& $tplHandler->find($tplset,
'module', $module->get(
'mid'));
374 if (is_array($delTemplates) && count($delTemplates) > 0) {
379 $xoopsTpl->clear_cache(
null,
'mod_' . $module->get(
'dirname'));
381 foreach ($delTemplates as $tpl) {
382 if (!$tplHandler->delete($tpl)) {
389 public static function uninstallAllOfModuleTemplates(&$module, &$log)
394 public static function clearAllOfModuleTemplatesForUpdate(&$module, &$log)
413 $definedBlocks = $module->getInfo(
'blocks');
414 if (
false == $definedBlocks) {
419 foreach ($definedBlocks as $block) {
424 foreach ($definedBlocks as $idx => $block) {
425 if (isset($block[
'func_num'])) {
426 $updateblocks[$idx] = $block;
428 $successFlag =
false;
434 if (
false == $successFlag) {
437 foreach ($definedBlocks as $idx => $block) {
439 $block[
'func_num'] = $idx;
440 $updateblocks[$idx] = $block;
442 $successFlag =
false;
449 if (
false == $successFlag) {
454 foreach ($definedBlocks as $block) {
455 $block[
'func_num'] = $func_num;
456 $updateblocks[] = $block;
461 foreach ($updateblocks as $block) {
483 $handler =& xoops_gethandler(
'block');
484 $criteria =
new Criteria(
'mid', $module->get(
'mid'));
486 $blockArr =& $handler->getObjectsDirectly($criteria);
490 foreach (array_keys($blockArr) as $idx) {
506 $options = $block[
'options'] ??
null;
507 $edit_func = $block[
'edit_func'] ??
null;
508 $template = $block[
'template'] ??
null;
509 $visible = $block[
'visible'] ?? $block[
'visible_any'] ?? 0;
510 $blockHandler =& xoops_gethandler(
'block');
511 $blockObj =& $blockHandler->create();
513 $blockObj->set(
'mid', $module->getVar(
'mid'));
514 $blockObj->set(
'options', $options);
515 $blockObj->set(
'name', $block[
'name']);
516 $blockObj->set(
'title', $block[
'name']);
517 $blockObj->set(
'block_type',
'M');
518 $blockObj->set(
'c_type', 1);
519 $blockObj->set(
'isactive', 1);
520 $blockObj->set(
'dirname', $module->getVar(
'dirname'));
521 $blockObj->set(
'func_file', $block[
'file']);
527 if (isset($block[
'class'])) {
528 $show_func =
'cl::' . $block[
'class'];
530 $show_func = $block[
'show_func'];
533 $blockObj->set(
'show_func', $show_func);
534 $blockObj->set(
'edit_func', $edit_func);
535 $blockObj->set(
'template', $template);
536 $blockObj->set(
'last_modified', time());
537 $blockObj->set(
'visible', $visible);
539 $func_num = isset($block[
'func_num']) ? (int)$block[
'func_num'] : $func_num;
540 $blockObj->set(
'func_num', $func_num);
553 public static function installBlock(&$module, &$blockObj, &$block, &$log)
555 $isNew = $blockObj->isNew();
556 $blockHandler =& xoops_gethandler(
'block');
558 if (!empty($block[
'show_all_module'])) {
563 if (!$blockHandler->insert($blockObj, $autolink)) {
570 $tplHandler =& xoops_gethandler(
'tplfile');
578 if (!empty($block[
'show_all_module'])) {
579 $link_sql =
'INSERT INTO ' . $blockHandler->db->prefix(
'block_module_link') .
' (block_id, module_id) VALUES (' . $blockObj->getVar(
'bid') .
', 0)';
580 if (!$blockHandler->db->query($link_sql)) {
584 $gpermHandler =& xoops_gethandler(
'groupperm');
585 $bperm =& $gpermHandler->create();
586 $bperm->setVar(
'gperm_itemid', $blockObj->getVar(
'bid'));
587 $bperm->setVar(
'gperm_name',
'block_read');
588 $bperm->setVar(
'gperm_modid', 1);
590 if (!empty($block[
'visible_any'])) {
591 $memberHandler =& xoops_gethandler(
'member');
592 $groupObjects =& $memberHandler->getGroups();
593 foreach ($groupObjects as $group) {
594 $bperm->setVar(
'gperm_groupid', $group->getVar(
'groupid'));
596 if (!$gpermHandler->insert($bperm)) {
601 $root =& XCube_Root::getSingleton();
602 $groups = $root->mContext->mXoopsUser->getGroups(
true);
603 foreach ($groups as $mygroup) {
604 $bperm->setVar(
'gperm_groupid', $mygroup);
606 if (!$gpermHandler->insert($bperm)) {
629 $blockHandler =& xoops_gethandler(
'block');
630 $blockHandler->delete($block);
636 $gpermHandler =& xoops_gethandler(
'groupperm');
638 $criteria->add(
new Criteria(
'gperm_name',
'block_read'));
639 $criteria->add(
new Criteria(
'gperm_itemid', $block->get(
'bid')));
640 $criteria->add(
new Criteria(
'gperm_modid', 1));
641 $gpermHandler->deleteAll($criteria);
654 if (
null == $block->get(
'template')) {
658 $tplHandler =& xoops_gethandler(
'tplfile');
661 $criteria->add(
new Criteria(
'tpl_type',
'block'));
662 $criteria->add(
new Criteria(
'tpl_tplset',
'default'));
663 $criteria->add(
new Criteria(
'tpl_module', $module->get(
'dirname')));
664 $criteria->add(
new Criteria(
'tpl_file', $block->get(
'template')));
665 $tplfiles =& $tplHandler->getObjects($criteria);
667 if ((is_countable($tplfiles) ? count($tplfiles) : 0) > 0) {
668 $tplfile =& $tplfiles[0];
670 $tplfile =& $tplHandler->create();
671 $tplfile->set(
'tpl_refid', $block->get(
'bid'));
672 $tplfile->set(
'tpl_tplset',
'default');
673 $tplfile->set(
'tpl_file', $block->get(
'template'));
674 $tplfile->set(
'tpl_module', $module->get(
'dirname'));
675 $tplfile->set(
'tpl_type',
'block');
677 $tplfile->set(
'tpl_lastimported', 0);
681 $tplfile->set(
'tpl_source', $tplSource);
682 $tplfile->set(
'tpl_lastmodified', time());
684 if ($tplHandler->insert($tplfile)) {
708 $filePath = XOOPS_MODULE_PATH .
'/' . $dirname .
'/templates/blocks/' . $fileName;
710 $filePath = XOOPS_MODULE_PATH .
'/' . $dirname .
'/templates/' . $fileName;
713 if (!file_exists($filePath)) {
717 $lines = file($filePath);
718 if (
false == $lines) {
723 foreach ($lines as $line) {
727 $tpldata .= str_replace(
"\n",
"\r\n", str_replace(
"\r\n",
"\n", $line));
733 public static function installAllOfConfigs(&$module, &$log)
735 $dirname = $module->get(
'dirname');
738 $preferences =& $fileReader->loadPreferenceInformations();
743 foreach (array_keys($preferences->mPreferences) as $idx) {
744 Legacy_ModuleInstallUtils::installPreferenceByInfo($preferences->mPreferences[$idx], $module, $log);
750 foreach (array_keys($preferences->mComments) as $idx) {
751 Legacy_ModuleInstallUtils::installPreferenceByInfo($preferences->mComments[$idx], $module, $log);
757 foreach (array_keys($preferences->mNotifications) as $idx) {
758 Legacy_ModuleInstallUtils::installPreferenceByInfo($preferences->mNotifications[$idx], $module, $log);
762 public static function installPreferenceByInfo(&$info, &$module, &$log)
764 $handler =& xoops_gethandler(
'config');
765 $config =& $handler->createConfig();
766 $config->set(
'conf_modid', $module->get(
'mid'));
767 $config->set(
'conf_catid', 0);
768 $config->set(
'conf_name', $info->mName);
769 $config->set(
'conf_title', $info->mTitle);
770 $config->set(
'conf_desc', $info->mDescription);
771 $config->set(
'conf_formtype', $info->mFormType);
772 $config->set(
'conf_valuetype', $info->mValueType);
773 $config->setConfValueForInput($info->mDefault);
774 $config->set(
'conf_order', $info->mOrder);
776 if ((is_countable($info->mOption->mOptions) ? count($info->mOption->mOptions) : 0) > 0) {
777 foreach (array_keys($info->mOption->mOptions) as $idx) {
778 $option =& $handler->createConfigOption();
779 $option->set(
'confop_name', $info->mOption->mOptions[$idx]->mName);
780 $option->set(
'confop_value', $info->mOption->mOptions[$idx]->mValue);
781 $config->setConfOptions($option);
786 if ($handler->insertConfig($config)) {
800 $configInfos = $module->getInfo(
'config');
805 if (0 != $module->getVar(
'hascomments')) {
806 require_once XOOPS_ROOT_PATH .
'/include/comment_constants.php';
809 'name' =>
'com_rule',
810 'title' =>
'_CM_COMRULES',
812 'formtype' =>
'select',
813 'valuetype' =>
'int',
815 'options' => [
'_CM_COMNOCOM' => XOOPS_COMMENT_APPROVENONE,
'_CM_COMAPPROVEALL' => XOOPS_COMMENT_APPROVEALL,
'_CM_COMAPPROVEUSER' => XOOPS_COMMENT_APPROVEUSER,
'_CM_COMAPPROVEADMIN' => XOOPS_COMMENT_APPROVEADMIN]
819 'name' =>
'com_anonpost',
820 'title' =>
'_CM_COMANONPOST',
822 'formtype' =>
'yesno',
823 'valuetype' =>
'int',
831 if (0 != $module->get(
'hasnotification')) {
832 require_once XOOPS_ROOT_PATH .
'/include/notification_constants.php';
833 require_once XOOPS_ROOT_PATH .
'/include/notification_functions.php';
836 $t_options[
'_NOT_CONFIG_DISABLE'] = XOOPS_NOTIFICATION_DISABLE;
837 $t_options[
'_NOT_CONFIG_ENABLEBLOCK'] = XOOPS_NOTIFICATION_ENABLEBLOCK;
838 $t_options[
'_NOT_CONFIG_ENABLEINLINE'] = XOOPS_NOTIFICATION_ENABLEINLINE;
839 $t_options[
'_NOT_CONFIG_ENABLEBOTH'] = XOOPS_NOTIFICATION_ENABLEBOTH;
842 'name' =>
'notification_enabled',
843 'title' =>
'_NOT_CONFIG_ENABLE',
844 'description' =>
'_NOT_CONFIG_ENABLEDSC',
845 'formtype' =>
'select',
846 'valuetype' =>
'int',
847 'default' => XOOPS_NOTIFICATION_ENABLEBOTH,
848 'options' => $t_options
859 $t_categoryArr =& notificationCategoryInfo(
'', $module->get(
'mid'));
860 foreach ($t_categoryArr as $t_category) {
861 $t_eventArr =& notificationEvents($t_category[
'name'],
false, $module->get(
'mid'));
862 foreach ($t_eventArr as $t_event) {
863 if (!empty($t_event[
'invisible'])) {
866 $t_optionName = $t_category[
'title'] .
' : ' . $t_event[
'title'];
867 $t_options[$t_optionName] = $t_category[
'name'] .
'-' . $t_event[
'name'];
872 'name' =>
'notification_events',
873 'title' =>
'_NOT_CONFIG_EVENTS',
874 'description' =>
'_NOT_CONFIG_EVENTSDSC',
875 'formtype' =>
'select_multi',
876 'valuetype' =>
'array',
877 'default' => array_values($t_options),
878 'options' => $t_options
893 if (0 == $module->get(
'hasconfig')) {
897 $configHandler =& xoops_gethandler(
'config');
898 $configs =& $configHandler->getConfigs(
new Criteria(
'conf_modid', $module->get(
'mid')));
900 if (0 == (is_countable($configs) ? count($configs) : 0)) {
904 foreach ($configs as $config) {
905 $configHandler->deleteConfig($config);
909 public static function smartUpdateAllOfBlocks(&$module, &$log)
911 $dirname = $module->get(
'dirname');
914 $latestBlocks =& $fileReader->loadBlockInformations();
917 $currentBlocks =& $dbReader->loadBlockInformations();
919 $currentBlocks->update($latestBlocks);
921 foreach (array_keys($currentBlocks->mBlocks) as $idx) {
922 switch ($currentBlocks->mBlocks[$idx]->mStatus) {
923 case LEGACY_INSTALLINFO_STATUS_LOADED:
924 Legacy_ModuleInstallUtils::updateBlockTemplateByInfo($currentBlocks->mBlocks[$idx], $module, $log);
927 case LEGACY_INSTALLINFO_STATUS_UPDATED:
928 Legacy_ModuleInstallUtils::updateBlockByInfo($currentBlocks->mBlocks[$idx], $module, $log);
931 case LEGACY_INSTALLINFO_STATUS_NEW:
932 Legacy_ModuleInstallUtils::installBlockByInfo($currentBlocks->mBlocks[$idx], $module, $log);
935 case LEGACY_INSTALLINFO_STATUS_DELETED:
942 public static function smartUpdateAllOfPreferences(&$module, &$log)
944 $dirname = $module->get(
'dirname');
946 $fileReader =
new Legacy_ModinfoX2FileReader($dirname);
947 $latestPreferences =& $fileReader->loadPreferenceInformations();
949 $dbReader =
new Legacy_ModinfoX2DBReader($dirname);
950 $currentPreferences =& $dbReader->loadPreferenceInformations();
952 $currentPreferences->update($latestPreferences);
957 foreach (array_keys($currentPreferences->mPreferences) as $idx) {
958 switch ($currentPreferences->mPreferences[$idx]->mStatus) {
959 case LEGACY_INSTALLINFO_STATUS_UPDATED:
960 Legacy_ModuleInstallUtils::updatePreferenceByInfo($currentPreferences->mPreferences[$idx], $module, $log);
963 case LEGACY_INSTALLINFO_STATUS_ORDER_UPDATED:
964 Legacy_ModuleInstallUtils::updatePreferenceOrderByInfo($currentPreferences->mPreferences[$idx], $module, $log);
967 case LEGACY_INSTALLINFO_STATUS_NEW:
968 Legacy_ModuleInstallUtils::installPreferenceByInfo($currentPreferences->mPreferences[$idx], $module, $log);
971 case LEGACY_INSTALLINFO_STATUS_DELETED:
972 Legacy_ModuleInstallUtils::uninstallPreferenceByOrder($currentPreferences->mPreferences[$idx]->mOrder, $module, $log);
980 foreach (array_keys($currentPreferences->mComments) as $idx) {
981 switch ($currentPreferences->mComments[$idx]->mStatus) {
982 case LEGACY_INSTALLINFO_STATUS_UPDATED:
983 Legacy_ModuleInstallUtils::updatePreferenceByInfo($currentPreferences->mComments[$idx], $module, $log);
986 case LEGACY_INSTALLINFO_STATUS_ORDER_UPDATED:
987 Legacy_ModuleInstallUtils::updatePreferenceOrderByInfo($currentPreferences->mComments[$idx], $module, $log);
990 case LEGACY_INSTALLINFO_STATUS_NEW:
991 Legacy_ModuleInstallUtils::installPreferenceByInfo($currentPreferences->mComments[$idx], $module, $log);
994 case LEGACY_INSTALLINFO_STATUS_DELETED:
995 Legacy_ModuleInstallUtils::uninstallPreferenceByOrder($currentPreferences->mComments[$idx]->mOrder, $module, $log);
1003 foreach (array_keys($currentPreferences->mNotifications) as $idx) {
1004 switch ($currentPreferences->mNotifications[$idx]->mStatus) {
1005 case LEGACY_INSTALLINFO_STATUS_UPDATED:
1006 Legacy_ModuleInstallUtils::updatePreferenceByInfo($currentPreferences->mNotifications[$idx], $module, $log);
1009 case LEGACY_INSTALLINFO_STATUS_ORDER_UPDATED:
1010 Legacy_ModuleInstallUtils::updatePreferenceOrderByInfo($currentPreferences->mNotifications[$idx], $module, $log);
1013 case LEGACY_INSTALLINFO_STATUS_NEW:
1014 Legacy_ModuleInstallUtils::installPreferenceByInfo($currentPreferences->mNotifications[$idx], $module, $log);
1017 case LEGACY_INSTALLINFO_STATUS_DELETED:
1018 Legacy_ModuleInstallUtils::uninstallPreferenceByOrder($currentPreferences->mNotifications[$idx]->mOrder, $module, $log);
1024 public static function updateBlockTemplateByInfo(&$info, &$module, &$log)
1026 $handler =& xoops_getmodulehandler(
'newblocks',
'legacy');
1028 $criteria =
new CriteriaCompo();
1029 $criteria->add(
new Criteria(
'dirname', $module->get(
'dirname')));
1030 $criteria->add(
new Criteria(
'func_num', $info->mFuncNum));
1032 $blockArr =& $handler->getObjects($criteria);
1033 foreach (array_keys($blockArr) as $idx) {
1039 public static function updateBlockByInfo(&$info, &$module, &$log)
1041 $handler =& xoops_getmodulehandler(
'newblocks',
'legacy');
1043 $criteria =
new CriteriaCompo();
1044 $criteria->add(
new Criteria(
'dirname', $module->get(
'dirname')));
1045 $criteria->add(
new Criteria(
'func_num', $info->mFuncNum));
1047 $blockArr =& $handler->getObjects($criteria);
1048 foreach (array_keys($blockArr) as $idx) {
1049 $blockArr[$idx]->set(
'options', $info->mOptions);
1050 $blockArr[$idx]->set(
'name', $info->mName);
1051 $blockArr[$idx]->set(
'func_file', $info->mFuncFile);
1052 $blockArr[$idx]->set(
'show_func', $info->mShowFunc);
1053 $blockArr[$idx]->set(
'edit_func', $info->mEditFunc);
1054 $blockArr[$idx]->set(
'template', $info->mTemplate);
1056 if ($handler->insert($blockArr[$idx])) {
1067 public static function updatePreferenceByInfo(&$info, &$module, &$log)
1069 $handler =& xoops_gethandler(
'config');
1071 $criteria =
new CriteriaCompo();
1072 $criteria->add(
new Criteria(
'conf_modid', $module->get(
'mid')));
1073 $criteria->add(
new Criteria(
'conf_catid', 0));
1074 $criteria->add(
new Criteria(
'conf_name', $info->mName));
1076 $configArr =& $handler->getConfigs($criteria);
1078 if (!((is_countable($configArr) ? count($configArr) : 0) > 0 && is_object($configArr[0]))) {
1079 $log->addError(
'Execption Error: Could not find config.');
1083 $config =& $configArr[0];
1085 $config->set(
'conf_title', $info->mTitle);
1086 $config->set(
'conf_desc', $info->mDescription);
1091 $oldValueType = $config->get(
'conf_valuetype');
1092 if ($config->get(
'conf_formtype') != $info->mFormType && $oldValueType != $info->mValueType) {
1093 $config->set(
'conf_formtype', $info->mFormType);
1094 $config->set(
'conf_valuetype', $info->mValueType);
1095 $config->setConfValueForInput($info->mDefault);
1097 $updateValue =
null;
1098 if ($oldValueType != $info->mValueType) {
1099 if (
'array' === $oldValueType ||
'array' === $info->mValueType) {
1100 $updateValue = $info->mDefault;
1102 $updateValue = $config->getConfValueForOutput();
1105 $config->set(
'conf_formtype', $info->mFormType);
1106 $config->set(
'conf_valuetype', $info->mValueType);
1107 if (
null !== $updateValue) {
1108 $config->setConfValueForInput($updateValue);
1112 $config->set(
'conf_order', $info->mOrder);
1114 $optionArr =& $handler->getConfigOptions(
new Criteria(
'conf_id', $config->get(
'conf_id')));
1115 if (is_array($optionArr)) {
1116 foreach (array_keys($optionArr) as $idx) {
1117 $handler->_oHandler->delete($optionArr[$idx]);
1121 if ((is_countable($info->mOption->mOptions) ? count($info->mOption->mOptions) : 0) > 0) {
1122 foreach (array_keys($info->mOption->mOptions) as $idx) {
1123 $option =& $handler->createConfigOption();
1124 $option->set(
'confop_name', $info->mOption->mOptions[$idx]->mName);
1125 $option->set(
'confop_value', $info->mOption->mOptions[$idx]->mValue);
1126 $option->set(
'conf_id', $option->get(
'conf_id'));
1127 $config->setConfOptions($option);
1132 if ($handler->insertConfig($config)) {
1139 public static function updatePreferenceOrderByInfo(&$info, &$module, &$log)
1141 $handler =& xoops_gethandler(
'config');
1143 $criteria =
new CriteriaCompo();
1144 $criteria->add(
new Criteria(
'conf_modid', $module->get(
'mid')));
1145 $criteria->add(
new Criteria(
'conf_catid', 0));
1146 $criteria->add(
new Criteria(
'conf_name', $info->mName));
1148 $configArr =& $handler->getConfigs($criteria);
1150 if (!((is_countable($configArr) ? count($configArr) : 0) > 0 && is_object($configArr[0]))) {
1151 $log->addError(
'Execption Error: Could not find config.');
1155 $config =& $configArr[0];
1157 $config->set(
'conf_order', $info->mOrder);
1159 if (!$handler->insertConfig($config)) {
1160 $log->addError(
XCube_Utils::formatString(
"Could not update the order of preference '{0}'.", $config->get(
'conf_name')));
1164 public static function installBlockByInfo(&$info, &$module, &$log)
1166 $handler =& xoops_gethandler(
'block');
1167 $block =& $handler->create();
1169 $block->set(
'mid', $module->get(
'mid'));
1170 $block->set(
'func_num', $info->mFuncNum);
1171 $block->set(
'options', $info->mOptions);
1172 $block->set(
'name', $info->mName);
1173 $block->set(
'title', $info->mName);
1174 $block->set(
'dirname', $module->get(
'dirname'));
1175 $block->set(
'func_file', $info->mFuncFile);
1176 $block->set(
'show_func', $info->mShowFunc);
1177 $block->set(
'edit_func', $info->mEditFunc);
1178 $block->set(
'template', $info->mTemplate);
1179 $block->set(
'block_type',
'M');
1180 $block->set(
'c_type', 1);
1182 if (!$handler->insert($block)) {
1202 $handler =& xoops_getmodulehandler(
'newblocks',
'legacy');
1205 $criteria->add(
new Criteria(
'dirname', $module->get(
'dirname')));
1206 $criteria->add(
new Criteria(
'func_num', $func_num));
1208 $blockArr =& $handler->getObjects($criteria);
1209 foreach (array_keys($blockArr) as $idx) {
1210 if ($handler->delete($blockArr[$idx])) {
1211 $log->addReport(
XCube_Utils::formatString(_AD_LEGACY_MESSAGE_UNINSTALLATION_BLOCK_SUCCESSFUL, $blockArr[$idx]->
get(
'name')));
1216 Legacy_ModuleInstallUtils::uninstallBlockTemplate($blockArr[$idx], $module, $log);
1234 $handler =& xoops_gethandler(
'tplfile');
1236 $criteria->add(
new Criteria(
'tpl_refid', $block->get(
'bid')));
1237 $criteria->add(
new Criteria(
'tpl_file', $block->get(
'template')));
1238 $criteria->add(
new Criteria(
'tpl_module', $module->get(
'dirname')));
1239 $criteria->add(
new Criteria(
'tpl_type',
'block'));
1241 if (
null != $tplset) {
1243 $criteria->add(
new Criteria(
'tpl_tplset', $tplset));
1246 $handler->deleteAll($criteria);
1249 public static function uninstallBlockTemplate(&$block, &$module, &$log)
1266 public static function uninstallPreferenceByOrder($order, &$module, &$log)
1268 $handler =& xoops_gethandler(
'config');
1271 $criteria->add(
new Criteria(
'conf_modid', $module->get(
'mid')));
1272 $criteria->add(
new Criteria(
'conf_catid', 0));
1273 $criteria->add(
new Criteria(
'conf_order', $order));
1275 $configArr =& $handler->getConfigs($criteria);
1277 foreach (array_keys($configArr) as $idx) {
1278 if ($handler->deleteConfig($configArr[$idx])) {
1293 public static function DBquery($query, &$module, $log)
1295 require_once XOOPS_MODULE_PATH .
'/legacy/admin/class/Legacy_SQLScanner.class.php';
1297 $successFlag =
true;
1300 $scanner->setDB_PREFIX(XOOPS_DB_PREFIX);
1301 $scanner->setDirname($module->get(
'dirname'));
1302 $scanner->setBuffer($query);
1304 $sqlArr = $scanner->getSQL();
1306 $root =& XCube_Root::getSingleton();
1308 foreach ($sqlArr as $sql) {
1309 if ($root->mController->mDB->query($sql)) {
1310 $log->addReport(
"Success: {$sql}");
1311 $successFlag &=
true;
1313 $log->addError(
"Failure: {$sql}");
1314 $successFlag =
false;
1318 return $successFlag;
1321 public static function deleteAllOfNotifications(&$module, &$log)
1323 $handler =& xoops_gethandler(
'notification');
1324 $criteria =
new Criteria(
'not_modid', $module->get(
'mid'));
1325 $handler->deleteAll($criteria);
1328 public static function deleteAllOfComments(&$module, &$log)
1330 $handler =& xoops_gethandler(
'comment');
1331 $criteria =
new Criteria(
'com_modid', $module->get(
'mid'));
1332 $handler->deleteAll($criteria);