コード例 #1
0
ファイル: Thread.php プロジェクト: namgiangle90/tokyobaito
 /**
  * Logs the moderator actions for thread edits.
  *
  * @param array $thread
  * @param XenForo_DataWriter_Discussion_Thread $dw
  * @param array $skip Array of keys to skip logging for
  */
 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);
         }
     }
 }
コード例 #2
0
 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 'moderate_replies_th':
                     XenForo_Model_Log::logModeratorAction('thread', $thread, $value ? 'enable_moderate_replies' : 'disable_moderate_replies');
                     $skip[] = 'moderate_replies_th';
                     break;
             }
         }
     }
     return parent::_updateModeratorLogThreadEdit($thread, $dw, $skip);
 }