View/Edit #47:www_list

Switch to edit mode.

Name(s): www_list
1:  "Return a nice HTML table of mail messages."
2:  caller_perms().wizard || raise(E_PERM)
3:  {ng, seq, who} = args
4:  chunk = 41
5:  ret = {}
6:  if (typeof(seq) == $LIST)
7:    messages = ng:headers_in_seq(seq[1])
8:  else
9:    seq = $string_utils:substitute(seq, {{"%f", ng.name}, {"%<has>", "has"}, {"%%", "%"}})
10:   if (seq != ng.name + " has no messages.")
11:     ret = {@ret, @$msg:substitute($msg.msg_www_error, seq)}
12:   endif
13:   messages = {}
14: endif
15: if (!messages)
16:   return {@ret, "<P><I>[No messages]</I></P>"}
17: endif
18: "Build the table"
19: ret = {@ret, "<table border=0 cellpadding=3 cellspacing=0>", "<tr>", "  <th bgcolor='#cccccc'>&nbsp;</th><th align=left bgcolor='#cccccc'><font face=\"sans-serif\" size=2>Subject</font></th><th align=left bgcolor='#cccccc'><font face=\"sans-serif\" size=2>From</font></th><th align=left bgcolor='#cccccc'><font face=\"sans-serif\" size=2>Date</font></th>", "</tr>"}
20: for x in ($list_utils:reverse(messages))
21:   $command_utils:suspend_if_needed()
22:   msg = x[1]
23:   date = x[2][1]
24:   year = who:ctime(date)[21..24]
25:   if (who:ctime()[21..24] != year)
26:     date = who:ctime(date)[1..11] + year
27:   elseif (who:ctime()[1..10] != who:ctime(date)[1..10])
28:     date = who:ctime(date)[1..16]
29:   else
30:     date = who:ctime(date)[1..4] + who:ctime(date)[12..16]
31:   endif
32:   from = x[2][2]
33:   subj = $su:trim(x[2][4])
34:   if (!subj)
35:     subj = "[No Subject]"
36:   elseif (length(subj) > 40)
37:     subj = tostr(subj[1..37], "...")
38:   endif
39:   read = msg in ng:unread_messages(who)
40:   td1 = read ? "  <td><b><font face='sans-serif' size=2>" | "  <td><font face='sans-serif' size=2>"
41:   tdr = read ? "  <td align='right'><b><font face='sans-serif' size=2>" | "  <td align='right'><font face='sans-serif' size=2>"
42:   td2 = read ? "</font></b></td>" | "</font></td>"
43:   ret = {@ret, "<tr>"}
44:   ret = {@ret, tostr(tdr, msg, ":", td2)}
45:   ret = {@ret, tostr(td1, "<a href=\"", $mail_agent:www_link(ng, msg), "\">", subj, "</a>", td2)}
46:   ret = {@ret, tostr(td1, from, td2)}
47:   ret = {@ret, tostr(td1, date, td2)}
48:   ret = {@ret, "</tr>"}
49: endfor
50: ret = {@ret, "</table>"}
51: "Find out the neighbouring ranges."
52: prevlink = "<IMG SRC='" + $www:fileURL($mailer, "arrow-dn-dis.gif") + "' width=9 height=5 alt='v'>"
53: prevlink = prevlink + "<font color='#a9a9a9'>Previous messages</font>" + prevlink
54: nextlink = "<IMG SRC='" + $www:fileURL($mailer, "arrow-up-dis.gif") + "' width=9 height=5 alt='^' ALIGN='top'>"
55: nextlink = nextlink + "<font color='#a9a9a9'>Next messages</font>" + nextlink
56: if (typeof(seq) == $LIST && length(seq[1]) == 2)
57:   prev = ng:parse_message_seq(tostr("1..", seq[1][1]))
58:   if (typeof(prev) == $LIST)
59:     prev = ng:headers_in_seq(prev[1])
60:     if (length(prev) > chunk)
61:       prevlink = "<IMG SRC='" + $www:fileURL($mailer, "arrow-dn-sharp.gif") + "' width=9 height=5 alt='v' align='absbottom' border=0>"
62:       prevlink = tostr("<A HREF='/mail_agent?ng=", toint(ng), "&seq=", prev[$ - chunk + 1][1], "-", seq[1][1], "'>", prevlink, "Previous messages", prevlink, "</A>")
63:     elseif (length(prev) > 1)
64:       prevlink = "<IMG SRC='" + $www:fileURL($mailer, "arrow-dn-sharp.gif") + "' width=9 height=5 alt='v' align='absbottom' border=0>"
65:       prevlink = tostr("<A HREF='/mail_agent?ng=", toint(ng), "&seq=1-", seq[1][1], "'>", prevlink, "Previous messages", prevlink, "</A>")
66:     endif
67:   endif
68:   next = ng:parse_message_seq(tostr(seq[1][2] - 1, "..$"))
69:   if (typeof(next) == $LIST)
70:     next = ng:headers_in_seq(next[1])
71:     if (length(next) > chunk)
72:       nextlink = "<IMG SRC='" + $www:fileURL($mailer, "arrow-up-sharp.gif") + "' width=9 height=5 alt='^' align='top' border=0>"
73:       nextlink = tostr("<A HREF='/mail_agent?ng=", toint(ng), "&seq=", seq[1][2] - 1, "-", next[chunk][1], "'>", nextlink, "Next messages", nextlink, "</A>")
74:     elseif (length(next) > 1)
75:       nextlink = "<IMG SRC='" + $www:fileURL($mailer, "arrow-up-sharp.gif") + "' width=9 height=5 alt='^' align='top' border=0>"
76:       nextlink = tostr("<A HREF='/mail_agent?ng=", toint(ng), "&seq=", seq[1][2] - 1, "-$'>", nextlink, "Next messages", nextlink, "</A>")
77:     endif
78:   endif
79: endif
80: ret = {@ret, tostr("<P>", prevlink, " &nbsp; ", nextlink, "</P>")}
81: return ret
82: "Last modified by Dax (#789) on Tue May  3 14:09:30 2005 MDT."

Verb arguments: this none this
Verb perms: Readable eXecutable NOT-Debug
Verb owned by: Dax (#789)

You are not logged in.

[home | help | who | search | setup | code]