summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpiaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2010-10-18 19:19:46 +0800
committerpiaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2010-10-18 19:19:46 +0800
commita53b1ebe358b98aa6bb0549a52f3ae6d731cb7c4 (patch)
tree2bd4f2fd6455f5b89f4f21f621a3eaba4fa22230
parentbb64aee2154f2e6bbf59555560716457d37c7535 (diff)
downloadpttbbs-a53b1ebe358b98aa6bb0549a52f3ae6d731cb7c4.tar
pttbbs-a53b1ebe358b98aa6bb0549a52f3ae6d731cb7c4.tar.gz
pttbbs-a53b1ebe358b98aa6bb0549a52f3ae6d731cb7c4.tar.bz2
pttbbs-a53b1ebe358b98aa6bb0549a52f3ae6d731cb7c4.tar.lz
pttbbs-a53b1ebe358b98aa6bb0549a52f3ae6d731cb7c4.tar.xz
pttbbs-a53b1ebe358b98aa6bb0549a52f3ae6d731cb7c4.tar.zst
pttbbs-a53b1ebe358b98aa6bb0549a52f3ae6d731cb7c4.zip
add limitation for self-deleting posts
git-svn-id: http://opensvn.csie.org/pttbbs/trunk@5123 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r--pttbbs/include/common.h1
-rw-r--r--pttbbs/include/pttstruct.h1
-rw-r--r--pttbbs/mbbsd/bbs.c7
-rw-r--r--pttbbs/mbbsd/board.c16
-rw-r--r--pttbbs/mbbsd/edit.c19
5 files changed, 43 insertions, 1 deletions
diff --git a/pttbbs/include/common.h b/pttbbs/include/common.h
index e2bb2112..e3ba731d 100644
--- a/pttbbs/include/common.h
+++ b/pttbbs/include/common.h
@@ -225,6 +225,7 @@
#define EDITFLAG_KIND_NEWPOST (0x00000010)
#define EDITFLAG_KIND_REPLYPOST (0x00000020)
#define EDITFLAG_KIND_SENDMAIL (0x00000040)
+#define EDITFLAG_WARN_NOSELFDEL (0x00000100)
#define EDIT_ABORTED -1
/* ----------------------------------------------------- */
diff --git a/pttbbs/include/pttstruct.h b/pttbbs/include/pttstruct.h
index 9a4d4cf6..3e8d7310 100644
--- a/pttbbs/include/pttstruct.h
+++ b/pttbbs/include/pttstruct.h
@@ -235,6 +235,7 @@ typedef struct boardheader_t { /* 256 bytes */
#define BRD_OVER18 0x01000000 /* 十八禁 */
#define BRD_NOREPLY 0x02000000 /* 不可回文 */
#define BRD_ALIGNEDCMT 0x04000000 /* 對齊式的推文 */
+#define BRD_NOSELFDELPOST 0x08000000 /* 不可自刪 */
#define BRD_LINK_TARGET(x) ((x)->postexpire)
#define GROUPOP() (currmode & MODE_GROUPOP)
diff --git a/pttbbs/mbbsd/bbs.c b/pttbbs/mbbsd/bbs.c
index 96875984..e2c94a42 100644
--- a/pttbbs/mbbsd/bbs.c
+++ b/pttbbs/mbbsd/bbs.c
@@ -1098,6 +1098,8 @@ do_general(int garbage)
edflags = EDITFLAG_ALLOWTITLE;
edflags = solveEdFlagByBoard(currboard, edflags);
+ if (bp->brdattr & BRD_NOSELFDELPOST)
+ edflags |= EDITFLAG_WARN_NOSELFDEL;
#if defined(PLAY_ANGEL) && defined(BN_ANGELPRAY)
// XXX 惡搞的 code。
@@ -3098,6 +3100,11 @@ del_post(int ent, fileheader_t * fhdr, char *direct)
)
return DONOTHING;
+ if ((bp->brdattr & BRD_NOSELFDELPOST) && !(currmode & MODE_BOARD)) {
+ vmsg("抱歉,本看板目前禁止自刪文章。");
+ return DONOTHING;
+ }
+
if (fhdr->filename[0]=='L') fhdr->filename[0]='M';
#ifdef SAFE_ARTICLE_DELETE
diff --git a/pttbbs/mbbsd/board.c b/pttbbs/mbbsd/board.c
index 3dabe07d..1499ab32 100644
--- a/pttbbs/mbbsd/board.c
+++ b/pttbbs/mbbsd/board.c
@@ -353,6 +353,13 @@ b_config(void)
ANSI_COLOR(1)"不開放" : "開放"
);
+ prints( " " ANSI_COLOR(1;36) "d" ANSI_RESET
+ " - %s" ANSI_RESET
+ " 自刪文章\n",
+ (bp->brdattr & BRD_NOSELFDELPOST) ?
+ ANSI_COLOR(1)"開放" : "不開放"
+ );
+
prints( " " ANSI_COLOR(1;36) "r" ANSI_RESET
" - %s " ANSI_RESET "推薦文章\n",
(bp->brdattr & BRD_NORECOMMEND) ?
@@ -768,6 +775,15 @@ b_config(void)
touched = 1;
break;
+ case 'd':
+ if (0) { //!(HasUserPerm(PERM_SYSOP) || (HasUserPerm(PERM_SYSSUPERSUBOP) && GROUPOP()) ) ) {
+ vmsg("此項設定需要群組長或站長權限");
+ break;
+ }
+ bp->brdattr ^= BRD_NOSELFDELPOST;
+ touched = 1;
+ break;
+
default:
finished = 1;
break;
diff --git a/pttbbs/mbbsd/edit.c b/pttbbs/mbbsd/edit.c
index 75844c3e..ac91137f 100644
--- a/pttbbs/mbbsd/edit.c
+++ b/pttbbs/mbbsd/edit.c
@@ -481,6 +481,18 @@ get_edit_kind_prompt(int flags)
return NULL;
}
+static const char *
+get_edit_warn_prompt(int flags) {
+ int no_self_sel = (flags & EDITFLAG_WARN_NOSELFDEL);
+
+ // FIXME not always on boards, maybe
+ if (no_self_sel)
+ return ANSI_COLOR(0;1;31)
+ "注意: 此看板禁止自刪文章,發出後將只有板主以上才能刪文!!!" ANSI_RESET;
+
+ return NULL;
+}
+
//#define SLOW_CHECK_DETAIL
static void
edit_buffer_check_healthy(textline_t *line)
@@ -1834,7 +1846,8 @@ static void upload_file(void);
// 0 if write ok & exit
static int
write_file(const char *fpath, int saveheader, int *islocal, char mytitle[STRLEN],
- int upload, int chtitle, const char *kind_prompt, int *pentropy)
+ int upload, int chtitle, const char *kind_prompt, const char *warn_prompt,
+ int *pentropy)
{
FILE *fp = NULL;
textline_t *p;
@@ -1869,8 +1882,11 @@ write_file(const char *fpath, int saveheader, int *islocal, char mytitle[STRLEN]
outs(" (A)放棄 (E)繼續 (R/W/D)讀寫刪暫存檔");
+ // TODO FIXME what if prompt is multiline?
if (kind_prompt)
mvouts(4, 0, kind_prompt);
+ if (warn_prompt)
+ mvouts(6, 0, warn_prompt);
getdata(2, 0, "確定要儲存檔案嗎? ", ans, 2, LCECHO);
// avoid lots pots
@@ -3669,6 +3685,7 @@ vedit2(const char *fpath, int saveheader, int *islocal, char title[STRLEN], int
(flags & EDITFLAG_UPLOAD) ? 1 : 0,
(flags & EDITFLAG_ALLOWTITLE) ? 1 : 0,
get_edit_kind_prompt(flags),
+ get_edit_warn_prompt(flags),
&entropy);
if (tmp != KEEP_EDITING) {
currutmp->mode = mode0;