summaryrefslogtreecommitdiffstats
path: root/mbbsd
diff options
context:
space:
mode:
authorvictor <victor@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2004-03-12 17:39:16 +0800
committervictor <victor@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2004-03-12 17:39:16 +0800
commitf10d92d96581666a7ac2898168f0cc6f7558f32c (patch)
treeb0d98f8554c5113bc244dc7ced2ba5f7627809f7 /mbbsd
parent786d63f533b3cd2ff6cda0ef1797fdace352561c (diff)
downloadpttbbs-f10d92d96581666a7ac2898168f0cc6f7558f32c.tar
pttbbs-f10d92d96581666a7ac2898168f0cc6f7558f32c.tar.gz
pttbbs-f10d92d96581666a7ac2898168f0cc6f7558f32c.tar.bz2
pttbbs-f10d92d96581666a7ac2898168f0cc6f7558f32c.tar.lz
pttbbs-f10d92d96581666a7ac2898168f0cc6f7558f32c.tar.xz
pttbbs-f10d92d96581666a7ac2898168f0cc6f7558f32c.tar.zst
pttbbs-f10d92d96581666a7ac2898168f0cc6f7558f32c.zip
merge from victor.symbolic branch
symbolic link to board rename something might cause misunderstanding git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@1589 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'mbbsd')
-rw-r--r--mbbsd/admin.c97
-rw-r--r--mbbsd/bbs.c6
-rw-r--r--mbbsd/board.c282
-rw-r--r--mbbsd/cache.c4
-rw-r--r--mbbsd/fav.c6
-rw-r--r--mbbsd/name.c2
6 files changed, 251 insertions, 146 deletions
diff --git a/mbbsd/admin.c b/mbbsd/admin.c
index 1b10e8e1..0dfb74dc 100644
--- a/mbbsd/admin.c
+++ b/mbbsd/admin.c
@@ -338,6 +338,12 @@ m_mod_board(char *bname)
getdata_str(9, 0, msg_sure_ny, genbuf, 3, LCECHO, "N");
if (genbuf[0] != 'y' || !bname[0])
outs(MSG_DEL_CANCEL);
+ else if (bh.brdattr & BRD_SYMBOLIC) {
+ memset(&bh, 0, sizeof(bh));
+ substitute_record(fn_board, &bh, sizeof(bh), bid);
+ reset_board(bid);
+ log_usies("DelLink", bh.brdname);
+ }
else {
strlcpy(bname, bh.brdname, sizeof(bh.brdname));
snprintf(genbuf, sizeof(genbuf),
@@ -592,12 +598,25 @@ x_file()
return FULLUPDATE;
}
+static int add_board_record(boardheader_t *board)
+{
+ int bid;
+ if ((bid = getbnum("")) > 0) {
+ substitute_record(fn_board, board, sizeof(boardheader_t), bid);
+ reset_board(bid);
+ } else if (append_record(fn_board, (fileheader_t *)board, sizeof(boardheader_t)) == -1) {
+ return -1;
+ } else {
+ addbrd_touchcache();
+ }
+ return 0;
+}
+
int
m_newbrd(int recover)
{
boardheader_t newboard;
char ans[4];
- int bid;
char genbuf[200];
stand_title("建立新板");
@@ -622,8 +641,7 @@ m_newbrd(int recover)
break;
} while (1);
- if (strlen(genbuf) >= 4)
- strncpy(newboard.title, genbuf, 4);
+ strncpy(newboard.title, genbuf, 4);
newboard.title[4] = ' ';
@@ -633,9 +651,7 @@ m_newbrd(int recover)
setbpath(genbuf, newboard.brdname);
if (recover) {
- struct stat sb;
-
- if (stat(genbuf, &sb) == -1 || !(sb.st_mode & S_IFDIR)) {
+ if (dashd(genbuf)) {
outs("此看板已經存在! 請取不同英文板名");
pressanykey();
return -1;
@@ -684,16 +700,9 @@ m_newbrd(int recover)
clear();
}
}
- if ((bid = getbnum("")) > 0) {
- substitute_record(fn_board, &newboard, sizeof(newboard), bid);
- reset_board(bid);
- } else if (append_record(fn_board, (fileheader_t *) & newboard,
- sizeof(newboard)) == -1) {
- pressanykey();
- return -1;
- } else {
- addbrd_touchcache();
- }
+
+ add_board_record(&newboard);
+ pressanykey();
setup_man(&newboard);
outs("\n新板成立");
@@ -703,6 +712,62 @@ m_newbrd(int recover)
return 0;
}
+int make_symbolic_link(char *bname, int gid)
+{
+ boardheader_t newboard;
+ int bid;
+
+ bid = getbnum(bname);
+ memset(&newboard, 0, sizeof(newboard));
+
+ /*
+ * known issue:
+ * These two stuff will be used for sorting. But duplicated brdnames
+ * may cause wrong binary-search result. So I replace the last
+ * letters of brdname to '~'(ascii code 126) in order to correct the
+ * resuilt, thought I think it's a dirty solution.
+ *
+ * Duplicate entry with same brdname may cause wrong result, if
+ * searching by key brdname. But people don't need to know a board
+ * is symbolic, so just let SYSOP know it. You may want to read
+ * board.c:load_boards().
+ */
+
+ strlcpy(newboard.brdname, bname, sizeof(newboard.brdname));
+ newboard.brdname[strlen(bname) - 1] = '~';
+ strlcpy(newboard.title, bcache[bid - 1].title, sizeof(newboard.title));
+ strcpy(newboard.title + 5, "@看板連結");
+
+ newboard.gid = gid;
+ BRD_LINK_TARGET(&newboard) = bid;
+ newboard.brdattr = BRD_NOTRAN | BRD_SYMBOLIC;
+
+ if (add_board_record(&newboard) < 0)
+ return -1;
+ return bid;
+}
+
+int make_symbolic_link_interactively(int gid)
+{
+ char buf[32];
+
+ generalnamecomplete(msg_bid, buf, sizeof(buf), SHM->Bnumber,
+ completeboard_compar,
+ completeboard_permission,
+ completeboard_getname);
+ if (!buf[0])
+ return -1;
+
+ stand_title("建立看板連結");
+
+ if (make_symbolic_link(buf, gid) < 0) {
+ vmsg("看板連結建立失敗");
+ return -1;
+ }
+ log_usies("NewSymbolic", buf);
+ return 0;
+}
+
static int
auto_scan(char fdata[][STRLEN], char ans[])
{
diff --git a/mbbsd/bbs.c b/mbbsd/bbs.c
index f24e503a..934d375a 100644
--- a/mbbsd/bbs.c
+++ b/mbbsd/bbs.c
@@ -113,7 +113,7 @@ set_board()
boardheader_t *bp;
bp = getbcache(currbid);
- if( !Ben_Perm(bp) ){
+ if( !HasPerm(bp) ){
vmsg("access control violation, exit");
u_exit("access control violation!");
exit(-1);
@@ -123,7 +123,7 @@ set_board()
strcpy(currBM, "徵求中");
else
snprintf(currBM, sizeof(currBM), "板主:%s", bp->BM);
- currmode = (currmode & (MODE_DIRTY | MODE_MENU)) | MODE_STARTED;
+ currmode = (currmode & (MODE_DIRTY | MODE_GROUPOP)) | MODE_STARTED;
if (HAS_PERM(PERM_ALLBOARD) || is_BM_cache(currbid))
currmode = currmode | MODE_BOARD | MODE_POST;
@@ -308,7 +308,7 @@ do_select(int ent, fileheader_t * fhdr, char *direct)
if (bname[0] == '\0' || !(i = getbnum(bname)))
return FULLUPDATE;
bh = getbcache(i);
- if (!Ben_Perm(bh))
+ if (!HasPerm(bh))
return FULLUPDATE;
strlcpy(bname, bh->brdname, sizeof(bname));
currbid = i;
diff --git a/mbbsd/board.c b/mbbsd/board.c
index 3a47b0ed..57a5519b 100644
--- a/mbbsd/board.c
+++ b/mbbsd/board.c
@@ -270,13 +270,19 @@ brc_unread(const char *fname, int bnum, const int *blist)
return 0;
}
-#define BRD_NULL 0
-#define BRD_FAV 1
-#define BRD_BOARD 2
-#define BRD_LINE 4
-#define BRD_FOLDER 8
-#define BRD_TAG 16
-#define BRD_UNREAD 32
+/* personal board state
+ * 相對於看板的 attr (BRD_* in ../include/pttstruct.h),
+ * 這些是用在 user interface 的 flag */
+#define NBRD_FAV 1
+#define NBRD_BOARD 2
+#define NBRD_LINE 4
+#define NBRD_FOLDER 8
+#define NBRD_TAG 16
+#define NBRD_UNREAD 32
+#define NBRD_SYMBOLIC 64
+
+#define TITLE_MATCH(bptr, key) ((key)[0] && !strcasestr((bptr)->title, (key)))
+#define GROUPOP() (currmode & MODE_GROUPOP)
#define B_TOTAL(bptr) (SHM->total[(bptr)->bid - 1])
@@ -292,6 +298,11 @@ static char choose_board_depth = 0;
static short brdnum;
static char yank_flag = 1;
+inline int getbid(boardheader_t *fh)
+{
+ return (fh - bcache);
+}
+
void imovefav(int old)
{
char buf[5];
@@ -308,16 +319,16 @@ void imovefav(int old)
void load_brdbuf(void)
{
- static char firsttime = 1;
-
char buf[128];
setuserfile(buf, FAV4);
if( !dashf(buf) ) {
fav_v3_to_v4();
}
fav_load();
- updatenewfav(1);
- firsttime = 0;
+
+ /* subscribe new fav (deprecated) */
+ if (fav_stack_num <= 0)
+ updatenewfav(1);
}
void
@@ -335,7 +346,7 @@ save_brdbuf(void)
}
int
-Ben_Perm(boardheader_t * bptr)
+HasPerm(boardheader_t * bptr)
{
register int level, brdattr;
@@ -393,7 +404,7 @@ check_newpost(boardstat_t * ptr)
int tbrc_list[BRC_MAXNUM], tbrc_num;
time_t ftime;
- ptr->myattr &= ~BRD_UNREAD;
+ ptr->myattr &= ~NBRD_UNREAD;
if (B_BH(ptr)->brdattr & BRD_GROUPBOARD)
return 0;
@@ -407,7 +418,7 @@ check_newpost(boardstat_t * ptr)
if ( brc_read_record(B_BH(ptr)->brdname, &tbrc_num, tbrc_list) == 0 ||
brc_unread_time(ftime, tbrc_num, tbrc_list) )
- ptr->myattr |= BRD_UNREAD;
+ ptr->myattr |= NBRD_UNREAD;
return 1;
}
@@ -452,10 +463,10 @@ addnewbrdstat(int n, int state)
ptr->bid = n + 1;
ptr->myattr = state;
- if ((B_BH(ptr)->brdattr & BRD_HIDE) && state == BRD_BOARD)
+ if ((B_BH(ptr)->brdattr & BRD_HIDE) && state == NBRD_BOARD)
B_BH(ptr)->brdattr |= BRD_POSTMASK;
if (yank_flag != 0)
- ptr->myattr &= ~BRD_FAV;
+ ptr->myattr &= ~NBRD_FAV;
check_newpost(ptr);
return ptr;
}
@@ -498,17 +509,14 @@ load_boards(char *key)
if ( !key[0] ){
if (get_item_type(&fav->favh[i]) == FAVT_LINE )
- state = BRD_LINE;
+ state = NBRD_LINE;
else if (get_item_type(&fav->favh[i]) == FAVT_FOLDER )
- state = BRD_FOLDER;
+ state = NBRD_FOLDER;
else {
bptr = &bcache[ fav_getid(&fav->favh[i]) - 1];
- if( yank_flag == 0 )
- state = BRD_BOARD;
- else
- continue;
+ state = NBRD_BOARD;
if (is_set_attr(&fav->favh[i], FAVH_UNREAD))
- state |= BRD_UNREAD;
+ state |= NBRD_UNREAD;
}
} else {
if (get_item_type(&fav->favh[i]) == FAVT_LINE )
@@ -518,25 +526,25 @@ load_boards(char *key)
get_folder_title(fav_getid(&fav->favh[i])),
key)
)
- state = BRD_FOLDER;
+ state = NBRD_FOLDER;
else
continue;
}else{
bptr = &bcache[ fav_getid(&fav->favh[i]) - 1];
- if( Ben_Perm(bptr) && strcasestr(bptr->title, key))
- state = BRD_BOARD;
+ if( HasPerm(bptr) && strcasestr(bptr->title, key))
+ state = NBRD_BOARD;
else
continue;
if (is_set_attr(&fav->favh[i], FAVH_UNREAD))
- state |= BRD_UNREAD;
+ state |= NBRD_UNREAD;
}
}
if (is_set_attr(&fav->favh[i], FAVH_TAG))
- state |= BRD_TAG;
+ state |= NBRD_TAG;
if (is_set_attr(&fav->favh[i], FAVH_ADM_TAG))
- state |= BRD_TAG;
- addnewbrdstat(fav_getid(&fav->favh[i]) - 1, BRD_FAV | state);
+ state |= NBRD_TAG;
+ addnewbrdstat(fav_getid(&fav->favh[i]) - 1, NBRD_FAV | state);
}
if (brdnum == 0)
addnewbrdstat(0, 0);
@@ -556,11 +564,11 @@ load_boards(char *key)
for (i = 0; i < numboards; i++) {
if ((bptr = SHM->bsorted[type][i]) == NULL)
continue;
- n = (int)(bptr - bcache);
+ n = getbid(bptr);
if (!bptr->brdname[0] ||
- (bptr->brdattr & BRD_GROUPBOARD) ||
- !((state = Ben_Perm(bptr)) || (currmode & MODE_MENU)) ||
- (key[0] && !strcasestr(bptr->title, key))
+ (bptr->brdattr & (BRD_GROUPBOARD | BRD_SYMBOLIC)) ||
+ !((state = Ben_Perm(bptr)) || GROUPOP()) ||
+ TITLE_MATCH(bptr, key)
#ifndef HOTBOARDCACHE
|| (class_bid == -1 && bptr->nuser < 5)
#endif
@@ -584,11 +592,19 @@ load_boards(char *key)
nbrd = (boardstat_t *) malloc(childcount * sizeof(boardstat_t));
for (bptr = bptr->firstchild[type]; bptr != NULL;
bptr = bptr->next[type]) {
- n = (int)(bptr - bcache);
- if (!((state = Ben_Perm(bptr)) || (currmode & MODE_MENU))
- || (yank_flag == 0 && !(getbrdattr(n) & BRD_FAV)) ||
- (key[0] && !strcasestr(bptr->title, key)))
+ n = getbid(bptr);
+ state = HasPerm(bptr);
+ if ( !(state || GROUPOP()) || TITLE_MATCH(bptr, key) )
continue;
+
+ if (bptr->brdattr & BRD_SYMBOLIC) {
+
+ /* Only SYSOP knows a board is symbolic */
+ if (HAS_PERM(PERM_SYSOP))
+ state |= NBRD_SYMBOLIC;
+ else
+ n = BRD_LINK_TARGET(bptr) - 1;
+ }
addnewbrdstat(n, state);
}
byMALLOC = 0;
@@ -619,7 +635,7 @@ search_board()
CreateNameList();
for (num = 0; num < brdnum; num++)
if (yank_flag != 0 ||
- (nbrd[num].myattr & BRD_BOARD && Ben_Perm(B_BH(&nbrd[num]))) )
+ (nbrd[num].myattr & NBRD_BOARD && HasPerm(B_BH(&nbrd[num]))) )
AddNameList(B_BH(&nbrd[num])->brdname);
namecomplete(MSG_SELECT_BOARD, genbuf);
FreeNameList();
@@ -640,7 +656,7 @@ unread_position(char *dirfile, boardstat_t * ptr)
total = B_TOTAL(ptr);
num = total + 1;
- if ((ptr->myattr & BRD_UNREAD) && (fd = open(dirfile, O_RDWR)) > 0) {
+ if ((ptr->myattr & NBRD_UNREAD) && (fd = open(dirfile, O_RDWR)) > 0) {
if (!brc_initial(B_BH(ptr)->brdname)) {
num = 1;
} else {
@@ -675,11 +691,11 @@ unread_position(char *dirfile, boardstat_t * ptr)
static char
get_fav_type(boardstat_t *ptr)
{
- if (ptr->myattr & BRD_FOLDER)
+ if (ptr->myattr & NBRD_FOLDER)
return FAVT_FOLDER;
- else if (ptr->myattr & BRD_BOARD)
+ else if (ptr->myattr & NBRD_BOARD)
return FAVT_BOARD;
- else if (ptr->myattr & BRD_LINE)
+ else if (ptr->myattr & NBRD_LINE)
return FAVT_LINE;
return 0;
}
@@ -744,22 +760,22 @@ show_brdlist(int head, int clsflag, int newflag)
clrtoeol();
if (head < brdnum) {
ptr = &nbrd[head++];
- if (ptr->myattr & BRD_LINE){
+ if (ptr->myattr & NBRD_LINE){
if( !newflag )
prints("%5d %c %s------------ ------------------------------------------\033[m",
head,
- ptr->myattr & BRD_TAG ? 'D' : ' ',
- ptr->myattr & BRD_FAV ? "" : "\033[1;30m");
+ ptr->myattr & NBRD_TAG ? 'D' : ' ',
+ ptr->myattr & NBRD_FAV ? "" : "\033[1;30m");
else
- prints(" %s------------ ------------------------------------------\033[m", ptr->myattr & BRD_FAV ? "" : "\033[1;30m");
+ prints(" %s------------ ------------------------------------------\033[m", ptr->myattr & NBRD_FAV ? "" : "\033[1;30m");
continue;
}
- else if (ptr->myattr & BRD_FOLDER){
+ else if (ptr->myattr & NBRD_FOLDER){
char *title = get_folder_title(ptr->bid);
if( !newflag )
prints("%5d %c %sMyFavFolder\033[m 目錄 □%-34s\033[m",
head,
- ptr->myattr & BRD_TAG ? 'D' : ' ',
+ ptr->myattr & NBRD_TAG ? 'D' : ' ',
!(cuser.uflag2 & FAVNOHILIGHT) ? "\033[1;36m" : "",
title);
else
@@ -776,18 +792,18 @@ show_brdlist(int head, int clsflag, int newflag)
prints("%5d%c%s", head,
!(B_BH(ptr)->brdattr & BRD_HIDE) ? ' ' :
(B_BH(ptr)->brdattr & BRD_POSTMASK) ? ')' : '-',
- (ptr->myattr & BRD_TAG) ? "D " :
+ (ptr->myattr & NBRD_TAG) ? "D " :
(B_BH(ptr)->brdattr & BRD_GROUPBOARD) ? " " :
- unread[ptr->myattr & BRD_UNREAD ? 1 : 0]);
+ unread[ptr->myattr & NBRD_UNREAD ? 1 : 0]);
} else {
if (B_BH(ptr)->brdattr & BRD_GROUPBOARD)
prints(" ");
else
prints("%6d%s", (int)(B_TOTAL(ptr)),
- unread[ptr->myattr & BRD_UNREAD ? 1 : 0]);
+ unread[ptr->myattr & NBRD_UNREAD ? 1 : 0]);
}
if (class_bid != 1) {
- if (!(currmode & MODE_MENU) && !Ben_Perm(B_BH(ptr))) {
+ if (!GROUPOP() && !HasPerm(B_BH(ptr))) {
prints("Unknown?? 隱板 ?這個板是隱板");
}
else {
@@ -860,11 +876,16 @@ static void
set_menu_BM(char *BM)
{
if (HAS_PERM(PERM_ALLBOARD) || is_BM(BM)) {
- currmode |= MODE_MENU;
+ currmode |= MODE_GROUPOP;
cuser.userlevel |= PERM_SYSSUBOP;
}
}
+static void replace_link_by_target(boardstat_t *board)
+{
+ board->bid = BRD_LINK_TARGET(&bcache[board->bid - 1]);
+ board->myattr &= ~NBRD_SYMBOLIC;
+}
static void
choose_board(int newflag)
@@ -872,7 +893,7 @@ choose_board(int newflag)
static short num = 0;
boardstat_t *ptr;
int head = -1, ch = 0, currmodetmp, tmp, tmp1, bidtmp;
- char keyword[13] = "";
+ char keyword[13] = "", buf[64];
setutmpmode(newflag ? READNEW : READBRD);
if( get_current_fav() == NULL )
@@ -899,7 +920,7 @@ choose_board(int newflag)
yank_flag++;
continue;
}
- if (HAS_PERM(PERM_SYSOP) || (currmode & MODE_MENU)) {
+ if (HAS_PERM(PERM_SYSOP) || GROUPOP()) {
if (m_newbrd(0) == -1)
break;
brdnum = -1;
@@ -921,7 +942,7 @@ choose_board(int newflag)
tmp = num;
while (num < brdnum) {
ptr = &nbrd[num];
- if (ptr->myattr & BRD_UNREAD)
+ if (ptr->myattr & NBRD_UNREAD)
break;
num++;
}
@@ -996,12 +1017,12 @@ choose_board(int newflag)
}
else if (yank_flag != 0) {
/* 站長管理用的 tag */
- if (ptr->myattr & BRD_TAG)
+ if (ptr->myattr & NBRD_TAG)
set_attr(getadmtag(ptr->bid), FAVH_ADM_TAG, 0);
else
fav_add_admtag(ptr->bid);
}
- ptr->myattr ^= BRD_TAG;
+ ptr->myattr ^= NBRD_TAG;
head = 9999;
case KEY_DOWN:
case 'n':
@@ -1044,16 +1065,13 @@ choose_board(int newflag)
break;
case 'S':
if(yank_flag == 0){
- char input[4];
move(b_lines - 2, 0);
prints("重新排序看板 "
"\033[1;33m(注意, 這個動作會覆寫原來設定)\033[m \n");
- getdata(b_lines - 1, 0,
- "排序方式 (1)按照板名排序 (2)按照類別排序 ==> [0]取消 ",
- input, sizeof(input), DOECHO);
- if( input[0] == '1' )
+ tmp = getans("排序方式 (1)按照板名排序 (2)按照類別排序 ==> [0]取消 ");
+ if( tmp == '1' )
fav_sort_by_name();
- else if( input[0] == '2' )
+ else if( tmp == '2' )
fav_sort_by_class();
}
else
@@ -1062,24 +1080,30 @@ choose_board(int newflag)
break;
case 'y':
if (get_current_fav() != NULL || yank_flag != 0)
- yank_flag = (yank_flag + 1) % 2;
+ yank_flag = (yank_flag + 1) % 2;
brdnum = -1;
break;
case Ctrl('D'):
- fav_remove_all_tagged_item();
- brdnum = -1;
+ if (HAS_PERM(PERM_LOGINOK)) {
+ fav_remove_all_tagged_item();
+ brdnum = -1;
+ }
break;
case Ctrl('A'):
- fav_add_all_tagged_item();
- brdnum = -1;
+ if (HAS_PERM(PERM_LOGINOK)) {
+ fav_add_all_tagged_item();
+ brdnum = -1;
+ }
break;
case Ctrl('T'):
- fav_remove_all_tag();
- brdnum = -1;
+ if (HAS_PERM(PERM_LOGINOK)) {
+ fav_remove_all_tag();
+ brdnum = -1;
+ }
break;
case Ctrl('P'):
if (class_bid != 0 &&
- (HAS_PERM(PERM_SYSOP) || (currmode & MODE_MENU))) {
+ (HAS_PERM(PERM_SYSOP) || GROUPOP())) {
fav_t *fav = get_current_fav();
for (tmp = 0; tmp < fav->DataTail; tmp++) {
short bid = fav_getid(&fav->favh[tmp]);
@@ -1099,7 +1123,13 @@ choose_board(int newflag)
}
break;
case 'L':
- if (HAS_PERM(PERM_BASIC)) {
+ if (HAS_PERM(PERM_SYSOP) && class_bid > 0) {
+ if (make_symbolic_link_interactively(class_bid) < 0)
+ break;
+ brdnum = -1;
+ head = 9999;
+ }
+ else if (HAS_PERM(PERM_LOGINOK) && yank_flag == 0) {
if (fav_add_line() == NULL) {
vmsg("新增失敗,分隔線/總最愛 數量達最大值。");
break;
@@ -1111,27 +1141,35 @@ choose_board(int newflag)
head = 9999;
}
break;
+/*
+ case 'l':
+ if (HAS_PERM(PERM_SYSOP) && (nbrd[num].myattr & NBRD_SYMBOLIC)) {
+ replace_link_by_target(&nbrd[num]);
+ head = 9999;
+ }
+ break;
+*/
case 'm':
- if (HAS_PERM(PERM_BASIC)) {
+ if (HAS_PERM(PERM_LOGINOK)) {
ptr = &nbrd[num];
if (yank_flag == 0) {
- if (ptr->myattr & BRD_FAV) {
+ if (ptr->myattr & NBRD_FAV) {
if (getans("你確定刪除嗎? [N/y]") != 'y')
break;
fav_remove_item(ptr->bid, get_fav_type(ptr));
- ptr->myattr &= ~BRD_FAV;
+ ptr->myattr &= ~NBRD_FAV;
}
}
else {
if (getboard(ptr->bid) != NULL) {
fav_remove_item(ptr->bid, FAVT_BOARD);
- ptr->myattr &= ~BRD_FAV;
+ ptr->myattr &= ~NBRD_FAV;
}
else {
if (fav_add_board(ptr->bid) == NULL)
vmsg("你的最愛太多了啦 真花心");
else
- ptr->myattr |= BRD_FAV;
+ ptr->myattr |= NBRD_FAV;
}
}
brdnum = -1;
@@ -1139,7 +1177,7 @@ choose_board(int newflag)
}
break;
case 'M':
- if (HAS_PERM(PERM_BASIC)){
+ if (HAS_PERM(PERM_LOGINOK)){
if (class_bid == 0 && yank_flag == 0){
imovefav(num);
brdnum = -1;
@@ -1148,7 +1186,7 @@ choose_board(int newflag)
}
break;
case 'g':
- if (HAS_PERM(PERM_BASIC) && yank_flag == 0) {
+ if (HAS_PERM(PERM_LOGINOK) && yank_flag == 0) {
fav_type_t *ft;
if (fav_stack_full()){
vmsg("目錄已達最大層數!!");
@@ -1167,18 +1205,17 @@ choose_board(int newflag)
}
break;
case 'T':
- if (HAS_PERM(PERM_BASIC) && nbrd[num].myattr & BRD_FOLDER) {
- char title[64];
+ if (HAS_PERM(PERM_LOGINOK) && nbrd[num].myattr & NBRD_FOLDER) {
fav_type_t *ft = getfolder(nbrd[num].bid);
- strlcpy(title, get_item_title(ft), sizeof(title));
- getdata_buf(b_lines - 1, 0, "請輸入檔名:", title, sizeof(title), DOECHO);
- fav_set_folder_title(ft, title);
+ strlcpy(buf, get_item_title(ft), sizeof(buf));
+ getdata_buf(b_lines - 1, 0, "請輸入板名:", buf, 65, DOECHO);
+ fav_set_folder_title(ft, buf);
brdnum = -1;
}
break;
case 'K':
- if (HAS_PERM(PERM_BASIC)) {
- char c, fname[80], genbuf[256];
+ if (HAS_PERM(PERM_LOGINOK)) {
+ char c, fname[80];
if (!current_fav_at_root()) {
vmsg("請到我的最愛最上層執行本功\能");
break;
@@ -1196,17 +1233,17 @@ choose_board(int newflag)
case '2':
fav_save();
setuserfile(fname, FAV4);
- sprintf(genbuf, "%s.bak", fname);
- Copy(fname, genbuf);
+ sprintf(buf, "%s.bak", fname);
+ Copy(fname, buf);
break;
case '3':
setuserfile(fname, FAV4);
- sprintf(genbuf, "%s.bak", fname);
- if (!dashf(genbuf)){
+ sprintf(buf, "%s.bak", fname);
+ if (!dashf(buf)){
vmsg("你沒有備份你的最愛喔");
break;
}
- Copy(genbuf, fname);
+ Copy(buf, fname);
fav_free();
load_brdbuf();
break;
@@ -1215,7 +1252,7 @@ choose_board(int newflag)
}
break;
case 'z':
- if (HAS_PERM(PERM_BASIC))
+ if (HAS_PERM(PERM_LOGINOK))
vmsg("嘿嘿 這個功\能已經被我的最愛取代掉了喔!");
break;
#ifdef DEBUG
@@ -1228,7 +1265,7 @@ choose_board(int newflag)
break;
#endif
case 'Z':
- if (HAS_PERM(PERM_BASIC)) {
+ if (HAS_PERM(PERM_LOGINOK)) {
char genbuf[256];
sprintf(genbuf, "確定要 %s訂閱\ 新看板? [N/y] ", cuser.uflag2 & FAVNEW_FLAG ? "取消" : "");
if (getans(genbuf) != 'y')
@@ -1243,19 +1280,20 @@ choose_board(int newflag)
vmsg("取消訂閱\新看板");
}
break;
+
case 'v':
case 'V':
ptr = &nbrd[num];
- if(nbrd[num].bid < 0 || !Ben_Perm(B_BH(ptr)))
+ if(nbrd[num].bid < 0 || !HasPerm(B_BH(ptr)))
break;
if (ch == 'v') {
- ptr->myattr &= ~BRD_UNREAD;
+ ptr->myattr &= ~NBRD_UNREAD;
brc_trunc(B_BH(ptr)->brdname, now);
setbrdtime(ptr->bid, now);
} else {
brc_trunc(B_BH(ptr)->brdname, 1);
setbrdtime(ptr->bid, 1);
- ptr->myattr |= BRD_UNREAD;
+ ptr->myattr |= NBRD_UNREAD;
}
show_brdlist(head, 0, newflag);
break;
@@ -1267,7 +1305,7 @@ choose_board(int newflag)
num = tmp;
break;
case 'E':
- if (HAS_PERM(PERM_SYSOP) || (currmode & MODE_MENU)) {
+ if (HAS_PERM(PERM_SYSOP) || GROUPOP()) {
ptr = &nbrd[num];
move(1, 1);
clrtobot();
@@ -1276,21 +1314,20 @@ choose_board(int newflag)
}
break;
case 'R':
- if (HAS_PERM(PERM_SYSOP) || (currmode & MODE_MENU)) {
+ if (HAS_PERM(PERM_SYSOP) || GROUPOP()) {
m_newbrd(1);
brdnum = -1;
}
break;
case 'B':
- if (HAS_PERM(PERM_SYSOP) || (currmode & MODE_MENU)) {
+ if (HAS_PERM(PERM_SYSOP) || GROUPOP()) {
m_newbrd(0);
brdnum = -1;
}
break;
case 'W':
if (class_bid > 0 &&
- (HAS_PERM(PERM_SYSOP) || (currmode & MODE_MENU))) {
- char buf[128];
+ (HAS_PERM(PERM_SYSOP) || GROUPOP())) {
setbpath(buf, bcache[class_bid - 1].brdname);
mkdir(buf, 0755); /* Ptt:開群組目錄 */
b_note_edit_bname(class_bid);
@@ -1309,27 +1346,30 @@ choose_board(int newflag)
case '\r':
case 'r':
{
- char buf[STRLEN];
-
ptr = &nbrd[num];
- if (yank_flag == 0 && get_fav_type(&nbrd[0]) == 0)
- break;
- else if (ptr->myattr & BRD_LINE)
- break;
- else if (ptr->myattr & BRD_FOLDER){
- int t = num;
- num = 0;
- fav_folder_in(ptr->bid);
- choose_board(0);
- fav_folder_out();
- num = t;
- brdnum = -1;
- head = 9999;
- break;
+ if (yank_flag == 0) {
+ if (get_fav_type(&nbrd[0]) == 0)
+ break;
+ else if (ptr->myattr & NBRD_LINE)
+ break;
+ else if (ptr->myattr & NBRD_FOLDER){
+ int t = num;
+ num = 0;
+ fav_folder_in(ptr->bid);
+ choose_board(0);
+ fav_folder_out();
+ num = t;
+ brdnum = -1;
+ head = 9999;
+ break;
+ }
+ }
+ else if (ptr->myattr & NBRD_SYMBOLIC) {
+ replace_link_by_target(ptr);
}
if (!(B_BH(ptr)->brdattr & BRD_GROUPBOARD)) { /* 非sub class */
- if (Ben_Perm(B_BH(ptr))) {
+ if (HasPerm(B_BH(ptr))) {
brc_initial(B_BH(ptr)->brdname);
if (newflag) {
@@ -1355,7 +1395,7 @@ choose_board(int newflag)
else
class_bid = -1; /* 熱門群組用 */
- if (!(currmode & MODE_MENU)) /* 如果還沒有小組長權限 */
+ if (!GROUPOP()) /* 如果還沒有小組長權限 */
set_menu_BM(B_BH(ptr)->BM);
if (now < B_BH(ptr)->bupdate) {
diff --git a/mbbsd/cache.c b/mbbsd/cache.c
index cacdb1d7..ff409191 100644
--- a/mbbsd/cache.c
+++ b/mbbsd/cache.c
@@ -667,7 +667,7 @@ reset_board(int bid) /* XXXbid: from 1 */
}
}
-#ifndef _BBS_UTIL_C_ /* because of Ben_Perm() in board.c */
+#ifndef _BBS_UTIL_C_ /* because of HasPerm() in board.c */
int
apply_boards(int (*func) (boardheader_t *))
{
@@ -675,7 +675,7 @@ apply_boards(int (*func) (boardheader_t *))
register boardheader_t *bhdr;
for (i = 0, bhdr = bcache; i < numboards; i++, bhdr++) {
- if (!(bhdr->brdattr & BRD_GROUPBOARD) && Ben_Perm(bhdr) &&
+ if (!(bhdr->brdattr & BRD_GROUPBOARD) && HasPerm(bhdr) &&
(*func) (bhdr) == QUIT)
return QUIT;
}
diff --git a/mbbsd/fav.c b/mbbsd/fav.c
index c06a9628..4cf1da34 100644
--- a/mbbsd/fav.c
+++ b/mbbsd/fav.c
@@ -242,7 +242,7 @@ static void rebuild_fav(fav_t *fp, int clean_invisible)
bp = &bcache[cast_board(ft)->bid - 1];
if (!bp->brdname[0])
continue;
- if ( clean_invisible && !Ben_Perm(bp))
+ if ( clean_invisible && !HasPerm(bp))
continue;
break;
case FAVT_LINE:
@@ -896,7 +896,7 @@ void updatenewfav(int mode)
for(i = 0; i < numboards + 1 && brd[i] != BRD_END; i++){
if(brd[i] == BRD_NEW){
- if(bcache[i].brdname[0] && Ben_Perm(&bcache[i])){ // check the permission if the board exsits
+ if(bcache[i].brdname[0] && HasPerm(&bcache[i])){ // check the permission if the board exsits
if(mode)
fav_add_board(i + 1);
brd[i] = BRD_OLD;
@@ -909,7 +909,7 @@ void updatenewfav(int mode)
}
if( i < numboards) // the board number may change
for(i-- ; i < numboards; i++){
- if(bcache[i].brdname[0] && Ben_Perm(&bcache[i])){
+ if(bcache[i].brdname[0] && HasPerm(&bcache[i])){
if(mode)
fav_add_board(i + 1);
brd[i] = BRD_OLD;
diff --git a/mbbsd/name.c b/mbbsd/name.c
index 0b58604e..9d467352 100644
--- a/mbbsd/name.c
+++ b/mbbsd/name.c
@@ -674,7 +674,7 @@ completeboard_compar(int where, char *str, int len)
int
completeboard_permission(int where)
{
- return (((currmode & MODE_MENU) || Ben_Perm(SHM->bsorted[0][where])) &&
+ return ((GROUPOP() || HasPerm(SHM->bsorted[0][where])) &&
!(SHM->bsorted[0][where]->brdattr & BRD_GROUPBOARD));
}