Update point triggers to use diff syntax for giving and taking points

This commit is contained in:
Kijin Sung 2023-06-19 13:35:25 +09:00
parent 833ba2390a
commit 2b8f5ca947

View file

@ -34,6 +34,8 @@ class pointController extends point
$diff = intval($config->signup_point); $diff = intval($config->signup_point);
if ($diff != 0) if ($diff != 0)
{ {
// New member is not supposed to have points,
// but we check just in case another module has intervened.
$cur_point = PointModel::getPoint($member_srl); $cur_point = PointModel::getPoint($member_srl);
$this->setPoint($member_srl, $cur_point + $diff, 'signup'); $this->setPoint($member_srl, $cur_point + $diff, 'signup');
} }
@ -60,8 +62,7 @@ class pointController extends point
$diff = intval($config->login_point); $diff = intval($config->login_point);
if ($diff != 0) if ($diff != 0)
{ {
$cur_point = PointModel::getPoint($member_srl); $this->setPoint($member_srl, $diff, 'plus');
$this->setPoint($member_srl, $cur_point + $diff);
} }
} }
@ -118,8 +119,7 @@ class pointController extends point
// Increase the point. // Increase the point.
if ($diff != 0) if ($diff != 0)
{ {
$cur_point = PointModel::getPoint($member_srl); $this->setPoint($member_srl, $diff, 'plus');
$this->setPoint($member_srl, $cur_point + $diff);
} }
} }
@ -179,8 +179,7 @@ class pointController extends point
// Increase the point. // Increase the point.
if ($diff != 0) if ($diff != 0)
{ {
$cur_point = PointModel::getPoint($member_srl); $this->setPoint($member_srl, $diff, 'plus');
$this->setPoint($member_srl, $cur_point + $diff);
} }
// Remove the reference to the original document. // Remove the reference to the original document.
@ -231,11 +230,10 @@ class pointController extends point
// Subtract points for the document. // Subtract points for the document.
$diff = $this->_getModulePointConfig($module_srl, 'insert_document'); $diff = $this->_getModulePointConfig($module_srl, 'insert_document');
// Increase the point. // Decrease the point.
if ($diff != 0) if ($diff != 0)
{ {
$cur_point = PointModel::getPoint($member_srl); $this->setPoint($member_srl, $diff, 'minus');
$this->setPoint($member_srl, $cur_point - $diff);
} }
} }
@ -292,8 +290,7 @@ class pointController extends point
// Increase the point. // Increase the point.
if ($diff != 0) if ($diff != 0)
{ {
$cur_point = PointModel::getPoint($member_srl); $this->setPoint($member_srl, $diff, 'plus');
$this->setPoint($member_srl, $cur_point + $diff);
} }
} }
@ -349,8 +346,7 @@ class pointController extends point
// Decrease the point. // Decrease the point.
if ($diff != 0) if ($diff != 0)
{ {
$cur_point = PointModel::getPoint($member_srl); $this->setPoint($member_srl, $diff, 'minus');
$this->setPoint($member_srl, $cur_point - $diff);
} }
} }
@ -399,8 +395,7 @@ class pointController extends point
// Update the point. // Update the point.
if ($diff != 0) if ($diff != 0)
{ {
$cur_point = PointModel::getPoint($member_srl); $this->setPoint($member_srl, $diff, 'minus');
$this->setPoint($member_srl, $cur_point - $diff);
} }
} }
@ -457,8 +452,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 = PointModel::getPoint($logged_member_srl); $this->setPoint($logged_member_srl, $point, 'plus');
$this->setPoint($logged_member_srl, $cur_point + $point);
} }
} }
@ -468,8 +462,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 = PointModel::getPoint($author_member_srl); $this->setPoint($author_member_srl, $point, 'plus');
$this->setPoint($author_member_srl, $cur_point + $point);
} }
} }
} }
@ -564,15 +557,14 @@ class pointController extends point
$args->member_srl = $logged_member_srl; $args->member_srl = $logged_member_srl;
$args->document_srl = $obj->document_srl; $args->document_srl = $obj->document_srl;
$output = executeQuery('document.insertDocumentReadedLog', $args); $output = executeQuery('document.insertDocumentReadedLog', $args);
$this->setPoint($logged_member_srl, $cur_point + $reader_point); $this->setPoint($logged_member_srl, $reader_point, 'plus');
} }
} }
// 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 = PointModel::getPoint($author_member_srl); $this->setPoint($author_member_srl, $author_point, 'plus');
$this->setPoint($author_member_srl, $cur_point + $author_point);
} }
} }
@ -620,8 +612,7 @@ class pointController extends point
{ {
$point = -1 * $point; $point = -1 * $point;
} }
$cur_point = PointModel::getPoint($logged_member_srl); $this->setPoint($logged_member_srl, $point, 'plus');
$this->setPoint($logged_member_srl, $cur_point + $point);
} }
} }
@ -636,8 +627,7 @@ class pointController extends point
{ {
$point = -1 * $point; $point = -1 * $point;
} }
$cur_point = PointModel::getPoint($target_member_srl); $this->setPoint($target_member_srl, $point, 'plus');
$this->setPoint($target_member_srl, $cur_point + $point);
} }
} }
} }