fix for empty message bases on www
This commit is contained in:
parent
999ec8871d
commit
9b20880e66
135
src/www_msgs.c
135
src/www_msgs.c
@ -134,79 +134,80 @@ char *www_msgs_messagelist(struct user_record *user, int conference, int area, i
|
|||||||
|
|
||||||
if (mhrs == NULL) {
|
if (mhrs == NULL) {
|
||||||
stralloc_cats(&page, "<h3>No Messages</h3>\n");
|
stralloc_cats(&page, "<h3>No Messages</h3>\n");
|
||||||
}
|
} else {
|
||||||
|
|
||||||
stralloc_cats(&page, "<div class=\"div-table\">\n");
|
stralloc_cats(&page, "<div class=\"div-table\">\n");
|
||||||
|
|
||||||
jb = open_jam_base(ma->path);
|
jb = open_jam_base(ma->path);
|
||||||
if (!jb) {
|
if (!jb) {
|
||||||
free(page.s);
|
free(page.s);
|
||||||
|
free_message_headers(mhrs);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
if (JAM_ReadLastRead(jb, user->id, &jlr) == JAM_NO_USER) {
|
||||||
|
jlr.LastReadMsg = 0;
|
||||||
|
jlr.HighReadMsg = 0;
|
||||||
|
}
|
||||||
|
JAM_CloseMB(jb);
|
||||||
|
free(jb);
|
||||||
|
skip_f = mhrs->msg_count - skip;
|
||||||
|
skip_t = mhrs->msg_count - skip - 50;
|
||||||
|
if (skip_t < 0) {
|
||||||
|
skip_t = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = skip_f - 1; i >= skip_t; i--) {
|
||||||
|
date = (time_t)mhrs->msgs[i]->msg_h->DateWritten;
|
||||||
|
gmtime_r(&date, &msg_date);
|
||||||
|
to = www_sanitize(mhrs->msgs[i]->to);
|
||||||
|
from = www_sanitize(mhrs->msgs[i]->from);
|
||||||
|
subject = www_sanitize(mhrs->msgs[i]->subject);
|
||||||
|
if (msgbase_is_flagged(user, conference, area, mhrs->msgs[i]->msg_h->MsgNum)) {
|
||||||
|
if (conf.date_style == 1) {
|
||||||
|
snprintf(buffer, sizeof buffer, "<div class=\"msg-summary-flag\"><div class=\"msg-summary-id\">%d</div><div class=\"msg-summary-subject\"><a href=\"%smsgs/%d/%d/%d\">%s</a></div><div class=\"msg-summary-from\">%s</div><div class=\"msg-summary-to\">%s</div><div class=\"msg-summary-date\">%.2d:%.2d %.2d-%.2d-%.2d</div></div>\n", mhrs->msgs[i]->msg_no + 1, conf.www_url, conference, area, mhrs->msgs[i]->msg_h->MsgNum, subject, from, to, msg_date.tm_hour, msg_date.tm_min, msg_date.tm_mon + 1, msg_date.tm_mday, msg_date.tm_year - 100);
|
||||||
|
} else {
|
||||||
|
snprintf(buffer, sizeof buffer, "<div class=\"msg-summary-flag\"><div class=\"msg-summary-id\">%d</div><div class=\"msg-summary-subject\"><a href=\"%smsgs/%d/%d/%d\">%s</a></div><div class=\"msg-summary-from\">%s</div><div class=\"msg-summary-to\">%s</div><div class=\"msg-summary-date\">%.2d:%.2d %.2d-%.2d-%.2d</div></div>\n", mhrs->msgs[i]->msg_no + 1, conf.www_url, conference, area, mhrs->msgs[i]->msg_h->MsgNum, subject, from, to, msg_date.tm_hour, msg_date.tm_min, msg_date.tm_mday, msg_date.tm_mon + 1, msg_date.tm_year - 100);
|
||||||
|
}
|
||||||
|
} else if (mhrs->msgs[i]->msg_h->MsgNum > jlr.HighReadMsg) {
|
||||||
|
if (conf.date_style == 1) {
|
||||||
|
snprintf(buffer, sizeof buffer, "<div class=\"msg-summary\"><div class=\"msg-summary-id\">%d</div><div class=\"msg-summary-subject\"><a href=\"%smsgs/%d/%d/%d\">%s</a></div><div class=\"msg-summary-from\">%s</div><div class=\"msg-summary-to\">%s</div><div class=\"msg-summary-date\">%.2d:%.2d %.2d-%.2d-%.2d</div></div>\n", mhrs->msgs[i]->msg_no + 1, conf.www_url, conference, area, mhrs->msgs[i]->msg_h->MsgNum, subject, from, to, msg_date.tm_hour, msg_date.tm_min, msg_date.tm_mon + 1, msg_date.tm_mday, msg_date.tm_year - 100);
|
||||||
|
} else {
|
||||||
|
snprintf(buffer, sizeof buffer, "<div class=\"msg-summary\"><div class=\"msg-summary-id\">%d</div><div class=\"msg-summary-subject\"><a href=\"%smsgs/%d/%d/%d\">%s</a></div><div class=\"msg-summary-from\">%s</div><div class=\"msg-summary-to\">%s</div><div class=\"msg-summary-date\">%.2d:%.2d %.2d-%.2d-%.2d</div></div>\n", mhrs->msgs[i]->msg_no + 1, conf.www_url, conference, area, mhrs->msgs[i]->msg_h->MsgNum, subject, from, to, msg_date.tm_hour, msg_date.tm_min, msg_date.tm_mday, msg_date.tm_mon + 1, msg_date.tm_year - 100);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (conf.date_style == 1) {
|
||||||
|
snprintf(buffer, sizeof buffer, "<div class=\"msg-summary-seen\"><div class=\"msg-summary-id\">%d</div><div class=\"msg-summary-subject\"><a href=\"%smsgs/%d/%d/%d\">%s</a></div><div class=\"msg-summary-from\">%s</div><div class=\"msg-summary-to\">%s</div><div class=\"msg-summary-date\">%.2d:%.2d %.2d-%.2d-%.2d</div></div>\n", mhrs->msgs[i]->msg_no + 1, conf.www_url, conference, area, mhrs->msgs[i]->msg_h->MsgNum, subject, from, to, msg_date.tm_hour, msg_date.tm_min, msg_date.tm_mon + 1, msg_date.tm_mday, msg_date.tm_year - 100);
|
||||||
|
} else {
|
||||||
|
snprintf(buffer, sizeof buffer, "<div class=\"msg-summary-seen\"><div class=\"msg-summary-id\">%d</div><div class=\"msg-summary-subject\"><a href=\"%smsgs/%d/%d/%d\">%s</a></div><div class=\"msg-summary-from\">%s</div><div class=\"msg-summary-to\">%s</div><div class=\"msg-summary-date\">%.2d:%.2d %.2d-%.2d-%.2d</div></div>\n", mhrs->msgs[i]->msg_no + 1, conf.www_url, conference, area, mhrs->msgs[i]->msg_h->MsgNum, subject, from, to, msg_date.tm_hour, msg_date.tm_min, msg_date.tm_mday, msg_date.tm_mon + 1, msg_date.tm_year - 100);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
free(to);
|
||||||
|
free(from);
|
||||||
|
free(subject);
|
||||||
|
|
||||||
|
stralloc_cats(&page, buffer);
|
||||||
|
}
|
||||||
|
stralloc_cats(&page, "</div>\n");
|
||||||
|
if (skip + 50 <= mhrs->msg_count) {
|
||||||
|
snprintf(buffer, sizeof buffer,
|
||||||
|
"<div class=\"msg-summary-next\"><a href=\"%smsgs/%d/%d/?skip=%d\">Next</a></div>\n",
|
||||||
|
conf.www_url, conference, area, skip + 50);
|
||||||
|
stralloc_cats(&page, buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (skip > 0) {
|
||||||
|
if (skip - 50 < 0) {
|
||||||
|
snprintf(buffer, sizeof buffer, "<div class=\"msg-summary-prev\"><a href=\"%smsgs/%d/%d/\">Prev</a></div>\n", conf.www_url, conference, area);
|
||||||
|
} else {
|
||||||
|
snprintf(buffer, sizeof buffer, "<div class=\"msg-summary-prev\"><a href=\"%smsgs/%d/%d/?skip=%d\">Prev</a></div>\n", conf.www_url, conference, area, skip - 50);
|
||||||
|
}
|
||||||
|
stralloc_cats(&page, buffer);
|
||||||
|
}
|
||||||
free_message_headers(mhrs);
|
free_message_headers(mhrs);
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
if (JAM_ReadLastRead(jb, user->id, &jlr) == JAM_NO_USER) {
|
|
||||||
jlr.LastReadMsg = 0;
|
|
||||||
jlr.HighReadMsg = 0;
|
|
||||||
}
|
|
||||||
JAM_CloseMB(jb);
|
|
||||||
free(jb);
|
|
||||||
skip_f = mhrs->msg_count - skip;
|
|
||||||
skip_t = mhrs->msg_count - skip - 50;
|
|
||||||
if (skip_t < 0) {
|
|
||||||
skip_t = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = skip_f - 1; i >= skip_t; i--) {
|
|
||||||
date = (time_t)mhrs->msgs[i]->msg_h->DateWritten;
|
|
||||||
gmtime_r(&date, &msg_date);
|
|
||||||
to = www_sanitize(mhrs->msgs[i]->to);
|
|
||||||
from = www_sanitize(mhrs->msgs[i]->from);
|
|
||||||
subject = www_sanitize(mhrs->msgs[i]->subject);
|
|
||||||
if (msgbase_is_flagged(user, conference, area, mhrs->msgs[i]->msg_h->MsgNum)) {
|
|
||||||
if (conf.date_style == 1) {
|
|
||||||
snprintf(buffer, sizeof buffer, "<div class=\"msg-summary-flag\"><div class=\"msg-summary-id\">%d</div><div class=\"msg-summary-subject\"><a href=\"%smsgs/%d/%d/%d\">%s</a></div><div class=\"msg-summary-from\">%s</div><div class=\"msg-summary-to\">%s</div><div class=\"msg-summary-date\">%.2d:%.2d %.2d-%.2d-%.2d</div></div>\n", mhrs->msgs[i]->msg_no + 1, conf.www_url, conference, area, mhrs->msgs[i]->msg_h->MsgNum, subject, from, to, msg_date.tm_hour, msg_date.tm_min, msg_date.tm_mon + 1, msg_date.tm_mday, msg_date.tm_year - 100);
|
|
||||||
} else {
|
|
||||||
snprintf(buffer, sizeof buffer, "<div class=\"msg-summary-flag\"><div class=\"msg-summary-id\">%d</div><div class=\"msg-summary-subject\"><a href=\"%smsgs/%d/%d/%d\">%s</a></div><div class=\"msg-summary-from\">%s</div><div class=\"msg-summary-to\">%s</div><div class=\"msg-summary-date\">%.2d:%.2d %.2d-%.2d-%.2d</div></div>\n", mhrs->msgs[i]->msg_no + 1, conf.www_url, conference, area, mhrs->msgs[i]->msg_h->MsgNum, subject, from, to, msg_date.tm_hour, msg_date.tm_min, msg_date.tm_mday, msg_date.tm_mon + 1, msg_date.tm_year - 100);
|
|
||||||
}
|
|
||||||
} else if (mhrs->msgs[i]->msg_h->MsgNum > jlr.HighReadMsg) {
|
|
||||||
if (conf.date_style == 1) {
|
|
||||||
snprintf(buffer, sizeof buffer, "<div class=\"msg-summary\"><div class=\"msg-summary-id\">%d</div><div class=\"msg-summary-subject\"><a href=\"%smsgs/%d/%d/%d\">%s</a></div><div class=\"msg-summary-from\">%s</div><div class=\"msg-summary-to\">%s</div><div class=\"msg-summary-date\">%.2d:%.2d %.2d-%.2d-%.2d</div></div>\n", mhrs->msgs[i]->msg_no + 1, conf.www_url, conference, area, mhrs->msgs[i]->msg_h->MsgNum, subject, from, to, msg_date.tm_hour, msg_date.tm_min, msg_date.tm_mon + 1, msg_date.tm_mday, msg_date.tm_year - 100);
|
|
||||||
} else {
|
|
||||||
snprintf(buffer, sizeof buffer, "<div class=\"msg-summary\"><div class=\"msg-summary-id\">%d</div><div class=\"msg-summary-subject\"><a href=\"%smsgs/%d/%d/%d\">%s</a></div><div class=\"msg-summary-from\">%s</div><div class=\"msg-summary-to\">%s</div><div class=\"msg-summary-date\">%.2d:%.2d %.2d-%.2d-%.2d</div></div>\n", mhrs->msgs[i]->msg_no + 1, conf.www_url, conference, area, mhrs->msgs[i]->msg_h->MsgNum, subject, from, to, msg_date.tm_hour, msg_date.tm_min, msg_date.tm_mday, msg_date.tm_mon + 1, msg_date.tm_year - 100);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (conf.date_style == 1) {
|
|
||||||
snprintf(buffer, sizeof buffer, "<div class=\"msg-summary-seen\"><div class=\"msg-summary-id\">%d</div><div class=\"msg-summary-subject\"><a href=\"%smsgs/%d/%d/%d\">%s</a></div><div class=\"msg-summary-from\">%s</div><div class=\"msg-summary-to\">%s</div><div class=\"msg-summary-date\">%.2d:%.2d %.2d-%.2d-%.2d</div></div>\n", mhrs->msgs[i]->msg_no + 1, conf.www_url, conference, area, mhrs->msgs[i]->msg_h->MsgNum, subject, from, to, msg_date.tm_hour, msg_date.tm_min, msg_date.tm_mon + 1, msg_date.tm_mday, msg_date.tm_year - 100);
|
|
||||||
} else {
|
|
||||||
snprintf(buffer, sizeof buffer, "<div class=\"msg-summary-seen\"><div class=\"msg-summary-id\">%d</div><div class=\"msg-summary-subject\"><a href=\"%smsgs/%d/%d/%d\">%s</a></div><div class=\"msg-summary-from\">%s</div><div class=\"msg-summary-to\">%s</div><div class=\"msg-summary-date\">%.2d:%.2d %.2d-%.2d-%.2d</div></div>\n", mhrs->msgs[i]->msg_no + 1, conf.www_url, conference, area, mhrs->msgs[i]->msg_h->MsgNum, subject, from, to, msg_date.tm_hour, msg_date.tm_min, msg_date.tm_mday, msg_date.tm_mon + 1, msg_date.tm_year - 100);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
free(to);
|
|
||||||
free(from);
|
|
||||||
free(subject);
|
|
||||||
|
|
||||||
stralloc_cats(&page, buffer);
|
|
||||||
}
|
|
||||||
stralloc_cats(&page, "</div>\n");
|
|
||||||
if (skip + 50 <= mhrs->msg_count) {
|
|
||||||
snprintf(buffer, sizeof buffer,
|
|
||||||
"<div class=\"msg-summary-next\"><a href=\"%smsgs/%d/%d/?skip=%d\">Next</a></div>\n",
|
|
||||||
conf.www_url, conference, area, skip + 50);
|
|
||||||
stralloc_cats(&page, buffer);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (skip > 0) {
|
|
||||||
if (skip - 50 < 0) {
|
|
||||||
snprintf(buffer, sizeof buffer, "<div class=\"msg-summary-prev\"><a href=\"%smsgs/%d/%d/\">Prev</a></div>\n", conf.www_url, conference, area);
|
|
||||||
} else {
|
|
||||||
snprintf(buffer, sizeof buffer, "<div class=\"msg-summary-prev\"><a href=\"%smsgs/%d/%d/?skip=%d\">Prev</a></div>\n", conf.www_url, conference, area, skip - 50);
|
|
||||||
}
|
|
||||||
stralloc_cats(&page, buffer);
|
|
||||||
}
|
}
|
||||||
stralloc_0(&page);
|
stralloc_0(&page);
|
||||||
|
|
||||||
free_message_headers(mhrs);
|
|
||||||
return page.s;
|
return page.s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user