|
From: Jon O. <jon...@us...> - 2005-03-29 20:07:40
|
Update of /cvsroot/mxbb/kb_076_mxaddon/root/includes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8431/modules/kb_076_mxaddon/root/includes Modified Files: functions_kb.php kb_article.php kb_post.php Log Message: small bugs, reported in phpbb dev thread - added regenerate search tables Index: kb_article.php =================================================================== RCS file: /cvsroot/mxbb/kb_076_mxaddon/root/includes/kb_article.php,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** kb_article.php 28 Mar 2005 20:54:53 -0000 1.2 --- kb_article.php 29 Mar 2005 20:06:58 -0000 1.3 *************** *** 424,428 **** $i = 0; ! while ( $i < count( $art_pages ) ) { --- 424,428 ---- $i = 0; ! while ( $i < count( $art_pages ) ) { *************** *** 431,435 **** $art_split = explode( '[toc]', $art_pages[$i] ); $article_toc = $art_split[0]; ! // Fix up the toc title --- 431,435 ---- $art_split = explode( '[toc]', $art_pages[$i] ); $article_toc = $art_split[0]; ! // Fix up the toc title *************** *** 441,445 **** // Parse message ! $article_toc = preg_replace( "/\[(\S+)\]/e", "", $article_toc ); $article_toc = make_clickable( $article_toc ); --- 441,445 ---- // Parse message ! $article_toc = preg_replace( "'\[[\/\!]*?[^\[\]]*?\]'si", "", $article_toc ); // Fixed $article_toc = make_clickable( $article_toc ); Index: kb_post.php =================================================================== RCS file: /cvsroot/mxbb/kb_076_mxaddon/root/includes/kb_post.php,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** kb_post.php 28 Mar 2005 20:54:53 -0000 1.1 --- kb_post.php 29 Mar 2005 20:06:58 -0000 1.2 *************** *** 240,263 **** } ! if ( !$approve || $approve == 0 ) ! { ! email_kb_admin( $kb_config['notify'] ); ! } // Insert phpBB post if using kb commenting if ( $approve == 1 && $kb_config['use_comments'] && $kb_is_auth['auth_comment']) { - $kb_comment = array(); - - // Populate the kb_comment variable - $kb_comment = kb_get_data($row, $userdata, $kb_post_mode); - - // Compose post header - $subject = $lang['KB_comment_prefix'] . $kb_comment['article_title']; - $message_temp = kb_compose_comment( $kb_comment ); - - $kb_message = $message_temp['message']; - $kb_update_message = $message_temp['update_message']; - // Post $topic_data = kb_insert_post( $kb_message, $subject, $kb_comment['category_forum_id'], $kb_comment['article_editor_id'], $kb_comment['article_editor'], $kb_comment['article_editor_sig'], $kb_comment['topic_id'], $kb_update_message ); --- 240,258 ---- } ! $kb_comment = array(); ! ! // Populate the kb_comment variable ! $kb_comment = kb_get_data($row, $userdata, $kb_post_mode); + // Compose post header + $subject = $lang['KB_comment_prefix'] . $kb_comment['article_title']; + $message_temp = kb_compose_comment( $kb_comment ); + + $kb_message = $message_temp['message']; + $kb_update_message = $message_temp['update_message']; + // Insert phpBB post if using kb commenting if ( $approve == 1 && $kb_config['use_comments'] && $kb_is_auth['auth_comment']) { // Post $topic_data = kb_insert_post( $kb_message, $subject, $kb_comment['category_forum_id'], $kb_comment['article_editor_id'], $kb_comment['article_editor'], $kb_comment['article_editor_sig'], $kb_comment['topic_id'], $kb_update_message ); *************** *** 272,275 **** --- 267,274 ---- } + $kb_message_tmp = $kb_message . '\n\n' . $kb_update_message; + + kb_notify( $kb_config['notify'], $kb_message_tmp, $kb_config['admin_id'], $kb_comment['article_author_id'] ); + $kb_custom_field->file_update_data( $article_id ); Index: functions_kb.php =================================================================== RCS file: /cvsroot/mxbb/kb_076_mxaddon/root/includes/functions_kb.php,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** functions_kb.php 28 Mar 2005 20:54:53 -0000 1.2 --- functions_kb.php 29 Mar 2005 20:06:57 -0000 1.3 *************** *** 403,528 **** // email admin ! function email_kb_admin( $action ) { ! global $lang, $emailer, $board_config, $kb_config, $db, $module_root_path, $phpbb_root_path, $mx_root_path, $phpEx, $is_block, $page_id, $images; ! if ( $action == 2 ) { ! $email_body = $lang['Email_body']; ! include( $phpbb_root_path . 'includes/emailer.' . $phpEx ); ! $emailer = new emailer( $board_config['smtp_delivery'] ); ! $email_headers = 'From: ' . $board_config['board_email'] . "\nReturn-Path: " . $board_config['board_email'] . "\n"; ! $emailer->email_address( $board_config['board_email'] ); ! $emailer->set_subject( $lang['New_article'] ); ! $emailer->extra_headers( $email_headers ); ! $emailer->msg = $email_body; - $emailer->send(); - $emailer->reset(); } ! else if ( $action == 1 ) { ! $sql = "UPDATE " . USERS_TABLE . " ! SET user_new_privmsg = '1', user_last_privmsg = '9999999999' ! WHERE user_id = " . $kb_config['admin_id']; ! ! if ( !( $result = $db->sql_query( $sql ) ) ) ! { ! mx_message_die( GENERAL_ERROR, 'Could not update users table', '', __LINE__, __FILE__, $sql ); ! } ! // added by snake for extended PM ! $approve_pm_view = "<table width=" . "100%" . " border=" . "1" . " cellspacing=" . "0" . " cellpadding=" . "0" . "><tr><td>" . $lang['Category'] . "</td><td>" . $lang['Art_action'] . "</td></tr>"; ! ! $sql = "SELECT * FROM " . KB_ARTICLES_TABLE . " WHERE approved = '2' ORDER BY article_id DESC LIMIT 1"; ! if ( !( $article_result = $db->sql_query( $sql ) ) ) ! { ! message_die( GENERAL_ERROR, "Could not obtain article data", '', __LINE__, __FILE__, $sql ); ! } ! ! while ( $article = $db->sql_fetchrow( $article_result ) ) ! { ! $approved_yesno = $article['approved']; ! $article_description = $article['article_description']; ! $article_cat = $article['article_category_id']; ! $bbcode_uid = $article['bbcode_uid']; // to enadbe bbcode from article html seems to wolr by default even whwn off ! $articlebody = "[quote:$bbcode_uid]" . $article['article_body'] . "<br>[/quote:$bbcode_uid]"; // include the post for approve.. ! // type ! $type_id = $article['article_type']; ! $article_type = get_kb_type( $type_id ); ! $article_date = create_date( $board_config['default_dateformat'], $article['article_date'], $board_config['board_timezone'] ); ! // author information ! $author_id = $article['article_author_id']; ! ! if ( $author_id == 0 ) ! { ! $author = ( $username != '' ) ? $lang['Guest'] : $article['username']; ! } ! else ! { ! $author_name = get_kb_author( $author_id ); ! $temp_url = append_sid( $phpbb_root_path . "profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . "=$author_id" ); ! $author = '<a href="' . $temp_url . '" class="gen">' . $author_name . '</a>'; ! } ! ! $article_id = $article['article_id']; ! $views = $article['views']; ! $article_title = $article['article_title']; ! $temp_url = append_sid( this_kb_mxurl( "mode=article&k=$article_id" ) ); ! $article = '<a href="' . $temp_url . '" class="gen">' . $article_title . '</a>'; ! ! $approve = ''; ! $delete = ''; ! $category_name = ''; ! ! $category = get_kb_cat( $article_cat ); ! $category_name = $category['category_name']; ! ! $kb_path_tmp = MXBB_MODULE ? PORTAL_URL . $module_root_path : $phpbb_root_path; ! ! if ( $approved_yesno == 2 ) ! { ! // approve ! $temp_url = append_sid( $kb_path_tmp . "admin/admin_kb_art.$phpEx?mode=approve&a=$article_id" ); ! $approve = '<a href="' . $temp_url . '"><img src="' . PORTAL_URL . $images['icon_approve'] . '" border="0" alt="' . $lang['Approve'] . '"></a>'; ! } ! else ! { ! // unapprove ! $temp_url = append_sid( $kb_path_tmp . "admin/admin_kb_art.$phpEx?mode=unapprove&a=$article_id" ); ! $unapprove = '<a href="' . $temp_url . '"><img src="' . PORTAL_URL . $images['icon_unapprove'] . '" border="0" alt="' . $lang['Un_approve'] . '"></a>'; ! } ! $temp_url = append_sid( $kb_path_tmp . "admin/admin_kb_art.$phpEx?mode=delete&a=$article_id" ); ! $delete = '<a href="' . $temp_url . '"><img src="' . $phpbb_root_path . $images['icon_delpost'] . '" border="0" alt="' . $lang['Delete'] . '"></a>'; ! $approve_pm_view .= "<tr><td>$category_name</td><td>$approve ' ' $delete ' ' $unapprove</td></tr>"; // the action table ! } ! ! $approve_pm_view .= "</table>"; // end action table ! ! $user_id = $kb_config['admin_id']; ! $new_article_subject = $lang['New_article']; ! $new_article = $lang['Email_body']; // original code ! $new_article .= $articlebody; // the extended Pm body ! $new_article .= '<p>' . $approve_pm_view; // the extended Pm body ! $new_article .= '<br><a href=' . $kb_path_tmp . 'admin/admin_kb_art.' . $phpEx . '>KB Admin page</a><br>'; // the extended Pm body ! $new_article = addslashes( $new_article ); ! ! $privmsgs_date = date( "U" ); ! // End Snake Extend PM Mod ! $sql = "INSERT INTO " . PRIVMSGS_TABLE . " (privmsgs_type, privmsgs_subject, privmsgs_from_userid, privmsgs_to_userid, privmsgs_date, privmsgs_enable_html, privmsgs_enable_bbcode, privmsgs_enable_smilies, privmsgs_attach_sig) VALUES ('5', '" . $new_article_subject . "', '" . $user_id . "', '" . $user_id . "', '" . $privmsgs_date . "', '0', '1', '1', '0')"; ! if ( !$db->sql_query( $sql ) ) ! { ! mx_message_die( GENERAL_ERROR, 'Could not insert private message sent info', '', __LINE__, __FILE__, $sql ); ! } ! $privmsg_sent_id = $db->sql_nextid(); ! $privmsgs_text = $lang['register_pm_subject']; ! ! $sql = "INSERT INTO " . PRIVMSGS_TEXT_TABLE . " (privmsgs_text_id, privmsgs_bbcode_uid, privmsgs_text) VALUES ($privmsg_sent_id, '" . $bbcode_uid . "', '" . $new_article . "')"; // need to aply the bbcode_uid for bbcode to work ! if ( !$db->sql_query( $sql ) ) ! { ! mx_message_die( GENERAL_ERROR, 'Could not insert private message sent text', '', __LINE__, __FILE__, $sql ); ! } } - return; } --- 403,425 ---- // email admin ! function kb_notify( $action, $message, $to_id, $from_id ) { ! global $lang, $board_config, $kb_config, $db, $module_root_path, $phpbb_root_path, $mx_root_path, $phpEx; ! if ( $action == 2 ) // Mail { ! $email_subject = $lang['KB_title'] . ' - ' . $lang['KB_notify_subject']; ! $email_body = $lang['KB_notify_body'] . '\n\n\n' . $message; ! kb_mailer( $to_id, $email_body, $email_subject, $from_id ); } ! else if ( $action == 1 ) // PM { ! $email_subject = $lang['KB_title'] . ' - ' . $lang['KB_notify_subject']; ! $email_body = $lang['KB_notify_body'] . '\n\n\n' . $message; ! ! kb_insert_pm( $to_id, $email_body, $email_subject, $from_id ); } } *************** *** 706,709 **** --- 603,688 ---- } // insert_pm() + function kb_mailer( + $to_id, + $message, + $subject, + $from_id, + $html_on = 0, + $bbcode_on = 1, + $smilies_on = 1) + { + global $db, $lang, $user_ip, $board_config, $userdata, $phpbb_root_path, $phpEx; + + if ( !$from_id ) + { + $from_id = $userdata['user_id']; + } + + //get varibles ready + $to_id = intval($to_id); + $from_id = intval($from_id); + $msg_time = time(); + $attach_sig = $userdata['user_attachsig']; + + //get to users info + $sql = "SELECT user_id, user_notify_pm, user_email, user_lang, user_active + FROM " . USERS_TABLE . " + WHERE user_id = '$to_id' + AND user_id <> " . ANONYMOUS; + if ( !($result = $db->sql_query($sql)) ) + { + $error = TRUE; + $error_msg = $lang['No_such_user']; + } + + $to_userdata = $db->sql_fetchrow($result); + + $privmsg_subject = trim(strip_tags($subject)); + if ( empty($privmsg_subject) ) + { + $error = TRUE; + $error_msg .= ( ( !empty($error_msg) ) ? '<br />' : '' ) . $lang['Empty_subject']; + } + + if ( !empty($message) ) + { + if ( !$error ) + { + if ( $bbcode_on ) + { + $bbcode_uid = make_bbcode_uid(); + } + + $privmsg_message = prepare_message($message, $html_on, $bbcode_on, $smilies_on, $bbcode_uid); + $privmsg_message = str_replace('\\\n', '\n', $privmsg_message); + + } + } + else + { + $error = TRUE; + $error_msg .= ( ( !empty($error_msg) ) ? '<br />' : '' ) . $lang['Empty_message']; + } + + + $script_name = preg_replace('/^\/?(.*?)\/?$/', "\\1", trim($board_config['script_path'])); + $script_name = ( $script_name != '' ) ? $script_name . '/privmsg.'.$phpEx : 'privmsg.'.$phpEx; + $server_name = trim($board_config['server_name']); + $server_protocol = ( $board_config['cookie_secure'] ) ? 'https://' : 'http://'; + $server_port = ( $board_config['server_port'] <> 80 ) ? ':' . trim($board_config['server_port']) . '/' : '/'; + + include($phpbb_root_path . 'includes/emailer.'.$phpEx); + $emailer = new emailer($board_config['smtp_delivery']); + + $emailer->from( $board_config['board_email'] ); + $emailer->replyto( $board_config['board_email'] ); + + $emailer->email_address($to_userdata['user_email'] ); + $emailer->set_subject( $subject ); + $emailer->msg = $message; + + $emailer->send(); + $emailer->reset(); + } // get categories for index |