#944 포인트 모듈 비활성화 방법 추가

포인트 모듈을 켜고 끌 수 있게 하여서 트리거를 거치지 않을 수 있도록 하는 방법 추가.
https://github.com/xpressengine/xe-core/issues/944
This commit is contained in:
MinSoo Kim 2015-02-16 15:01:50 +09:00
parent c5893358d5
commit b1dadd21c4
6 changed files with 188 additions and 78 deletions

View file

@ -119,6 +119,31 @@ class moduleController extends module
return $output;
}
/**
* @brief Delete module trigger
*
*/
function deleteModuleTriggers($module)
{
$args = new stdClass();
$args->module = $module;
$output = executeQuery('module.deleteModuleTriggers', $args);
if($output->toBool())
{
//remove from cache
$GLOBALS['__triggers__'] = NULL;
$oCacheHandler = CacheHandler::getInstance('object', NULL, TRUE);
if($oCacheHandler->isSupport())
{
$cache_key = 'triggers';
$oCacheHandler->delete($cache_key);
}
}
return $output;
}
/**
* @brief Add module extend
*

View file

@ -0,0 +1,8 @@
<query id="deleteModuleTriggers" action="delete">
<tables>
<table name="module_trigger" />
</tables>
<conditions>
<condition operation="equal" column="module" var="module" notnull="notnull" />
</conditions>
</query>

View file

@ -47,6 +47,28 @@
<value xml:lang="tr"><![CDATA[Pano/blog gibi her modülün, "yazma/silme/yorum ekleme/yorum silme gibi kendi eylemleri bulunmaktadır. ".<br />Pano/blog harici, puan sistemli link modüllerine davranış değerleri ekleyebilirsiniz.<br />Virgül(,) çoklu değerleri ayıracaktır.]]></value>
<value xml:lang="vi"><![CDATA[Mỗi Module, Board hay Blog có một mức cho điểm khác nhau khi "gửi bài, xóa bài, thêm bài, gửi bình luận, xóa bình luận".<br />Bạn có thể chỉ thêm những giá trị liên kết với hệ thống điểm vào mỗi Module Blog, Board.<br />Để thêm nhiều giá trị bằng cách sử dụng dấu (,) giữa các giá trị.]]></value>
</item>
<item name="point_io">
<value xml:lang="ko"><![CDATA[포인트 모듈 켜기]]></value>
<value xml:lang="en"><![CDATA[Point module On]]></value>
<value xml:lang="jp"><![CDATA[Point module On]]></value>
<value xml:lang="zh-CN"><![CDATA[Point module On]]></value>
<value xml:lang="zh-TW"><![CDATA[Point module On]]></value>
<value xml:lang="ru"><![CDATA[Point module On]]></value>
<value xml:lang="es"><![CDATA[Point module On]]></value>
<value xml:lang="tr"><![CDATA[Point module On]]></value>
<value xml:lang="vi"><![CDATA[Point module On]]></value>
</item>
<item name="about_point_io">
<value xml:lang="ko"><![CDATA[체크 하면 포인트 모듈 기능을 켤 수 있습니다. 포인트 모듈 기능을 끌 경우, 포인트 모듈의 모든 트리거가 삭제됩니다. 포인트 기록은 유지되지만 새로 기록 되지는 않습니다.]]></value>
<value xml:lang="en"><![CDATA[Point module can be on or off. If you OFF this module, every triggers will be deleted from database and will not be called by XE Core. Point record would be preserved.]]></value>
<value xml:lang="jp"><![CDATA[Point module can be on or off. If you OFF this module, every triggers will be deleted from database and will not be called by XE Core. Point record would be preserved.]]></value>
<value xml:lang="zh-CN"><![CDATA[Point module can be on or off. If you OFF this module, every triggers will be deleted from database and will not be called by XE Core. Point record would be preserved.]]></value>
<value xml:lang="zh-TW"><![CDATA[Point module can be on or off. If you OFF this module, every triggers will be deleted from database and will not be called by XE Core. Point record would be preserved.]]></value>
<value xml:lang="ru"><![CDATA[Point module can be on or off. If you OFF this module, every triggers will be deleted from database and will not be called by XE Core. Point record would be preserved.]]></value>
<value xml:lang="es"><![CDATA[Point module can be on or off. If you OFF this module, every triggers will be deleted from database and will not be called by XE Core. Point record would be preserved.]]></value>
<value xml:lang="tr"><![CDATA[Point module can be on or off. If you OFF this module, every triggers will be deleted from database and will not be called by XE Core. Point record would be preserved.]]></value>
<value xml:lang="vi"><![CDATA[Point module can be on or off. If you OFF this module, every triggers will be deleted from database and will not be called by XE Core. Point record would be preserved.]]></value>
</item>
<item name="max_level">
<value xml:lang="ko"><![CDATA[최고 레벨]]></value>
<value xml:lang="en"><![CDATA[Max Level]]></value>

View file

@ -24,6 +24,19 @@ class pointAdminController extends point
$config = $oModuleModel->getModuleConfig('point');
// Arrange variables
$args = Context::getRequestVars();
//if module IO config is off
if($args->able_module == 'Y')
{
// Re-install triggers, if it was disabled.
if($config->able_module == 'N')
{
$this->moduleUpdate();
}
//module IO config is on
$config->able_module = 'Y';
// Check the point name
$config->point_name = $args->point_name;
if(!$config->point_name) $config->point_name = 'point';
@ -93,6 +106,16 @@ class pointAdminController extends point
}
// A function to calculate per-level points
$config->expression = $args->expression;
}
else
{
//module IO config is OFF, Other settings will not be modified.
$config->able_module = 'N';
// Delete Triggers
$oModuleController = getController('module');
$oModuleController->deleteModuleTriggers('point');
}
// Save
$oModuleController = getController('module');
$oModuleController->insertModuleConfig('point', $config);

View file

@ -20,6 +20,8 @@ class point extends ModuleObject
$oModuleController = getController('module');
// The highest level
$config = new stdClass;
// default, point module is OFF
$config->able_module = 'N';
$config->max_level = 30;
// Per-level score
for($i=1;$i<=30;$i++)
@ -97,6 +99,11 @@ class point extends ModuleObject
{
// Get the information of the point module
$oModuleModel = getModel('module');
$config = $oModuleModel->getModuleConfig('point');
// check if module is abled
if($config->able_module != 'N')
{
// Add a trigger for registration/insert document/insert comment/upload a file/download
if(!$oModuleModel->getTrigger('member.insertMember', 'point', 'controller', 'triggerInsertMember', 'after')) return true;
if(!$oModuleModel->getTrigger('document.insertDocument', 'point', 'controller', 'triggerInsertDocument', 'after')) return true;
@ -118,6 +125,7 @@ class point extends ModuleObject
// 2012. 08. 29 Add a trigger to copy additional setting when the module is copied
if(!$oModuleModel->getTrigger('module.procModuleAdminCopyModule', 'point', 'controller', 'triggerCopyModule', 'after')) return true;
}
return false;
}

View file

@ -2,12 +2,19 @@
<div cond="$XE_VALIDATOR_MESSAGE && $XE_VALIDATOR_ID == 'modules/point/tpl/config/1'" class="message {$XE_VALIDATOR_MESSAGE_TYPE}">
<p>{$XE_VALIDATOR_MESSAGE}</p>
</div>
<form ruleset="insertConfig" action="./" method="post" class="x_form-horizontal">
<form ruleset="insertConfig" action="./" method="post" id="point_module_config_form" class="x_form-horizontal">
<input type="hidden" name="module" value="point" />
<input type="hidden" name="act" value="procPointAdminInsertConfig" />
<input type="hidden" name="xe_validator_id" value="modules/point/tpl/config/1" />
<section class="section">
<section class="section default">
<h1>{$lang->is_default}</h1>
<div class="x_control-group module_io">
<label for="able_module" class="x_control-label">{$lang->point_io}</label>
<div class="x_controls" style="padding-top:3px">
<input type="checkbox" name="able_module" id="able_module" value="Y" checked="checked"|cond="!$config->able_module||$config->able_module=='Y'" />
<span class="x_help-inline">{$lang->about_point_io}</span>
</div>
</div>
<div class="x_control-group">
<label for="max_level" class="x_control-label">{$lang->max_level}</label>
<div class="x_controls">
@ -167,3 +174,20 @@
<p id="pointReCal"></p>
</section>
</form>
<script>
jQuery(function($){
var point_module_cfg = $('#point_module_config_form .default .x_control-group:not(.module_io), #point_module_config_form .section:not(.default),.x_nav-tabs>li:not(.x_active)');
if(!$('#able_module').is(':checked'))
{
point_module_cfg.hide();
}
$('#able_module').change(function(){
if($(this).is(':checked')){
point_module_cfg.slideDown(200);
} else {
point_module_cfg.slideUp(200);
}
});
});
</script>