diff options
author | piaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2011-02-21 00:42:10 +0800 |
---|---|---|
committer | piaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2011-02-21 00:42:10 +0800 |
commit | 24103dd4f950321797a226fac51f73ed97525a7e (patch) | |
tree | 247a4ef12691460f47129b54e3ca4e30975bdeac | |
parent | ce22ad1c7fe85a6223385414d58e807c226337f6 (diff) | |
download | pttbbs-24103dd4f950321797a226fac51f73ed97525a7e.tar pttbbs-24103dd4f950321797a226fac51f73ed97525a7e.tar.gz pttbbs-24103dd4f950321797a226fac51f73ed97525a7e.tar.bz2 pttbbs-24103dd4f950321797a226fac51f73ed97525a7e.tar.lz pttbbs-24103dd4f950321797a226fac51f73ed97525a7e.tar.xz pttbbs-24103dd4f950321797a226fac51f73ed97525a7e.tar.zst pttbbs-24103dd4f950321797a226fac51f73ed97525a7e.zip |
add "notify user when being banned by board"
git-svn-id: http://opensvn.csie.org/pttbbs/trunk@5311 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r-- | pttbbs/include/proto.h | 1 | ||||
-rw-r--r-- | pttbbs/mbbsd/acl.c | 33 | ||||
-rw-r--r-- | pttbbs/mbbsd/mail.c | 21 |
3 files changed, 52 insertions, 3 deletions
diff --git a/pttbbs/include/proto.h b/pttbbs/include/proto.h index 4555eeaa..f335c1b7 100644 --- a/pttbbs/include/proto.h +++ b/pttbbs/include/proto.h @@ -345,6 +345,7 @@ int load_mailalert(const char *userid); int sendalert(const char *userid, int alert); int sendalert_uid(int uid, int alert); int mail_muser(const userec_t muser, const char *title, const char *filename); +int mail_log2id_text(const char *id, const char *title, const char *message, const char *owner, char newmail); int mail_log2id(const char *id, const char *title, const char *srcfile, const char *owner, char newmail, char trymove); int mail_id(const char* id, const char *title, const char *filename, const char *owner); int m_read(void); diff --git a/pttbbs/mbbsd/acl.c b/pttbbs/mbbsd/acl.c index 63feddfb..56b2ce9e 100644 --- a/pttbbs/mbbsd/acl.c +++ b/pttbbs/mbbsd/acl.c @@ -138,6 +138,7 @@ int edit_banned_list_for_board(const char *board) { // TODO generalize this. int result; + int do_notify = 0; char uid[IDLEN+1], ans[3]; char history_log[PATHLEN]; char reason[STRLEN]; @@ -294,12 +295,22 @@ ANSI_COLOR(1) " - 想查看某使用者為何被水桶可用(S)或是(L)再用 / 搜尋\n" continue; } + getdata(7, 0, "要寄信通知使用者嗎? (會附上前面輸入的理由) [Y/n]: ", + ans, sizeof(ans), LCECHO); + if (ans[0] == 'n') + do_notify = 0; + else + do_notify = 1; + move(1, 0); clrtobot(); prints("\n使用者 %s 即將加入禁言名單 (期限: %s)\n" - "理由: %s\n", uid, datebuf, reason); + "理由: %s\n" + "%s" ANSI_RESET "寄信通知使用者\n", + uid, datebuf, reason, + do_notify ? ANSI_COLOR(1;32) "會" : ANSI_COLOR(1;31) "不會"); // last chance - getdata(5, 0, "確認以上資料全部正確嗎? [y/N]: ", + getdata(6, 0, "確認以上資料全部正確嗎? [y/N]: ", ans, sizeof(ans), LCECHO); if (ans[0] != 'y') { vmsg("請重新輸入"); @@ -316,6 +327,18 @@ ANSI_COLOR(1) " - 想查看某使用者為何被水桶可用(S)或是(L)再用 / 搜尋\n" ANSI_COLOR(0;31)"[系統錯誤] "ANSI_COLOR(1), cuser.userid, uid, datebuf, reason); vmsg(result ? "已將使用者加入禁言名單" : "失敗,請向站長報告"); + if (result && do_notify) { + char xtitle[STRLEN]; + char xmsg[STRLEN*5]; + + snprintf(xtitle, sizeof(xtitle), "%s 看板禁言通知(水桶)", board); + snprintf(xmsg, sizeof(xmsg), + "%s 看板已將您放入禁言(水桶)名單\n" + "原因: %s\n" + "其它資訊請洽該看板板規與公告。\n", board, reason); + mail_log2id_text(uid, xtitle, xmsg, "[系統通知]", 1); + sendalert(uid, ALERT_NEW_MAIL); + } invalid_board_permission_cache(board); break; @@ -368,8 +391,12 @@ ANSI_COLOR(1) " - 想查看某使用者為何被水桶可用(S)或是(L)再用 / 搜尋\n" { char old_log[PATHLEN]; setbfile(old_log, board, fn_water); - if (more(old_log, YEA) == -1) + if (dashf(old_log)) { + vmsg("請注意: 此份資料僅供參考,與現在實際水桶名單完全沒有關係。"); + more(old_log, YEA); + } else { vmsg("無舊水桶資料。"); + } } break; #endif diff --git a/pttbbs/mbbsd/mail.c b/pttbbs/mbbsd/mail.c index 5d98d856..e4633327 100644 --- a/pttbbs/mbbsd/mail.c +++ b/pttbbs/mbbsd/mail.c @@ -149,6 +149,27 @@ mail_muser(userec_t muser, const char *title, const char *filename) return mail_id(muser.userid, title, filename, cuser.userid); } +int +mail_log2id_text(const char *id, const char *title, const char *message, const char *owner, char newmail) +{ + fileheader_t mhdr; + char dst[PATHLEN], dirf[PATHLEN]; + + sethomepath(dst, id); + if (stampfile(dst, &mhdr) < 0) + return -1; + + strlcpy(mhdr.owner, owner, sizeof(mhdr.owner)); + strlcpy(mhdr.title, title, sizeof(mhdr.title)); + mhdr.filemode = newmail ? 0 : FILE_READ; + log_filef(dst, LOG_CREAT, message); + + sethomedir(dirf, id); + append_record(dirf, &mhdr, sizeof(mhdr)); + return 0; +} + + // TODO add header option? int mail_log2id(const char *id, const char *title, const char *src, const char *owner, char newmail, char trymove) |