1 頁 (共 2 頁)

[問題] 請問回覆通知信中的回覆者名字該如何加入 ?

發表於 : 2002-04-06 02:54
monkey
如題

我的是 RC3
在收到回覆通知信時如果想知道對方 ( 回覆者 ) 的名字
該加些甚麼呢?
在那裡加?

因為我想在信中就能先知道是誰所回覆的 ....

發表於 : 2002-04-06 04:11
oO]-[Oo
Niels Chr. Denmark
Posted: Thu Jan 17, 2002 2:56 am Post subject: HACK - Replyers name in "Reply Notification" email posible

--------------------------------------------------------------------------------

I think it is usefull for the users to know by whom, the reply is made, when they recive a email notification.
Therefor I have looked into the code of "POSTING.PHP", and added this line rigth after "TOPIC_TITLE, => $topic_title," like this

"TOPIC_TITLE" => $topic_title,
"REPLY_BY"=> $userdata['username'],

this way I'm able of altering the replyers name in the email template, this has the effect that the user will additionaly get the name of the person who made the reply

this is done by altering the file "TOPIC_NOTIFY.TPL" in the langues/email dir
I have then changed the file to something like this
"...This topic has received a reply from "{REPLY_BY}" since your..."


This litel hack is fully backward compatible, so if you dicide only to apply the hack to a specific language it doesen't matter with the rest


- please fell free to comment , if you don't like it fell also free not to use it

發表於 : 2002-04-06 10:56
monkey
不行哩\r
我用這樣的
$template->assign_vars(array(
"TOPIC_TITLE" => $topic_title,
"REPLY_BY" => $userdata['username'],
"POST_SUBJECT" => $preview_subject,
"POSTER_NAME" => $preview_username,
"POST_DATE" => create_date($board_config['default_dateformat'], time(), $board_config['board_timezone']),
"MESSAGE" => $preview_message,

這個 {REPLY_BY} 也加在 topic_notify.tpl 了
還是不行
請指教

發表於 : 2002-04-06 11:57
oO]-[Oo
會出現甚麼東東?? {REPLY_BY}加個""比較妥當

發表於 : 2002-04-06 12:10
monkey
就是甚麼都沒出現\r
我也加了 "{REPLY_BY}"
結果只出現 ""

請幫幫忙
^_^

發表於 : 2002-04-06 12:13
CPY
這樣的情況可能您的 {REPLY_BY}
沒正確給予 "值" ,要好好檢查^^
前幾天在做WBB Hank的時候ㄝ遇到這情形~嘻

發表於 : 2002-04-06 12:17
CPY
看ㄌ一下,您 $userdata['username'] 有指定好ㄇ^^"
這種語法跟WBB好像@@"

PS.我玩ㄉ是WBB有錯誤的話....就不要理這兩篇文章^^"

發表於 : 2002-04-06 12:18
monkey
這個我也知\r
那請問這個 "值" 該如何定義呢 ??

謝謝

發表於 : 2002-04-06 12:25
oO]-[Oo
先在 includes/post.php 找到這陀

[php]<?php
//
// Handle user notification on new post
//
function user_notification($mode, &$post_data, &$forum_id, &$topic_id, &$post_id, &$notify_user)
{
global $HTTP_SERVER_VARS, $HTTP_ENV_VARS;
global $board_config, $lang, $db, $phpbb_root_path, $phpEx;
global $userdata, $user_ip;

$current_time = time();

if ( $mode == "delete" )
{
$delete_sql = ( !$post_data['first_post'] && !$post_data['last_post'] ) ? " AND user_id = " . $userdata['user_id'] : "";
$sql = "DELETE FROM " . TOPICS_WATCH_TABLE . " WHERE topic_id = $topic_id" . $delete_sql;
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, "Couldn't change topic notify data", "", __LINE__, __FILE__, $sql);
}
}
else
{
if ( $mode == "reply" )
{
$sql = "SELECT ban_userid
FROM " . BANLIST_TABLE;
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, "", "", __LINE__, __FILE__, $sql);
}

$user_id_sql = "";
while ( $row = $db->sql_fetchrow($result) )
{
if ( isset($row['ban_userid']) )
{
$user_id_sql = ", " . $row['ban_userid'];
}
}

$sql = "SELECT u.user_id, u.username, u.user_email, u.user_lang, t.topic_title
FROM " . TOPICS_WATCH_TABLE . " tw, " . TOPICS_TABLE . " t, " . USERS_TABLE . " u
WHERE tw.topic_id = $topic_id
AND tw.user_id NOT IN (" . $userdata['user_id'] . ", " . ANONYMOUS . $user_id_sql . " )
AND tw.notify_status = " . TOPIC_WATCH_UN_NOTIFIED . "
AND t.topic_id = tw.topic_id
AND u.user_id = tw.user_id";
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, "", "", __LINE__, __FILE__, $sql);
}

$orig_word = array();
$replacement_word = array();
obtain_word_list($orig_word, $replacement_word);

include($phpbb_root_path . 'includes/emailer.'.$phpEx);
$emailer = new emailer($board_config['smtp_delivery']);

$script_name = preg_replace("/^\/?(.*?)\/?$/", "\\\1", trim($board_config['script_path']));
$script_name = ( $script_name != '' ) ? $script_name . '/viewtopic.'.$phpEx : 'viewtopic.'.$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']) . '/' : '/';

$email_headers = "From: " . $board_config['board_email'] . "
Return-Path: " . $board_config['board_email'] . "
";

$update_watched_sql = "";
if ( $row = $db->sql_fetchrow($result) )
{
$topic_title = preg_replace($orig_word, $replacement_word, unprepare_message($row['topic_title']));

do
{
if ( $row['user_email'] != "" )
{
$emailer->use_template("topic_notify", $row['user_lang']);
$emailer->email_address($row['user_email']);
$emailer->set_subject($lang['Topic_reply_notification']);
$emailer->extra_headers($email_headers);

$emailer->assign_vars(array(
"EMAIL_SIG" => str_replace("<br />", "
", "--
" . $board_config['board_email_sig']),
"USERNAME" => $row['username'],
"SITENAME" => $board_config['sitename'],
"TOPIC_TITLE" => $topic_title,

"U_TOPIC" => $server_protocol . $server_name . $server_port . $script_name . "?" . POST_POST_URL . "=$post_id#$post_id",
"U_STOP_WATCHING_TOPIC" => $server_protocol . $server_name . $server_port . $script_name . "?" . POST_TOPIC_URL . "=$topic_id&unwatch=topic")
);

$emailer->send();
$emailer->reset();

$update_watched_sql .= ( $update_watched_sql != "" ) ? ", " . $row['user_id'] : $row['user_id'];
}
}
while ( $row = $db->sql_fetchrow($result) );
}

if ( $update_watched_sql != "" )
{
$sql = "UPDATE " . TOPICS_WATCH_TABLE . "
SET notify_status = " . TOPIC_WATCH_NOTIFIED . "
WHERE topic_id = $topic_id
AND user_id IN ($update_watched_sql)";
$db->sql_query($sql);
}
}

$sql = "SELECT topic_id
FROM " . TOPICS_WATCH_TABLE . "
WHERE topic_id = $topic_id
AND user_id = " . $userdata['user_id'];
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, "Couldn't obtain topic watch information", "", __LINE__, __FILE__, $sql);
}

$row = $db->sql_fetchrow($result);

if ( !$notify_user && !empty($row['topic_id']) )
{
$sql = "DELETE FROM " . TOPICS_WATCH_TABLE . "
WHERE topic_id = $topic_id
AND user_id = " . $userdata['user_id'];
if ( !$result = $db->sql_query($sql) )
{
message_die(GENERAL_ERROR, "Couldn't delete topic watch information", "", __LINE__, __FILE__, $sql);
}
}
else if ( $notify_user && empty($row['topic_id']) )
{
$sql = "INSERT INTO " . TOPICS_WATCH_TABLE . " (user_id, topic_id, notify_status)
VALUES (" . $userdata['user_id'] . ", $topic_id, 0)";
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, "Couldn't insert topic watch information", "", __LINE__, __FILE__, $sql);
}
}
}
}
?>[/php]

改成

[php]<?php

//
// Handle user notification on new post
//
function user_notification($mode, &$post_data, &$forum_id, &$topic_id, &$post_id, &$notify_user, $replyby='')
{
global $HTTP_SERVER_VARS, $HTTP_ENV_VARS;
global $board_config, $lang, $db, $phpbb_root_path, $phpEx;
global $userdata, $user_ip;

$current_time = time();

if ( $mode == "delete" )
{
\n $delete_sql = ( !$post_data['first_post'] && !$post_data['last_post'] ) ? " AND user_id = " . $userdata['user_id'] : "";
$sql = "DELETE FROM " . TOPICS_WATCH_TABLE . " WHERE topic_id = $topic_id" . $delete_sql;
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, "Couldn't change topic notify data", "", __LINE__, __FILE__, $sql);
}
}
else
{
if ( $mode == "reply" )
{
$sql = "SELECT ban_userid
FROM " . BANLIST_TABLE;
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, "", "", __LINE__, __FILE__, $sql);
}

$user_id_sql = "";
while ( $row = $db->sql_fetchrow($result) )
{
if ( isset($row['ban_userid']) )
{
$user_id_sql = ", " . $row['ban_userid'];
}
}

$sql = "SELECT u.user_id, u.username, u.user_email, u.user_lang, t.topic_title
FROM " . TOPICS_WATCH_TABLE . " tw, " . TOPICS_TABLE . " t, " . USERS_TABLE . " u
WHERE tw.topic_id = $topic_id
AND tw.user_id NOT IN (" . $userdata['user_id'] . ", " . ANONYMOUS . $user_id_sql . " )
AND tw.notify_status = " . TOPIC_WATCH_UN_NOTIFIED . "
AND t.topic_id = tw.topic_id
AND u.user_id = tw.user_id";
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, "", "", __LINE__, __FILE__, $sql);
}

$orig_word = array();
$replacement_word = array();
obtain_word_list($orig_word, $replacement_word);

include($phpbb_root_path . 'includes/emailer.'.$phpEx);
$emailer = new emailer($board_config['smtp_delivery']);

$script_name = preg_replace("/^\/?(.*?)\/?$/", "\\\1", trim($board_config['script_path']));
$script_name = ( $script_name != '' ) ? $script_name . '/viewtopic.'.$phpEx : 'viewtopic.'.$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']) . '/' : '/';

$email_headers = "From: " . $board_config['board_email'] . "
Return-Path: " . $board_config['board_email'] . "
";

$update_watched_sql = "";
if ( $row = $db->sql_fetchrow($result) )
{
$topic_title = preg_replace($orig_word, $replacement_word, unprepare_message($row['topic_title']));

do
{
if ( $row['user_email'] != "" )
{
$emailer->use_template("topic_notify", $row['user_lang']);
$emailer->email_address($row['user_email']);
$emailer->set_subject($lang['Topic_reply_notification']);
$emailer->extra_headers($email_headers);

$emailer->assign_vars(array(
"EMAIL_SIG" => str_replace("<br />", "
", "--
" . $board_config['board_email_sig']),
"USERNAME" => $row['username'],\r
"SITENAME" => $board_config['sitename'],
"TOPIC_TITLE" => $topic_title,
"REPLY_BY" => $replyby,

"U_TOPIC" => $server_protocol . $server_name . $server_port . $script_name . "?" . POST_POST_URL . "=$post_id#$post_id",
"U_STOP_WATCHING_TOPIC" => $server_protocol . $server_name . $server_port . $script_name . "?" . POST_TOPIC_URL . "=$topic_id&unwatch=topic")
);

$emailer->send();
$emailer->reset();

$update_watched_sql .= ( $update_watched_sql != "" ) ? ", " . $row['user_id'] : $row['user_id'];
}
}
while ( $row = $db->sql_fetchrow($result) );
}

if ( $update_watched_sql != "" )
{
$sql = "UPDATE " . TOPICS_WATCH_TABLE . "
SET notify_status = " . TOPIC_WATCH_NOTIFIED . "
WHERE topic_id = $topic_id
AND user_id IN ($update_watched_sql)";
$db->sql_query($sql);
}
}

$sql = "SELECT topic_id
FROM " . TOPICS_WATCH_TABLE . "
WHERE topic_id = $topic_id
AND user_id = " . $userdata['user_id'];
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, "Couldn't obtain topic watch information", "", __LINE__, __FILE__, $sql);
}

$row = $db->sql_fetchrow($result);

if ( !$notify_user && !empty($row['topic_id']) )
{
$sql = "DELETE FROM " . TOPICS_WATCH_TABLE . "
WHERE topic_id = $topic_id
AND user_id = " . $userdata['user_id'];
if ( !$result = $db->sql_query($sql) )
{
message_die(GENERAL_ERROR, "Couldn't delete topic watch information", "", __LINE__, __FILE__, $sql);
}
}
else if ( $notify_user && empty($row['topic_id']) )
{
$sql = "INSERT INTO " . TOPICS_WATCH_TABLE . " (user_id, topic_id, notify_status)
VALUES (" . $userdata['user_id'] . ", $topic_id, 0)";
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, "Couldn't insert topic watch information", "", __LINE__, __FILE__, $sql);
}
}
}
}
?>[/php]

然後在 posting.php 找\r

[php]<?php
user_notification($mode, $post_data, $forum_id, $topic_id, $post_id, $notify_user);
?>[/php]

改成

[php]<?php
user_notification($mode, $post_data, $forum_id, $topic_id, $post_id, $notify_user, $userdata['username']);
?>[/php]

試試看, RC3可以用, 原理是一樣的

發表於 : 2002-04-06 12:32
CPY
挖賽...南宮博速的功力....
越看越精湛~~
何時才有這樣的功力阿@@"

發表於 : 2002-04-06 12:41
monkey
post.php 出 error
無法執行
請縮小範圍指出變更後的重點
謝謝

發表於 : 2002-04-06 13:28
oO]-[Oo
function user_notification($mode, &$post_data, &$forum_id, &$topic_id, &$post_id, &$notify_user)
>>
function user_notification($mode, &$post_data, &$forum_id, &$topic_id, &$post_id, &$notify_user, $replyby='')

"TOPIC_TITLE" => $topic_title,
"REPLY_BY" => $replyby,

發表於 : 2002-04-06 14:16
monkey
OOHOO 寫:function user_notification($mode, &$post_data, &$forum_id, &$topic_id, &$post_id, &$notify_user)
>>
function user_notification($mode, &$post_data, &$forum_id, &$topic_id, &$post_id, &$notify_user, $replyby='')

"TOPIC_TITLE" => $topic_title,
"REPLY_BY" => $replyby,
Yeah, OK.
終於搞定
謝謝南宮搏士的細心指點
感激不盡\r
:-D

發表於 : 2002-05-04 04:31
monkey
我又遇到麻煩了

我終於 upgrade to 2.0.0 FINAL
但這個方法好像不行

請問我該如何再改??

煩請幫忙
謝謝

發表於 : 2002-05-06 18:15
monkey
anybody know ??