<?php
use XoopsModules\Tadtools\Utility;
if (!class_exists('XoopsModules\Tadtools\Utility')) {
require XOOPS_ROOT_PATH . '/modules/tadtools/preloads/autoloader.php';
}
use XoopsModules\Tad_signup\Update;
if (!class_exists('XoopsModules\Tad_signup\Update')) {
require dirname(__DIR__) . '/preloads/autoloader.php';
}
// 更新前
function xoops_module_pre_update_tad_signup(XoopsModule $module, $old_version)
{
// 有上傳功能才需要
Utility::mk_dir(XOOPS_ROOT_PATH . "/uploads/tad_signup");
// 若有用到CKEditor編輯器才需要
Utility::mk_dir(XOOPS_ROOT_PATH . "/uploads/tad_signup/file");
Utility::mk_dir(XOOPS_ROOT_PATH . "/uploads/tad_signup/image");
Utility::mk_dir(XOOPS_ROOT_PATH . "/uploads/tad_signup/image/.thumbs");
$gperm_handler = xoops_getHandler('groupperm');
$groupid = Update::mk_group(_MD_TAD_SIGNUP_ADMIN);
if (!$gperm_handler->checkRight($module->dirname(), 1, $groupid, $module->mid())) {
$perm_handler = xoops_getHandler('groupperm');
$perm = $perm_handler->create();
$perm->setVar('gperm_groupid', $groupid);
$perm->setVar('gperm_itemid', 1);
$perm->setVar('gperm_name', $module->dirname()); //一般為模組目錄名稱
$perm->setVar('gperm_modid', $module->mid());
$perm_handler->insert($perm);
}
return true;
}
// 更新後
function xoops_module_update_tad_signup(XoopsModule $module, $old_version)
{
global $xoopsDB;
// 新增候補欄位
if (Update::chk_candidate()) {
Update::go_candidate();
}
return true;
}
link to https://github.com/tadlearn/tad_signup/commit/af4f4ac282c3915a7f192e913f2c890ae6367b5c \