diff options
author | victor <victor@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2003-11-22 19:37:52 +0800 |
---|---|---|
committer | victor <victor@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2003-11-22 19:37:52 +0800 |
commit | 73633286ba5abef91660b5e731117e7293e83529 (patch) | |
tree | e09b49efe317c671608c6de58b6647c18ad1255a | |
parent | 9a6d820518d2db326a0342f6d09c8433cae5cd27 (diff) | |
download | pttbbs-73633286ba5abef91660b5e731117e7293e83529.tar pttbbs-73633286ba5abef91660b5e731117e7293e83529.tar.gz pttbbs-73633286ba5abef91660b5e731117e7293e83529.tar.bz2 pttbbs-73633286ba5abef91660b5e731117e7293e83529.tar.lz pttbbs-73633286ba5abef91660b5e731117e7293e83529.tar.xz pttbbs-73633286ba5abef91660b5e731117e7293e83529.tar.zst pttbbs-73633286ba5abef91660b5e731117e7293e83529.zip |
fix 't' for admin, add docs/fav4.txt
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@1364 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r-- | docs/fav.txt | 41 | ||||
-rw-r--r-- | include/proto.h | 3 | ||||
-rw-r--r-- | mbbsd/board.c | 9 | ||||
-rw-r--r-- | mbbsd/fav.c | 31 |
4 files changed, 80 insertions, 4 deletions
diff --git a/docs/fav.txt b/docs/fav.txt new file mode 100644 index 00000000..32a616cc --- /dev/null +++ b/docs/fav.txt @@ -0,0 +1,41 @@ +Favorite ver.4 + +Feature +======= +•重寫、整個架構改變 +•folding + +Structure +========= + fav4 的主要架構如下: + +•fav_t + 進入我的最愛時,看到的東西就是根據 fav_t 生出來的。 + 裡面紀錄者,這一個 level 中有多少個看板、目錄、分隔線。(favh) + +•fav_type_t + 這算是架在以下三個東西之上的介面,等於是將他們視為同一種東西,方便之後的存取。 + 用一個 void * 指標指向某塊記憶體,存取時可透過 type 變數來得知正確的型態。 + +•fav_board_t + 紀錄了 bid 及上次拜訪時間。 + +•fav_line_t + 紀錄了 lid + +•fav_folder_t + 紀錄了 fid 及可自訂的名稱。 + +•fav.c 中以 cast_(board|line|folder)_t() 來將一個 fav_type_t 轉為正確的型態。 + +Policy +====== +•為了避免過度的資料搬移,當將一個 item 從我的最愛中移除時,只將他的 FAVH_FAV + flag 移除。而沒有這個 flag 的 item 也不被視為我的最愛。 + +•我的最愛中,沒設 FAVH_FAV 的資料,將在某些時候,如寫入檔案時,呼叫 + rebuild_fav 清除乾淨。 + +•站長搬移看板所用的 t ,因為不能只存在 nbrd 裡面,又不然再弄出額外的空間, + 所以當站長不在我的最愛按了 t ,會把這個記錄暫存在 fav 中(FAVH_ADM_TAG == 1, + FAVH_FAV == 0)。 diff --git a/include/proto.h b/include/proto.h index fa7ffd06..f551df57 100644 --- a/include/proto.h +++ b/include/proto.h @@ -223,6 +223,7 @@ void fav_sort_by_class(void); int fav_load(void); int fav_save(void); void fav_remove_item(short id, char type); +fav_type_t *getadmtag(short bid); fav_type_t *getboard(short bid); fav_type_t *getfolder(short fid); char getbrdattr(short bid); @@ -235,7 +236,7 @@ void fav_move(int from, int to); fav_type_t *fav_add_line(void); fav_type_t *fav_add_folder(void); fav_type_t *fav_add_board(int bid); -void fav_remove_all_tagged_item(void); +fav_type_t *fav_add_admtag(int bid); void fav_remove_all_tagged_item(void); void fav_add_all_tagged_item(void); void fav_remove_all_tag(void); diff --git a/mbbsd/board.c b/mbbsd/board.c index 148f5d1d..c6ed5d7d 100644 --- a/mbbsd/board.c +++ b/mbbsd/board.c @@ -560,6 +560,8 @@ load_boards(char *key) if (is_set_attr(&fav->favh[i], FAVH_TAG)) state |= BRD_TAG; + if (is_set_attr(&fav->favh[i], FAVH_ADM_TAG)) + state |= BRD_TAG; addnewbrdstat(fav_getid(&fav->favh[i]) - 1, BRD_FAV | state); } if (brdnum == 0) @@ -1006,9 +1008,10 @@ choose_board(int newflag) } else if (yank_flag != 0) { /* 站長管理用的 tag */ - fav_type_t *ft = fav_add_board(ptr->bid); - set_attr(ft, FAVH_FAV, 0); // turn off FAVH_FAV - set_attr(ft, FAVH_ADM_TAG, 1); // turn on FAVH_ADM_TAG + if (ptr->myattr & BRD_TAG) + set_attr(getadmtag(ptr->bid), FAVH_ADM_TAG, 0); + else + fav_add_admtag(ptr->bid); } ptr->myattr ^= BRD_TAG; head = 9999; diff --git a/mbbsd/fav.c b/mbbsd/fav.c index 08b837a6..ca3fc5b4 100644 --- a/mbbsd/fav.c +++ b/mbbsd/fav.c @@ -528,6 +528,19 @@ void fav_remove_item(short id, char type) fav_remove(get_current_fav(), get_fav_item(id, type)); } +fav_type_t *getadmtag(short bid) +{ + int i; + fav_t *fp = get_fav_root(); + fav_type_t *ft; + for (i = 0; i < fp->DataTail; i++) { + ft = &fp->favh[i]; + if (cast_board(ft)->bid == bid && is_set_attr(ft, FAVH_ADM_TAG)) + return ft; + } + return NULL; +} + fav_type_t *getboard(short bid) { return get_fav_item(bid, FAVT_BOARD); @@ -705,6 +718,24 @@ fav_type_t *fav_add_board(int bid) cast_board(ft)->bid = bid; return ft; } + +/* for administrator to move/administrate board */ +fav_type_t *fav_add_admtag(int bid) +{ + fav_t *fp = get_fav_root(); + fav_type_t *ft; + if (is_maxsize()) + return NULL; + ft = fav_item_allocate(FAVT_BOARD); + if (ft == NULL) + return NULL; + // turn on FAVH_ADM_TAG + set_attr(ft, FAVH_ADM_TAG, 1); + fav_add(fp, ft); + cast_board(ft)->bid = bid; + return ft; +} + /* --- */ /* everything about the tag in fav mode. |