issue 46 apply validator to point module

git-svn-id: http://xe-core.googlecode.com/svn/branches/1.5.0@8544 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
ovclas 2011-06-29 08:15:55 +00:00
parent 13bf055f34
commit a765754a07
18 changed files with 92 additions and 18 deletions

View file

@ -7,9 +7,9 @@
<action name="dispPointAdminModuleConfig" type="view" standalone="true" />
<action name="dispPointAdminPointList" type="view" standalone="true" />
<action name="procPointAdminInsertConfig" type="controller" standalone="true" />
<action name="procPointAdminInsertConfig" type="controller" standalone="true" ruleset="insertConfig" />
<action name="procPointAdminInsertModuleConfig" type="controller" standalone="true" />
<action name="procPointAdminUpdatePoint" type="controller" standalone="true" />
<action name="procPointAdminUpdatePoint" type="controller" standalone="true" ruleset="updatePoint" />
<action name="procPointAdminInsertPointModuleConfig" type="controller" standalone="true" />
<action name="procPointAdminApplyPoint" type="controller" standalone="true" />
<action name="procPointAdminReset" type="controller" standalone="true" />

View file

@ -66,4 +66,5 @@
$lang->point_recal_message = 'Adjusting Point. (%d / %d)';
$lang->point_recal_finished = 'Point recalculation is finished.';
$lang->point_update_desc = '포인트를 증가시키려면 +를 감소시키려면 -를 숫자앞에 표기한 후 업데이트 해 주세요. + 또는 - 표시가 없으면 입력한 값으로 설정 됩니다.';
?>

View file

@ -66,4 +66,5 @@
$lang->point_recal_message = 'Ajuste de Punto. (%d / %d)';
$lang->point_recal_finished = 'Punto cálculo está acabado.';
$lang->point_update_desc = '포인트를 증가시키려면 +를 감소시키려면 -를 숫자앞에 표기한 후 업데이트 해 주세요. + 또는 - 표시가 없으면 입력한 값으로 설정 됩니다.';
?>

View file

@ -66,4 +66,5 @@
$lang->point_recal_message = 'En train d\'Adjuster le Point. (%d / %d)';
$lang->point_recal_finished = 'Recalcul des Points est fini.';
$lang->point_update_desc = '포인트를 증가시키려면 +를 감소시키려면 -를 숫자앞에 표기한 후 업데이트 해 주세요. + 또는 - 표시가 없으면 입력한 값으로 설정 됩니다.';
?>

View file

@ -65,4 +65,5 @@
$lang->point_recal_message = 'ただ今ポイントを適用しています。 (%d / %d)';
$lang->point_recal_finished = 'ポイント再計算が完了しました。';
$lang->point_update_desc = '포인트를 증가시키려면 +를 감소시키려면 -를 숫자앞에 표기한 후 업데이트 해 주세요. + 또는 - 표시가 없으면 입력한 값으로 설정 됩니다.';
?>

View file

@ -50,4 +50,5 @@
$lang->msg_disallow_by_point = "포인트가 부족하여 글을 읽으실 수 없습니다. (필요한 포인트 : %d, 현재 포인트 : %d)";
$lang->point_recal_message = '포인트 적용중입니다. (%d / %d)';
$lang->point_recal_finished = '포인트 재계산이 완료되었습니다.';
$lang->point_update_desc = '포인트를 증가시키려면 +를 감소시키려면 -를 숫자앞에 표기한 후 업데이트 해 주세요. + 또는 - 표시가 없으면 입력한 값으로 설정 됩니다.';
?>

View file

@ -66,4 +66,5 @@
$lang->point_recal_message = '포인트 적용중입니다. (%d / %d)';
$lang->point_recal_finished = '포인트 재계산이 모두 완료되었습니다';
$lang->point_update_desc = '포인트를 증가시키려면 +를 감소시키려면 -를 숫자앞에 표기한 후 업데이트 해 주세요. + 또는 - 표시가 없으면 입력한 값으로 설정 됩니다.';
?>

View file

@ -66,4 +66,5 @@
$lang->point_recal_message = 'Puan Düzeltiliyor. (%d / %d)';
$lang->point_recal_finished = 'Puan tekrar hesaplaması bitti.';
$lang->point_update_desc = '포인트를 증가시키려면 +를 감소시키려면 -를 숫자앞에 표기한 후 업데이트 해 주세요. + 또는 - 표시가 없으면 입력한 값으로 설정 됩니다.';
?>

View file

@ -68,4 +68,5 @@
$lang->point_recal_message = 'Điều chỉnh điểm. (%d / %d)';
$lang->point_recal_finished = 'Đã kết thúc việc tính toán lại điểm.';
$lang->point_update_desc = '포인트를 증가시키려면 +를 감소시키려면 -를 숫자앞에 표기한 후 업데이트 해 주세요. + 또는 - 표시가 없으면 입력한 값으로 설정 됩니다.';
?>

View file

@ -65,4 +65,5 @@
$lang->point_recal_message = '计算并应用中(%d / %d)。';
$lang->point_recal_finished = '积分重新计算并应用完毕。';
$lang->point_update_desc = '포인트를 증가시키려면 +를 감소시키려면 -를 숫자앞에 표기한 후 업데이트 해 주세요. + 또는 - 표시가 없으면 입력한 값으로 설정 됩니다.';
?>

View file

@ -66,4 +66,5 @@
$lang->point_recal_message = '計算並套用中(%d / %d)。';
$lang->point_recal_finished = '點數重新計算並套用完畢。';
$lang->point_update_desc = '포인트를 증가시키려면 +를 감소시키려면 -를 숫자앞에 표기한 후 업데이트 해 주세요. + 또는 - 표시가 없으면 입력한 값으로 설정 됩니다.';
?>

View file

@ -69,6 +69,11 @@
$oModuleController->insertModuleConfig('point', $config);
$this->setMessage('success_updated');
if(!in_array(Context::getRequestMethod(),array('XMLRPC','JSON'))) {
$returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'module', 'admin', 'act', 'dispPointAdminConfig');
header('location:'.$returnUrl);
return;
}
}
/**
@ -93,6 +98,11 @@
}
$this->setMessage('success_updated');
if(!in_array(Context::getRequestMethod(),array('XMLRPC','JSON'))) {
$returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'module', 'admin', 'act', 'dispPointAdminModuleConfig');
header('location:'.$returnUrl);
return;
}
}
/**
@ -128,12 +138,36 @@
* @brief Change members points
**/
function procPointAdminUpdatePoint() {
$action = Context::get('action');
$member_srl = Context::get('member_srl');
$point = Context::get('point');
preg_match('/^(\+|-)?([1-9][0-9]*)$/', $point, $m);
$action = '';
switch($m[1])
{
case '+':
$action = 'add';
break;
case '-':
$action = 'minus';
break;
default:
$action = 'update';
break;
}
$point = $m[2];
$oPointController = &getController('point');
return $oPointController->setPoint($member_srl, (int)$point, $action);
$output = $oPointController->setPoint($member_srl, (int)$point, $action);
if(!in_array(Context::getRequestMethod(),array('XMLRPC','JSON'))) {
$returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'module', 'admin', 'act', 'dispPointAdminPointList');
header('location:'.$returnUrl);
return;
}
return $output;
}
/**

View file

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<ruleset version="1.5.0">
<customrules>
<rule name="less_than_1000" type="expr" test="$$ &lt; 1000" />
</customrules>
<fields>
<field name="max_level" required="true" rule="number,less_than_1000" />
<field name="point_name" required="true" />
<field name="signup_point" required="true" default="0" />
<field name="login_point" required="true" default="0" />
<field name="insert_document" required="true" default="0" />
<field name="insert_comment" required="true" default="0" />
<field name="upload_file" required="true" default="0" />
<field name="download_file" required="true" default="0" />
<field name="read_document" required="true" default="0" />
<field name="voted" required="true" default="0" />
<field name="blamed" required="true" default="0" />
<field name="level_icon" required="true" default="default" />
</fields>
</ruleset>

View file

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<ruleset version="1.5.0">
<customrules>
<rule name="number_with_plus_minus" type="regex" test="/^(\+|-)?[1-9][0-9]*$/" />
</customrules>
<fields>
<field name="member_srl" required="true" rule="number" />
<field name="point" required="true" rule="number_with_plus_minus" />
</fields>
</ruleset>

View file

@ -1,7 +1,8 @@
<!--%import("filter/insert_config.xml")-->
<!--#include("./header.html")-->
<form action="./" method="get" onsubmit="return procFilter(this, insert_config);">
<p class="xe_validator_error">{$XE_VALIDATOR_ERROR}</p>
<form ruleset="insertConfig" action="./" method="post">
<input type="hidden" name="act" value="procPointAdminInsertConfig" />
<div class="adminLeftContent">

View file

@ -52,15 +52,14 @@ function doPointRecal() {
);
}
function updatePoint(member_srl, action)
function updatePoint(member_srl)
{
var $point = jQuery('#point_'+member_srl);
get_by_id('update_member_srl').value = member_srl;
get_by_id('update_action').value = action;
get_by_id('update_point').value = $point.attr('value');
get_by_id('update_point').value = $point.val();
var hF = get_by_id('updateForm');
procFilter(hF, update_point);
hF.submit();
}

View file

@ -1,7 +1,8 @@
<!--%import("filter/update_point.xml")-->
<!--%import("js/point_admin.js")-->
<!--#include("header.html")-->
<p>{$lang->point_update_desc}</p>
<p class="xe_validator_error">{$XE_VALIDATOR_ERROR}</p>
<table cellspacing="0" class="crossTable">
<caption>Total {number_format($total_count)}, Page {number_format($page)}/{number_format($total_page)}</caption>
<thead>
@ -26,9 +27,7 @@
<input type="hidden" name="member_srl" value="{$val->member_srl}" />
<input type="text" name="orgpoint" value="{$val->point}" class="inputTypeText w80" readonly />
<input type="text" id="point_{$val->member_srl}" name="point" class="inputTypeText w80" />
<span class="button"><input type="button" value="+" onclick="updatePoint({$val->member_srl}, 'add')"/></span>
<span class="button"><input type="button" value="-" onclick="updatePoint({$val->member_srl}, 'minus')"/></span>
<span class="button"><input type="button" value="{$lang->cmd_update}" onclick="updatePoint({$val->member_srl}, 'update')" /></span>
<span class="button"><input type="button" value="{$lang->cmd_update}" onclick="updatePoint({$val->member_srl})" /></span>
</form>
</td>
<td class="number center">{$val->level}</td>
@ -37,8 +36,8 @@
</tbody>
</table>
<form id="updateForm" action="./" method="POST">
<input type="hidden" id="update_action" name="action" value="" />
<form ruleset="updatePoint" id="updateForm" action="./" method="POST">
<input type="hidden" name="act" value="procPointAdminUpdatePoint" />
<input type="hidden" id="update_member_srl" name="member_srl" value="" />
<input type="hidden" id="update_point" name="point" class="inputTypeText w80" />
</form>

View file

@ -1,7 +1,8 @@
<!--%import("filter/insert_module_config.xml")-->
<!--#include("./header.html")-->
<form action="./" method="get" onsubmit="return procFilter(this, insert_module_config);" id="fo_point">
<p class="xe_validator_error">{$XE_VALIDATOR_ERROR}</p>
<form action="./" method="post" id="fo_point">
<input type="hidden" name="act" value="procPointAdminInsertModuleConfig" />
<table cellspacing="0" class="crossTable">
<thead>