Add config entry to change member mid

This commit is contained in:
Kijin Sung 2023-06-20 01:25:05 +09:00
parent eee0eebff9
commit 030455025b
2 changed files with 55 additions and 0 deletions

View file

@ -222,6 +222,7 @@ class MemberAdminController extends Member
public function procMemberAdminInsertDefaultConfig()
{
$args = Context::gets(
'member_mid',
'enable_join',
'enable_join_key',
'enable_confirm',
@ -239,6 +240,50 @@ class MemberAdminController extends Member
'member_profile_view'
);
// Update member mid
$config = MemberModel::getMemberConfig();
if ($args->member_mid !== ($config->mid ?? null))
{
if (!preg_match('/^[a-z][a-z0-9_]+$/i', $args->member_mid))
{
return new BaseObject(-1, 'msg_limit_mid');
}
if ($config->mid)
{
$module_info = ModuleModel::getModuleInfoByMid($config->mid);
if (!$module_info || $module_info->module !== $this->module)
{
$module_info = null;
}
}
else
{
$module_info = null;
}
if ($module_info)
{
$module_info->mid = $args->member_mid;
$output = ModuleController::getInstance()->updateModule($module_info);
}
else
{
$output = $this->createMid($args->member_mid, $config->skin ?: 'default', $config->mskin ?: 'default');
}
if ($output->toBool())
{
$args->mid = $args->member_mid;
unset($args->member_mid);
}
else
{
return $output;
}
}
// Update join key
if ($args->enable_join === 'KEY')
{
$args->enable_join = 'N';

View file

@ -5,6 +5,16 @@
<input type="hidden" name="act" value="procMemberAdminInsertDefaultConfig" />
<input type="hidden" name="success_return_url" value="{getUrl('', 'module', 'admin', 'act', $act)}" />
<input type="hidden" name="xe_validator_id" value="modules/member/tpl/1" />
<div class="x_control-group">
<label class="x_control-label" for="member_mid">{$lang->url}</label>
<div class="x_controls">
<span class="baseurl" style="display:inline-block;transform:translateY(2px)">
{$site_module_info->domain}{\RX_BASEURL}<!--@if(!config('url.rewrite'))-->index.php?mid=<!--@endif-->
</span>
<input type="text" name="member_mid" id="member_mid" value="{$config->mid ?? 'member'}" />
<p class="x_help-block">{$lang->about_mid}</p>
</div>
</div>
<div class="x_control-group">
<div class="x_control-label">{$lang->enable_join}</div>
<div class="x_controls">