summaryrefslogtreecommitdiffstats
path: root/mbbsd
diff options
context:
space:
mode:
authorpiaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2008-04-01 16:48:47 +0800
committerpiaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2008-04-01 16:48:47 +0800
commit59f8d6883f61d07fb32f6cd189f30fcdc1322bb7 (patch)
tree8a126b1f909f3044aabb1789efb2a80904538808 /mbbsd
parentb7bc8f550f372e3a00b82889b49dd9a25d0160cd (diff)
downloadpttbbs-59f8d6883f61d07fb32f6cd189f30fcdc1322bb7.tar
pttbbs-59f8d6883f61d07fb32f6cd189f30fcdc1322bb7.tar.gz
pttbbs-59f8d6883f61d07fb32f6cd189f30fcdc1322bb7.tar.bz2
pttbbs-59f8d6883f61d07fb32f6cd189f30fcdc1322bb7.tar.lz
pttbbs-59f8d6883f61d07fb32f6cd189f30fcdc1322bb7.tar.xz
pttbbs-59f8d6883f61d07fb32f6cd189f30fcdc1322bb7.tar.zst
pttbbs-59f8d6883f61d07fb32f6cd189f30fcdc1322bb7.zip
- logging regform validation results to specific board (BN_ID_RECORD)
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@4058 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'mbbsd')
-rw-r--r--mbbsd/register.c59
-rw-r--r--mbbsd/syspost.c20
2 files changed, 64 insertions, 15 deletions
diff --git a/mbbsd/register.c b/mbbsd/register.c
index 50213851..781bc74e 100644
--- a/mbbsd/register.c
+++ b/mbbsd/register.c
@@ -1373,6 +1373,36 @@ append_regform(const RegformEntry *pre, const char *logfn,
return 1;
}
+// prototype declare
+static void regform_print_reasons(const char *reason, FILE *fp);
+
+void
+regform_log2board(const RegformEntry *pre, char accept, const char *reason)
+{
+#ifdef BN_ID_RECORD
+ char fn[PATHLEN];
+ char title[STRLEN];
+ FILE *fp = NULL;
+
+ snprintf(title, sizeof(title),
+ "[審核結果] %s: %s (審核者: %s)",
+ accept ? "通過":"退回", pre->userid, cuser.userid);
+
+ if (post_msg_fpath(BN_ID_RECORD, title, title, "[註冊系統]", fn) < 0 ||
+ ((fp = fopen(fn, "at")) == NULL))
+ return;
+
+ fprintf(fp, "\n");
+
+ if (!accept) // print out reject reasons
+ regform_print_reasons(reason, fp);
+
+ fprintf(fp, "\n");
+ print_regform_entry_localized(pre, fp, 1);
+ fclose(fp);
+#endif // BN_ID_RECORD
+}
+
int regform_estimate_queuesize()
{
#ifdef USE_REGFORM2
@@ -1441,8 +1471,6 @@ regform_accept(const char *userid, const char *justify)
mail_muser(muser, "[註冊成功\囉]", "etc/registered");
}
-int print_regform_entry_localized(const RegformEntry *pre, FILE *fp, int close);
-
void
regform_reject(const char *userid, const char *reason, const RegformEntry *pre)
{
@@ -1478,14 +1506,7 @@ regform_reject(const char *userid, const char *reason, const RegformEntry *pre)
fprintf(fp, "%s 註冊失敗。\n", Cdate(&now));
// multiple abbrev loop
- if (REASON_IN_ABBREV(reason[0]))
- {
- int i = 0;
- for (i = 0; i < REASON_LEN && REASON_IN_ABBREV(reason[i]); i++)
- fprintf(fp, "[退回原因] 請%s\n", REASON_EXPANDABBREV(reason[i]));
- } else {
- fprintf(fp, "[退回原因] %s\n", reason);
- }
+ regform_print_reasons(reason, fp);
fclose(fp);
mail_muser(muser, "[註冊失敗]", buf);
}
@@ -1547,6 +1568,20 @@ prompt_regform_ui()
}
static void
+regform_print_reasons(const char *reason, FILE *fp)
+{
+ // multiple abbrev loop
+ if (REASON_IN_ABBREV(reason[0]))
+ {
+ int i = 0;
+ for (i = 0; i < REASON_LEN && REASON_IN_ABBREV(reason[i]); i++)
+ fprintf(fp, "[退回原因] 請%s\n", REASON_EXPANDABBREV(reason[i]));
+ } else {
+ fprintf(fp, "[退回原因] %s\n", reason);
+ }
+}
+
+static void
resolve_reason(char *s, int y)
{
// should start with REASON_FIRSTABBREV
@@ -1724,6 +1759,7 @@ regfrm_accept(RegformEntry *pre)
cuser.userid, pre->userid, Cdate(&now));
file_append_line(FN_REGISTER_LOG, buf);
AppendTail(fn, FN_REGISTER_LOG, 0);
+ regform_log2board(pre, 1, NULL);
// remove from queue
unlink(fn);
@@ -1753,6 +1789,7 @@ regfrm_reject(RegformEntry *pre, const char *reason)
cuser.userid, pre->userid, reason, Cdate(&now));
file_append_line(FN_REGISTER_LOG, buf);
AppendTail(fn, FN_REGISTER_LOG, 0);
+ regform_log2board(pre, 0, reason);
// remove from queue
unlink(fn);
@@ -3042,6 +3079,7 @@ handle_register_form(const char *regfile, int dryrun)
// log form to FN_REGISTER_LOG
append_regform(&forms[i], FN_REGISTER_LOG,
"Approved", cuser.userid, NULL);
+ regform_log2board(&forms[i], 1, NULL);
}
else if (ans[i] == 'n')
{
@@ -3049,6 +3087,7 @@ handle_register_form(const char *regfile, int dryrun)
// log form to FN_REGISTER_LOG
append_regform(&forms[i], FN_REGISTER_LOG,
"Rejected", cuser.userid, rejects[i]);
+ regform_log2board(&forms[i], 0, rejects[i]);
}
else if (ans[i] == 's')
{
diff --git a/mbbsd/syspost.c b/mbbsd/syspost.c
index 6654d5ba..b4d56c73 100644
--- a/mbbsd/syspost.c
+++ b/mbbsd/syspost.c
@@ -1,13 +1,16 @@
/* $Id$ */
#include "bbs.h"
-int
-post_msg(const char *bname, const char *title, const char *msg, const char *author)
+int
+post_msg_fpath(const char* bname, const char* title, const char *msg, const char* author, char *fname)
{
FILE *fp;
int bid;
fileheader_t fhdr;
- char fname[PATHLEN];
+ char dirfn[PATHLEN];
+
+ // fname should be lengthed in PATHLEN
+ assert(fname);
/* 在 bname 板發表新文章 */
setbpath(fname, bname);
@@ -27,13 +30,20 @@ post_msg(const char *bname, const char *title, const char *msg, const char *auth
/* 將檔案加入列表 */
strlcpy(fhdr.title, title, sizeof(fhdr.title));
strlcpy(fhdr.owner, author, sizeof(fhdr.owner));
- setbdir(fname, bname);
- if (append_record(fname, &fhdr, sizeof(fhdr)) != -1)
+ setbdir(dirfn, bname);
+ if (append_record(dirfn, &fhdr, sizeof(fhdr)) != -1)
if ((bid = getbnum(bname)) > 0)
setbtotal(bid);
return 0;
}
+int
+post_msg(const char* bname, const char* title, const char *msg, const char* author)
+{
+ char fname[PATHLEN];
+ return post_msg_fpath(bname, title, msg, author, fname);
+}
+
int
post_file(const char *bname, const char *title, const char *filename, const char *author)
{