/[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.17 by sysadm, Sat Jun 7 10:00:10 2025 UTC Revision 1.20 by sysadm, Thu Jun 12 12:14:28 2025 UTC
# Line 17  Line 17 
17  #include "section_list_display.h"  #include "section_list_display.h"
18  #include "section_list_loader.h"  #include "section_list_loader.h"
19  #include "article_cache.h"  #include "article_cache.h"
20    #include "article_post.h"
21  #include "common.h"  #include "common.h"
22  #include "io.h"  #include "io.h"
23  #include "screen.h"  #include "screen.h"
24  #include "log.h"  #include "log.h"
25    #include "user_priv.h"
26  #include "article_view_log.h"  #include "article_view_log.h"
27  #include "str_process.h"  #include "str_process.h"
28  #include <time.h>  #include <time.h>
# Line 38  enum select_cmd_t Line 40  enum select_cmd_t
40          CHANGE_PAGE = 2,          CHANGE_PAGE = 2,
41          REFRESH_SCREEN = 3,          REFRESH_SCREEN = 3,
42          CHANGE_NAME_DISPLAY = 4,          CHANGE_NAME_DISPLAY = 4,
43            POST_ARTICLE = 5,
44            EDIT_ARTICLE = 6,
45  };  };
46    
47  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 59  static int section_list_draw_items(int p Line 63  static int section_list_draw_items(int p
63    
64          for (i = 0; i < article_count; i++)          for (i = 0; i < article_count; i++)
65          {          {
66                  is_viewed = article_view_log_is_viewed(p_articles[i]->aid, &BBS_article_view_log);                  if (p_articles[i]->uid == BBS_priv.uid)
                 if (is_viewed < 0)  
67                  {                  {
68                          log_error("article_view_log_is_viewed(aid=%d) error\n", p_articles[i]->aid);                          is_viewed = 1;
69                          is_viewed = 0;                  }
70                    else
71                    {
72                            is_viewed = article_view_log_is_viewed(p_articles[i]->aid, &BBS_article_view_log);
73                            if (is_viewed < 0)
74                            {
75                                    log_error("article_view_log_is_viewed(aid=%d) error\n", p_articles[i]->aid);
76                                    is_viewed = 0;
77                            }
78                  }                  }
79    
80                  article_flag = (is_viewed ? ' ' : 'N');                  article_flag = (is_viewed ? ' ' : 'N');
# Line 185  static enum select_cmd_t section_list_se Line 196  static enum select_cmd_t section_list_se
196                                  return VIEW_ARTICLE;                                  return VIEW_ARTICLE;
197                          }                          }
198                          break;                          break;
199                    case Ctrl('P'):
200                            return POST_ARTICLE;
201                    case 'E':
202                            return EDIT_ARTICLE;
203                  case KEY_HOME:                  case KEY_HOME:
204                          *p_page_id = 0;                          *p_page_id = 0;
205                  case KEY_PGUP:                  case KEY_PGUP:
# Line 281  static int display_article_key_handler(i Line 296  static int display_article_key_handler(i
296                  }                  }
297                  *p_key = 0;                  *p_key = 0;
298                  break;                  break;
299            case 'r': // Reply article
300                    return 1;
301          case KEY_UP:          case KEY_UP:
302          case KEY_PGUP:          case KEY_PGUP:
303          case KEY_HOME:          case KEY_HOME:
# Line 426  int section_list_display(const char *sna Line 443  int section_list_display(const char *sna
443                                          break;                                          break;
444                                  }                                  }
445    
446                                  ret = display_data(cache.p_data, cache.line_total, cache.line_offsets, 1, 0,                                  ret = display_data(cache.p_data, cache.line_total, cache.line_offsets, 0,
447                                                                     display_article_key_handler, DATA_READ_HELP);                                                                     display_article_key_handler, DATA_READ_HELP);
448    
449                                  if (article_cache_unload(&cache) < 0)                                  if (article_cache_unload(&cache) < 0)
# Line 526  int section_list_display(const char *sna Line 543  int section_list_display(const char *sna
543                                                  loop = 1;                                                  loop = 1;
544                                          }                                          }
545                                          break;                                          break;
546                                    case 'r': // Reply article
547                                            if (article_post(p_section, p_articles[selected_index], ARTICLE_POST_REPLY) < 0)
548                                            {
549                                                    log_error("article_post(aid=%d, REPLY) error\n", p_articles[selected_index]->aid);
550                                            }
551                                            loop = 1;
552                                            break;
553                                  }                                  }
554                          } while (loop);                          } while (loop);
555    
# Line 543  int section_list_display(const char *sna Line 567  int section_list_display(const char *sna
567                          if (section_list_draw_screen(sname, stitle, master_list, display_nickname) < 0)                          if (section_list_draw_screen(sname, stitle, master_list, display_nickname) < 0)
568                          {                          {
569                                  log_error("section_list_draw_screen() error\n");                                  log_error("section_list_draw_screen() error\n");
570                                    return -2;
571                            }
572                            break;
573                    case POST_ARTICLE:
574                            if (article_post(p_section, NULL, ARTICLE_POST_NEW) < 0)
575                            {
576                                    log_error("article_post(sid=%d, NEW) error\n", p_section->sid);
577                            }
578                            if (section_list_draw_screen(sname, stitle, master_list, display_nickname) < 0)
579                            {
580                                    log_error("section_list_draw_screen() error\n");
581                                    return -2;
582                            }
583                            break;
584                    case EDIT_ARTICLE:
585                            if (p_articles[selected_index]->uid != BBS_priv.uid)
586                            {
587                                    break;
588                            }
589                            if (article_post(p_section, p_articles[selected_index], ARTICLE_POST_EDIT) < 0)
590                            {
591                                    log_error("article_post(aid=%d, EDIT) error\n", p_articles[selected_index]->aid);
592                            }
593                            if (section_list_draw_screen(sname, stitle, master_list, display_nickname) < 0)
594                            {
595                                    log_error("section_list_draw_screen() error\n");
596                                  return -2;                                  return -2;
597                          }                          }
598                          break;                          break;


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

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