/** * Event: rfd.api.pre_update_topic * * Validate trader_type being passed in * * @param phpbbEvent $event */ public function rfd_api_pre_update_topic(phpbbEvent $event) { $data = $event->get_data(); $topic_id = $data['topic_id']; $forum_id = $data['forum_id']; $errors = $data['errors']; $type = $this->request->variable('trader_type', '', false, \phpbb\request\request_interface::POST); // if trader_type is not set, set it to the current trader_type if (!isset($type)) { $type = $this->manager->getTopicType($topic_id); $type = $this->manager->validateForumType($forum_id, $type, false); } else { if ($this->manager->getForumStatus($forum_id)) { $type = $this->manager->validateForumType($forum_id, $type, true); } } // Expose error if trader_type is not supported by the forum if (is_null($type)) { $errors[] = 'This forum does not support that trader type'; $data['errors'] = $errors; $event->set_data($data); } else { // Overwrite the request so that submit_post_end listener can handle trader_type $this->request->overwrite('prefixfield', $type, \phpbb\request\request_interface::POST); } }
/** * @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>')); } }
/** * Return true iff current user can reply to the given feedback * * @param $from_id - The user id of the sender of the feedback * @param $to_id - The user id of the receiver of the feedback * @param $topic_id - The topic id of the feedback */ private function canReplyToFeedback($from_id, $to_id, $topic_id) { return $this->user->data['user_id'] == $to_id && $this->manager->canGiveFeedback($from_id, $this->user->data['user_id'], $topic_id); }