Change method calls to static in point module

This commit is contained in:
Kijin Sung 2020-05-24 20:49:09 +09:00
parent c90d529c74
commit f6d4de8e70
3 changed files with 36 additions and 46 deletions

View file

@ -32,7 +32,7 @@ class pointController extends point
return; return;
} }
$cur_point = getModel('point')->getPoint($member_srl); $cur_point = PointModel::getPoint($member_srl);
$this->setPoint($member_srl, $cur_point + $point, 'signup'); $this->setPoint($member_srl, $cur_point + $point, 'signup');
} }
@ -60,7 +60,7 @@ class pointController extends point
return; return;
} }
$cur_point = getModel('point')->getPoint($member_srl); $cur_point = PointModel::getPoint($member_srl);
$this->setPoint($member_srl, $cur_point + $point); $this->setPoint($member_srl, $cur_point + $point);
} }
@ -97,13 +97,13 @@ class pointController extends point
{ {
return; return;
} }
if ($obj->status === getModel('document')->getConfigStatus('temp')) if ($obj->status === DocumentModel::getConfigStatus('temp'))
{ {
return; return;
} }
// Get the points of the member // Get the points of the member
$cur_point = getModel('point')->getPoint($member_srl); $cur_point = PointModel::getPoint($member_srl);
// Add points for the document. // Add points for the document.
$document_point = $this->_getModulePointConfig($module_srl, 'insert_document'); $document_point = $this->_getModulePointConfig($module_srl, 'insert_document');
@ -126,8 +126,7 @@ class pointController extends point
*/ */
public function triggerUpdateDocument($obj) public function triggerUpdateDocument($obj)
{ {
$oDocumentModel = getModel('document'); $oDocument = DocumentModel::getDocument($obj->document_srl);
$oDocument = $oDocumentModel->getDocument($obj->document_srl);
$module_srl = $oDocument->get('module_srl'); $module_srl = $oDocument->get('module_srl');
$member_srl = abs($oDocument->get('member_srl')); $member_srl = abs($oDocument->get('member_srl'));
@ -137,11 +136,11 @@ class pointController extends point
} }
// Only give points if the document is being updated from TEMP to another status such as PUBLIC. // Only give points if the document is being updated from TEMP to another status such as PUBLIC.
if ($obj->status === $oDocumentModel->getConfigStatus('temp') || $oDocument->get('status') !== $oDocumentModel->getConfigStatus('temp')) if ($obj->status === DocumentModel::getConfigStatus('temp') || $oDocument->get('status') !== DocumentModel::getConfigStatus('temp'))
{ {
if ($obj->uploaded_count > $oDocument->get('uploaded_count')) if ($obj->uploaded_count > $oDocument->get('uploaded_count'))
{ {
$cur_point = getModel('point')->getPoint($member_srl); $cur_point = PointModel::getPoint($member_srl);
$attached_files_point = $this->_getModulePointConfig($module_srl, 'upload_file'); $attached_files_point = $this->_getModulePointConfig($module_srl, 'upload_file');
$cur_point += $attached_files_point * ($obj->uploaded_count - $oDocument->get('uploaded_count')); $cur_point += $attached_files_point * ($obj->uploaded_count - $oDocument->get('uploaded_count'));
$this->setPoint($member_srl, $cur_point); $this->setPoint($member_srl, $cur_point);
@ -150,7 +149,7 @@ class pointController extends point
} }
// Get the points of the member // Get the points of the member
$cur_point = getModel('point')->getPoint($member_srl); $cur_point = PointModel::getPoint($member_srl);
// Add points for the document. // Add points for the document.
$document_point = $this->_getModulePointConfig($module_srl, 'insert_document'); $document_point = $this->_getModulePointConfig($module_srl, 'insert_document');
@ -203,13 +202,13 @@ class pointController extends point
{ {
return; return;
} }
if ($obj->status === getModel('document')->getConfigStatus('temp')) if ($obj->status === DocumentModel::getConfigStatus('temp'))
{ {
return; return;
} }
// Get the points of the member // Get the points of the member
$cur_point = getModel('point')->getPoint($member_srl); $cur_point = PointModel::getPoint($member_srl);
// Subtract points for the document. // Subtract points for the document.
$document_point = $this->_getModulePointConfig($module_srl, 'insert_document'); $document_point = $this->_getModulePointConfig($module_srl, 'insert_document');
@ -243,7 +242,7 @@ class pointController extends point
} }
// Abort if the comment and the document have the same author. // Abort if the comment and the document have the same author.
$oDocument = getModel('document')->getDocument($obj->document_srl); $oDocument = DocumentModel::getDocument($obj->document_srl);
if (!$oDocument->isExists() || abs($oDocument->get('member_srl')) == $member_srl) if (!$oDocument->isExists() || abs($oDocument->get('member_srl')) == $member_srl)
{ {
return; return;
@ -258,7 +257,7 @@ class pointController extends point
} }
// Get the points of the member // Get the points of the member
$cur_point = getModel('point')->getPoint($member_srl); $cur_point = PointModel::getPoint($member_srl);
// Add points for the comment. // Add points for the comment.
$comment_point = $this->_getModulePointConfig($module_srl, 'insert_comment'); $comment_point = $this->_getModulePointConfig($module_srl, 'insert_comment');
@ -307,7 +306,7 @@ class pointController extends point
} }
// Abort if the comment and the document have the same author. // Abort if the comment and the document have the same author.
$oDocument = getModel('document')->getDocument($obj->document_srl); $oDocument = DocumentModel::getDocument($obj->document_srl);
if (!$oDocument->isExists() || abs($oDocument->get('member_srl')) == $member_srl) if (!$oDocument->isExists() || abs($oDocument->get('member_srl')) == $member_srl)
{ {
return; return;
@ -324,7 +323,7 @@ class pointController extends point
$module_srl = $oDocument->get('module_srl'); $module_srl = $oDocument->get('module_srl');
// Get the points of the member // Get the points of the member
$cur_point = getModel('point')->getPoint($member_srl); $cur_point = PointModel::getPoint($member_srl);
// Add points for the comment. // Add points for the comment.
$comment_point = $this->_getModulePointConfig($module_srl, 'insert_comment'); $comment_point = $this->_getModulePointConfig($module_srl, 'insert_comment');
@ -372,7 +371,7 @@ class pointController extends point
} }
// Get the points of the member // Get the points of the member
$cur_point = getModel('point')->getPoint($member_srl); $cur_point = PointModel::getPoint($member_srl);
// Subtract points for the file. // Subtract points for the file.
$file_point = $this->_getModulePointConfig($module_srl, 'upload_file'); $file_point = $this->_getModulePointConfig($module_srl, 'upload_file');
@ -403,7 +402,7 @@ class pointController extends point
} }
// Get current points. // Get current points.
$cur_point = $logged_member_srl ? getModel('point')->getPoint($logged_member_srl) : 0; $cur_point = $logged_member_srl ? PointModel::getPoint($logged_member_srl) : 0;
// If the user (member or guest) does not have enough points, deny access. // If the user (member or guest) does not have enough points, deny access.
$config = $this->getConfig(); $config = $this->getConfig();
@ -435,7 +434,7 @@ class pointController extends point
$point = $this->_getModulePointConfig($module_srl, 'download_file'); $point = $this->_getModulePointConfig($module_srl, 'download_file');
if ($point) if ($point)
{ {
$cur_point = getModel('point')->getPoint($logged_member_srl); $cur_point = PointModel::getPoint($logged_member_srl);
$this->setPoint($logged_member_srl, $cur_point + $point); $this->setPoint($logged_member_srl, $cur_point + $point);
} }
} }
@ -446,7 +445,7 @@ class pointController extends point
$point = $this->_getModulePointConfig($module_srl, 'download_file_author'); $point = $this->_getModulePointConfig($module_srl, 'download_file_author');
if ($point) if ($point)
{ {
$cur_point = getModel('point')->getPoint($author_member_srl); $cur_point = PointModel::getPoint($author_member_srl);
$this->setPoint($author_member_srl, $cur_point + $point); $this->setPoint($author_member_srl, $cur_point + $point);
} }
} }
@ -517,7 +516,7 @@ class pointController extends point
if ($reader_point) if ($reader_point)
{ {
// Get current points. // Get current points.
$cur_point = $logged_member_srl ? getModel('point')->getPoint($logged_member_srl) : 0; $cur_point = $logged_member_srl ? PointModel::getPoint($logged_member_srl) : 0;
// If the reader does not have enough points, deny access. // If the reader does not have enough points, deny access.
if ($cur_point + $reader_point < 0 && $config->disable_read_document == 'Y') if ($cur_point + $reader_point < 0 && $config->disable_read_document == 'Y')
@ -554,7 +553,7 @@ class pointController extends point
// Adjust points of the person who wrote the document. // Adjust points of the person who wrote the document.
if ($author_point && $author_member_srl) if ($author_point && $author_member_srl)
{ {
$cur_point = getModel('point')->getPoint($author_member_srl); $cur_point = PointModel::getPoint($author_member_srl);
$this->setPoint($author_member_srl, $cur_point + $author_point); $this->setPoint($author_member_srl, $cur_point + $author_point);
} }
} }
@ -579,13 +578,13 @@ class pointController extends point
$config = $this->getConfig(); $config = $this->getConfig();
if ($is_comment) if ($is_comment)
{ {
$regdate = ztime(getModel('comment')->getComment($obj->comment_srl)->get('regdate')); $regdate = ztime(CommentModel::getComment($obj->comment_srl)->get('regdate'));
$logged_config_key = ($obj->point > 0) ? 'voter_comment_limit' : 'blamer_comment_limit'; $logged_config_key = ($obj->point > 0) ? 'voter_comment_limit' : 'blamer_comment_limit';
$target_config_key = ($obj->point > 0) ? 'voted_comment_limit' : 'blamed_comment_limit'; $target_config_key = ($obj->point > 0) ? 'voted_comment_limit' : 'blamed_comment_limit';
} }
else else
{ {
$regdate = ztime(getModel('document')->getDocument($obj->document_srl)->get('regdate')); $regdate = ztime(DocumentModel::getDocument($obj->document_srl)->get('regdate'));
$logged_config_key = ($obj->point > 0) ? 'voter_limit' : 'blamer_limit'; $logged_config_key = ($obj->point > 0) ? 'voter_limit' : 'blamer_limit';
$target_config_key = ($obj->point > 0) ? 'voted_limit' : 'blamed_limit'; $target_config_key = ($obj->point > 0) ? 'voted_limit' : 'blamed_limit';
} }
@ -603,7 +602,7 @@ class pointController extends point
{ {
$point = -1 * $point; $point = -1 * $point;
} }
$cur_point = getModel('point')->getPoint($logged_member_srl); $cur_point = PointModel::getPoint($logged_member_srl);
$this->setPoint($logged_member_srl, $cur_point + $point); $this->setPoint($logged_member_srl, $cur_point + $point);
} }
} }
@ -619,7 +618,7 @@ class pointController extends point
{ {
$point = -1 * $point; $point = -1 * $point;
} }
$cur_point = getModel('point')->getPoint($target_member_srl); $cur_point = PointModel::getPoint($target_member_srl);
$this->setPoint($target_member_srl, $cur_point + $point); $this->setPoint($target_member_srl, $cur_point + $point);
} }
} }
@ -630,8 +629,7 @@ class pointController extends point
*/ */
public function triggerCopyModule($obj) public function triggerCopyModule($obj)
{ {
$oModuleModel = getModel('module'); $pointConfig = ModuleModel::getModulePartConfig('point', $obj->originModuleSrl);
$pointConfig = $oModuleModel->getModulePartConfig('point', $obj->originModuleSrl);
$oModuleController = getController('module'); $oModuleController = getController('module');
if(is_array($obj->moduleSrlList)) if(is_array($obj->moduleSrlList))
@ -653,14 +651,11 @@ class pointController extends point
if(!$mode || !in_array($mode,$mode_arr)) $mode = 'update'; if(!$mode || !in_array($mode,$mode_arr)) $mode = 'update';
// Get configuration information // Get configuration information
$oMemberModel = getModel('member'); $config = ModuleModel::getModuleConfig('point');
$oModuleModel = getModel('module');
$oPointModel = getModel('point');
$config = $oModuleModel->getModuleConfig('point');
// Get the default configuration information // Get the default configuration information
$current_point = $oPointModel->getPoint($member_srl, false, $exists); $current_point = PointModel::getPoint($member_srl, false, $exists);
$current_level = $oPointModel->getLevel($current_point, $config->level_step); $current_level = PointModel::getLevel($current_point, $config->level_step);
// Change points // Change points
$args = new stdClass(); $args = new stdClass();
@ -722,7 +717,7 @@ class pointController extends point
} }
// Get a new level // Get a new level
$level = $oPointModel->getLevel($point, $config->level_step); $level = PointModel::getLevel($point, $config->level_step);
// If existing level and a new one are different attempt to set a point group // If existing level and a new one are different attempt to set a point group
$new_group_list = array(); $new_group_list = array();
@ -744,7 +739,7 @@ class pointController extends point
if($point_group && is_array($point_group) && count($point_group) ) if($point_group && is_array($point_group) && count($point_group) )
{ {
// Get the default group // Get the default group
$default_group = $oMemberModel->getDefaultGroup(); $default_group = MemberModel::getDefaultGroup();
asort($point_group); asort($point_group);
// Reset group after initialization // Reset group after initialization
@ -862,13 +857,11 @@ class pointController extends point
return 0; return 0;
} }
$oModuleModel = getModel('module');
if ($module_srl) if ($module_srl)
{ {
if (!isset(self::$_module_config_cache[$module_srl])) if (!isset(self::$_module_config_cache[$module_srl]))
{ {
self::$_module_config_cache[$module_srl] = $oModuleModel->getModulePartConfig('point', $module_srl); self::$_module_config_cache[$module_srl] = ModuleModel::getModulePartConfig('point', $module_srl);
} }
$module_config = self::$_module_config_cache[$module_srl]; $module_config = self::$_module_config_cache[$module_srl];
} }

View file

@ -123,7 +123,7 @@ class pointModel extends point
{ {
return; return;
} }
if (!getModel('module')->isSiteAdmin($logged_info)) if (!ModuleModel::isSiteAdmin($logged_info))
{ {
$member_srls = array_filter($member_srls, function($member_srl) use($logged_info) { return $member_srl == $logged_info->member_srl; }); $member_srls = array_filter($member_srls, function($member_srl) use($logged_info) { return $member_srl == $logged_info->member_srl; });
if (!count($member_srls)) if (!count($member_srls))
@ -132,8 +132,7 @@ class pointModel extends point
} }
} }
$oModuleModel = getModel('module'); $config = ModuleModel::getModuleConfig('point');
$config = $oModuleModel->getModuleConfig('point');
$info = array(); $info = array();
foreach($member_srls as $v) foreach($member_srls as $v)
@ -212,8 +211,7 @@ class pointModel extends point
if($output->total_count) if($output->total_count)
{ {
$oModuleModel = getModel('module'); $config = ModuleModel::getModuleConfig('point');
$config = $oModuleModel->getModuleConfig('point');
foreach($output->data as $key => $val) foreach($output->data as $key => $val)
{ {

View file

@ -33,12 +33,11 @@ class pointView extends point
if(!$current_module_srl) return; if(!$current_module_srl) return;
} }
// Get the configuration information // Get the configuration information
$oModuleModel = getModel('module'); $config = ModuleModel::getModuleConfig('point');
$config = $oModuleModel->getModuleConfig('point');
if($current_module_srl) if($current_module_srl)
{ {
$module_config = $oModuleModel->getModulePartConfig('point', $current_module_srl); $module_config = ModuleModel::getModulePartConfig('point', $current_module_srl);
if(!$module_config) if(!$module_config)
{ {
$module_config['insert_document'] = $config->insert_document; $module_config['insert_document'] = $config->insert_document;