Example #1
0
 /**
  * @param array $report_ids
  * @param $mode
  */
 private function update_reports_status(array $report_ids, $mode, $action)
 {
     global $user, $phpbb_log;
     $module_name = '\\rfd\\trader\\mcp\\mcp_trader_module';
     $redirect = 'mcp.php?i=' . $module_name . '&mode=open_trader_reports';
     $success_msg = '';
     if (!$report_ids) {
         trigger_error('NO_REPORT_SELECTED');
     }
     if (!$this->manager->isTraderModerator()) {
         trigger_error('NOT_AUTHORISED');
     }
     $s_hidden_fields = build_hidden_fields(array('i' => $module_name, 'mode' => $mode, 'report_id_list' => $report_ids, 'action' => $action, 'redirect' => $redirect));
     if (confirm_box(true)) {
         // add moderator log entries
         foreach ($report_ids as $report_id) {
             $report = $this->manager->get_report($report_id);
             if ($report && $action == 'delete') {
                 $this->manager->deleteReport($report['report_id'], $phpbb_log, $user);
             } else {
                 if ($report && $action == 'close' && !$this->manager->isReportClosed($report)) {
                     $this->manager->closeReport($report['report_id'], $phpbb_log, $user);
                 }
             }
         }
         $success_msg = 'REPORT' . (count($report_ids) > 1 ? 'S' : '') . '_' . ($action == 'close' ? 'CLOSED' : 'DELETED') . '_SUCCESS';
     } else {
         $confirm_msg = ($action == 'close' ? 'CLOSE' : 'DELETE') . '_REPORT' . (count($report_ids) > 1 ? 'S' : '') . '_CONFIRM';
         confirm_box(false, $user->lang($confirm_msg), $s_hidden_fields);
     }
     if (!$success_msg) {
         redirect($redirect);
     } else {
         meta_refresh(3, $redirect);
         trigger_error($user->lang[$success_msg] . '<br /><br />' . sprintf($user->lang['RETURN_PAGE'], "<a href=\"{$redirect}\">", '</a>'));
     }
 }