|
From: Josh G. <os...@us...> - 2005-01-03 21:41:01
|
Update of /cvsroot/nanuke/nanuke0.x/modules/forum In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30689/modules/forum Modified Files: module.php posting.php viewtopic.php Added Files: report.php Log Message: - More minor forum module stuff - Viewtopic print view - Report post Index: module.php =================================================================== RCS file: /cvsroot/nanuke/nanuke0.x/modules/forum/module.php,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** module.php 24 Dec 2004 04:52:44 -0000 1.6 --- module.php 3 Jan 2005 21:40:45 -0000 1.7 *************** *** 121,124 **** --- 121,128 ---- require($nanuke_root_path . 'modules/forum/posting.'.$phpEx); break; + // Report + case 'report': + require($nanuke_root_path . 'modules/forum/report.'.$phpEx); + break; } } *************** *** 148,152 **** // array of components ! 'components' => array('index', 'viewforum', 'viewtopic', 'posting'), // array of blocks --- 152,156 ---- // array of components ! 'components' => array('index', 'viewforum', 'viewtopic', 'posting', 'report'), // array of blocks Index: posting.php =================================================================== RCS file: /cvsroot/nanuke/nanuke0.x/modules/forum/posting.php,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** posting.php 24 Dec 2004 04:52:44 -0000 1.3 --- posting.php 3 Jan 2005 21:40:45 -0000 1.4 *************** *** 643,647 **** if ($last_post_time) { ! if ($last_post_time && ($current_time - $last_post_time) < intval($config['flood_interval'])) { $error[] = $user->lang['FLOOD_ERROR']; --- 643,647 ---- if ($last_post_time) { ! if (($current_time - $last_post_time) > 0 && ($current_time - $last_post_time) < intval($config['flood_interval'])) { $error[] = $user->lang['FLOOD_ERROR']; *************** *** 1129,1135 **** 'S_SAVE_ALLOWED' => ($auth->acl_get('u_savedrafts') && $user->data['user_id'] != ANONYMOUS), 'S_HAS_DRAFTS' => ($auth->acl_get('u_savedrafts') && $user->data['user_id'] != ANONYMOUS && $drafts), - 'S_FORM_ENCTYPE' => $form_enctype, - 'S_POST_ACTION' => $s_action, 'S_HIDDEN_FIELDS' => $s_hidden_fields) ); --- 1129,1133 ---- *************** *** 1144,1148 **** 'S_POLL_DELETE' => ($mode == 'edit' && $poll_options && ((!$poll_last_vote && $poster_id == $user->data['user_id'] && $auth->acl_get('f_delete', $forum_id)) || $auth->acl_get('m_delete', $forum_id))), ! 'L_POLL_OPTIONS_EXPLAIN'=> sprintf($user->lang['POLL_OPTIONS_EXPLAIN'], $config['max_poll_options']), 'VOTE_CHANGE_CHECKED' => (isset($poll_vote_change) && $poll_vote_change) ? ' checked="checked"' : '', --- 1142,1146 ---- 'S_POLL_DELETE' => ($mode == 'edit' && $poll_options && ((!$poll_last_vote && $poster_id == $user->data['user_id'] && $auth->acl_get('f_delete', $forum_id)) || $auth->acl_get('m_delete', $forum_id))), ! 'L_POLL_OPTIONS_EXPLAIN'=> sprintf($user->lang['POLL_OPTIONS_EXPLAIN'], $config['module_forum_max_poll_options']), 'VOTE_CHANGE_CHECKED' => (isset($poll_vote_change) && $poll_vote_change) ? ' checked="checked"' : '', *************** *** 1161,1168 **** } ! // Set "before and after blocks" HTML $template->assign_vars(array( ! 'S_BEFORE_BLOCKS_HTML' => '<form action="'.$s_action.'" method="post" name="post"'.$form_enctype.'>', ! 'S_AFTER_BLOCKS_HTML' => '</form>' )); --- 1159,1166 ---- } ! // $template->assign_vars(array( ! 'S_POST_FORM_ACTION' => $s_action, ! 'S_POST_FORM_ENCTYPE' => $form_enctype )); --- NEW FILE: report.php --- <?php /** * Report script for NA-Nuke forum module, ported from sections of phpBB's report.php. * * @script: NA-Nuke * @module: forum * @version: $Id: report.php,v 1.1 2005/01/03 21:40:45 osjp Exp $ * @website: www.jportalhome.com * @email: jo...@jp... * @copyright: (C) 2004 JPortal * @begin: Mon Jan 03 2005 * @license: Free, Open Source (GPL) */ // Make sure we are not being called directly if (!defined('IN_NANUKE')) { die('Hacking attempt'); } require($nanuke_root_path . 'modules/forum/includes/functions_display.' . $phpEx); // Include language file for MCP actions $user->add_lang('mcp', false, false, 'modules/forum/language'); $id = request_var('p', 0); $report_post = (request_var('p', 0)) ? true : false; $reason_id = request_var('reason_id', 0); $user_notify = (!empty($_REQUEST['notify']) && $user->data['user_id'] != ANONYMOUS) ? true : false; $report_text = request_var('report_text', ''); if (!$id) { trigger_error('INVALID_MODE'); } $redirect_url = "{$nanuke_root_path}index.$phpEx$SID&mod=forum&com=viewtopic&p=$id#$id"; // Has the report been cancelled? if (isset($_POST['cancel'])) { redirect($redirect_url); } // Grab all relevant data $sql = 'SELECT f.*, t.*, p.* FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t, ' . FORUMS_TABLE . " f WHERE p.post_id = $id AND p.topic_id = t.topic_id AND p.forum_id = f.forum_id"; $result = $db->sql_query($sql); if (!($report_data = $db->sql_fetchrow($result))) { $message = $user->lang['POST_NOT_EXIST']; trigger_error($message); } $forum_id = $report_data['forum_id']; $topic_id = $report_data['topic_id']; $post_id = $report_data['post_id']; // Check required permissions $acl_check_ary = array('f_list' => 'POST_NOT_EXIST', 'f_read' => 'USER_CANNOT_READ', 'f_report' => 'USER_CANNOT_REPORT'); foreach ($acl_check_ary as $acl => $error) { if (!$auth->acl_get($acl, $forum_id)) { trigger_error($error); } } unset($acl_check_ary); // Check if the post has already been reported by this user $sql = 'SELECT * FROM ' . REPORTS_TABLE . ' WHERE post_id = ' . $post_id . ' AND nan_module = "forum" AND user_id = ' . $user->data['user_id']; $result = $db->sql_query($sql); if ($row = $db->sql_fetchrow($result)) { if ($user->data['user_id'] != ANONYMOUS) { // A report exists, extract $row if we're going to display the form if ($reason_id) { $report_id = (int) $row['report_id']; } else { // Overwrite set variables extract($row); } } else { trigger_error($user->lang['ALREADY_REPORTED'] . '<br /><br />' . sprintf($user->lang['RETURN_TOPIC'], '<a href="' . $redirect_url . '">', '</a>')); } } else { $report_id = 0; } // Has the report been confirmed? if (isset($_POST['submit']) && $reason_id) { $sql = 'SELECT reason_name FROM ' . REASONS_TABLE . " WHERE reason_id = $reason_id"; $result = $db->sql_query($sql); if (!($row = $db->sql_fetchrow($result)) || (!$report_text && $row['reason_name'] == 'other')) { trigger_error('EMPTY_REPORT'); } $db->sql_freeresult($result); $reason_desc = (!empty($user->lang['report_reasons']['DESCRIPTION'][$row['reason_name']])) ? $user->lang['report_reasons']['DESCRIPTION'][$row['reason_name']] : $row['reason_name']; $sql_ary = array( 'reason_id' => (int) $reason_id, 'post_id' => $id, 'user_id' => (int) $user->data['user_id'], 'user_notify' => (int) $user_notify, 'report_time' => (int) time(), 'report_text' => (string) $report_text ); if ($report_id) { $sql = 'UPDATE ' . REPORTS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' WHERE report_id = ' . $report_id; $db->sql_query($sql); } else { $sql = 'INSERT INTO ' . REPORTS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary); $db->sql_query($sql); $report_id = $db->sql_nextid(); } if (!$report_data['post_reported']) { $sql = 'UPDATE ' . POSTS_TABLE . ' SET post_reported = 1 WHERE post_id = ' . $id; $db->sql_query($sql); } if (!$report_data['topic_reported']) { $sql = 'UPDATE ' . TOPICS_TABLE . ' SET topic_reported = 1 WHERE topic_id = ' . $report_data['topic_id']; $db->sql_query($sql); } // Send Notifications // PM: Reported Post is put into all admin's boxes (not notifying about 'this' PM) // All persons get notified about a new report, if notified by PM, send out email notifications too // Send notifications to moderators $acl_list = ($report_post) ? $auth->acl_get_list(false, array('m_', 'a_'), array(0, $report_data['forum_id'])) : $auth->acl_get_list(false, 'a_', 0); $notify_user = ($report_post) ? $acl_list[$report_data['forum_id']]['m_'] : array(); $notify_user = array_unique(array_merge($notify_user, $acl_list[0]['a_'])); unset($acl_list); // How to notify them? $sql = 'SELECT user_id, username, user_options, user_lang, user_email, user_notify_type, user_jabber FROM ' . USERS_TABLE . ' WHERE user_id IN (' . implode(', ', $notify_user) . ')'; $result = $db->sql_query($sql); $notify_user = array(); while ($row = $db->sql_fetchrow($result)) { $notify_user[$row['user_id']] = array( 'name' => $row['username'], 'email' => $row['user_email'], 'jabber'=> $row['user_jabber'], 'lang' => $row['user_lang'], 'notify_type' => $row['user_notify_type'], 'pm' => $user->optionget('report_pm_notify', $row['user_options']) ); } $db->sql_freeresult($result); $report_data = array( 'id' => $id, 'report_id' => $report_id, 'reporter' => $user->data['username'], 'reason' => $reason_desc, 'text' => $report_text, 'subject' => $report_data['post_subject'], 'view_post' => "index.$phpEx?mod=forum&com=viewtopic&f={$report_data['forum_id']}&t={$report_data['topic_id']}&p=$id&e=$id" ); report_notification($notify_user, $report_data); meta_refresh(3, $redirect_url); $message = $user->lang['POST_REPORTED_SUCCESS'] . '<br /><br />' . sprintf($user->lang['RETURN_TOPIC'], '<a href="' . $redirect_url . '">', '</a>'); trigger_error($message); } // Generate the form $sql = 'SELECT * FROM ' . REASONS_TABLE . ' ORDER BY reason_priority ASC'; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { $row['reason_name'] = strtoupper($row['reason_name']); $reason_title = (!empty($user->lang['report_reasons']['TITLE'][$row['reason_name']])) ? $user->lang['report_reasons']['TITLE'][$row['reason_name']] : ucwords(str_replace('_', ' ', $row['reason_name'])); $reason_desc = (!empty($user->lang['report_reasons']['DESCRIPTION'][$row['reason_name']])) ? $user->lang['report_reasons']['DESCRIPTION'][$row['reason_name']] : $row['reason_desc']; $template->assign_block_vars('reason', array( 'ID' => $row['reason_id'], 'NAME' => htmlspecialchars($reason_title), 'DESCRIPTION' => htmlspecialchars($reason_desc), 'S_SELECTED' => ($row['reason_id'] == $reason_id) ? true : false) ); } $u_report = "p=$id"; $template->assign_vars(array( 'REPORT_TEXT' => $report_text, 'S_REPORT_ACTION' => "{$nanuke_root_path}index.$phpEx$SID&mod=forum&com=report&$u_report&report_id=$report_id", 'S_NOTIFY' => (!empty($user_notify)) ? true : false, 'S_CAN_NOTIFY' => ($user->data['user_id'] == ANONYMOUS) ? false : true, 'S_REPORT_POST' => $report_post) ); // Generate navlinks generate_forum_nav($report_data, false); $template->assign_block_vars('navlinks', array( 'NAVNAME' => $user->lang['REPORT_POST'], 'S_CURRENT_PAGE' => true )); // Start output of page $page_title = $user->lang['REPORT_POST']; page_header($page_title); $template->set_filenames(array( 'body' => 'report_body.html') ); page_footer(); function report_notification($notify_user, $report_data) { global $config, $nanuke_root_path, $phpEx; include_once($nanuke_root_path . 'includes/functions_messenger.' . $phpEx); include_once($nanuke_root_path . 'modules/ucp/includes/functions_privmsgs.' . $phpEx); $messenger = new messenger(); $email_sig = str_replace('<br />', "\n", "-- \n" . $config['board_email_sig']); $email_template = 'new_report_post'; $view_report_url = "index.$phpEx&mod=forum&com=mcp?i=queue&r=" . $report_data['report_id']; foreach ($notify_user as $user_id => $notify_row) { // Send notification by email if (!$notify_row['pm']) { print_r($notify_user); $messenger->to($notify_row['email'], $notify_row['name']); $messenger->im($notify_row['jabber'], $notify_row['name']); $messenger->replyto($config['board_email']); $messenger->template($email_template, $notify_row['lang']); $messenger->assign_vars(array( 'EMAIL_SIG' => $email_sig, 'SITENAME' => $config['sitename'], 'USERNAME' => $notify_row['name'], 'SUBJECT' => $report_data['subject'], 'REPORTER' => $report_data['reporter'], 'REPORT_REASON' => $report_data['reason'], 'REPORT_TEXT' => $report_data['text'], 'U_VIEW_REPORT' => generate_board_url() . '/' . $view_report_url, 'U_VIEW_POST' => generate_board_url() . '/' . $report_data['view_post']) ); $messenger->send($notify_row['notify_type']); $messenger->reset(); if ($messenger->queue) { $messenger->queue->save(); } } else { // Use messenger for getting the correct message, we use the email template $messenger->template($email_template, $notify_row['lang']); $messenger->assign_vars(array( 'EMAIL_SIG' => $email_sig, 'SITENAME' => $config['sitename'], 'USERNAME' => $notify_row['name'], 'SUBJECT' => $report_data['subject'], 'REPORTER' => $report_data['reporter'], 'REPORT_REASON' => $report_data['reason'], 'REPORT_TEXT' => $report_data['text'], 'U_VIEW_REPORT' => generate_board_url() . '/' . $view_report_url) ); // break the sending process... $messenger->send(false, true); $messenger->reset(); // do not put in reporters outbox submit_pm('post', $report_data['subject'], '', array(), array(), array( 'address_list' => array('u' => array($user_id => 'to')), 'icon_id' => 0, 'enable_bbcode' => 0, 'enable_html' => 0, 'enable_smilies' => 0, 'enable_magic_url' => 1, 'enable_sig' => 0, 'message_md5' => md5($messenger->msg), 'bbcode_bitfield' => 0, 'bbcode_uid' => 0, 'attachment_data' => array(), 'filename_data' => array(), 'message' => $messenger->msg ), true, false); } } unset($messenger); } ?> Index: viewtopic.php =================================================================== RCS file: /cvsroot/nanuke/nanuke0.x/modules/forum/viewtopic.php,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** viewtopic.php 24 Dec 2004 04:52:44 -0000 1.3 --- viewtopic.php 3 Jan 2005 21:40:45 -0000 1.4 *************** *** 192,195 **** --- 192,199 ---- } + // NA-Nuke hack: sometimes the "bookmarked" var is not present in the $topic_data + // array (extracted below), but it is still requested in this page, causing PHP notices. Prevent this. + $topic_data['bookmarked'] = (isset($topic_data['bookmarked']) ? $topic_data['bookmarked'] : false); + // Extract the data extract($topic_data); *************** *** 498,502 **** 'S_SEARCHBOX_ACTION' => "search.$phpEx$SID&f=$forum_id", ! 'U_TOPIC' => "{$server_path}index.$phpEx$SID&mod=forum&com=viewtopic&f=$forum_id&t=$topic_id", 'U_FORUM' => $server_path, 'U_VIEW_UNREAD_POST' => "index.$phpEx$SID&mod=forum&com=viewtopic&f=$forum_id&t=$topic_id&view=unread#unread", --- 502,506 ---- 'S_SEARCHBOX_ACTION' => "search.$phpEx$SID&f=$forum_id", ! 'U_TOPIC' => "{$server_path}index.$phpEx?mod=forum&com=viewtopic&f=$forum_id&t=$topic_id", 'U_FORUM' => $server_path, 'U_VIEW_UNREAD_POST' => "index.$phpEx$SID&mod=forum&com=viewtopic&f=$forum_id&t=$topic_id&view=unread#unread", *************** *** 1276,1280 **** 'U_JABBER' => $user_cache[$poster_id]['jabber'], ! 'U_REPORT' => "report.$phpEx$SID&p=" . $row['post_id'], 'U_MCP_REPORT' => ($auth->acl_gets('m_', 'a_', 'f_report', $forum_id)) ? "mcp.$phpEx$SID&mode=post_details&p=" . $row['post_id'] : '', 'U_MCP_APPROVE' => ($auth->acl_get('m_approve', $forum_id)) ? "mcp.$phpEx$SID&i=queue&mode=approve&p=" . $row['post_id'] : '', --- 1280,1284 ---- 'U_JABBER' => $user_cache[$poster_id]['jabber'], ! 'U_REPORT' => "index.$phpEx$SID&mod=forum&com=report&p=" . $row['post_id'], 'U_MCP_REPORT' => ($auth->acl_gets('m_', 'a_', 'f_report', $forum_id)) ? "mcp.$phpEx$SID&mode=post_details&p=" . $row['post_id'] : '', 'U_MCP_APPROVE' => ($auth->acl_get('m_approve', $forum_id)) ? "mcp.$phpEx$SID&i=queue&mode=approve&p=" . $row['post_id'] : '', |