Attachment "all_read.patch" to
ticket [06b10546ba]
added by
anonymous
2013-03-17 10:06:06.
Index: server.c
==================================================================
--- server.c
+++ server.c
@@ -38,10 +38,11 @@
static int param_mark_unread;
static int param_lastchecked;
static int param_local_images;
static int param_offset;
static int param_single_page;
+static int param_all_read;
struct ParamPosts *param_posts;
const static int port = 8090;
const int per_page = 10;
@@ -527,10 +528,25 @@
send_line(s, "<a href=\"%s/planpdf/%s?%s\">[Plan PDF]</a>\n",
cgi_url_path, path, str_params);
}
#endif
+
+ {
+ send_line(s, "<form style=\"display: inline;\" method=\"get\">\n");
+ send_line(s, "<input type=\"hidden\" name=\"show_read\" value=\"%i\"/>\n",
+ param_show_read);
+ send_line(s, "<input type=\"hidden\" name=\"single_page\" value=\"%i\"/>\n",
+ param_single_page);
+ send_line(s, "<input type=\"hidden\" name=\"local_images\" value=\"%i\"/>\n",
+ param_local_images);
+ send_line(s, "<input type=\"hidden\" name=\"offset\" value=\"%i\"/>\n",
+ param_offset);
+ send_line(s, "<input type=\"hidden\" name=\"all_read\" value=\"1\"/>\n");
+ send_line(s, "<input type=\"submit\" value=\"Mark all as read\"/>\n");
+ send_line(s, "</form>\n");
+ }
send_line(s, "</div>\n");
strncpy(base, "files/", sizeof base);
mystrncat(base, path, sizeof base);
@@ -561,10 +577,20 @@
if (param_show_read)
mystrncat(str_params, "&show_read=1", sizeof str_params);
if (!param_local_images)
mystrncat(str_params, "&local_images=0", sizeof str_params);
+ if (param_all_read)
+ {
+ if (0)
+ fprintf(stderr,"Marking all as read....\n");
+ for(j = 0; j < fm->nitems; ++j)
+ {
+ fm->item[j].marked_read = 1;
+ set_read(base, &fm->item[j]);
+ }
+ }
if (!param_single_page)
{
int page = 0;
int offset_is_head = 0;
@@ -815,10 +841,11 @@
param_mark_read = -1;
param_lastchecked = -1;
param_local_images = 1;
param_offset = -1; /* -1 means the last */
param_single_page = 0;
+ param_all_read = 0;
if (path != NULL)
{
char *querycopy = strdup(query);
char *text = querycopy;
@@ -843,10 +870,13 @@
if (strstr(token, "offset="))
sscanf(token, "offset=%i", ¶m_offset);
if (strstr(token, "single_page="))
sscanf(token, "single_page=%i", ¶m_single_page);
+
+ if(strstr(token, "all_read=1"))
+ param_all_read = 1;
if (strstr(token, "posts="))
{
int npost, res;
res = sscanf(token, "posts=%i", &npost);