Fix #2145 rename $is_admin to more descriptive variable name in some controller actions

This commit is contained in:
Kijin Sung 2023-09-13 11:15:13 +09:00
parent 71e4118bd5
commit 26f923d64b
3 changed files with 18 additions and 18 deletions

View file

@ -920,11 +920,11 @@ class CommentController extends Comment
/** /**
* Fix the comment * Fix the comment
* @param object $obj * @param object $obj
* @param bool $is_admin * @param bool $skip_grant_check
* @param bool $manual_updated * @param bool $manual_updated
* @return object * @return object
*/ */
function updateComment($obj, $is_admin = FALSE, $manual_updated = FALSE) function updateComment($obj, $skip_grant_check = FALSE, $manual_updated = FALSE)
{ {
if(!$manual_updated && !checkCSRF()) if(!$manual_updated && !checkCSRF())
{ {
@ -971,7 +971,7 @@ class CommentController extends Comment
} }
// check if permission is granted // check if permission is granted
if(!$is_admin && !$source_obj->isGranted()) if(!$skip_grant_check && !$source_obj->isGranted())
{ {
return new BaseObject(-1, 'msg_not_permitted'); return new BaseObject(-1, 'msg_not_permitted');
} }
@ -1058,10 +1058,10 @@ class CommentController extends Comment
/** /**
* Fix comment the delete comment message * Fix comment the delete comment message
* @param object $obj * @param object $obj
* @param bool $is_admin * @param bool $skip_grant_check
* @return object * @return object
*/ */
function updateCommentByDelete($obj, $is_admin = FALSE) function updateCommentByDelete($obj, $skip_grant_check = FALSE)
{ {
if (!$obj->comment_srl) if (!$obj->comment_srl)
{ {
@ -1074,7 +1074,7 @@ class CommentController extends Comment
{ {
return new BaseObject(-1, 'msg_not_founded'); return new BaseObject(-1, 'msg_not_founded');
} }
if(!$is_admin && !$comment->isGranted()) if(!$skip_grant_check && !$comment->isGranted())
{ {
return new BaseObject(-1, 'msg_not_permitted'); return new BaseObject(-1, 'msg_not_permitted');
} }
@ -1087,7 +1087,7 @@ class CommentController extends Comment
} }
// If the case manager to delete comments, it indicated that the administrator deleted. // If the case manager to delete comments, it indicated that the administrator deleted.
if($is_admin === true && $obj->member_srl !== $this->user->member_srl) if($obj->member_srl !== $this->user->member_srl && $this->user->member_srl)
{ {
$obj->content = lang('msg_admin_deleted_comment'); $obj->content = lang('msg_admin_deleted_comment');
$obj->status = RX_STATUS_DELETED_BY_ADMIN; $obj->status = RX_STATUS_DELETED_BY_ADMIN;

View file

@ -1236,12 +1236,12 @@ class DocumentController extends Document
/** /**
* Deleting Documents * Deleting Documents
* @param int $document_srl * @param int $document_srl
* @param bool $is_admin * @param bool $skip_grant_check
* @param bool $isEmptyTrash * @param bool $isEmptyTrash
* @param documentItem $oDocument * @param documentItem $oDocument
* @return object * @return object
*/ */
function deleteDocument($document_srl, $is_admin = false, $isEmptyTrash = false, $oDocument = null) function deleteDocument($document_srl, $skip_grant_check = false, $isEmptyTrash = false, $oDocument = null)
{ {
// Call a trigger (before) // Call a trigger (before)
$trigger_obj = new stdClass(); $trigger_obj = new stdClass();
@ -1253,7 +1253,7 @@ class DocumentController extends Document
// Check if the document exists // Check if the document exists
if(!$isEmptyTrash) if(!$isEmptyTrash)
{ {
$oDocument = DocumentModel::getDocument($document_srl, $is_admin); $oDocument = DocumentModel::getDocument($document_srl);
} }
else if($isEmptyTrash && $oDocument == null) else if($isEmptyTrash && $oDocument == null)
{ {
@ -1265,7 +1265,7 @@ class DocumentController extends Document
{ {
return new BaseObject(-1, 'msg_invalid_document'); return new BaseObject(-1, 'msg_invalid_document');
} }
if(!$oDocument->isGranted()) if(!$skip_grant_check && !$oDocument->isGranted())
{ {
return new BaseObject(-1, 'msg_not_permitted'); return new BaseObject(-1, 'msg_not_permitted');
} }

View file

@ -2883,9 +2883,9 @@ class MemberController extends Member
/** /**
* Modify member information * Modify member information
* *
* @param bool $is_admin , modified 2013-11-22 * @param bool $deprecated_allow_update_other
*/ */
function updateMember($args, $is_admin = FALSE) function updateMember($args, $deprecated_allow_update_other = FALSE)
{ {
// Call a trigger (before) // Call a trigger (before)
$output = ModuleHandler::triggerCall('member.updateMember', 'before', $args); $output = ModuleHandler::triggerCall('member.updateMember', 'before', $args);
@ -2912,14 +2912,14 @@ class MemberController extends Member
unset($args->is_admin); unset($args->is_admin);
unset($args->limit_date); unset($args->limit_date);
unset($args->description); unset($args->description);
if($is_admin == false) if (!$deprecated_allow_update_other)
{ {
unset($args->denied); unset($args->denied);
unset($args->status); unset($args->status);
} if ($logged_info->member_srl != $args->member_srl)
if($logged_info->member_srl != $args->member_srl && $is_admin == false) {
{ return new BaseObject(-1, 'msg_invalid_request');
return new BaseObject(-1, 'msg_invalid_request'); }
} }
} }