유저 설정값을 view에서 미리 처리하여 전달

This commit is contained in:
BJRambo 2021-02-03 13:35:48 +09:00
parent 041860f9ee
commit 8c8a163561
4 changed files with 56 additions and 59 deletions

View file

@ -17,26 +17,17 @@
</h1> </h1>
<p>{$lang->ncenterlite_userconfig_about} <strong style="color:#ff0000" cond="$member_srl && $member_srl != $logged_info->member_srl">({$lang->ncenterlite_userconfig_about_warning})</strong></p> <p>{$lang->ncenterlite_userconfig_about} <strong style="color:#ff0000" cond="$member_srl && $member_srl != $logged_info->member_srl">({$lang->ncenterlite_userconfig_about_warning})</strong></p>
{@ $uc = get_object_vars($user_config)}
<!--@foreach($notify_types as $notify_type => $notify_srl)--> <!--@foreach($notify_types as $notify_type => $notify_srl)-->
<div class="control-group"> <div class="control-group">
<label class="x_control-label">{$lang->get('ncenterlite_type_' . $notify_type)}</label> <label class="x_control-label">{$lang->get('ncenterlite_type_' . $notify_type)}</label>
<div class="x_controls"> <div class="x_controls">
{@ $available = isset($module_config->use[$notify_type]['web']) && $module_config->use[$notify_type]['web'] !== 'N'} <label class="x_inline"><input type="checkbox" name="use[{$notify_type}][web]" value="1" disabled="disabled"|cond="!$user_selected[$notify_type]['web']->available" checked="checked"|cond="$user_selected[$notify_type]['web']->available && $user_selected[$notify_type]['web']->selected" /> {$lang->cmd_web_notify}</label>
{@ $selected = (is_array($uc[$notify_type]) && in_array('web', $uc[$notify_type]))} <label class="x_inline"><input type="checkbox" name="use[{$notify_type}][mail]" value="1" disabled="disabled"|cond="!$user_selected[$notify_type]['mail']->available" checked="checked"|cond="$user_selected[$notify_type]['mail']->available && $user_selected[$notify_type]['mail']->selected" /> {$lang->cmd_mail_notify}</label>
<label class="x_inline"><input type="checkbox" name="use[{$notify_type}][web]" value="1" disabled="disabled"|cond="!$available" checked="checked"|cond="$available && $selected" /> {$lang->cmd_web_notify}</label>
{@ $available = isset($module_config->use[$notify_type]['mail']) && $module_config->use[$notify_type]['mail'] !== 'N'}
{@ $selected = (is_array($uc[$notify_type]) && in_array('mail', $uc[$notify_type]))}
<label class="x_inline"><input type="checkbox" name="use[{$notify_type}][mail]" value="1" disabled="disabled"|cond="!$available" checked="checked"|cond="$available && $selected" /> {$lang->cmd_mail_notify}</label>
<!--@if($sms_available)--> <!--@if($sms_available)-->
{@ $available = isset($module_config->use[$notify_type]['sms']) && $module_config->use[$notify_type]['sms'] !== 'N'} <label class="x_inline"><input type="checkbox" name="use[{$notify_type}][sms]" value="1" disabled="disabled"|cond="!$user_selected[$notify_type]['sms']->available" checked="checked"|cond="$user_selected[$notify_type]['sms']->available && $user_selected[$notify_type]['sms']->selected" /> {$lang->cmd_sms_notify}</label>
{@ $selected = (is_array($uc[$notify_type]) && in_array('sms', $uc[$notify_type]))}
<label class="x_inline"><input type="checkbox" name="use[{$notify_type}][sms]" value="1" disabled="disabled"|cond="!$available" checked="checked"|cond="$available && $selected" /> {$lang->cmd_sms_notify}</label>
<!--@endif--> <!--@endif-->
<!--@if($push_available)--> <!--@if($push_available)-->
{@ $available = isset($module_config->use[$notify_type]['push']) && $module_config->use[$notify_type]['push'] !== 'N'} <label class="x_inline"><input type="checkbox" name="use[{$notify_type}][push]" value="1" disabled="disabled"|cond="!$user_selected[$notify_type]['push']->available" checked="checked"|cond="$user_selected[$notify_type]['push']->available && $user_selected[$notify_type]['push']->selected" /> {$lang->cmd_push_notify}</label>
{@ $selected = (is_array($uc[$notify_type]) && in_array('push', $uc[$notify_type]))}
<label class="x_inline"><input type="checkbox" name="use[{$notify_type}][push]" value="1" disabled="disabled"|cond="!$available" checked="checked"|cond="$available && $selected" /> {$lang->cmd_push_notify}</label>
<!--@endif--> <!--@endif-->
<p class="help-block">{sprintf($lang->get('ncenterlite_' . $notify_type . '_noti_about'), $logged_info->nick_name)}</p> <p class="help-block">{sprintf($lang->get('ncenterlite_' . $notify_type . '_noti_about'), $logged_info->nick_name)}</p>
</div> </div>

View file

@ -70,13 +70,35 @@ class ncenterliteView extends ncenterlite
$user_config = NcenterliteModel::getUserConfig($member_srl) ?: new stdClass; $user_config = NcenterliteModel::getUserConfig($member_srl) ?: new stdClass;
$notify_types = NcenterliteModel::getUserSetNotifyTypes(); $notify_types = NcenterliteModel::getUserSetNotifyTypes();
foreach ($notify_types as $type => $srl)
$userConfigArray = get_object_vars($user_config);
$otherNotifyType = [
'web',
'mail',
'sms',
'push',
];
$user_selected = [];
foreach($notify_types as $notify_type => $notify_srl)
{ {
$user_config->{$type . '_notify'} = $user_config->{$type} ? 'Y' : 'N'; $user_config->{$notify_type . '_notify'} = $user_config->{$notify_type} ? 'Y' : 'N';
$user_selected[$notify_type] = [];
foreach ($otherNotifyType as $item)
{
$available = isset($config->use[$notify_type][$item]) && $config->use[$notify_type][$item] !== 'N';
$selected = (is_array($userConfigArray[$notify_type]) && in_array($item, $userConfigArray[$notify_type]));
$user_selected[$notify_type][$item] = new stdClass();
$user_selected[$notify_type][$item]->available = $available;
$user_selected[$notify_type][$item]->selected = $selected;
}
} }
Context::set('member_info', $member_info); Context::set('member_info', $member_info);
Context::set('notify_types', $notify_types); Context::set('notify_types', $notify_types);
Context::set('user_config', $user_config); Context::set('user_config', $user_config);
Context::set('user_selected', $user_selected);
Context::set('module_config', NcenterliteModel::getConfig()); Context::set('module_config', NcenterliteModel::getConfig());
Context::set('sms_available', Rhymix\Framework\SMS::getDefaultDriver()->getName() !== 'Dummy'); Context::set('sms_available', Rhymix\Framework\SMS::getDefaultDriver()->getName() !== 'Dummy');
Context::set('push_available', count(Rhymix\Framework\Config::get('push.types') ?? []) > 0); Context::set('push_available', count(Rhymix\Framework\Config::get('push.types') ?? []) > 0);

View file

@ -19,30 +19,21 @@
</h1> </h1>
<p>{$lang->ncenterlite_userconfig_about} <strong style="color:#ff0000" cond="$member_srl && $member_srl != $logged_info->member_srl">({$lang->ncenterlite_userconfig_about_warning})</strong></p> <p>{$lang->ncenterlite_userconfig_about} <strong style="color:#ff0000" cond="$member_srl && $member_srl != $logged_info->member_srl">({$lang->ncenterlite_userconfig_about_warning})</strong></p>
{@ $uc = get_object_vars($user_config)}
<!--@foreach($notify_types as $notify_type => $notify_srl)--> <!--@foreach($notify_types as $notify_type => $notify_srl)-->
<div class="control-group"> <div class="control-group">
<label class="x_control-label">{$lang->get('ncenterlite_type_' . $notify_type)}</label> <label class="x_control-label">{$lang->get('ncenterlite_type_' . $notify_type)}</label>
<div class="x_controls"> <div class="x_controls">
{@ $available = isset($module_config->use[$notify_type]['web']) && $module_config->use[$notify_type]['web'] !== 'N'} <label class="x_inline"><input type="checkbox" name="use[{$notify_type}][web]" value="1" disabled="disabled"|cond="!$user_selected[$notify_type]['web']->available" checked="checked"|cond="$user_selected[$notify_type]['web']->available && $user_selected[$notify_type]['web']->selected" /> {$lang->cmd_web_notify}</label>
{@ $selected = (is_array($uc[$notify_type]) && in_array('web', $uc[$notify_type]))} <label class="x_inline"><input type="checkbox" name="use[{$notify_type}][mail]" value="1" disabled="disabled"|cond="!$user_selected[$notify_type]['mail']->available" checked="checked"|cond="$user_selected[$notify_type]['mail']->available && $user_selected[$notify_type]['mail']->selected" /> {$lang->cmd_mail_notify}</label>
<label class="x_inline"><input type="checkbox" name="use[{$notify_type}][web]" value="1" disabled="disabled"|cond="!$available" checked="checked"|cond="$available && $selected" /> {$lang->cmd_web_notify}</label> <!--@if($sms_available)-->
{@ $available = isset($module_config->use[$notify_type]['mail']) && $module_config->use[$notify_type]['mail'] !== 'N'} <label class="x_inline"><input type="checkbox" name="use[{$notify_type}][sms]" value="1" disabled="disabled"|cond="!$user_selected[$notify_type]['sms']->available" checked="checked"|cond="$user_selected[$notify_type]['sms']->available && $user_selected[$notify_type]['sms']->selected" /> {$lang->cmd_sms_notify}</label>
{@ $selected = (is_array($uc[$notify_type]) && in_array('mail', $uc[$notify_type]))} <!--@endif-->
<label class="x_inline"><input type="checkbox" name="use[{$notify_type}][mail]" value="1" disabled="disabled"|cond="!$available" checked="checked"|cond="$available && $selected" /> {$lang->cmd_mail_notify}</label> <!--@if($push_available)-->
<!--@if($sms_available)--> <label class="x_inline"><input type="checkbox" name="use[{$notify_type}][push]" value="1" disabled="disabled"|cond="!$user_selected[$notify_type]['push']->available" checked="checked"|cond="$user_selected[$notify_type]['push']->available && $user_selected[$notify_type]['push']->selected" /> {$lang->cmd_push_notify}</label>
{@ $available = isset($module_config->use[$notify_type]['sms']) && $module_config->use[$notify_type]['sms'] !== 'N'} <!--@endif-->
{@ $selected = (is_array($uc[$notify_type]) && in_array('sms', $uc[$notify_type]))} <p class="help-block">{sprintf($lang->get('ncenterlite_' . $notify_type . '_noti_about'), $logged_info->nick_name)}</p>
<label class="x_inline"><input type="checkbox" name="use[{$notify_type}][sms]" value="1" disabled="disabled"|cond="!$available" checked="checked"|cond="$available && $selected" /> {$lang->cmd_sms_notify}</label>
<!--@endif-->
<!--@if($push_available)-->
{@ $available = isset($module_config->use[$notify_type]['push']) && $module_config->use[$notify_type]['push'] !== 'N'}
{@ $selected = (is_array($uc[$notify_type]) && in_array('push', $uc[$notify_type]))}
<label class="x_inline"><input type="checkbox" name="use[{$notify_type}][push]" value="1" disabled="disabled"|cond="!$available" checked="checked"|cond="$available && $selected" /> {$lang->cmd_push_notify}</label>
<!--@endif-->
<p class="help-block">{sprintf($lang->get('ncenterlite_' . $notify_type . '_noti_about'), $logged_info->nick_name)}</p>
</div>
</div> </div>
</div>
<!--@endforeach--> <!--@endforeach-->
</section> </section>
<div class="clearfix btnArea"> <div class="clearfix btnArea">

View file

@ -19,30 +19,21 @@
</h1> </h1>
<p>{$lang->ncenterlite_userconfig_about} <strong style="color:#ff0000" cond="$member_srl && $member_srl != $logged_info->member_srl">({$lang->ncenterlite_userconfig_about_warning})</strong></p> <p>{$lang->ncenterlite_userconfig_about} <strong style="color:#ff0000" cond="$member_srl && $member_srl != $logged_info->member_srl">({$lang->ncenterlite_userconfig_about_warning})</strong></p>
{@ $uc = get_object_vars($user_config)}
<!--@foreach($notify_types as $notify_type => $notify_srl)--> <!--@foreach($notify_types as $notify_type => $notify_srl)-->
<div class="control-group"> <div class="control-group">
<label class="x_control-label">{$lang->get('ncenterlite_type_' . $notify_type)}</label> <label class="x_control-label">{$lang->get('ncenterlite_type_' . $notify_type)}</label>
<div class="x_controls"> <div class="x_controls">
{@ $available = isset($module_config->use[$notify_type]['web']) && $module_config->use[$notify_type]['web'] !== 'N'} <label class="x_inline"><input type="checkbox" name="use[{$notify_type}][web]" value="1" disabled="disabled"|cond="!$user_selected[$notify_type]['web']->available" checked="checked"|cond="$user_selected[$notify_type]['web']->available && $user_selected[$notify_type]['web']->selected" /> {$lang->cmd_web_notify}</label>
{@ $selected = (is_array($uc[$notify_type]) && in_array('web', $uc[$notify_type]))} <label class="x_inline"><input type="checkbox" name="use[{$notify_type}][mail]" value="1" disabled="disabled"|cond="!$user_selected[$notify_type]['mail']->available" checked="checked"|cond="$user_selected[$notify_type]['mail']->available && $user_selected[$notify_type]['mail']->selected" /> {$lang->cmd_mail_notify}</label>
<label class="x_inline"><input type="checkbox" name="use[{$notify_type}][web]" value="1" disabled="disabled"|cond="!$available" checked="checked"|cond="$available && $selected" /> {$lang->cmd_web_notify}</label> <!--@if($sms_available)-->
{@ $available = isset($module_config->use[$notify_type]['mail']) && $module_config->use[$notify_type]['mail'] !== 'N'} <label class="x_inline"><input type="checkbox" name="use[{$notify_type}][sms]" value="1" disabled="disabled"|cond="!$user_selected[$notify_type]['sms']->available" checked="checked"|cond="$user_selected[$notify_type]['sms']->available && $user_selected[$notify_type]['sms']->selected" /> {$lang->cmd_sms_notify}</label>
{@ $selected = (is_array($uc[$notify_type]) && in_array('mail', $uc[$notify_type]))} <!--@endif-->
<label class="x_inline"><input type="checkbox" name="use[{$notify_type}][mail]" value="1" disabled="disabled"|cond="!$available" checked="checked"|cond="$available && $selected" /> {$lang->cmd_mail_notify}</label> <!--@if($push_available)-->
<!--@if($sms_available)--> <label class="x_inline"><input type="checkbox" name="use[{$notify_type}][push]" value="1" disabled="disabled"|cond="!$user_selected[$notify_type]['push']->available" checked="checked"|cond="$user_selected[$notify_type]['push']->available && $user_selected[$notify_type]['push']->selected" /> {$lang->cmd_push_notify}</label>
{@ $available = isset($module_config->use[$notify_type]['sms']) && $module_config->use[$notify_type]['sms'] !== 'N'} <!--@endif-->
{@ $selected = (is_array($uc[$notify_type]) && in_array('sms', $uc[$notify_type]))} <p class="help-block">{sprintf($lang->get('ncenterlite_' . $notify_type . '_noti_about'), $logged_info->nick_name)}</p>
<label class="x_inline"><input type="checkbox" name="use[{$notify_type}][sms]" value="1" disabled="disabled"|cond="!$available" checked="checked"|cond="$available && $selected" /> {$lang->cmd_sms_notify}</label>
<!--@endif-->
<!--@if($push_available)-->
{@ $available = isset($module_config->use[$notify_type]['push']) && $module_config->use[$notify_type]['push'] !== 'N'}
{@ $selected = (is_array($uc[$notify_type]) && in_array('push', $uc[$notify_type]))}
<label class="x_inline"><input type="checkbox" name="use[{$notify_type}][push]" value="1" disabled="disabled"|cond="!$available" checked="checked"|cond="$available && $selected" /> {$lang->cmd_push_notify}</label>
<!--@endif-->
<p class="help-block">{sprintf($lang->get('ncenterlite_' . $notify_type . '_noti_about'), $logged_info->nick_name)}</p>
</div>
</div> </div>
</div>
<!--@endforeach--> <!--@endforeach-->
</section> </section>
<div class="clearfix btnArea"> <div class="clearfix btnArea">
@ -53,3 +44,5 @@
</form> </form>
</div> </div>
<include target="../../../member/skins/default/common_footer.html" /> <include target="../../../member/skins/default/common_footer.html" />