/[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.2 by sysadm, Wed May 28 07:41:46 2025 UTC Revision 1.29 by sysadm, Mon Jun 16 14:30:44 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"
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"
 #include <time.h>  
 #define _POSIX_C_SOURCE 200809L  
31  #include <string.h>  #include <string.h>
32    #include <time.h>
33    #include <sys/param.h>
34    
35    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  {  {
# Line 31  enum select_cmd_t Line 41  enum select_cmd_t
41          VIEW_ARTICLE = 1,          VIEW_ARTICLE = 1,
42          CHANGE_PAGE = 2,          CHANGE_PAGE = 2,
43          REFRESH_SCREEN = 3,          REFRESH_SCREEN = 3,
44            CHANGE_NAME_DISPLAY = 4,
45            POST_ARTICLE = 5,
46            EDIT_ARTICLE = 6,
47            DELETE_ARTICLE = 7,
48            SHOW_HELP = 8,
49  };  };
50    
51  static int section_list_draw_items(SECTION_LIST *p_section, int page_id, ARTICLE *p_articles[], int article_count)  static int section_list_draw_items(int page_id, ARTICLE *p_articles[], int article_count, int display_nickname)
52  {  {
53          char str_time[LINE_BUFFER_LEN];          char str_time[LINE_BUFFER_LEN];
54          struct tm tm_sub;          struct tm tm_sub;
# Line 42  static int section_list_draw_items(SECTI Line 57  static int section_list_draw_items(SECTI
57          int eol;          int eol;
58          int len;          int len;
59          int i;          int i;
60            char article_flag;
61            int is_viewed;
62            time_t tm_now;
63    
64            time(&tm_now);
65    
66          clrline(4, 23);          clrline(4, 23);
67    
68          for (i = 0; i < article_count; i++)          for (i = 0; i < article_count; i++)
69          {          {
70                    if (p_articles[i]->uid == BBS_priv.uid)
71                    {
72                            is_viewed = 1;
73                    }
74                    else
75                    {
76                            is_viewed = article_view_log_is_viewed(p_articles[i]->aid, &BBS_article_view_log);
77                            if (is_viewed < 0)
78                            {
79                                    log_error("article_view_log_is_viewed(aid=%d) error\n", p_articles[i]->aid);
80                                    is_viewed = 0;
81                            }
82                    }
83    
84                    article_flag = (is_viewed ? ' ' : 'N');
85    
86                    if (p_articles[i]->excerption)
87                    {
88                            article_flag = (is_viewed ? 'm' : 'M');
89                    }
90                    else if (p_articles[i]->lock && is_viewed)
91                    {
92                            article_flag = 'x';
93                    }
94    
95                  localtime_r(&p_articles[i]->sub_dt, &tm_sub);                  localtime_r(&p_articles[i]->sub_dt, &tm_sub);
96                  strftime(str_time, sizeof(str_time), "%b %e", &tm_sub);                  if (tm_now - p_articles[i]->sub_dt < 3600 * 24 * 365)
97                  strncpy(title_f, p_articles[i]->title, sizeof(title_f) - 1);                  {
98                            strftime(str_time, sizeof(str_time), "%b %e ", &tm_sub);
99                    }
100                    else
101                    {
102                            strftime(str_time, sizeof(str_time), "%m/%Y", &tm_sub);
103                    }
104    
105                    strncpy(title_f, (p_articles[i]->tid == 0 ? "● " : ""), sizeof(title_f) - 1);
106                  title_f[sizeof(title_f) - 1] = '\0';                  title_f[sizeof(title_f) - 1] = '\0';
107                  len = split_line(title_f, (p_articles[i]->tid == 0 ? 46 : 49), &eol, &title_f_len);                  strncat(title_f, (p_articles[i]->transship ? "[转载]" : ""), sizeof(title_f) - 1 - strnlen(title_f, sizeof(title_f)));
108                    strncat(title_f, p_articles[i]->title, sizeof(title_f) - 1 - strnlen(title_f, sizeof(title_f)));
109                    len = split_line(title_f, 47 - (display_nickname ? 8 : 0), &eol, &title_f_len, 1);
110                  if (title_f[len] != '\0')                  if (title_f[len] != '\0')
111                  {                  {
112                          title_f[len] = '\0';                          title_f[len] = '\0';
113                  }                  }
114    
115                  moveto(4 + i, 1);                  moveto(4 + i, 1);
116                  prints("  %7d %s%*s %s  %s%s",                  prints("  %s%7d\033[m %c %s%*s %s %s%s\033[m",
117                               (p_articles[i]->aid == section_topic_view_tid ? "\033[1;33m" : (p_articles[i]->tid == section_topic_view_tid ? "\033[1;36m" : "")),
118                             p_articles[i]->aid,                             p_articles[i]->aid,
119                             p_articles[i]->username,                             article_flag,
120                             BBS_username_max_len - (int)strnlen(p_articles[i]->username, sizeof(p_articles[i]->username)),                             (display_nickname ? p_articles[i]->nickname : p_articles[i]->username),
121                               (display_nickname ? BBS_nickname_max_len - (int)strnlen(p_articles[i]->nickname, sizeof(p_articles[i]->nickname))
122                                                                     : BBS_username_max_len - (int)strnlen(p_articles[i]->username, sizeof(p_articles[i]->username))),
123                             "",                             "",
124                             str_time,                             str_time,
125                             (p_articles[i]->tid == 0 ? "● " : ""),                             (p_articles[i]->aid == section_topic_view_tid ? "\033[1;33m" : (p_articles[i]->tid == section_topic_view_tid ? "\033[1;36m" : "")),
126                             title_f);                             title_f);
127          }          }
128    
129          return 0;          return 0;
130  }  }
131    
132  static int section_list_draw_screen(SECTION_LIST *p_section)  static int section_list_draw_screen(const char *sname, const char *stitle, const char *master_list, int display_nickname)
133  {  {
134          char str_section_master[LINE_BUFFER_LEN] = "诚征版主中";          char str_section_master[LINE_BUFFER_LEN] = "诚征版主中";
135          char str_section_name[LINE_BUFFER_LEN];          char str_section_name[LINE_BUFFER_LEN];
136    
137          if (p_section->master_list[0] != '\0')          if (master_list[0] != '\0')
138          {          {
139                  snprintf(str_section_master, sizeof(str_section_master), "版主:%s", p_section->master_list);                  snprintf(str_section_master, sizeof(str_section_master), "版主:%s", master_list);
140          }          }
141          snprintf(str_section_name, sizeof(str_section_name), "讨论区 [%s]", p_section->sname);          snprintf(str_section_name, sizeof(str_section_name), "讨论区 [%s]", sname);
142    
143          clearscr();          clearscr();
144          show_top(str_section_master, p_section->stitle, str_section_name);          show_top(str_section_master, stitle, str_section_name);
145          moveto(2, 0);          moveto(2, 0);
146          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] 阅读[\033[1;32m→\033[0;37m,\033[1;32mENTER\033[0;37m]\033[m");          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] "
147                       "阅读[\033[1;32m→\033[0;37m,\033[1;32mENTER\033[0;37m] 发表[\033[1;32mCtrl-P\033[0;37m] "
148                       "%s[\033[1;32mn\033[0;37m] 帮助[\033[1;32mh\033[0;37m]\033[m",
149                       (display_nickname ? "显示用户名" : "显示昵称"));
150          moveto(3, 0);          moveto(3, 0);
151          prints("\033[44;37m  \033[1;37m 编 号  发 布 者     日  期  文 章 标 题                                      \033[m");          if (display_nickname)
152          show_bottom("");          {
153                    prints("\033[44;37m  \033[1;37m 编  号   发布者昵称           日  期  文章标题                               \033[m");
154            }
155            else
156            {
157                    prints("\033[44;37m  \033[1;37m 编  号   发 布 者     日  期  文章标题                                       \033[m");
158            }
159    
160          return 0;          return 0;
161  }  }
# Line 124  static enum select_cmd_t section_list_se Line 191  static enum select_cmd_t section_list_se
191                                  return EXIT_SECTION; // exit section                                  return EXIT_SECTION; // exit section
192                          }                          }
193                          continue;                          continue;
194                    case 'n':
195                            return CHANGE_NAME_DISPLAY;
196                  case CR:                  case CR:
197                          igetch_reset();                          igetch_reset();
198                    case 'r':
199                  case KEY_RIGHT:                  case KEY_RIGHT:
200                          if (item_count > 0)                          if (item_count > 0)
201                          {                          {
202                                  return VIEW_ARTICLE;                                  return VIEW_ARTICLE;
203                          }                          }
204                          break;                          break;
205                    case Ctrl('P'):
206                            return POST_ARTICLE;
207                    case 'E':
208                            return EDIT_ARTICLE;
209                    case 'd':
210                            return DELETE_ARTICLE;
211                  case KEY_HOME:                  case KEY_HOME:
212                          *p_page_id = 0;                          *p_page_id = 0;
213                    case 'P':
214                  case KEY_PGUP:                  case KEY_PGUP:
215                          *p_selected_index = 0;                          *p_selected_index = 0;
216                    case 'k':
217                  case KEY_UP:                  case KEY_UP:
218                          if (*p_selected_index <= 0)                          if (*p_selected_index <= 0)
219                          {                          {
# Line 150  static enum select_cmd_t section_list_se Line 228  static enum select_cmd_t section_list_se
228                                  (*p_selected_index)--;                                  (*p_selected_index)--;
229                          }                          }
230                          break;                          break;
231                    case '$':
232                  case KEY_END:                  case KEY_END:
233                          if (total_page > 0)                          if (total_page > 0)
234                          {                          {
235                                  *p_page_id = total_page - 1;                                  *p_page_id = total_page - 1;
236                          }                          }
237                    case 'N':
238                  case KEY_PGDN:                  case KEY_PGDN:
239                          if (item_count > 0)                          if (item_count > 0)
240                          {                          {
241                                  *p_selected_index = item_count - 1;                                  *p_selected_index = item_count - 1;
242                          }                          }
243                    case 'j':
244                  case KEY_DOWN:                  case KEY_DOWN:
245                          if (*p_selected_index + 1 >= item_count) // next page                          if (*p_selected_index + 1 >= item_count) // next page
246                          {                          {
# Line 168  static enum select_cmd_t section_list_se Line 249  static enum select_cmd_t section_list_se
249                                          (*p_page_id)++;                                          (*p_page_id)++;
250                                          *p_selected_index = 0;                                          *p_selected_index = 0;
251                                  }                                  }
252                                    else // end of last page
253                                    {
254                                            return CHANGE_PAGE; // force refresh pages
255                                    }
256                          }                          }
257                          else                          else
258                          {                          {
259                                  (*p_selected_index)++;                                  (*p_selected_index)++;
260                          }                          }
261                          break;                          break;
262                    case 'h':
263                            return SHOW_HELP;
264                  default:                  default:
265                  }                  }
266    
# Line 205  static enum select_cmd_t section_list_se Line 292  static enum select_cmd_t section_list_se
292          return EXIT_SECTION;          return EXIT_SECTION;
293  }  }
294    
295    static int display_article_key_handler(int *p_key, DISPLAY_CTX *p_ctx)
296    {
297            switch (*p_key)
298            {
299            case 'p':
300            case Ctrl('X'):
301                    section_topic_view_mode = !section_topic_view_mode;
302            case 0: // Set msg
303                    if (section_topic_view_mode)
304                    {
305                            snprintf(p_ctx->msg, sizeof(p_ctx->msg),
306                                             "| 返回[\033[32m←\033[33m,\033[32mESC\033[33m] "
307                                             "同主题阅读[\033[32m↑\033[33m/\033[32m↓\033[33m] "
308                                             "切换[\033[32mp\033[33m] 回复[\033[32mr\033[33m] 帮助[\033[32mh\033[33m] |");
309                    }
310                    else
311                    {
312                            snprintf(p_ctx->msg, sizeof(p_ctx->msg),
313                                             "| 返回[\033[32m←\033[33m,\033[32mESC\033[33m] "
314                                             "移动[\033[32m↑\033[33m/\033[32m↓\033[33m/\033[32mPgUp\033[33m/\033[32mPgDn\033[33m] "
315                                             "切换[\033[32mp\033[33m] 回复[\033[32mr\033[33m] 帮助[\033[32mh\033[33m] |");
316                    }
317                    *p_key = 0;
318                    break;
319            case 'r': // Reply article
320                    return 1;
321            case KEY_UP:
322            case KEY_PGUP:
323            case KEY_HOME:
324                    if (p_ctx->reach_begin)
325                    {
326                            if (section_topic_view_mode)
327                            {
328                                    *p_key = KEY_PGUP;
329                            }
330                            else
331                            {
332                                    *p_key = KEY_UP;
333                            }
334                            return 1;
335                    }
336                    break;
337            case 'k':
338                    if (section_topic_view_mode)
339                    {
340                            *p_key = KEY_PGUP;
341                    }
342                    else
343                    {
344                            *p_key = KEY_UP;
345                    }
346                    return 1;
347            case KEY_DOWN:
348            case KEY_PGDN:
349            case KEY_END:
350                    if (p_ctx->reach_end)
351                    {
352                            if (section_topic_view_mode)
353                            {
354                                    *p_key = KEY_PGDN;
355                            }
356                            else
357                            {
358                                    *p_key = KEY_DOWN;
359                            }
360                            return 1;
361                    }
362                    break;
363            case 'j':
364                    if (section_topic_view_mode)
365                    {
366                            *p_key = KEY_PGDN;
367                    }
368                    else
369                    {
370                            *p_key = KEY_DOWN;
371                    }
372                    return 1;
373            }
374    
375            return 0;
376    }
377    
378  int section_list_display(const char *sname)  int section_list_display(const char *sname)
379  {  {
380            static int display_nickname = 0;
381    
382          SECTION_LIST *p_section;          SECTION_LIST *p_section;
383            char stitle[BBS_section_title_max_len + 1];
384            char master_list[(BBS_username_max_len + 1) * 3 + 1];
385            char page_info_str[LINE_BUFFER_LEN];
386          ARTICLE *p_articles[BBS_article_limit_per_page];          ARTICLE *p_articles[BBS_article_limit_per_page];
387          int article_count;          int article_count;
388            int page_count;
389          int page_id = 0;          int page_id = 0;
390          int selected_index = 0;          int selected_index = 0;
391            ARTICLE_CACHE cache;
392          int ret;          int ret;
393            int loop;
394            int direction;
395            ARTICLE article_new;
396    
397          p_section = section_list_find_by_name(sname);          p_section = section_list_find_by_name(sname);
398          if (p_section == NULL)          if (p_section == NULL)
# Line 221  int section_list_display(const char *sna Line 401  int section_list_display(const char *sna
401                  return -1;                  return -1;
402          }          }
403    
404          if (section_list_draw_screen(p_section) < 0)          if ((ret = section_list_rd_lock(p_section)) < 0)
405            {
406                    log_error("section_list_rd_lock(sid = 0) error\n");
407                    return -2;
408            }
409    
410            strncpy(stitle, p_section->stitle, sizeof(stitle) - 1);
411            stitle[sizeof(stitle) - 1] = '\0';
412            strncpy(master_list, p_section->master_list, sizeof(master_list) - 1);
413            master_list[sizeof(master_list) - 1] = '\0';
414    
415            if ((ret = section_list_rd_unlock(p_section)) < 0)
416            {
417                    log_error("section_list_rd_unlock(sid = 0) error\n");
418                    return -2;
419            }
420    
421            if (section_list_draw_screen(sname, stitle, master_list, display_nickname) < 0)
422          {          {
423                  log_error("section_list_draw_screen() error\n");                  log_error("section_list_draw_screen() error\n");
424                  return -2;                  return -2;
425          }          }
426    
427          if (p_section->visible_article_count > 0)          ret = query_section_articles(p_section, page_id, p_articles, &article_count, &page_count);
428            if (ret < 0)
429          {          {
430                  ret = query_section_articles(p_section, page_id, p_articles, &article_count);                  log_error("query_section_articles(sid=%d, page_id=%d) error\n", p_section->sid, page_id);
431                  if (ret < 0)                  return -3;
                 {  
                         log_error("query_section_articles(sid=%d, page_id=%d) error\n", p_section->sid, page_id);  
                         return -3;  
                 }  
432          }          }
433          else // empty section  
434            if (article_count == 0) // empty section
435          {          {
                 article_count = 0;  
436                  selected_index = 0;                  selected_index = 0;
437          }          }
438    
439          while (!SYS_server_exit)          while (!SYS_server_exit)
440          {          {
441                  ret = section_list_draw_items(p_section, page_id, p_articles, article_count);                  ret = section_list_draw_items(page_id, p_articles, article_count, display_nickname);
442                  if (ret < 0)                  if (ret < 0)
443                  {                  {
444                          log_error("section_list_draw_items(sid=%d, page_id=%d) error\n", p_section->sid, page_id);                          log_error("section_list_draw_items(sid=%d, page_id=%d) error\n", p_section->sid, page_id);
445                          return -4;                          return -4;
446                  }                  }
447    
448                    snprintf(page_info_str, sizeof(page_info_str),
449                                     "\033[33m[第\033[36m%d\033[33m/\033[36m%d\033[33m页]",
450                                     page_id + 1, MAX(page_count, 1));
451    
452                    show_bottom(page_info_str);
453                  iflush();                  iflush();
454    
455                  ret = section_list_select(p_section->page_count, article_count, &page_id, &selected_index);                  ret = section_list_select(page_count, article_count, &page_id, &selected_index);
456                  switch (ret)                  switch (ret)
457                  {                  {
458                  case EXIT_SECTION:                  case EXIT_SECTION:
459                          return 0;                          return 0;
460                  case CHANGE_PAGE:                  case CHANGE_PAGE:
461                          if (p_section->visible_article_count > 0)                          ret = query_section_articles(p_section, page_id, p_articles, &article_count, &page_count);
462                            if (ret < 0)
463                            {
464                                    log_error("query_section_articles(sid=%d, page_id=%d) error\n", p_section->sid, page_id);
465                                    return -3;
466                            }
467                            if (article_count == 0) // empty section
468                            {
469                                    selected_index = 0;
470                            }
471                            else if (selected_index >= article_count)
472                            {
473                                    selected_index = article_count - 1;
474                            }
475                            break;
476                    case VIEW_ARTICLE:
477                            do
478                            {
479                                    loop = 0;
480    
481                                    if (article_cache_load(&cache, VAR_ARTICLE_CACHE_DIR, p_articles[selected_index]) < 0)
482                                    {
483                                            log_error("article_cache_load(aid=%d, cid=%d) error\n", p_articles[selected_index]->aid, p_articles[selected_index]->cid);
484                                            break;
485                                    }
486    
487                                    ret = display_data(cache.p_data, cache.line_total, cache.line_offsets, 0,
488                                                                       display_article_key_handler, DATA_READ_HELP);
489    
490                                    if (article_cache_unload(&cache) < 0)
491                                    {
492                                            log_error("article_cache_unload(aid=%d, cid=%d) error\n", p_articles[selected_index]->aid, p_articles[selected_index]->cid);
493                                            break;
494                                    }
495    
496                                    // Update article_view_log
497                                    if (article_view_log_set_viewed(p_articles[selected_index]->aid, &BBS_article_view_log) < 0)
498                                    {
499                                            log_error("article_view_log_set_viewed(aid=%d) error\n", p_articles[selected_index]->aid);
500                                    }
501    
502                                    switch (ret)
503                                    {
504                                    case KEY_UP:
505                                            if (selected_index <= 0)
506                                            {
507                                                    if (page_id > 0)
508                                                    {
509                                                            page_id--;
510                                                            selected_index = BBS_article_limit_per_page - 1;
511    
512                                                            ret = query_section_articles(p_section, page_id, p_articles, &article_count, &page_count);
513                                                            if (ret < 0)
514                                                            {
515                                                                    log_error("query_section_articles(sid=%d, page_id=%d) error\n", p_section->sid, page_id);
516                                                                    return -3;
517                                                            }
518    
519                                                            if (article_count != BBS_article_limit_per_page) // page is not full
520                                                            {
521                                                                    selected_index = MAX(0, article_count - 1);
522                                                            }
523                                                            else
524                                                            {
525                                                                    loop = 1;
526                                                            }
527                                                    }
528                                            }
529                                            else
530                                            {
531                                                    selected_index--;
532                                                    loop = 1;
533                                            }
534                                            break;
535                                    case KEY_DOWN:
536                                            if (selected_index + 1 >= article_count) // next page
537                                            {
538                                                    if (page_id + 1 < page_count)
539                                                    {
540                                                            page_id++;
541                                                            selected_index = 0;
542    
543                                                            ret = query_section_articles(p_section, page_id, p_articles, &article_count, &page_count);
544                                                            if (ret < 0)
545                                                            {
546                                                                    log_error("query_section_articles(sid=%d, page_id=%d) error\n", p_section->sid, page_id);
547                                                                    return -3;
548                                                            }
549    
550                                                            if (article_count == 0) // empty page
551                                                            {
552                                                                    selected_index = 0;
553                                                            }
554                                                            else
555                                                            {
556                                                                    loop = 1;
557                                                            }
558                                                    }
559                                            }
560                                            else
561                                            {
562                                                    selected_index++;
563                                                    loop = 1;
564                                            }
565                                            break;
566                                    case KEY_PGUP:
567                                    case KEY_PGDN:
568                                            direction = (ret == KEY_PGUP ? -1 : 1);
569                                            ret = locate_article_in_section(p_section, p_articles[selected_index], direction, &page_id, &selected_index, &page_count);
570                                            if (ret < 0)
571                                            {
572                                                    log_error("locate_article_in_section(sid=%d, aid=%d, direction=%d) error\n",
573                                                                      p_section->sid, p_articles[selected_index]->aid, direction);
574                                                    return -3;
575                                            }
576                                            else if (ret > 0)
577                                            {
578                                                    ret = query_section_articles(p_section, page_id, p_articles, &article_count, &page_count);
579                                                    if (ret < 0)
580                                                    {
581                                                            log_error("query_section_articles(sid=%d, page_id=%d) error\n", p_section->sid, page_id);
582                                                            return -3;
583                                                    }
584                                                    loop = 1;
585                                            }
586                                            break;
587                                    case 'r': // Reply article
588                                            if (article_reply(p_section, p_articles[selected_index], &article_new) < 0)
589                                            {
590                                                    log_error("article_post(aid=%d, REPLY) error\n", p_articles[selected_index]->aid);
591                                            }
592                                            loop = 1;
593                                            break;
594                                    }
595                            } while (loop);
596    
597                            // Update current topic
598                            section_topic_view_tid = (p_articles[selected_index]->tid == 0 ? p_articles[selected_index]->aid : p_articles[selected_index]->tid);
599                    case REFRESH_SCREEN:
600                            if (section_list_draw_screen(sname, stitle, master_list, display_nickname) < 0)
601                            {
602                                    log_error("section_list_draw_screen() error\n");
603                                    return -2;
604                            }
605                            break;
606                    case CHANGE_NAME_DISPLAY:
607                            display_nickname = !display_nickname;
608                            if (section_list_draw_screen(sname, stitle, master_list, display_nickname) < 0)
609                            {
610                                    log_error("section_list_draw_screen() error\n");
611                                    return -2;
612                            }
613                            break;
614                    case POST_ARTICLE:
615                            ret = article_post(p_section, &article_new);
616                            if (ret < 0)
617                          {                          {
618                                  ret = query_section_articles(p_section, page_id, p_articles, &article_count);                                  log_error("article_post(sid=%d) error\n", p_section->sid);
619                            }
620                            else if (ret > 0) // New article posted
621                            {
622                                    ret = query_section_articles(p_section, page_id, p_articles, &article_count, &page_count);
623                                  if (ret < 0)                                  if (ret < 0)
624                                  {                                  {
625                                          log_error("query_section_articles(sid=%d, page_id=%d) error\n", p_section->sid, page_id);                                          log_error("query_section_articles(sid=%d, page_id=%d) error\n", p_section->sid, page_id);
626                                          return -3;                                          return -3;
627                                  }                                  }
628                          }                          }
629                          else // empty section                          if (section_list_draw_screen(sname, stitle, master_list, display_nickname) < 0)
630                          {                          {
631                                  article_count = 0;                                  log_error("section_list_draw_screen() error\n");
632                                  selected_index = 0;                                  return -2;
633                          }                          }
634                          if (selected_index >= article_count)                          break;
635                    case EDIT_ARTICLE:
636                            if (!checkpriv(&BBS_priv, p_section->sid, S_POST) ||
637                                    p_articles[selected_index]->uid != BBS_priv.uid)
638                          {                          {
639                                  selected_index = article_count - 1;                                  break; // No permission
640                            }
641                            if (article_modify(p_section, p_articles[selected_index], &article_new) < 0)
642                            {
643                                    log_error("article_modify(aid=%d) error\n", p_articles[selected_index]->aid);
644                            }
645                            if (section_list_draw_screen(sname, stitle, master_list, display_nickname) < 0)
646                            {
647                                    log_error("section_list_draw_screen() error\n");
648                                    return -2;
649                          }                          }
650                          break;                          break;
651                  case VIEW_ARTICLE:                  case DELETE_ARTICLE:
652                          log_std("Debug: article %d selected\n", p_articles[selected_index]->aid);                          if (!checkpriv(&BBS_priv, p_section->sid, S_POST) ||
653                  case REFRESH_SCREEN:                                  (!checkpriv(&BBS_priv, p_section->sid, S_MAN_S) && p_articles[selected_index]->uid != BBS_priv.uid))
654                          if (section_list_draw_screen(p_section) < 0)                          {
655                                    break; // No permission
656                            }
657                            if (article_del(p_section, p_articles[selected_index]) < 0)
658                            {
659                                    log_error("article_del(aid=%d) error\n", p_articles[selected_index]->aid);
660                            }
661                            if (section_list_draw_screen(sname, stitle, master_list, display_nickname) < 0)
662                            {
663                                    log_error("section_list_draw_screen() error\n");
664                                    return -2;
665                            }
666                            break;
667                    case SHOW_HELP:
668                            // Display help information
669                            display_file(DATA_READ_HELP, 1);
670                            if (section_list_draw_screen(sname, stitle, master_list, display_nickname) < 0)
671                          {                          {
672                                  log_error("section_list_draw_screen() error\n");                                  log_error("section_list_draw_screen() error\n");
673                                  return -2;                                  return -2;


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

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