merge with 1.5.0_english

git-svn-id: http://xe-core.googlecode.com/svn/branches/1.5.0@8287 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
ovclas 2011-04-08 06:20:12 +00:00
commit 0943470d5f
219 changed files with 6420 additions and 8700 deletions

View file

@ -2,33 +2,30 @@
/**
* @class pointAdminController
* @author NHN (developers@xpressengine.com)
* @brief point모듈의 admin controller class
* @brief The admin controller class of the point module
**/
class pointAdminController extends point {
/**
* @brief 초기화
* @brief Initialization
**/
function init() {
}
/**
* @brief 기본 설정 저장
* @brief Save the default configurations
**/
function procPointAdminInsertConfig() {
// 설정 정보 가져오기
// Get the configuration information
$oModuleModel = &getModel('module');
$config = $oModuleModel->getModuleConfig('point');
// 변수 정리
// Arrange variables
$args = Context::getRequestVars();
// 포인트 이름 체크
// Check the point name
$config->point_name = $args->point_name;
if(!$config->point_name) $config->point_name = 'point';
// 기본 포인트 지정
// Specify the default points
$config->signup_point = (int)$args->signup_point;
$config->login_point = (int)$args->login_point;
$config->insert_document = (int)$args->insert_document;
@ -38,24 +35,19 @@
$config->download_file = (int)$args->download_file;
$config->voted = (int)$args->voted;
$config->blamed = (int)$args->blamed;
// 최고 레벨
// The highest level
$config->max_level = $args->max_level;
if($config->max_level>1000) $config->max_level = 1000;
if($config->max_level<1) $config->max_level = 1;
// 레벨 아이콘 설정
// Set the level icon
$config->level_icon = $args->level_icon;
// 포인트 미달시 다운로드 금지 여부 체크
// Check if downloads are not allowed
if($args->disable_download == 'Y') $config->disable_download = 'Y';
else $config->disable_download = 'N';
// 포인트 미달시 글 열람 금지 여부 체크
// Check if reading a document is not allowed
if($args->disable_read_document == 'Y') $config->disable_read_document = 'Y';
else $config->disable_read_document = 'N';
// 레벨별 그룹 설정
// Per-level group configurations
foreach($args as $key => $val) {
if(substr($key, 0, strlen('point_group_')) != 'point_group_') continue;
$group_srl = substr($key, strlen('point_group_'));
@ -64,18 +56,15 @@
else $config->point_group[$group_srl] = $level;
}
$config->group_reset = $args->group_reset;
// 레벨별 포인트 설정
// Per-level point configurations
unset($config->level_step);
for($i=1;$i<=$config->max_level;$i++) {
$key = "level_step_".$i;
$config->level_step[$i] = (int)$args->{$key};
}
// 레벨별 포인트 계산 함수
// A function to calculate per-level points
$config->expression = $args->expression;
// 저장
// Save
$oModuleController = &getController('module');
$oModuleController->insertModuleConfig('point', $config);
@ -83,7 +72,7 @@
}
/**
* @brief 모듈별 설정 저장
* @brief Save per-module configurations
**/
function procPointAdminInsertModuleConfig() {
$args = Context::getRequestVars();
@ -107,17 +96,15 @@
}
/**
* @brief 모듈별 개별 포인트 저장
* @brief Save individual points per module
**/
function procPointAdminInsertPointModuleConfig() {
$module_srl = Context::get('target_module_srl');
if(!$module_srl) return new Object(-1, 'msg_invalid_request');
// 여러개의 모듈 일괄 설정일 경우
// In case of batch configuration of several modules
if(preg_match('/^([0-9,]+)$/',$module_srl)) $module_srl = explode(',',$module_srl);
else $module_srl = array($module_srl);
// 설정 저장
// Save configurations
$oModuleController = &getController('module');
for($i=0;$i<count($module_srl);$i++) {
$srl = trim($module_srl[$i]);
@ -138,7 +125,7 @@
}
/**
* @brief 회원 포인트 변경
* @brief Change members points
**/
function procPointAdminUpdatePoint() {
$action = Context::get('action');
@ -150,21 +137,18 @@
}
/**
* @brief 전체글/ 댓글/ 첨부파일과 가입정보를 바탕으로 포인트를 재계산함. 로그인 점수는 1번만 부여됨
* @brief Recalculate points based on the list/comment/attachment and registration information. Granted only once a first-time login score.
**/
function procPointAdminReCal() {
set_time_limit(0);
// 모듈별 포인트 정보를 가져옴
// Get per-module points information
$oModuleModel = &getModel('module');
$config = $oModuleModel->getModuleConfig('point');
$module_config = $oModuleModel->getModulePartConfigs('point');
// 회원의 포인트 저장을 위한 변수
// A variable to store member's points
$member = array();
// 게시글 정보를 가져옴
// Get post information
$output = executeQueryArray('point.getDocumentPoint');
if(!$output->toBool()) return $output;
@ -179,8 +163,7 @@
}
}
$output = null;
// 댓글 정보를 가져옴
// Get comments information
$output = executeQueryArray('point.getCommentPoint');
if(!$output->toBool()) return $output;
@ -195,8 +178,7 @@
}
}
$output = null;
// 첨부파일 정보를 가져옴
// Get the attached files' information
$output = executeQueryArray('point.getFilePoint');
if(!$output->toBool()) return $output;
@ -211,12 +193,10 @@
}
}
$output = null;
// 모든 회원의 포인트를 0으로 세팅
// Set all members' points to 0
$output = executeQuery("point.initMemberPoint");
if(!$output->toBool()) return $output;
// 임시로 파일 저장
// Save the file temporarily
$f = fopen("./files/cache/pointRecal.txt","w");
foreach($member as $key => $val) {
$val += (int)$config->signup_point;
@ -230,7 +210,7 @@
}
/**
* @brief 파일로 저장한 회원 포인트를 5000 단위로 적용
* @brief Apply member points saved by file to units of 5,000 people
**/
function procPointAdminApplyPoint() {
$position = (int)Context::get('position');
@ -271,17 +251,15 @@
}
/**
* @brief 개별 모듈의 포인트 리셋
* @brief Reset points for each module
**/
function procPointAdminReset() {
$module_srl = Context::get('module_srls');
if(!$module_srl) return new Object(-1, 'msg_invalid_request');
// 여러개의 모듈 일괄 설정일 경우
// In case of batch configuration of several modules
if(preg_match('/^([0-9,]+)$/',$module_srl)) $module_srl = explode(',',$module_srl);
else $module_srl = array($module_srl);
// 설정 저장
// Save configurations
$oModuleController = &getController('module');
for($i=0;$i<count($module_srl);$i++) {
$srl = trim($module_srl[$i]);
@ -296,7 +274,7 @@
}
/**
* @brief 캐시파일 저장
* @brief Save the cache files
* @deprecated
**/
function cacheActList() {

View file

@ -2,35 +2,32 @@
/**
* @class pointAdminView
* @author NHN (developers@xpressengine.com)
* @brief point모듈의 admin view class
* @brief The admin view class of the point module
**/
class pointAdminView extends point {
/**
* @brief 초기화
* @brief Initialization
**/
function init() {
// 설정 정보 가져오기
// Get teh configuration information
$oModuleModel = &getModel('module');
$config = $oModuleModel->getModuleConfig('point');
// 설정 변수 지정
// Set the configuration variable
Context::set('config', $config);
// template path지정
// Set the template path
$this->setTemplatePath($this->module_path.'tpl');
}
/**
* @brief 기본 설정
* @brief Default configurations
**/
function dispPointAdminConfig() {
// 레벨 아이콘 목록 구함
// Get the list of level icons
$level_icon_list = FileHandler::readDir("./modules/point/icons");
Context::set('level_icon_list', $level_icon_list);
// 그룹 목록 가져오기
// Get the list of groups
$oMemberModel = &getModel('member');
$group_list = $oMemberModel->getGroups();
$selected_group_list = array();
@ -41,28 +38,34 @@
}
}
Context::set('group_list', $selected_group_list);
// 템플릿 지정
// Set the template
$this->setTemplateFile('config');
}
/**
* @brief 모듈별 점수 지정
* @brief Set per-module scores
**/
function dispPointAdminModuleConfig() {
// mid 목록 가져오기
// Get a list of mid
$oModuleModel = &getModel('module');
$mid_list = $oModuleModel->getMidList();
Context::set('mid_list', $mid_list);
Context::set('module_config', $oModuleModel->getModulePartConfigs('point'));
// 템플릿 지정
// Set the template
$this->setTemplateFile('module_config');
}
/**
* @brief 회원 포인트순 목록 가져오기
* @brief Configure the functional act
**/
function dispPointAdminActConfig() {
// Set the template
$this->setTemplateFile('action_config');
}
/**
* @brief Get a list of member points
**/
function dispPointAdminPointList() {
$oPointModel = &getModel('point');
@ -71,22 +74,18 @@
$args->page = Context::get('page');
$output = $oPointModel->getMemberList($args);
// 템플릿에 쓰기 위해서 context::set
// context::set for writing into a template
Context::set('total_count', $output->total_count);
Context::set('total_page', $output->total_page);
Context::set('page', $output->page);
Context::set('member_list', $output->data);
Context::set('page_navigation', $output->page_navigation);
// 멤버모델 객체 생성
// Create a member model object
$oMemberModel = &getModel('member');
// group 목록 가져오기
// Get a list of groups
$this->group_list = $oMemberModel->getGroups();
Context::set('group_list', $this->group_list);
// 템플릿 지정
// Set the template
$this->setTemplateFile('member_list');
}
}

View file

@ -2,85 +2,70 @@
/**
* @class point
* @author NHN (developers@xpressengine.com)
* @brief point모듈의 high class
* @brief The parent class of the point module
**/
class point extends ModuleObject {
/**
* @brief 설치시 추가 작업이 필요할시 구현
* @brief Additional tasks required to accomplish during the installation
**/
function moduleInstall() {
// action forward에 등록 (관리자 모드에서 사용하기 위함)
// Registration in action forward (for using in the administrator mode)
$oModuleController = &getController('module');
// 포인트 정보를 기록할 디렉토리 생성
// Create a directory to store points information
FileHandler::makeDir('./files/member_extra_info/point');
// 최고레벨
$oModuleController = &getController('module');
// The highest level
$config->max_level = 30;
// 레벨별 점수
// Per-level score
for($i=1;$i<=30;$i++) {
$config->level_step[$i] = pow($i,2)*90;
}
// 회원가입
// Points for registration
$config->signup_point = 10;
// 로그인 가입
// Login points
$config->login_point = 5;
// 포인트 호칭
// Point's name
$config->point_name = 'point';
// 레벨 아이콘 디렉토리
// Level icon directory
$config->level_icon = "default";
// 점수가 없을때 다운로드 금지 기능
// Prevent downloads if there are no scores
$config->disable_download = false;
/**
* 모듈별 기본 점수 action 정의 (게시판,블로그외에 어떤 모듈이 생길지 모르니 act값을 명시한다
* Define the default points per module as well as all actions (as we do not know if it is forum or blogs, specify "act")
**/
// 글작성
// Insert document
$config->insert_document = 10;
$config->insert_document_act = 'procBoardInsertDocument';
$config->delete_document_act = 'procBoardDeleteDocument';
// 댓글작성
// Insert comment
$config->insert_comment = 5;
$config->insert_comment_act = 'procBoardInsertComment,procBlogInsertComment';
$config->delete_comment_act = 'procBoardDeleteComment,procBlogDeleteComment';
// 업로드
// Upload
$config->upload_file = 5;
$config->upload_file_act = 'procFileUpload';
$config->delete_file_act = 'procFileDelete';
// 다운로드
// Download
$config->download_file = -5;
$config->download_file_act = 'procFileDownload';
// 조회
// View
$config->read_document = 0;
// 추천 / 비추천
// Vote up / Vote down
$config->voted = 0;
$config->blamed = 0;
// 설정 저장
// Save configurations
$oModuleController->insertModuleConfig('point', $config);
// 빠른 실행을 위해서 act list를 캐싱
// Cash act list for faster execution
$oPointController = &getAdminController('point');
$oPointController->cacheActList();
// 가입/글작성/댓글작성/파일업로드/다운로드에 대한 트리거 추가
// Add a trigger for registration/insert document/insert comment/upload a file/download
$oModuleController->insertTrigger('member.insertMember', 'point', 'controller', 'triggerInsertMember', 'after');
$oModuleController->insertTrigger('document.insertDocument', 'point', 'controller', 'triggerInsertDocument', 'after');
$oModuleController->insertTrigger('document.deleteDocument', 'point', 'controller', 'triggerBeforeDeleteDocument', 'before');
@ -94,24 +79,21 @@
$oModuleController->insertTrigger('member.doLogin', 'point', 'controller', 'triggerAfterLogin', 'after');
$oModuleController->insertTrigger('module.dispAdditionSetup', 'point', 'view', 'triggerDispPointAdditionSetup', 'after');
$oModuleController->insertTrigger('document.updateReadedCount', 'point', 'controller', 'triggerUpdateReadedCount', 'after');
// 추천 / 비추천에 대한 트리거 추가 2008.05.13 haneul
// Add a trigger for voting up and down 2008.05.13 haneul
$oModuleController->insertTrigger('document.updateVotedCount', 'point', 'controller', 'triggerUpdateVotedCount', 'after');
// 임시저장글을 정상 저장시 포인트 지급하도록 트리거 추가 2009. 05. 19 zero
// Add a trigger for using points for permanent saving of a temporarily saved document 2009.05.19 zero
$oModuleController->insertTrigger('document.updateDocument', 'point', 'controller', 'triggerUpdateDocument', 'before');
return new Object();
}
/**
* @brief 설치가 이상이 없는지 체크하는 method
* @brief A method to check if the installation has been successful
**/
function checkUpdate() {
// point 모듈 정보 가져옴
// Get the information of the point module
$oModuleModel = &getModel('module');
// 가입/글작성/댓글작성/파일업로드/다운로드에 대한 트리거 추가
// 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;
if(!$oModuleModel->getTrigger('document.deleteDocument', 'point', 'controller', 'triggerBeforeDeleteDocument', 'before')) return true;
@ -125,25 +107,22 @@
if(!$oModuleModel->getTrigger('member.doLogin', 'point', 'controller', 'triggerAfterLogin', 'after')) return true;
if(!$oModuleModel->getTrigger('module.dispAdditionSetup', 'point', 'view', 'triggerDispPointAdditionSetup', 'after')) return true;
if(!$oModuleModel->getTrigger('document.updateReadedCount', 'point', 'controller', 'triggerUpdateReadedCount', 'after')) return true;
// 추천 / 비추천에 대한 트리거 추가 2008.05.13 haneul
// Add a trigger for voting up and down 2008.05.13 haneul
if(!$oModuleModel->getTrigger('document.updateVotedCount', 'point', 'controller', 'triggerUpdateVotedCount', 'after')) return true;
// 임시저장글을 정상 저장시 포인트 지급하도록 트리거 추가 2009. 05. 19 zero
// Add a trigger for using points for permanent saving of a temporarily saved document 2009.05.19 zero
if(!$oModuleModel->getTrigger('document.updateDocument', 'point', 'controller', 'triggerUpdateDocument', 'before')) return true;
return false;
}
/**
* @brief 업데이트 실행
* @brief Execute update
**/
function moduleUpdate() {
// point 모듈 정보 가져옴
// Get the information of the point module
$oModuleModel = &getModel('module');
$oModuleController = &getController('module');
// 가입/글작성/댓글작성/파일업로드/다운로드에 대한 트리거 추가
// Add a trigger for registration/insert document/insert comment/upload a file/download
if(!$oModuleModel->getTrigger('member.insertMember', 'point', 'controller', 'triggerInsertMember', 'after'))
$oModuleController->insertTrigger('member.insertMember', 'point', 'controller', 'triggerInsertMember', 'after');
if(!$oModuleModel->getTrigger('document.insertDocument', 'point', 'controller', 'triggerInsertDocument', 'after'))
@ -170,12 +149,10 @@
$oModuleController->insertTrigger('module.dispAdditionSetup', 'point', 'view', 'triggerDispPointAdditionSetup', 'after');
if(!$oModuleModel->getTrigger('document.updateReadedCount', 'point', 'controller', 'triggerUpdateReadedCount', 'after'))
$oModuleController->insertTrigger('document.updateReadedCount', 'point', 'controller', 'triggerUpdateReadedCount', 'after');
// 추천 / 비추천에 대한 트리거 추가 2008.05.13 haneul
// Add a trigger for voting up and down 2008.05.13 haneul
if(!$oModuleModel->getTrigger('document.updateVotedCount', 'point', 'controller', 'triggerUpdateVotedCount', 'after'))
$oModuleController->insertTrigger('document.updateVotedCount', 'point', 'controller', 'triggerUpdateVotedCount', 'after');
// 임시저장글을 정상 저장시 포인트 지급하도록 트리거 추가 2009. 05. 19 zero
// Add a trigger for using points for permanent saving of a temporarily saved document 2009.05.19 zero
if(!$oModuleModel->getTrigger('document.updateDocument', 'point', 'controller', 'triggerUpdateDocument', 'before'))
$oModuleController->insertTrigger('document.updateDocument', 'point', 'controller', 'triggerUpdateDocument', 'before');
@ -183,10 +160,10 @@
}
/**
* @brief 캐시 파일 재생성
* @brief Re-create the cache file
**/
function recompileCache() {
// point action 파일 재정의
// redefine point action file
$oPointAdminController = &getAdminController('point');
$oPointAdminController->cacheActList();

View file

@ -2,35 +2,32 @@
/**
* @class pointController
* @author NHN (developers@xpressengine.com)
* @brief point모듈의 Controller class
* @brief Controller class of point modules
**/
class pointController extends point {
/**
* @brief 초기화
* @brief Initialization
**/
function init() {
}
/**
* @brief 회원가입 포인트 적용 trigger
* @brief Membership point application trigger
**/
function triggerInsertMember(&$obj) {
// point 모듈 정보 가져옴
// Get the point module information
$oModuleModel = &getModel('module');
$config = $oModuleModel->getModuleConfig('point');
// 가입한 회원의 member_srl을 구함
// Get the member_srl of the newly registered member
$member_srl = $obj->member_srl;
// 대상 회원의 포인트를 구함
// Get the points of the member
$oPointModel = &getModel('point');
$cur_point = $oPointModel->getPoint($member_srl, true);
$point = $config->signup_point;
// 포인트 증감
// Increase the point
$cur_point += $point;
$this->setPoint($member_srl,$cur_point, 'signup');
@ -38,26 +35,22 @@
}
/**
* @brief 회원 로그인 포인트 적용 trigger
* @brief A trigger to add points to the member for login
**/
function triggerAfterLogin(&$obj) {
$member_srl = $obj->member_srl;
if(!$member_srl) return new Object();
// 바로 이전 로그인이 오늘이 아니어야 포인트를 줌
// If the last login is not today, give the points
if(substr($obj->last_login,0,8)==date("Ymd")) return new Object();
// point 모듈 정보 가져옴
// Get the point module information
$oModuleModel = &getModel('module');
$config = $oModuleModel->getModuleConfig('point');
// 대상 회원의 포인트를 구함
// Get the points of the member
$oPointModel = &getModel('point');
$cur_point = $oPointModel->getPoint($member_srl, true);
$point = $config->login_point;
// 포인트 증감
// Increase the point
$cur_point += $point;
$this->setPoint($member_srl,$cur_point);
@ -65,43 +58,38 @@
}
/**
* @brief 게시글 등록 포인트 적용 trigger
* @brief A trigger to add points to the member for creating a post
**/
function triggerInsertDocument(&$obj) {
$module_srl = $obj->module_srl;
$member_srl = $obj->member_srl;
if(!$module_srl || !$member_srl) return new Object();
// 임시저장일 경우 포인트를 지급하지 않도록 수정
// The fix to disable giving points for saving the document temporarily
if($module_srl == $member_srl) return new Object();
// point 모듈 정보 가져옴
// Get the point module information
$oModuleModel = &getModel('module');
$config = $oModuleModel->getModuleConfig('point');
$module_config = $oModuleModel->getModulePartConfig('point',$module_srl);
// 대상 회원의 포인트를 구함
// Get the points of the member
$oPointModel = &getModel('point');
$cur_point = $oPointModel->getPoint($member_srl, true);
$point = $module_config['insert_document'];
if(!isset($point)) $point = $config->insert_document;
$cur_point += $point;
// 첨부파일 등록에 대한 포인트 추가
// Add points for attaching a file
$point = $module_config['upload_file'];
if(!isset($point)) $point = $config->upload_file;
if($obj->uploaded_count) $cur_point += $point * $obj->uploaded_count;
// 포인트 증감
// Increase the point
$this->setPoint($member_srl,$cur_point);
return new Object();
}
/**
* @brief 임시저장된 글을 정상 등록시 포인트 적용하는 trigger
* 1.2.3 에서 임시저장시에 포인트 지급되지 않도록 변경됨
* @brief The trigger to give points for normal saving the temporarily saved document
* Temporary storage at the point in 1.2.3 changed to avoid payment
**/
function triggerUpdateDocument(&$obj) {
$oDocumentModel = &getModel('document');
@ -113,28 +101,23 @@
$module_srl = $oDocument->get('module_srl');
$member_srl = $oDocument->get('member_srl');
if(!$module_srl || !$member_srl) return new Object();
// 임시저장된 것이 아니면 return
// Return if it is not a temporarily saved document
if($module_srl != $member_srl) return new Object();
// point 모듈 정보 가져옴
// Get the point module information
$config = $oModuleModel->getModuleConfig('point');
$module_config = $oModuleModel->getModulePartConfig('point',$obj->module_srl);
// 대상 회원의 포인트를 구함
// Get the points of the member
$oPointModel = &getModel('point');
$cur_point = $oPointModel->getPoint($member_srl, true);
$point = $module_config['insert_document'];
if(!isset($point)) $point = $config->insert_document;
$cur_point += $point;
// 첨부파일 등록에 대한 포인트 추가
// Add points for attaching a file
$point = $module_config['upload_file'];
if(!isset($point)) $point = $config->upload_file;
if($obj->uploaded_count) $cur_point += $point * $obj->uploaded_count;
// 포인트 증감
// Increase the point
$this->setPoint($member_srl,$cur_point);
return new Object();
@ -142,7 +125,7 @@
}
/**
* @brief 게시글 삭제 이전에 게시글의 댓글에 대한 포인트 감소 처리를 하는 trigger
* @brief The trigger which deducts the points related to post comments before deleting the post itself
**/
function triggerBeforeDeleteDocument(&$obj) {
$document_srl = $obj->document_srl;
@ -151,42 +134,33 @@
$oDocumentModel = &getModel('document');
$oDocument = $oDocumentModel->getDocument($document_srl);
if(!$oDocument->isExists()) return new Object();
// point 모듈 정보 가져옴
// Get the point module information
$oModuleModel = &getModel('module');
$config = $oModuleModel->getModuleConfig('point');
$module_config = $oModuleModel->getModulePartConfig('point',$oDocument->get('module_srl'));
// 지울 대상 글의 댓글에 대한 처리
// The process related to clearing the post comments
$comment_point = $module_config['insert_comment'];
if(!isset($comment_point)) $comment_point = $config->insert_comment;
// 댓글 포인트가 있으면 증감(+) 이면 차감 시도
// If there are comment points, attempt to deduct
if($comment_point>0) return new Object();
// 해당 글에 포함된 모든 댓글을 추출
// Get all the comments related to this post
$cp_args->document_srl = $document_srl;
$output = executeQueryArray('point.getCommentUsers', $cp_args);
// 대상이 없으면 return
// Return if there is no object
if(!$output->data) return new Object();
// 대상 회원 번호를 정리
// Organize the member number
$member_srls = array();
$cnt = count($output->data);
for($i=0;$i<$cnt;$i++) {
if($output->data[$i]->member_srl<1) continue;
$member_srls[abs($output->data[$i]->member_srl)] = $output->data[$i]->count;
}
// 원글 작성 회원의 번호는 제거
// Remove the member number who has written the original post
if($member_srl) unset($member_srls[abs($member_srl)]);
if(!count($member_srls)) return new Object();
// 각 회원들을 모두 돌면서 포인트 감소
// Remove all the points for each member
$oPointModel = &getModel('point');
// 포인트를 구해옴
// Get the points
$point = $module_config['download_file'];
foreach($member_srls as $member_srl => $cnt) {
$cur_point = $oPointModel->getPoint($member_srl, true);
@ -198,73 +172,62 @@
}
/**
* @brief 게시글 삭제 포인트 적용 trigger
* @brief A trigger to give points for deleting the post
**/
function triggerDeleteDocument(&$obj) {
$module_srl = $obj->module_srl;
$member_srl = $obj->member_srl;
// 지울 대상 글에 대한 처리
// The process related to clearing the post object
if(!$module_srl || !$member_srl) return new Object();
// 로그인 상태일때만 실행
// Run only when logged in
$logged_info = Context::get('logged_info');
if(!$logged_info->member_srl) return new Object();
// 대상 회원의 포인트를 구함
// Get the points of the member
$oPointModel = &getModel('point');
$cur_point = $oPointModel->getPoint($member_srl, true);
// point 모듈 정보 가져옴
// Get the point module information
$oModuleModel = &getModel('module');
$config = $oModuleModel->getModuleConfig('point');
$module_config = $oModuleModel->getModulePartConfig('point', $module_srl);
$point = $module_config['insert_document'];
if(!isset($point)) $point = $config->insert_document;
// 포인트가 마이너스 즉 글을 작성시 마다 차감되는 경우라면 글 삭제시 증가시켜주지 않도록 수정
// if the point is set to decrease when writing a document, make sure it does not increase the points when deleting an article
if($point < 0) return new Object();
$cur_point -= $point;
// 첨부파일 삭제에 대한 포인트 추가
// Add points related to deleting an attachment
$point = $module_config['upload_file'];
if(!isset($point)) $point = $config->upload_file;
if($obj->uploaded_count) $cur_point -= $point * $obj->uploaded_count;
// 포인트 증감
// Increase the point
$this->setPoint($member_srl,$cur_point);
return new Object();
}
/**
* @brief 댓글 등록 포인트 적용 trigger
* @brief A trigger which gives points for entering a comment
**/
function triggerInsertComment(&$obj) {
$module_srl = $obj->module_srl;
$member_srl = $obj->member_srl;
if(!$module_srl || !$member_srl) return new Object();
// 원글이 본인의 글이라면 포인트를 올리지 않음
// Do not increase the points if the member is the author of the post
$document_srl = $obj->document_srl;
$oDocumentModel = &getModel('document');
$oDocument = $oDocumentModel->getDocument($document_srl);
if(!$oDocument->isExists() || abs($oDocument->get('member_srl'))==abs($member_srl)) return new Object();
// point 모듈 정보 가져옴
// Get the point module information
$oModuleModel = &getModel('module');
$config = $oModuleModel->getModuleConfig('point');
$module_config = $oModuleModel->getModulePartConfig('point', $module_srl);
// 대상 회원의 포인트를 구함
// Get the points of the member
$oPointModel = &getModel('point');
$cur_point = $oPointModel->getPoint($member_srl, true);
$point = $module_config['insert_comment'];
if(!isset($point)) $point = $config->insert_comment;
// 포인트 증감
// Increase the point
$cur_point += $point;
$this->setPoint($member_srl,$cur_point);
@ -272,7 +235,7 @@
}
/**
* @brief 댓글 삭제 포인트 적용 trigger
* @brief A trigger which gives points for deleting a comment
**/
function triggerDeleteComment(&$obj) {
$oModuleModel = &getModel('module');
@ -283,26 +246,21 @@
$member_srl = abs($obj->member_srl);
$document_srl = $obj->document_srl;
if(!$module_srl || !$member_srl) return new Object();
// 원글을 가져옴 (원글이 없거나 원글이 자신의 글이라면 포인트 적용 하지 않음)
// Get the original article (if the original article is missing or if the member is its author, do not apply the points)
$oDocument = $oDocumentModel->getDocument($document_srl);
if(!$oDocument->isExists()) return new Object();
if($oDocument->get('member_srl')==$member_srl) return new Object();
// point 모듈 정보 가져옴
// Get the point module information
$config = $oModuleModel->getModuleConfig('point');
$module_config = $oModuleModel->getModulePartConfig('point', $module_srl);
// 대상 회원의 포인트를 구함
// Get the points of the member
$cur_point = $oPointModel->getPoint($member_srl, true);
$point = $module_config['insert_comment'];
if(!isset($point)) $point = $config->insert_comment;
// 포인트가 마이너스 즉 댓글을 작성시 마다 차감되는 경우라면 댓글 삭제시 증가시켜주지 않도록 수정
// if the point is set to decrease when writing a comment, make sure it does not increase the points when deleting a comment
if($point < 0) return new Object();
// 포인트 증감
// Increase the point
$cur_point -= $point;
$this->setPoint($member_srl,$cur_point);
@ -310,16 +268,16 @@
}
/**
* @brief 파일 등록 trigger 추가
* 비유효 파일의 등록에 의한 포인트 획득을 방지하고자 method는 일단 무효로
* @brief Add the file registration trigger
* To prevent taking points for invalid file registration this method wlil return a null object
**/
function triggerInsertFile(&$obj) {
return new Object();
}
/**
* @brief 파일 삭제 포인트 적용 trigger
* 유효파일을 삭제할 경우에만 포인트 삭제
* @brief A trigger to give points for deleting a file
* Remove points only in case an invalid file is being deleted
**/
function triggerDeleteFile(&$obj) {
if($obj->isvalid != 'Y') return new Object();
@ -327,20 +285,17 @@
$module_srl = $obj->module_srl;
$member_srl = $obj->member_srl;
if(!$module_srl || !$member_srl) return new Object();
// point 모듈 정보 가져옴
// Get the point module information
$oModuleModel = &getModel('module');
$config = $oModuleModel->getModuleConfig('point');
$module_config = $oModuleModel->getModulePartConfig('point', $module_srl);
// 대상 회원의 포인트를 구함
// Get the points of the member
$oPointModel = &getModel('point');
$cur_point = $oPointModel->getPoint($member_srl, true);
$point = $module_config['upload_file'];
if(!isset($point)) $point = $config->upload_file;
// 포인트 증감
// Increase the point
$cur_point -= $point;
$this->setPoint($member_srl,$cur_point);
@ -348,70 +303,60 @@
}
/**
* @brief 파일 다운로드 전에 호출되는 trigger
* @brief The trigger called before a file is downloaded
**/
function triggerBeforeDownloadFile(&$obj) {
$logged_info = Context::get('logged_info');
$member_srl = $logged_info->member_srl;
$module_srl = $obj->module_srl;
if(!$module_srl) return new Object();
// 자신의 올린 파일이면 패스
// Pass if it is your file
if(abs($obj->member_srl) == abs($member_srl)) return new Object();
$oModuleModel = &getModel('module');
$config = $oModuleModel->getModuleConfig('point');
$module_config = $oModuleModel->getModulePartConfig('point', $module_srl);
// 포인트가 없으면 다운로드가 안되도록 하였으면 비로그인 회원일 경우 중지
// If it is set not to allow downloading for non-logged in users, do not permit
if(!Context::get('is_logged'))
{
if($config->disable_download == 'Y' && isset($module_config['download_file'])) return new Object(-1,'msg_not_permitted_download');
else return new Object();
}
// 대상 회원의 포인트를 구함
// Get the points of the member
$oPointModel = &getModel('point');
$cur_point = $oPointModel->getPoint($member_srl, true);
// 포인트를 구해옴
// Get the points
$point = $module_config['download_file'];
if(!isset($point)) $point = $config->download_file;
// 포인트가 0보다 작고 포인트가 없으면 파일 다운로드가 안되도록 했다면 오류
// If points are less than 0, and if downloading a file is not allowed in this case, give an errors
if($cur_point + $point < 0 && $config->disable_download == 'Y') return new Object(-1,'msg_not_permitted_download');
return new Object();
}
/**
* @brief 파일 다운로드 포인트 적용 trigger
* @brief The trigger to give points for downloading the file
**/
function triggerDownloadFile(&$obj) {
// 로그인 상태일때만 실행
// Run only when logged in
$logged_info = Context::get('logged_info');
if(!$logged_info->member_srl) return new Object();
$module_srl = $obj->module_srl;
$member_srl = $logged_info->member_srl;
if(!$module_srl) return new Object();
// 자신의 올린 파일이면 패스
// Pass if it is your file
if(abs($obj->member_srl) == abs($member_srl)) return new Object();
// point 모듈 정보 가져옴
// Get the point module information
$oModuleModel = &getModel('module');
$config = $oModuleModel->getModuleConfig('point');
$module_config = $oModuleModel->getModulePartConfig('point', $module_srl);
// 대상 회원의 포인트를 구함
// Get the points of the member
$oPointModel = &getModel('point');
$cur_point = $oPointModel->getPoint($member_srl, true);
// 포인트를 구해옴
// Get the points
$point = $module_config['download_file'];
if(!isset($point)) $point = $config->download_file;
// 포인트 증감
// Increase the point
$cur_point += $point;
$this->setPoint($member_srl,$cur_point);
@ -419,35 +364,28 @@
}
/**
* @brief 조회수 증가시 포인트 적용
* 포인트가 없을때 조회를 하지 못하는 기능의 적용도 실행
* @brief Give points for hits increase
* Run it even if there are no points
**/
function triggerUpdateReadedCount(&$obj) {
$oModuleModel = &getModel('module');
$oPointModel = &getModel('point');
// 접속자의 정보 구함
// Get visitor information
$logged_info = Context::get('logged_info');
$member_srl = $logged_info->member_srl;
// 원글의 회원 번호 구함
// Get the original author number
$target_member_srl = abs($obj->get('member_srl'));
// 원글을 적은 이와 동일하면 조회수 올리지 않고 pass
// Pass without increasing the hits if the viewer is the same as the author
if($target_member_srl == $member_srl) return new Object();
// 모듈별 point 정보 가져옴
// Get the point information for each module
$config = $oModuleModel->getModuleConfig('point');
$module_config = $oModuleModel->getModulePartConfig('point', $obj->get('module_srl'));
// 조회 포인트를 구해옴
// Get hits points
$point = $module_config['read_document'];
if(!isset($point)) $point = $config->read_document;
// 조회 포인트가 없으면 pass
// Pass if there are no requested points
if(!$point) return new Object();
// 회원일 경우 읽은 적이 있으면 그냥 pass 하고 그렇지 않으면 현재 포인트 구함
// In case of a registered member, if it is read but cannot just pass, then get the current points
if($member_srl) {
$args->member_srl = $member_srl;
$args->document_srl = $obj->document_srl;
@ -457,26 +395,20 @@
} else {
$cur_point = 0;
}
// 포인트 모듈 기본 설정 가져옴
// Get the defaul configurations of the Point Module
$config = $oModuleModel->getModuleConfig('point');
// 조회 포인트가 -(마이너스)일때 현재 포인트와 비교
// When the requested points are negative, compared it with the current point
if($config->disable_read_document == 'Y' && $point < 0 && abs($point)>$cur_point) {
$obj->add('content', sprintf(Context::getLang('msg_disallow_by_point'), abs($point), $cur_point));
return new Object();
}
// 로그인 사용자가 아니라면 pass
// If not logged in, pass
if(!$logged_info->member_srl) return new Object();
// 조회 포인트가 없으면 패스
// Pass, if there are no requested points
if(!$point) return new Object();
// 읽은 기록이 없으면 기록 남김
// If the read record is missing, leave it
$output = executeQuery('document.insertDocumentReadedLog', $args);
// 포인트 증감
// Increase the point
$cur_point += $point;
$this->setPoint($member_srl,$cur_point);
@ -484,7 +416,7 @@
}
/**
* @brief 추천/비추천 포인트 적용
* @brief Points for voting up or down
**/
function triggerUpdateVotedCount(&$obj) {
@ -508,8 +440,7 @@
}
if(!$point) return new Object();
// 포인트 증감
// Increase the point
$cur_point += $point;
$this->setPoint($member_srl,$cur_point);
@ -517,24 +448,21 @@
}
/**
* @brief 포인트 설정
* @brief Set points
**/
function setPoint($member_srl, $point, $mode = null) {
$member_srl = abs($member_srl);
$mode_arr = array('add', 'minus', 'update', 'signup');
if(!$mode || !in_array($mode,$mode_arr)) $mode = 'update';
// 설정 정보 가져오기
// Get configuration information
$oMemberModel = &getModel('member');
$oModuleModel = &getModel('module');
$oPointModel = &getModel('point');
$config = $oModuleModel->getModuleConfig('point');
// 기존 포인트 정보를 구함
// Get the default configuration information
$prev_point = $oPointModel->getPoint($member_srl, true);
$prev_level = $oPointModel->getLevel($prev_point, $config->level_step);
// 포인트 변경
// Change points
$args->member_srl = $member_srl;
$args->point = $prev_point;
@ -555,44 +483,36 @@
}
if($args->point < 0) $args->point = 0;
$point = $args->point;
// 포인트가 있으면 update, 없으면 insert
// If there are points, update, if no, insert
$oPointModel = &getModel('point');
if($oPointModel->isExistsPoint($member_srl)) executeQuery("point.updatePoint", $args);
else executeQuery("point.insertPoint", $args);
// 새로운 레벨을 구함
// Get a new level
$level = $oPointModel->getLevel($point, $config->level_step);
// 기존 레벨과 새로운 레벨이 다르면 포인트 그룹 설정 시도
// If existing level and a new one are different attempt to set a point group
if($level != $prev_level) {
// 현재 포인트 대비하여 레벨을 계산하고 레벨에 맞는 그룹 설정을 체크
// Check if the level, for which the current points are prepared, is calculate and set the correct group
$point_group = $config->point_group;
// 포인트 그룹 정보가 있을때 시행
// If the point group exists
if($point_group && is_array($point_group) && count($point_group) ) {
// 기본 그룹을 구함
// Get the default group
$default_group = $oMemberModel->getDefaultGroup();
// 제거될 그룹과 새로 부여 받을 그룹을 구함
// Get the removed group and the newly granted group
$del_group_list = array();
$new_group_srls = array();
asort($point_group);
//그룹 초기화 후 재설정
// Reset group after initialization
if($config->group_reset != 'N') {
//새로운 레벨에 맞는 그룹이 있다면
// If the new level is in the right group
if(in_array($level, $point_group)) {
//현재 레벨의 그룹을 제외한 나머지는 모두 삭제
// Delete all groups except the one which the current level belongs to
foreach($point_group as $group_srl => $target_level) {
$del_group_list[] = $group_srl;
if($target_level == $level) $new_group_srls[] = $group_srl;
}
}
//그렇지 않고 레벨 감소인 경우 바로 이전 그룹을 추가
// Otherwise, in case the level is reduced, add the recent group
else {
$i = $level;
while($i > 0) {
@ -608,32 +528,28 @@
$i--;
}
}
//현재 레벨보다 높은 레벨의 그룹은 삭제
// Delete the group of a level which is higher than the current level
foreach($point_group as $group_srl => $target_level) {
if($target_level > $level) $del_group_list[] = $group_srl;
}
}
//새 그룹만 부여
// Grant a new group
else {
// 포인트 그룹 설정을 돌면서 현재 레벨까지 체크
// Check until the current level by rotating setting the configurations of the point groups
foreach($point_group as $group_srl => $target_level) {
$del_group_list[] = $group_srl;
if($target_level <= $level) $new_group_srls[] = $group_srl;
}
}
// 만약 새로운 그룹이 없다면 기본 그룹을 부여 받음
// If there is no a new group, granted the default group
if(!$new_group_srls[0]) $new_group_srls[0] = $default_group->group_srl;
// 연동 그룹 제거
// Remove linkage group
if($del_group_list && count($del_group_list)) {
$del_group_args->member_srl = $member_srl;
$del_group_args->group_srl = implode(',', $del_group_list);
$del_group_output = executeQuery('point.deleteMemberGroup', $del_group_args);
}
// 새로운 그룹을 부여
// Grant a new group
foreach($new_group_srls as $group_srl) {
$new_group_args->member_srl = $member_srl;
$new_group_args->group_srl = $group_srl;
@ -641,8 +557,7 @@
}
}
}
// 캐시 설정
// Cache Settings
$cache_path = sprintf('./files/member_extra_info/point/%s/', getNumberingPath($member_srl));
FileHandler::makedir($cache_path);

View file

@ -2,19 +2,19 @@
/**
* @class pointModel
* @author NHN (developers@xpressengine.com)
* @brief point 모듈의 model class
* @brief The model class fo the point module
**/
class pointModel extends point {
/**
* @brief 초기화
* @brief Initialization
**/
function init() {
}
/**
* @brief 포인트 정보가 있는지 체크
* @brief Check if there is points information
**/
function isExistsPoint($member_srl) {
$member_srl = abs($member_srl);
@ -25,7 +25,7 @@
}
/**
* @brief 포인트를 구해옴
* @brief Get the points
**/
function getPoint($member_srl, $from_db = false) {
$member_srl = abs($member_srl);
@ -34,8 +34,7 @@
$cache_filename = sprintf('%s%d.cache.txt', $path, $member_srl);
if(!$from_db && file_exists($cache_filename)) return trim(FileHandler::readFile($cache_filename));
// DB에서 가져옴
// Get from the DB
$args->member_srl = $member_srl;
$output = executeQuery('point.getPoint', $args);
$point = (int)$output->data->point;
@ -46,7 +45,7 @@
}
/**
* @brief 레벨을 구함
* @brief Get the level
**/
function getLevel($point, $level_step) {
$level_count = count($level_step);
@ -80,11 +79,10 @@
/**
* @brief 포인트 회원목록 가져오기
* @brief Get a list of points members list
**/
function getMemberList($args = null) {
// 검색 옵션 정리
// Arrange the search options
$args->is_admin = Context::get('is_admin')=='Y'?'Y':'';
$args->is_denied = Context::get('is_denied')=='Y'?'Y':'';
$args->selected_group_srl = Context::get('selected_group_srl');
@ -121,8 +119,7 @@
break;
}
}
// selected_group_srl이 있으면 query id를 변경 (table join때문에)
// If there is a selected_group_srl, change the "query id" (for table join)
if($args->selected_group_srl) {
$query_id = 'point.getMemberListWithinGroup';
} else {

View file

@ -2,23 +2,23 @@
/**
* @class pointView
* @author NHN (developers@xpressengine.com)
* @brief point moduleview class
* @brief The view class of the point module
*
* POINT 2.0형식으로 문서 출력
* POINT 2.0 format document output
*
**/
class pointView extends point {
/**
* @brief 초기화
* @brief Initialization
**/
function init() {
}
/**
* @brief 서비스형 모듈의 추가 설정을 위한 부분
* point의 사용 형태에 대한 설정만 받음
* @brief Additional configurations for a service module
* Receive the form for the form used by point
**/
function triggerDispPointAdditionSetup(&$obj) {
$current_module_srl = Context::get('module_srl');
@ -29,8 +29,7 @@
$current_module_srl = $current_module_info->module_srl;
if(!$current_module_srl) return new Object();
}
// 설정 정보 가져오기
// Get the configuration information
$oModuleModel = &getModel('module');
if($current_module_srl) {
@ -50,8 +49,7 @@
$module_config['module_srl'] = $current_module_srl;
$module_config['point_name'] = $config->point_name;
Context::set('module_config', $module_config);
// 템플릿 파일 지정
// Set the template file
$oTemplate = &TemplateHandler::getInstance();
$tpl = $oTemplate->compile($this->module_path.'tpl', 'point_module_config');
$obj .= $tpl;