/[LeafOK_CVS]/lbbs/src/section_list_display.c
ViewVC logotype

Diff of /lbbs/src/section_list_display.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.9 by sysadm, Thu May 29 09:44:01 2025 UTC Revision 1.31 by sysadm, Tue Jun 17 07:00:32 2025 UTC
# Line 14  Line 14 
14   *                                                                         *   *                                                                         *
15   ***************************************************************************/   ***************************************************************************/
16    
17    #define _POSIX_C_SOURCE 200809L
18    
19  #include "section_list_display.h"  #include "section_list_display.h"
20  #include "section_list_loader.h"  #include "section_list_loader.h"
21  #include "article_cache.h"  #include "article_cache.h"
22    #include "article_post.h"
23    #include "article_del.h"
24  #include "common.h"  #include "common.h"
25  #include "io.h"  #include "io.h"
26  #include "screen.h"  #include "screen.h"
27  #include "log.h"  #include "log.h"
28    #include "user_priv.h"
29    #include "article_view_log.h"
30  #include "str_process.h"  #include "str_process.h"
31    #include <string.h>
32  #include <time.h>  #include <time.h>
33  #include <sys/param.h>  #include <sys/param.h>
34  #define _POSIX_C_SOURCE 200809L  
35  #include <string.h>  static int section_topic_view_mode = 0;
36    static int section_topic_view_tid = -1;
37    
38  enum select_cmd_t  enum select_cmd_t
39  {  {
40          EXIT_SECTION = 0,          EXIT_SECTION = 0,
41          VIEW_ARTICLE = 1,          VIEW_ARTICLE = 1,
42          CHANGE_PAGE = 2,          CHANGE_PAGE = 2,
43          REFRESH_SCREEN = 3,          SHOW_HELP = 3,
44          CHANGE_NAME_DISPLAY = 4,          CHANGE_NAME_DISPLAY = 4,
45            POST_ARTICLE = 5,
46            EDIT_ARTICLE = 6,
47            DELETE_ARTICLE = 7,
48            FIRST_TOPIC_ARTICLE = 8,
49            LAST_TOPIC_ARTICLE = 9,
50  };  };
51    
52  static int section_list_draw_items(int page_id, ARTICLE *p_articles[], int article_count, int display_nickname)  static int section_list_draw_items(int page_id, ARTICLE *p_articles[], int article_count, int display_nickname)
# Line 46  static int section_list_draw_items(int p Line 59  static int section_list_draw_items(int p
59          int len;          int len;
60          int i;          int i;
61          char article_flag;          char article_flag;
62            int is_viewed;
63          time_t tm_now;          time_t tm_now;
64    
65          time(&tm_now);          time(&tm_now);
# Line 54  static int section_list_draw_items(int p Line 68  static int section_list_draw_items(int p
68    
69          for (i = 0; i < article_count; i++)          for (i = 0; i < article_count; i++)
70          {          {
71                  article_flag = ' ';                  if (p_articles[i]->uid == BBS_priv.uid)
72                    {
73                            is_viewed = 1;
74                    }
75                    else
76                    {
77                            is_viewed = article_view_log_is_viewed(p_articles[i]->aid, &BBS_article_view_log);
78                            if (is_viewed < 0)
79                            {
80                                    log_error("article_view_log_is_viewed(aid=%d) error\n", p_articles[i]->aid);
81                                    is_viewed = 0;
82                            }
83                    }
84    
85                    article_flag = (is_viewed ? ' ' : 'N');
86    
87                  if (p_articles[i]->excerption)                  if (p_articles[i]->excerption)
88                  {                  {
89                          article_flag = 'm';                          article_flag = (is_viewed ? 'm' : 'M');
90                  }                  }
91                  else if (p_articles[i]->lock)                  else if (p_articles[i]->lock && is_viewed)
92                  {                  {
93                          article_flag = 'x';                          article_flag = 'x';
94                  }                  }
# Line 79  static int section_list_draw_items(int p Line 107  static int section_list_draw_items(int p
107                  title_f[sizeof(title_f) - 1] = '\0';                  title_f[sizeof(title_f) - 1] = '\0';
108                  strncat(title_f, (p_articles[i]->transship ? "[转载]" : ""), sizeof(title_f) - 1 - strnlen(title_f, sizeof(title_f)));                  strncat(title_f, (p_articles[i]->transship ? "[转载]" : ""), sizeof(title_f) - 1 - strnlen(title_f, sizeof(title_f)));
109                  strncat(title_f, p_articles[i]->title, sizeof(title_f) - 1 - strnlen(title_f, sizeof(title_f)));                  strncat(title_f, p_articles[i]->title, sizeof(title_f) - 1 - strnlen(title_f, sizeof(title_f)));
110                  len = split_line(title_f, 47 - (display_nickname ? 8 : 0), &eol, &title_f_len);                  len = split_line(title_f, 47 - (display_nickname ? 8 : 0), &eol, &title_f_len, 1);
111                  if (title_f[len] != '\0')                  if (title_f[len] != '\0')
112                  {                  {
113                          title_f[len] = '\0';                          title_f[len] = '\0';
114                  }                  }
115    
116                  moveto(4 + i, 1);                  moveto(4 + i, 1);
117                  prints("  %7d %c %s%*s %s %s",                  prints("  %s%7d\033[m %c %s%*s %s %s%s\033[m",
118                               (p_articles[i]->aid == section_topic_view_tid ? "\033[1;33m" : (p_articles[i]->tid == section_topic_view_tid ? "\033[1;36m" : "")),
119                             p_articles[i]->aid,                             p_articles[i]->aid,
120                             article_flag,                             article_flag,
121                             (display_nickname ? p_articles[i]->nickname : p_articles[i]->username),                             (display_nickname ? p_articles[i]->nickname : p_articles[i]->username),
# Line 94  static int section_list_draw_items(int p Line 123  static int section_list_draw_items(int p
123                                                                   : BBS_username_max_len - (int)strnlen(p_articles[i]->username, sizeof(p_articles[i]->username))),                                                                   : BBS_username_max_len - (int)strnlen(p_articles[i]->username, sizeof(p_articles[i]->username))),
124                             "",                             "",
125                             str_time,                             str_time,
126                               (p_articles[i]->aid == section_topic_view_tid ? "\033[1;33m" : (p_articles[i]->tid == section_topic_view_tid ? "\033[1;36m" : "")),
127                             title_f);                             title_f);
128          }          }
129    
# Line 115  static int section_list_draw_screen(cons Line 145  static int section_list_draw_screen(cons
145          show_top(str_section_master, stitle, str_section_name);          show_top(str_section_master, stitle, str_section_name);
146          moveto(2, 0);          moveto(2, 0);
147          prints("返回[\033[1;32m←\033[0;37m,\033[1;32mESC\033[0;37m] 选择[\033[1;32m↑\033[0;37m,\033[1;32m↓\033[0;37m] "          prints("返回[\033[1;32m←\033[0;37m,\033[1;32mESC\033[0;37m] 选择[\033[1;32m↑\033[0;37m,\033[1;32m↓\033[0;37m] "
148                     "阅读[\033[1;32m→\033[0;37m,\033[1;32mENTER\033[0;37m]\033[m %s[\033[1;32mn\033[0;37m]\033[m",                     "阅读[\033[1;32m→\033[0;37m,\033[1;32mENTER\033[0;37m] 发表[\033[1;32mCtrl-P\033[0;37m] "
149                       "%s[\033[1;32mn\033[0;37m] 帮助[\033[1;32mh\033[0;37m]\033[m",
150                     (display_nickname ? "显示用户名" : "显示昵称"));                     (display_nickname ? "显示用户名" : "显示昵称"));
151          moveto(3, 0);          moveto(3, 0);
152          if (display_nickname)          if (display_nickname)
# Line 135  static enum select_cmd_t section_list_se Line 166  static enum select_cmd_t section_list_se
166          int old_page_id = *p_page_id;          int old_page_id = *p_page_id;
167          int old_selected_index = *p_selected_index;          int old_selected_index = *p_selected_index;
168          int ch;          int ch;
169            time_t last_refresh_tm = time(NULL);
         BBS_last_access_tm = time(0);  
170    
171          if (item_count > 0 && *p_selected_index >= 0)          if (item_count > 0 && *p_selected_index >= 0)
172          {          {
# Line 151  static enum select_cmd_t section_list_se Line 181  static enum select_cmd_t section_list_se
181    
182                  switch (ch)                  switch (ch)
183                  {                  {
                 case KEY_NULL: // broken pipe  
184                  case KEY_ESC:                  case KEY_ESC:
185                  case KEY_LEFT:                  case KEY_LEFT:
186                            BBS_last_access_tm = time(NULL);
187                    case KEY_NULL:                   // broken pipe
188                          return EXIT_SECTION; // exit section                          return EXIT_SECTION; // exit section
189                  case KEY_TIMEOUT:                  case KEY_TIMEOUT:
190                          if (time(0) - BBS_last_access_tm >= MAX_DELAY_TIME)                          if (time(NULL) - BBS_last_access_tm >= MAX_DELAY_TIME)
191                          {                          {
192                                  return EXIT_SECTION; // exit section                                  return EXIT_SECTION; // exit section
193                          }                          }
194                          continue;                          continue;
195                  case 'n':                  case 'n':
196                            BBS_last_access_tm = time(NULL);
197                          return CHANGE_NAME_DISPLAY;                          return CHANGE_NAME_DISPLAY;
198                  case CR:                  case CR:
199                          igetch_reset();                          igetch_reset();
200                    case 'r':
201                  case KEY_RIGHT:                  case KEY_RIGHT:
202                          if (item_count > 0)                          if (item_count > 0)
203                          {                          {
204                                    BBS_last_access_tm = time(NULL);
205                                  return VIEW_ARTICLE;                                  return VIEW_ARTICLE;
206                          }                          }
207                          break;                          break;
208                    case Ctrl('P'):
209                            return POST_ARTICLE;
210                    case 'E':
211                            return EDIT_ARTICLE;
212                    case 'd':
213                            return DELETE_ARTICLE;
214                  case KEY_HOME:                  case KEY_HOME:
215                          *p_page_id = 0;                          *p_page_id = 0;
216                    case 'P':
217                  case KEY_PGUP:                  case KEY_PGUP:
218                          *p_selected_index = 0;                          *p_selected_index = 0;
219                    case 'k':
220                  case KEY_UP:                  case KEY_UP:
221                          if (*p_selected_index <= 0)                          if (*p_selected_index <= 0)
222                          {                          {
# Line 189  static enum select_cmd_t section_list_se Line 231  static enum select_cmd_t section_list_se
231                                  (*p_selected_index)--;                                  (*p_selected_index)--;
232                          }                          }
233                          break;                          break;
234                    case '$':
235                  case KEY_END:                  case KEY_END:
236                          if (total_page > 0)                          if (total_page > 0)
237                          {                          {
238                                  *p_page_id = total_page - 1;                                  *p_page_id = total_page - 1;
239                          }                          }
240                    case 'N':
241                  case KEY_PGDN:                  case KEY_PGDN:
242                          if (item_count > 0)                          if (item_count > 0)
243                          {                          {
244                                  *p_selected_index = item_count - 1;                                  *p_selected_index = item_count - 1;
245                          }                          }
246                    case 'j':
247                  case KEY_DOWN:                  case KEY_DOWN:
248                          if (*p_selected_index + 1 >= item_count) // next page                          if (*p_selected_index + 1 >= item_count) // next page
249                          {                          {
# Line 207  static enum select_cmd_t section_list_se Line 252  static enum select_cmd_t section_list_se
252                                          (*p_page_id)++;                                          (*p_page_id)++;
253                                          *p_selected_index = 0;                                          *p_selected_index = 0;
254                                  }                                  }
255                                    else // end of last page
256                                    {
257                                            return CHANGE_PAGE; // force refresh pages
258                                    }
259                          }                          }
260                          else                          else
261                          {                          {
262                                  (*p_selected_index)++;                                  (*p_selected_index)++;
263                          }                          }
264                          break;                          break;
265                    case '=':
266                            return FIRST_TOPIC_ARTICLE;
267                    case '\\':
268                            return LAST_TOPIC_ARTICLE;
269                    case 'h':
270                            return SHOW_HELP;
271                  default:                  default:
272                  }                  }
273    
# Line 238  static enum select_cmd_t section_list_se Line 293  static enum select_cmd_t section_list_se
293                          old_selected_index = *p_selected_index;                          old_selected_index = *p_selected_index;
294                  }                  }
295    
296                  BBS_last_access_tm = time(0);                  BBS_last_access_tm = time(NULL);
297                    if (BBS_last_access_tm - last_refresh_tm >= BBS_section_list_load_interval)
298                    {
299                            return CHANGE_PAGE; // force section list refresh
300                    }
301          }          }
302    
303          return EXIT_SECTION;          return EXIT_SECTION;
304  }  }
305    
306    static int display_article_key_handler(int *p_key, DISPLAY_CTX *p_ctx)
307    {
308            switch (*p_key)
309            {
310            case 'p':
311            case Ctrl('X'):
312                    section_topic_view_mode = !section_topic_view_mode;
313            case 0: // Set msg
314                    if (section_topic_view_mode)
315                    {
316                            snprintf(p_ctx->msg, sizeof(p_ctx->msg),
317                                             "| 返回[\033[32m←\033[33m,\033[32mESC\033[33m] "
318                                             "同主题阅读[\033[32m↑\033[33m/\033[32m↓\033[33m] "
319                                             "切换[\033[32mp\033[33m] 回复[\033[32mr\033[33m] 帮助[\033[32mh\033[33m] |");
320                    }
321                    else
322                    {
323                            snprintf(p_ctx->msg, sizeof(p_ctx->msg),
324                                             "| 返回[\033[32m←\033[33m,\033[32mESC\033[33m] "
325                                             "移动[\033[32m↑\033[33m/\033[32m↓\033[33m/\033[32mPgUp\033[33m/\033[32mPgDn\033[33m] "
326                                             "切换[\033[32mp\033[33m] 回复[\033[32mr\033[33m] 帮助[\033[32mh\033[33m] |");
327                    }
328                    *p_key = 0;
329                    break;
330            case 'r': // Reply article
331                    return 1;
332            case '=': // First topic article
333                    return 1;
334            case '\\': // Last topic article
335                    return 1;
336            case KEY_UP:
337            case KEY_PGUP:
338            case KEY_HOME:
339                    if (p_ctx->reach_begin)
340                    {
341                            if (section_topic_view_mode)
342                            {
343                                    *p_key = KEY_PGUP;
344                            }
345                            else
346                            {
347                                    *p_key = KEY_UP;
348                            }
349                            return 1;
350                    }
351                    break;
352            case 'k':
353                    if (section_topic_view_mode)
354                    {
355                            *p_key = KEY_PGUP;
356                    }
357                    else
358                    {
359                            *p_key = KEY_UP;
360                    }
361                    return 1;
362            case KEY_DOWN:
363            case KEY_PGDN:
364            case KEY_END:
365                    if (p_ctx->reach_end)
366                    {
367                            if (section_topic_view_mode)
368                            {
369                                    *p_key = KEY_PGDN;
370                            }
371                            else
372                            {
373                                    *p_key = KEY_DOWN;
374                            }
375                            return 1;
376                    }
377                    break;
378            case 'j':
379                    if (section_topic_view_mode)
380                    {
381                            *p_key = KEY_PGDN;
382                    }
383                    else
384                    {
385                            *p_key = KEY_DOWN;
386                    }
387                    return 1;
388            }
389    
390            return 0;
391    }
392    
393  int section_list_display(const char *sname)  int section_list_display(const char *sname)
394  {  {
395          static int display_nickname = 0;          static int display_nickname = 0;
# Line 257  int section_list_display(const char *sna Line 403  int section_list_display(const char *sna
403          int page_count;          int page_count;
404          int page_id = 0;          int page_id = 0;
405          int selected_index = 0;          int selected_index = 0;
406          ARTICLE_CACHE article_cache;          ARTICLE_CACHE cache;
407          int ret;          int ret;
408            int loop;
409            int direction;
410            ARTICLE article_new;
411            int page_id_cur;
412    
413          p_section = section_list_find_by_name(sname);          p_section = section_list_find_by_name(sname);
414          if (p_section == NULL)          if (p_section == NULL)
# Line 340  int section_list_display(const char *sna Line 490  int section_list_display(const char *sna
490                          }                          }
491                          break;                          break;
492                  case VIEW_ARTICLE:                  case VIEW_ARTICLE:
493                          ret = article_cache_load(&article_cache, VAR_ARTICLE_CACHE_DIR, p_articles[selected_index]);                          do
                         if (ret < 0)  
494                          {                          {
495                                  log_error("article_cache_load(aid=%d, cid=%d)\n", p_articles[selected_index]->aid, p_articles[selected_index]->cid);                                  loop = 0;
496                                  break;  
497                          }                                  if (article_cache_load(&cache, VAR_ARTICLE_CACHE_DIR, p_articles[selected_index]) < 0)
498                                    {
499                                            log_error("article_cache_load(aid=%d, cid=%d) error\n", p_articles[selected_index]->aid, p_articles[selected_index]->cid);
500                                            break;
501                                    }
502    
503                          log_std("Debug: view article aid = %d, cid = %d\n", p_articles[selected_index]->aid, p_articles[selected_index]->cid);                                  ret = display_data(cache.p_data, cache.line_total, cache.line_offsets, 0,
504                                                                       display_article_key_handler, DATA_READ_HELP);
505    
506                          ret = article_cache_unload(&article_cache);                                  if (article_cache_unload(&cache) < 0)
507                          if (ret < 0)                                  {
508                                            log_error("article_cache_unload(aid=%d, cid=%d) error\n", p_articles[selected_index]->aid, p_articles[selected_index]->cid);
509                                            break;
510                                    }
511    
512                                    // Update article_view_log
513                                    if (article_view_log_set_viewed(p_articles[selected_index]->aid, &BBS_article_view_log) < 0)
514                                    {
515                                            log_error("article_view_log_set_viewed(aid=%d) error\n", p_articles[selected_index]->aid);
516                                    }
517    
518                                    switch (ret)
519                                    {
520                                    case KEY_UP:
521                                            if (selected_index <= 0)
522                                            {
523                                                    if (page_id > 0)
524                                                    {
525                                                            page_id--;
526                                                            selected_index = BBS_article_limit_per_page - 1;
527    
528                                                            ret = query_section_articles(p_section, page_id, p_articles, &article_count, &page_count);
529                                                            if (ret < 0)
530                                                            {
531                                                                    log_error("query_section_articles(sid=%d, page_id=%d) error\n", p_section->sid, page_id);
532                                                                    return -3;
533                                                            }
534    
535                                                            if (article_count != BBS_article_limit_per_page) // page is not full
536                                                            {
537                                                                    selected_index = MAX(0, article_count - 1);
538                                                            }
539                                                            else
540                                                            {
541                                                                    loop = 1;
542                                                            }
543                                                    }
544                                            }
545                                            else
546                                            {
547                                                    selected_index--;
548                                                    loop = 1;
549                                            }
550                                            break;
551                                    case KEY_DOWN:
552                                            if (selected_index + 1 >= article_count) // next page
553                                            {
554                                                    if (page_id + 1 < page_count)
555                                                    {
556                                                            page_id++;
557                                                            selected_index = 0;
558    
559                                                            ret = query_section_articles(p_section, page_id, p_articles, &article_count, &page_count);
560                                                            if (ret < 0)
561                                                            {
562                                                                    log_error("query_section_articles(sid=%d, page_id=%d) error\n", p_section->sid, page_id);
563                                                                    return -3;
564                                                            }
565    
566                                                            if (article_count == 0) // empty page
567                                                            {
568                                                                    selected_index = 0;
569                                                            }
570                                                            else
571                                                            {
572                                                                    loop = 1;
573                                                            }
574                                                    }
575                                            }
576                                            else
577                                            {
578                                                    selected_index++;
579                                                    loop = 1;
580                                            }
581                                            break;
582                                    case KEY_PGUP:
583                                    case KEY_PGDN:
584                                            direction = (ret == KEY_PGUP ? -1 : 1);
585                                            ret = locate_article_in_section(p_section, p_articles[selected_index], direction, 1,
586                                                                                                            &page_id, &selected_index, &article_count);
587                                            if (ret < 0)
588                                            {
589                                                    log_error("locate_article_in_section(sid=%d, aid=%d, direction=%d, step=1) error\n",
590                                                                      p_section->sid, p_articles[selected_index]->aid, direction);
591                                                    return -3;
592                                            }
593                                            else if (ret > 0) // found
594                                            {
595                                                    ret = query_section_articles(p_section, page_id, p_articles, &article_count, &page_count);
596                                                    if (ret < 0)
597                                                    {
598                                                            log_error("query_section_articles(sid=%d, page_id=%d) error\n", p_section->sid, page_id);
599                                                            return -3;
600                                                    }
601                                                    loop = 1;
602                                            }
603                                            break;
604                                    case 'r': // Reply article
605                                            if (article_reply(p_section, p_articles[selected_index], &article_new) < 0)
606                                            {
607                                                    log_error("article_post(aid=%d, REPLY) error\n", p_articles[selected_index]->aid);
608                                            }
609                                            loop = 1;
610                                            break;
611                                    case '=':  // First topic article
612                                    case '\\': // Last topic article
613                                            page_id_cur = page_id;
614                                            direction = (ret == '=' ? -1 : 1);
615                                            ret = locate_article_in_section(p_section, p_articles[selected_index], direction, BBS_article_limit_per_section,
616                                                                                                            &page_id, &selected_index, &article_count);
617                                            if (ret < 0)
618                                            {
619                                                    log_error("locate_article_in_section(sid=%d, aid=%d, direction=%d, step=%d) error\n",
620                                                                      p_section->sid, p_articles[selected_index]->aid, direction, BBS_article_limit_per_section);
621                                                    return -3;
622                                            }
623                                            else if (ret > 0) // found
624                                            {
625                                                    if (page_id != page_id_cur) // page changed
626                                                    {
627                                                            ret = query_section_articles(p_section, page_id, p_articles, &article_count, &page_count);
628                                                            if (ret < 0)
629                                                            {
630                                                                    log_error("query_section_articles(sid=%d, page_id=%d) error\n", p_section->sid, page_id);
631                                                                    return -3;
632                                                            }
633                                                    }
634                                                    loop = 1;
635                                            }
636                                            break;
637                                    }
638                            } while (loop);
639    
640                            // Update current topic
641                            section_topic_view_tid = (p_articles[selected_index]->tid == 0 ? p_articles[selected_index]->aid : p_articles[selected_index]->tid);
642                    case CHANGE_NAME_DISPLAY:
643                            display_nickname = !display_nickname;
644                            if (section_list_draw_screen(sname, stitle, master_list, display_nickname) < 0)
645                            {
646                                    log_error("section_list_draw_screen() error\n");
647                                    return -2;
648                            }
649                            break;
650                    case POST_ARTICLE:
651                            if ((ret = article_post(p_section, &article_new)) < 0)
652                          {                          {
653                                  log_error("article_cache_unload(aid=%d, cid=%d)\n", p_articles[selected_index]->aid, p_articles[selected_index]->cid);                                  log_error("article_post(sid=%d) error\n", p_section->sid);
654                                  break;                          }
655                            else if (ret > 0) // New article posted
656                            {
657                                    ret = query_section_articles(p_section, page_id, p_articles, &article_count, &page_count);
658                                    if (ret < 0)
659                                    {
660                                            log_error("query_section_articles(sid=%d, page_id=%d) error\n", p_section->sid, page_id);
661                                            return -3;
662                                    }
663                          }                          }
   
                         // TODO: locate last viewed article  
                 case REFRESH_SCREEN:  
664                          if (section_list_draw_screen(sname, stitle, master_list, display_nickname) < 0)                          if (section_list_draw_screen(sname, stitle, master_list, display_nickname) < 0)
665                          {                          {
666                                  log_error("section_list_draw_screen() error\n");                                  log_error("section_list_draw_screen() error\n");
667                                  return -2;                                  return -2;
668                          }                          }
669                          break;                          break;
670                  case CHANGE_NAME_DISPLAY:                  case EDIT_ARTICLE:
671                          display_nickname = !display_nickname;                          if (!checkpriv(&BBS_priv, p_section->sid, S_POST) ||
672                                    p_articles[selected_index]->uid != BBS_priv.uid)
673                            {
674                                    break; // No permission
675                            }
676                            if (article_modify(p_section, p_articles[selected_index], &article_new) < 0)
677                            {
678                                    log_error("article_modify(aid=%d) error\n", p_articles[selected_index]->aid);
679                            }
680                            if (section_list_draw_screen(sname, stitle, master_list, display_nickname) < 0)
681                            {
682                                    log_error("section_list_draw_screen() error\n");
683                                    return -2;
684                            }
685                            break;
686                    case DELETE_ARTICLE:
687                            if (!checkpriv(&BBS_priv, p_section->sid, S_POST) ||
688                                    (!checkpriv(&BBS_priv, p_section->sid, S_MAN_S) && p_articles[selected_index]->uid != BBS_priv.uid))
689                            {
690                                    break; // No permission
691                            }
692                            if ((ret = article_del(p_section, p_articles[selected_index])) < 0)
693                            {
694                                    log_error("article_del(aid=%d) error\n", p_articles[selected_index]->aid);
695                            }
696                            else if (ret > 0) // Article deleted
697                            {
698                                    ret = query_section_articles(p_section, page_id, p_articles, &article_count, &page_count);
699                                    if (ret < 0)
700                                    {
701                                            log_error("query_section_articles(sid=%d, page_id=%d) error\n", p_section->sid, page_id);
702                                            return -3;
703                                    }
704                            }
705                            if (section_list_draw_screen(sname, stitle, master_list, display_nickname) < 0)
706                            {
707                                    log_error("section_list_draw_screen() error\n");
708                                    return -2;
709                            }
710                            break;
711                    case FIRST_TOPIC_ARTICLE:
712                    case LAST_TOPIC_ARTICLE:
713                            page_id_cur = page_id;
714                            direction = (ret == FIRST_TOPIC_ARTICLE ? -1 : 1);
715                            ret = locate_article_in_section(p_section, p_articles[selected_index], direction, BBS_article_limit_per_section,
716                                                                                            &page_id, &selected_index, &article_count);
717                            if (ret < 0)
718                            {
719                                    log_error("locate_article_in_section(sid=%d, aid=%d, direction=%d, step=%d) error\n",
720                                                      p_section->sid, p_articles[selected_index]->aid, direction, BBS_article_limit_per_section);
721                                    return -3;
722                            }
723                            else if (ret > 0 && page_id != page_id_cur) // found and page changed
724                            {
725                                    ret = query_section_articles(p_section, page_id, p_articles, &article_count, &page_count);
726                                    if (ret < 0)
727                                    {
728                                            log_error("query_section_articles(sid=%d, page_id=%d) error\n", p_section->sid, page_id);
729                                            return -3;
730                                    }
731                            }
732                            break;
733                    case SHOW_HELP:
734                            // Display help information
735                            display_file(DATA_READ_HELP, 1);
736                          if (section_list_draw_screen(sname, stitle, master_list, display_nickname) < 0)                          if (section_list_draw_screen(sname, stitle, master_list, display_nickname) < 0)
737                          {                          {
738                                  log_error("section_list_draw_screen() error\n");                                  log_error("section_list_draw_screen() error\n");


Legend:
Removed lines/characters  
Changed lines/characters
  Added lines/characters

webmaster@leafok.com
ViewVC Help
Powered by ViewVC 1.3.0-beta1