arms
Well-known member
I'm now closing off all the nice to haves on my extra prefix addon (suffix)
One is to include any changes in the mod log.
atm changes are recorded as:
So I want to add the suffix_id case
But as far as i can see extending _updateModeratorLogThreadEdit will mean that I will run my case as well as all cases in the parent which gives me duplicates:
Anyone got any advice?
One is to include any changes in the mod log.
atm changes are recorded as:
Code:
Thread edited (suffix_id)
So I want to add the suffix_id case
PHP:
case 'suffix_id':
if ($oldValue)
{
$phrase = new XenForo_Phrase('thread_suffix_' . $oldValue);
$oldValue = $phrase->render();
}
else
{
$oldValue = '-';
}
XenForo_Model_Log::logModeratorAction(
'thread', $thread, 'suffix', array('old' => $oldValue)
);
break;
But as far as i can see extending _updateModeratorLogThreadEdit will mean that I will run my case as well as all cases in the parent which gives me duplicates:
Anyone got any advice?
PHP:
protected function _updateModeratorLogThreadEdit(array $thread, XenForo_DataWriter_Discussion_Thread $dw, array $skip = array())
{
$newData = $dw->getMergedNewData();
if ($newData)
{
$oldData = $dw->getMergedExistingData();
$basicLog = array();
foreach ($newData AS $key => $value)
{
$oldValue = (isset($oldData[$key]) ? $oldData[$key] : '-');
switch ($key)
{
case 'sticky':
XenForo_Model_Log::logModeratorAction('thread', $thread, ($value ? 'stick' : 'unstick'));
break;
case 'discussion_open':
XenForo_Model_Log::logModeratorAction('thread', $thread, ($value ? 'unlock' : 'lock'));
break;
case 'discussion_state':
if ($value == 'visible' && $oldValue == 'moderated')
{
XenForo_Model_Log::logModeratorAction('thread', $thread, 'approve');
}
else if ($value == 'visible' && $oldValue == 'deleted')
{
XenForo_Model_Log::logModeratorAction('thread', $thread, 'undelete');
}
else if ($value == 'deleted')
{
XenForo_Model_Log::logModeratorAction(
'thread', $thread, 'delete_soft', array('reason' => '')
);
}
else if ($value == 'moderated')
{
XenForo_Model_Log::logModeratorAction('thread', $thread, 'unapprove');
}
break;
case 'title':
XenForo_Model_Log::logModeratorAction(
'thread', $thread, 'title', array('old' => $oldValue)
);
break;
case 'prefix_id':
if ($oldValue)
{
$phrase = new XenForo_Phrase('thread_prefix_' . $oldValue);
$oldValue = $phrase->render();
}
else
{
$oldValue = '-';
}
XenForo_Model_Log::logModeratorAction(
'thread', $thread, 'prefix', array('old' => $oldValue)
);
break;
default:
if (!in_array($key, $skip))
{
$basicLog[$key] = $oldValue;
}
}
}
if ($basicLog)
{
XenForo_Model_Log::logModeratorAction('thread', $thread, 'edit', $basicLog);
}
}
}