mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-04 01:01:41 +09:00
Separate default value from options in member extra vars, too
This commit is contained in:
parent
4b2cc8c9cf
commit
c949e797b0
11 changed files with 92 additions and 44 deletions
|
|
@ -878,21 +878,27 @@ class MemberAdminController extends Member
|
|||
$args->column_type = Context::get('column_type');
|
||||
$args->column_name = strtolower(Context::get('column_id'));
|
||||
$args->column_title = Context::get('column_title');
|
||||
$args->default_value = explode("\n", str_replace("\r", '', Context::get('default_value')));
|
||||
$args->required = Context::get('required');
|
||||
$args->is_active = (isset($args->required));
|
||||
if(!in_array(strtoupper($args->required), array('Y','N')))$args->required = 'N';
|
||||
$args->description = Context::get('description') ? Context::get('description') : '';
|
||||
// Default values
|
||||
if(in_array($args->column_type, array('checkbox','select','radio')) && count($args->default_value))
|
||||
$args->default_value = trim(utf8_clean(Context::get('default_value')));
|
||||
$args->options = trim(utf8_clean(Context::get('options')));
|
||||
if ($args->options !== '')
|
||||
{
|
||||
$args->default_value = serialize($args->default_value);
|
||||
$args->options = array_map('trim', explode("\n", $args->options));
|
||||
$args->options = json_encode($args->options, \JSON_UNESCAPED_UNICODE | \JSON_UNESCAPED_SLASHES);
|
||||
}
|
||||
else
|
||||
{
|
||||
$args->default_value = '';
|
||||
$args->options = null;
|
||||
}
|
||||
|
||||
$args->required = Context::get('required');
|
||||
if (!in_array(strtoupper($args->required), array('Y','N')))
|
||||
{
|
||||
$args->required = 'N';
|
||||
}
|
||||
|
||||
$args->is_active = (isset($args->required));
|
||||
$args->description = Context::get('description') ? Context::get('description') : '';
|
||||
|
||||
// Check ID duplicated
|
||||
if (Context::isReservedWord($args->column_name))
|
||||
{
|
||||
|
|
@ -909,7 +915,7 @@ class MemberAdminController extends Member
|
|||
}
|
||||
}
|
||||
// Fix if member_join_form_srl exists. Add if not exists.
|
||||
$isInsert;
|
||||
$isInsert = false;
|
||||
if(!$args->member_join_form_srl)
|
||||
{
|
||||
$isInsert = true;
|
||||
|
|
|
|||
|
|
@ -288,13 +288,24 @@ class MemberAdminModel extends Member
|
|||
if($output->toBool() && $output->data)
|
||||
{
|
||||
$formInfo = $output->data;
|
||||
$default_value = $formInfo->default_value;
|
||||
if($default_value)
|
||||
$default_value = '';
|
||||
$options = '';
|
||||
if (isset($formInfo->options) && $formInfo->options !== '')
|
||||
{
|
||||
$default_value = unserialize($default_value);
|
||||
Context::set('default_value', $default_value);
|
||||
$default_value = $formInfo->default_value;
|
||||
$options = json_decode($formInfo->options, true);
|
||||
}
|
||||
elseif (preg_match('/^a:\d+:\{i:/', $formInfo->default_value))
|
||||
{
|
||||
$options = unserialize($formInfo->default_value);
|
||||
}
|
||||
else
|
||||
{
|
||||
$default_value = $formInfo->default_value;
|
||||
}
|
||||
Context::set('formInfo', $output->data);
|
||||
Context::set('default_value', $default_value);
|
||||
Context::set('options', $options);
|
||||
}
|
||||
|
||||
$oMemberModel = getModel('member');
|
||||
|
|
@ -314,7 +325,7 @@ class MemberAdminModel extends Member
|
|||
$oTemplate = TemplateHandler::getInstance();
|
||||
$tpl = $oTemplate->compile($this->module_path.'tpl', 'insert_join_form');
|
||||
|
||||
$this->add('tpl', str_replace("\n"," ",$tpl));
|
||||
$this->add('tpl', $tpl);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -486,7 +486,7 @@ class MemberAdminView extends Member
|
|||
{
|
||||
$extend_form_list = MemberModel::getCombineJoinForm($memberInfo);
|
||||
$security = new Security($extend_form_list);
|
||||
$security->encodeHTML('..column_title', '..description', '..default_value.');
|
||||
$security->encodeHTML('..column_title', '..description', '..default_value', '..options.');
|
||||
|
||||
if ($memberInfo)
|
||||
{
|
||||
|
|
@ -725,6 +725,7 @@ class MemberAdminView extends Member
|
|||
$input->input_id = $extendForm->column_name;
|
||||
$input->value = $extendForm->value ?? '';
|
||||
$input->default = $extendForm->default_value ?? null;
|
||||
$input->options = $extendForm->options ?? null;
|
||||
if ($extendForm->column_type === 'tel' || $extendForm->column_type === 'tel_intl')
|
||||
{
|
||||
$input->style = 'width:33.3px';
|
||||
|
|
|
|||
|
|
@ -167,6 +167,9 @@ class Member extends ModuleObject
|
|||
if(!$oDB->isIndexExists('member_auth_mail', 'idx_member_srl')) return true;
|
||||
if($oDB->isIndexExists('member_auth_mail', 'unique_key')) return true;
|
||||
|
||||
// Check join form options column
|
||||
if(!$oDB->isColumnExists('member_join_form', 'options')) return true;
|
||||
|
||||
// Update status column
|
||||
$output = executeQuery('member.getDeniedAndStatus');
|
||||
if ($output->data->count)
|
||||
|
|
@ -403,6 +406,12 @@ class Member extends ModuleObject
|
|||
$oDB->dropIndex('member_auth_mail', 'unique_key');
|
||||
}
|
||||
|
||||
// Check join form options column
|
||||
if(!$oDB->isColumnExists('member_join_form', 'options'))
|
||||
{
|
||||
$oDB->addColumn('member_join_form', 'options', 'text', null, null, null, 'default_value');
|
||||
}
|
||||
|
||||
// Update status column
|
||||
$output = executeQuery('member.getDeniedAndStatus');
|
||||
if ($output->data->count)
|
||||
|
|
|
|||
|
|
@ -2871,7 +2871,7 @@ class MemberController extends Member
|
|||
|
||||
$extend_form_list = MemberModel::getJoinFormlist();
|
||||
$security = new Security($extend_form_list);
|
||||
$security->encodeHTML('..column_title', '..description', '..default_value.');
|
||||
$security->encodeHTML('..column_title', '..description', '..default_value', '..options.');
|
||||
if($config->signupForm)
|
||||
{
|
||||
foreach($config->signupForm as $no => $formInfo)
|
||||
|
|
@ -3167,7 +3167,7 @@ class MemberController extends Member
|
|||
|
||||
$extend_form_list = MemberModel::getJoinFormlist();
|
||||
$security = new Security($extend_form_list);
|
||||
$security->encodeHTML('..column_title', '..description', '..default_value.');
|
||||
$security->encodeHTML('..column_title', '..description', '..default_value', '..options.');
|
||||
if($config->signupForm)
|
||||
{
|
||||
foreach($config->signupForm as $no => $formInfo)
|
||||
|
|
|
|||
|
|
@ -806,31 +806,38 @@ class MemberModel extends Member
|
|||
if(!$join_form_list) return NULL;
|
||||
// Need to unserialize because serialized array is inserted into DB in case of default_value
|
||||
if(!is_array($join_form_list)) $join_form_list = array($join_form_list);
|
||||
$join_form_count = count($join_form_list);
|
||||
for($i=0;$i<$join_form_count;$i++)
|
||||
foreach ($join_form_list as $i => $join_form)
|
||||
{
|
||||
$join_form_list[$i]->column_name = strtolower($join_form_list[$i]->column_name);
|
||||
$join_form->column_name = strtolower($join_form->column_name);
|
||||
|
||||
$member_join_form_srl = $join_form_list[$i]->member_join_form_srl;
|
||||
$column_type = $join_form_list[$i]->column_type;
|
||||
$column_name = $join_form_list[$i]->column_name;
|
||||
$column_title = $join_form_list[$i]->column_title;
|
||||
$default_value = $join_form_list[$i]->default_value;
|
||||
// Add language variable
|
||||
if(!isset($lang->extend_vars)) $lang->extend_vars = array();
|
||||
$lang->extend_vars[$column_name] = $column_title;
|
||||
// unserialize if the data type if checkbox, select and so on
|
||||
if(in_array($column_type, array('checkbox','select','radio')))
|
||||
$column_name = $join_form->column_name;
|
||||
$column_title = $join_form->column_title;
|
||||
if (!isset($lang->extend_vars))
|
||||
{
|
||||
$join_form_list[$i]->default_value = unserialize($default_value);
|
||||
if(!$join_form_list[$i]->default_value[0]) $join_form_list[$i]->default_value = '';
|
||||
$lang->extend_vars = array();
|
||||
}
|
||||
$lang->extend_vars[$column_name] = $column_title;
|
||||
|
||||
// unserialize if the data type if checkbox, select and so on
|
||||
if (in_array($join_form->column_type, ['checkbox','select','radio']))
|
||||
{
|
||||
if (isset($join_form->options) && $join_form->options !== '')
|
||||
{
|
||||
$join_form->options = json_decode($join_form->options, true);
|
||||
}
|
||||
elseif (preg_match('/^a:\d+:\{i:/', $join_form->default_value))
|
||||
{
|
||||
$join_form->options = unserialize($join_form->default_value);
|
||||
$join_form->default_value = '';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$join_form_list[$i]->default_value = '';
|
||||
$join_form->default_value = '';
|
||||
}
|
||||
|
||||
$list[$member_join_form_srl] = $join_form_list[$i];
|
||||
$list[$join_form->member_join_form_srl] = $join_form;
|
||||
}
|
||||
self::$_join_form_list = $list;
|
||||
}
|
||||
|
|
@ -958,12 +965,17 @@ class MemberModel extends Member
|
|||
$join_form = $output->data;
|
||||
if(!$join_form) return NULL;
|
||||
|
||||
$column_type = $join_form->column_type;
|
||||
$default_value = $join_form->default_value;
|
||||
|
||||
if(in_array($column_type, array('checkbox','select','radio')))
|
||||
if (in_array($join_form->column_type, ['checkbox','select','radio']))
|
||||
{
|
||||
$join_form->default_value = unserialize($default_value);
|
||||
if (isset($join_form->options) && $join_form->options !== '')
|
||||
{
|
||||
$join_form->options = json_decode($join_form->options, true);
|
||||
}
|
||||
elseif (preg_match('/^a:\d+:\{i:/', $join_form->default_value))
|
||||
{
|
||||
$join_form->options = unserialize($join_form->default_value);
|
||||
$join_form->default_value = '';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
|
|
@ -280,6 +280,7 @@ class MemberView extends Member
|
|||
$extvalue->input_id = $formInfo->name;
|
||||
$extvalue->value = $extendFormInfo[$formInfo->member_join_form_srl]->value ?? null;
|
||||
$extvalue->default = $extendFormInfo[$formInfo->member_join_form_srl]->default_value ?? null;
|
||||
$extvalue->options = $extendFormInfo[$formInfo->member_join_form_srl]->options ?? null;
|
||||
$item->value = $extvalue->getValueHTML();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@
|
|||
<column name="column_title" var="column_title" />
|
||||
<column name="required" var="required" default="N" />
|
||||
<column name="default_value" var="default_value" />
|
||||
<column name="options" var="options" />
|
||||
<column name="is_active" var="is_active" default="N" />
|
||||
<column name="description" var="description" />
|
||||
<column name="regdate" default="curdate()" />
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
<column name="column_title" var="column_title" />
|
||||
<column name="required" var="required" default="N" />
|
||||
<column name="default_value" var="default_value" />
|
||||
<column name="options" var="options" />
|
||||
<column name="is_active" var="is_active" default="N" />
|
||||
<column name="description" var="description" />
|
||||
</columns>
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
<column name="column_title" type="varchar" size="60" notnull="notnull" />
|
||||
<column name="required" type="char" size="1" default="N" notnull="notnull" />
|
||||
<column name="default_value" type="text" />
|
||||
<column name="options" type="text" />
|
||||
<column name="is_active" type="char" size="1" default="Y" />
|
||||
<column name="description" type="text" />
|
||||
<column name="list_order" type="number" size="11" notnull="notnull" default="1" index="idx_list_order" />
|
||||
|
|
|
|||
|
|
@ -26,11 +26,17 @@
|
|||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="x_control-group multiExample">
|
||||
<label for="multiSelect" class="x_control-label"><em style="color:red">*</em> {$lang->options}</label>
|
||||
<div class="x_control-group">
|
||||
<label for="default_value" class="x_control-label"> {$lang->default_value}</label>
|
||||
<div class="x_controls">
|
||||
<textarea rows="4" cols="42" id="multiSelect" name="default_value" style="vertical-align:top"><block cond="$default_value">{implode('|@|', $default_value)}</block></textarea>
|
||||
<p class="x_help-inline">{$lang->about_multi_type}</p>
|
||||
<input type="text" id="default_value" name="default_value" value="{$default_value}" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="x_control-group multiExample">
|
||||
<label for="multiSelect" class="x_control-label"> {$lang->options}</label>
|
||||
<div class="x_controls">
|
||||
<textarea rows="4" cols="42" id="multiSelect" name="options" style="vertical-align:top"><block cond="$options">{implode("\n", $options)}</block></textarea>
|
||||
<p class="x_help-block">{$lang->about_multi_type}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="x_control-group">
|
||||
|
|
@ -51,7 +57,6 @@
|
|||
<span class="x_pull-right"><button class="x_btn x_btn-primary" type="submit" name="mode" <!--@if($formInfo)-->value="update"<!--@else-->value="insert"<!--@end--> >{$lang->cmd_save}</button></span>
|
||||
</div>
|
||||
<script>
|
||||
var $ = jQuery;
|
||||
var typeSelect = $('.typeSelect');
|
||||
var multiOption = $('.typeSelect>option[value=checkbox], .typeSelect>option[value=radio], .typeSelect>option[value=select_multiple], .typeSelect>option[value=select]');
|
||||
var multiExample = $('.multiExample');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue