Mr. Jinx
Well-known member
I have extended the follow class:
XF/ModeratorLog/Post
The original Post looks like this:
And AbstractHandler:
My problem is the last part "return parent::isLoggable($content, $action, $actor);"
If I am correct, this will call the parent function isLoggable, so in this case it would call isLoggable from the original Post class.
The problem is that this would undo my modification.
If "$options->MrJinx_LogAllModActions_OwnActions" is set, it would call parent::isLoggable from the original Post function (I think).
Ofcource I could just return true, but what should be the proper way to extent a function like this?
XF/ModeratorLog/Post
Code:
namespace MrJinx\LogAllModActions\XF\ModeratorLog;
use XF\Mvc\Entity\Entity;
class Post extends XFCP_Post
{
public function isLoggable(Entity $content, $action, \XF\Entity\User $actor)
{
$options = \XF::options();
switch ($action)
{
case 'edit':
if (($actor->user_id == $content->user_id) && (!$options->MrJinx_LogAllModActions_OwnActions))
{
return false;
}
}
return parent::isLoggable($content, $action, $actor);
}
}
The original Post looks like this:
Code:
class Post extends AbstractHandler
{
public function isLoggable(Entity $content, $action, \XF\Entity\User $actor)
{
switch ($action)
{
case 'edit':
if ($actor->user_id == $content->user_id)
{
return false;
}
}
return parent::isLoggable($content, $action, $actor);
}
}
And AbstractHandler:
Code:
public function isLoggable(Entity $content, $action, \XF\Entity\User $actor)
{
return true;
}
My problem is the last part "return parent::isLoggable($content, $action, $actor);"
If I am correct, this will call the parent function isLoggable, so in this case it would call isLoggable from the original Post class.
The problem is that this would undo my modification.
If "$options->MrJinx_LogAllModActions_OwnActions" is set, it would call parent::isLoggable from the original Post function (I think).
Ofcource I could just return true, but what should be the proper way to extent a function like this?