Make getCommentList and getTotalCommentList triggers consistent with getDocumentList trigger

This commit is contained in:
Kijin Sung 2019-09-13 19:58:51 +09:00
parent 2238679527
commit 9b64b0f925

View file

@ -512,16 +512,25 @@ class commentModel extends comment
$args->status = 1; $args->status = 1;
} }
// call trigger (before) // Call trigger (before)
// This trigger can be used to set an alternative output using a different search method
unset($args->use_alternate_output);
$trigger_output = ModuleHandler::triggerCall('comment.getCommentList', 'before', $args); $trigger_output = ModuleHandler::triggerCall('comment.getCommentList', 'before', $args);
if($trigger_output instanceof BaseObject && !$trigger_output->toBool()) if($trigger_output instanceof BaseObject && !$trigger_output->toBool())
{ {
return $output; return $output;
} }
$output = executeQueryArray('comment.getCommentPageList', $args);
// return if an error occurs in the query results // If an alternate output is set, use it instead of running the default queries
if (isset($args->use_alternate_output) && $args->use_alternate_output instanceof BaseObject)
{
$output = $args->use_alternate_output;
}
else
{
// Execute normal query
$output = executeQueryArray('comment.getCommentPageList', $args);
if(!$output->toBool()) if(!$output->toBool())
{ {
return; return;
@ -537,14 +546,11 @@ class commentModel extends comment
return; return;
} }
} }
// call trigger (after)
$trigger_output = ModuleHandler::triggerCall('comment.getCommentList', 'after', $output);
if($trigger_output instanceof BaseObject && !$trigger_output->toBool())
{
return $trigger_output;
} }
// Call trigger (after)
// This trigger can be used to modify search results
ModuleHandler::triggerCall('comment.getCommentList', 'after', $output);
return $output; return $output;
} }
@ -817,8 +823,25 @@ class commentModel extends comment
} }
} }
// comment.getTotalCommentList query execution // Call trigger (before)
// This trigger can be used to set an alternative output using a different search method
unset($args->use_alternate_output);
$output = ModuleHandler::triggerCall('comment.getTotalCommentList', 'before', $args);
if($output instanceof BaseObject && !$output->toBool())
{
return $output;
}
// If an alternate output is set, use it instead of running the default queries
if (isset($args->use_alternate_output) && $args->use_alternate_output instanceof BaseObject)
{
$output = $args->use_alternate_output;
}
// Execute normal query
else
{
$output = executeQueryArray($query_id, $args, $columnList); $output = executeQueryArray($query_id, $args, $columnList);
}
// return when no result or error occurance // return when no result or error occurance
if(!$output->toBool() || !count($output->data)) if(!$output->toBool() || !count($output->data))
@ -834,6 +857,9 @@ class commentModel extends comment
$output->data[$key] = $_oComment; $output->data[$key] = $_oComment;
} }
// Call trigger (after)
// This trigger can be used to modify search results
ModuleHandler::triggerCall('comment.getTotalCommentList', 'after', $output);
return $output; return $output;
} }