diff options
Diffstat (limited to 'htc/dml.htc')
| -rw-r--r-- | htc/dml.htc | 382 |
1 files changed, 382 insertions, 0 deletions
diff --git a/htc/dml.htc b/htc/dml.htc new file mode 100644 index 0000000..9781952 --- /dev/null +++ b/htc/dml.htc | |||
| @@ -0,0 +1,382 @@ | |||
| 1 | \include{system.htc} | ||
| 2 | \include{html.htc} | ||
| 3 | \const{dml.address}{nobody} | ||
| 4 | \def{dml.init}{xxxx}{ | ||
| 5 | %{listname}{group}{path}{http} | ||
| 6 | \global{dml.listname}{\1} | ||
| 7 | \global{dml.group}{\2} | ||
| 8 | \global{dml.path}{\3} | ||
| 9 | \global{dml.http}{\4} | ||
| 10 | \if(count \dml.group){\open{DML}{\dml.path/data/dml.hdb}{1}} | ||
| 11 | } | ||
| 12 | \def{dml.mailuser}{xx}{ | ||
| 13 | \if{\user.id}{ | ||
| 14 | \log{mail user: \1} | ||
| 15 | \mail{\dml.address}{}{\user.email}{DML Server}{\now}{\1}{text/plain}{\2} | ||
| 16 | } | ||
| 17 | } | ||
| 18 | \def{dml.dfs}{xr}{ | ||
| 19 | \find.rec{\1}{ | ||
| 20 | \2; | ||
| 21 | \query(PARENT==\1){ | ||
| 22 | \dml.dfs(INDEX){\2} | ||
| 23 | } | ||
| 24 | } | ||
| 25 | } | ||
| 26 | \def{dml.bfs}{xr}{ | ||
| 27 | [cur:="";bfs:=\1]; | ||
| 28 | \while(count bfs){ | ||
| 29 | [cur=first bfs]; | ||
| 30 | \find.rec(cur){\2}; | ||
| 31 | \query(PARENT==cur)(bfs=bfs+++INDEX); | ||
| 32 | [bfs=rest bfs]; | ||
| 33 | } | ||
| 34 | } | ||
| 35 | \def{dml.ups}{xr}{ | ||
| 36 | [cur:=\1]; | ||
| 37 | \while(cur){ | ||
| 38 | \find.rec(cur){\2;[cur=PARENT]}(cur=0) | ||
| 39 | } | ||
| 40 | } | ||
| 41 | \def{dml.watchers}{}{ | ||
| 42 | \if(count \dml.group){ | ||
| 43 | [ | ||
| 44 | m.<-@; | ||
| 45 | break:=\dml.ups(m.INDEX){[BREAK] }; | ||
| 46 | attime:=\if(m.PROTECT)(m.TIME){\now}; | ||
| 47 | people:=\db{USERS}{\query(\allowed{\dml.group}(attime)){[UID] }} | ||
| 48 | ]; | ||
| 49 | [people---break]; | ||
| 50 | } | ||
| 51 | } | ||
| 52 | \def{dml.resubj}{x}{ | ||
| 53 | [tmp:=first \1];\if(tmp nen "re" && tmp nen "re:"){Re: \1}{\1} | ||
| 54 | } | ||
| 55 | \def{dml.opennode}{x}{ | ||
| 56 | \db{DML}{ | ||
| 57 | \dml.ups{\1}(BREAK=BREAK---\user.id); | ||
| 58 | \dml.confirm{Opening \dml.listname\[\1\]}; | ||
| 59 | } | ||
| 60 | } | ||
| 61 | \def{dml.closenode}{x}{ | ||
| 62 | \db{DML}{ | ||
| 63 | \find.rec{\1}{ | ||
| 64 | [BREAK=BREAK|||\user.id]; | ||
| 65 | \dml.confirm{Closing \dml.listname\[\1\]}; | ||
| 66 | } | ||
| 67 | } | ||
| 68 | } | ||
| 69 | \def{dml.addnode}{x}{ | ||
| 70 | %(node) - add to this node | ||
| 71 | %T.from - mail address | ||
| 72 | %T.reply - reply address | ||
| 73 | %T.name - user name | ||
| 74 | %T.subject - subject | ||
| 75 | %T.mime - MIME type | ||
| 76 | %T.body - message | ||
| 77 | %T.parts - attachments | ||
| 78 | %T.mime[i] - attachment MIME type | ||
| 79 | %T.body[i] - attachment body | ||
| 80 | %RETURN - node number | ||
| 81 | \db{DML}{ | ||
| 82 | [ | ||
| 83 | t.TIME:=\now; | ||
| 84 | t.PARENT:=\1; | ||
| 85 | t.AUTHOR:=\user.id; | ||
| 86 | t.MIME:=\T.mime; | ||
| 87 | t.SUBJECT:=\T.subject; | ||
| 88 | t.BODY:=\T.body; | ||
| 89 | t.INDEX:=\lastkey+1; | ||
| 90 | t.PROTECT:=1; | ||
| 91 | @<-t.; | ||
| 92 | ]; | ||
| 93 | \log{dml: adding \dml.listname\[[INDEX]\]}; | ||
| 94 | [t.INDEX]; | ||
| 95 | \for(i:=0)(i<\T.parts)(i+=1){ | ||
| 96 | [file:="A"++INDEX++"_"++\filesafe{\T.body[i]}]; | ||
| 97 | \log{dml: uploading \dml.listname\[[file]\]}; | ||
| 98 | \save{\dml.path/attach/[file]}{T.body[i]}{385}; | ||
| 99 | [ATTACH=ATTACH|||file]; | ||
| 100 | } | ||
| 101 | } | ||
| 102 | } | ||
| 103 | \def{dml.footer}{x}{ | ||
| 104 | \if(\1 eq "text/html"){<hr>}{----------------------------------------------} | ||
| 105 | Help: send email to \dml.address with subject 'help \dml.listname' | ||
| 106 | } | ||
| 107 | \def{dml.quickguide}{}{ | ||
| 108 | QUICK GUIDE | ||
| 109 | |||
| 110 | Mailing-lists on this server (\dml.address): | ||
| 111 | |||
| 112 | \getlists;[ex:=\dml.listname] | ||
| 113 | |||
| 114 | Mails received from the server ALWAYS starts with the listname | ||
| 115 | enclosed in stars (*). For example, | ||
| 116 | |||
| 117 | *[ex]\[7\]* hello world | ||
| 118 | |||
| 119 | means you've received a message from the list '[ex]' with | ||
| 120 | subject 'hello world'. The message is identified by its | ||
| 121 | message number, in this case 7. | ||
| 122 | |||
| 123 | EXAMPLES | ||
| 124 | |||
| 125 | To post a new message on '[ex]' with subject 'hello world', | ||
| 126 | mail to \dml.address with subject | ||
| 127 | |||
| 128 | new [ex] hello world | ||
| 129 | |||
| 130 | To post a new message on a particular message number, e.g. 7, | ||
| 131 | mail to \dml.address with subject | ||
| 132 | |||
| 133 | new [ex]\[7\] hello world | ||
| 134 | |||
| 135 | Note that message number 1 is the message root, and is the same | ||
| 136 | as issuing new without the \[\]. | ||
| 137 | |||
| 138 | To reply to a message from the list, use 'reply' in your mailing program, | ||
| 139 | but DO NOT REMOVE anything before the subject. The server will | ||
| 140 | insert the appropriate 'Re:'. For instance, replying to the first example | ||
| 141 | above would normally give a reply-subject in your mailprogram like | ||
| 142 | |||
| 143 | Re: *[ex]\[7\]* hello world | ||
| 144 | |||
| 145 | which will be sent from the server as | ||
| 146 | |||
| 147 | *[ex]\[n\]* Re: hello world | ||
| 148 | |||
| 149 | where n is some new number assigned to your message. | ||
| 150 | } | ||
| 151 | \def{dml.message}{}{ | ||
| 152 | HELP ON USAGE OF THE *\dml.listname* MAILING LIST AT \dml.address. | ||
| 153 | |||
| 154 | The address handles multiple mailinglists, and takes commands on the form: | ||
| 155 | |||
| 156 | <cmd> <list>\[<node>\] <subject> | ||
| 157 | or | ||
| 158 | <cmd> *<list>\[<node>\]* <subject> | ||
| 159 | |||
| 160 | where <cmd> is a command, <list> is a mailinglist, | ||
| 161 | <node> is a message number, and <subject> is the subject | ||
| 162 | line. The brackets \[\] should however be there as is. | ||
| 163 | |||
| 164 | Mailing-lists on this server (\dml.address): | ||
| 165 | |||
| 166 | \getlists | ||
| 167 | |||
| 168 | You are \user.name, and your user name at \dml.address | ||
| 169 | is \user.email. You may have clearance to several of | ||
| 170 | the lists above. | ||
| 171 | \if(\dml.listname eq "demo"){ | ||
| 172 | \n; | ||
| 173 | This is a demo mailing list and will not work to send mails to. | ||
| 174 | You will need to know the name of a list to which you belong. | ||
| 175 | } | ||
| 176 | Commands are not case sensitive. Available commands <cmd> are: | ||
| 177 | |||
| 178 | HELP \dml.listname | ||
| 179 | |||
| 180 | Displays this message. | ||
| 181 | |||
| 182 | WHO \dml.listname\[<node>\] | ||
| 183 | |||
| 184 | Retrieve which people are registered at the list. | ||
| 185 | If a node number is given, it tells which people | ||
| 186 | will receive a new message from that node. | ||
| 187 | Note that this command may be restricted on some lists. | ||
| 188 | |||
| 189 | SILENT \dml.listname\[<node>\] | ||
| 190 | |||
| 191 | Adds a new message to message number <node> on \dml.listname, | ||
| 192 | without broadcasting. | ||
| 193 | |||
| 194 | NEW \dml.listname\[<node>\] <subject> | ||
| 195 | |||
| 196 | Adds a new message to message number <node> on \dml.listname, | ||
| 197 | and broadcasts to \dml.listname. | ||
| 198 | |||
| 199 | REPLY \dml.listname\[<node>\] <subject> | ||
| 200 | |||
| 201 | Replies to message number <node> on \dml.listname. | ||
| 202 | Possible acronyms are Re, Re:, Sv, Sv:. | ||
| 203 | Note that this command is issued when you do | ||
| 204 | a normal reply, whether it be on a swedish or | ||
| 205 | american mail program. | ||
| 206 | |||
| 207 | OPEN \dml.listname\[<node>\] | ||
| 208 | |||
| 209 | Opens a <node>. When a <node> is open, you recieve | ||
| 210 | broadcast messages descending from that <node>. | ||
| 211 | |||
| 212 | CLOSE \dml.listname\[<node>\] | ||
| 213 | |||
| 214 | Closes a <node>. When a <node> is closed, you do not | ||
| 215 | recieve the broadcast messages descending from that <node>. | ||
| 216 | The obvious usage of this command is to turn off | ||
| 217 | uninteresting of lengthy threads. Also, since everything | ||
| 218 | added to this node will pass unnoticed, it may be used | ||
| 219 | to structure e.q. news in topics, together with the | ||
| 220 | SILENT command. | ||
| 221 | |||
| 222 | MAIL \dml.listname\[<node>\] | ||
| 223 | |||
| 224 | Retrieve message number <node> from \dml.listname. | ||
| 225 | This command may not serve certain messages on the basis of your | ||
| 226 | clearance and when you first entered the list. | ||
| 227 | |||
| 228 | \if(\dml.listname ne "demo"){ | ||
| 229 | To get additional help on how to use this system, how to | ||
| 230 | view or protect message trees, you may visit the | ||
| 231 | \dml.http/ web page. Of course the commands listed | ||
| 232 | above can be issued from there as well. You PIN code | ||
| 233 | at the server is \user.pin. | ||
| 234 | } | ||
| 235 | } | ||
| 236 | \def{dml.layout}{?xx}{ | ||
| 237 | [mime:=\on.arg{0}{\0}(MIME)]; | ||
| 238 | \2 | ||
| 239 | \if(ATTACH ne ""){ | ||
| 240 | \if(mime eq "text/html"){ | ||
| 241 | <hr> | ||
| 242 | Attachments (PIN: \su{\1}{\user.pin}) | ||
| 243 | \forall{i}(ATTACH){ | ||
| 244 | \href{\dml.http/attach/[i]?alias=\su{\1}{\user.alias}}(i)\n; | ||
| 245 | } | ||
| 246 | }{ | ||
| 247 | ---------------------------------------------- | ||
| 248 | Attachments (PIN: \su{\1}{\user.pin}) | ||
| 249 | \forall{i}(ATTACH){ | ||
| 250 | \dml.http/attach/[i]?alias=\su{\1}{\user.alias}\n; | ||
| 251 | } | ||
| 252 | } | ||
| 253 | }; | ||
| 254 | \dml.footer(mime) | ||
| 255 | } | ||
| 256 | \def{dml.error}{x}{ | ||
| 257 | %T.cmd | ||
| 258 | %T.list | ||
| 259 | %T.node | ||
| 260 | %T.subject | ||
| 261 | \mail.root{mailer: \1}{ | ||
| 262 | check <\T.cmd> \T.list\[\T.node\] \T.subject | ||
| 263 | }; | ||
| 264 | \dml.mailuser{error}{ | ||
| 265 | An error occurred while processing your command | ||
| 266 | |||
| 267 | \T.cmd \T.list\[\T.node\] \T.subject | ||
| 268 | |||
| 269 | \1 | ||
| 270 | ---------------------------------------------- | ||
| 271 | \dml.quickguide | ||
| 272 | \dml.footer(MIME) | ||
| 273 | } | ||
| 274 | } | ||
| 275 | \def{dml.help}{}{ | ||
| 276 | \dml.mailuser{help \dml.listname}{ | ||
| 277 | \dml.quickguide | ||
| 278 | |||
| 279 | ---------------------------------------------- | ||
| 280 | \dml.message | ||
| 281 | } | ||
| 282 | } | ||
| 283 | \def{dml.who}{x}{ | ||
| 284 | %(node) - mail this node to group | ||
| 285 | \db{DML}{ | ||
| 286 | \find.rec{\1}{ | ||
| 287 | \dml.mailuser{who \dml.listname}{ | ||
| 288 | PEOPLE LISTENING TO \dml.listname;\[\1\] at \dml.address | ||
| 289 | |||
| 290 | \forall{i}{\dml.watchers}{ | ||
| 291 | \su(i){\user.name <\user.email>}\n | ||
| 292 | } | ||
| 293 | } | ||
| 294 | }{ | ||
| 295 | \dml.error{Could not find node \dml.listname;\[\1\]} | ||
| 296 | } | ||
| 297 | } | ||
| 298 | } | ||
| 299 | \def{dml.confirm}{x}{ | ||
| 300 | %T.cmd | ||
| 301 | %T.list | ||
| 302 | %T.node | ||
| 303 | %T.subject | ||
| 304 | \dml.mailuser{\dml.listname: confirmation}{ | ||
| 305 | Your command | ||
| 306 | |||
| 307 | \1 | ||
| 308 | |||
| 309 | was processed sucessfully. | ||
| 310 | } | ||
| 311 | } | ||
| 312 | \def{dml.mail}{x}{ | ||
| 313 | %(node) - mail this node to user | ||
| 314 | \db{DML}{ | ||
| 315 | \find.rec{\1}{ | ||
| 316 | [attime:=\if(PROTECT)(TIME){\now}]; | ||
| 317 | \if{\user.allow{\dml.group}(attime)}{ | ||
| 318 | \log{dml: mailing \dml.listname\[[INDEX]\] to (\user.id)}; | ||
| 319 | \mail{\su(AUTHOR){\user.email}}{}{\user.email}{\su(AUTHOR){\user.name}} | ||
| 320 | (TIME){*\dml.listname\[[INDEX]\]* [SUBJECT]}(MIME){\dml.layout{\user.id}(BODY)}; | ||
| 321 | }{ | ||
| 322 | \log{dml: denying \dml.listname\[[INDEX]\] to (\user.id)}; | ||
| 323 | \dml.mailuser{\dml.listname\[[INDEX]\]: not found}{ | ||
| 324 | The node you requested could not be found | ||
| 325 | |||
| 326 | (or may be protected) | ||
| 327 | } | ||
| 328 | } | ||
| 329 | }{ | ||
| 330 | \dml.error{Could not find node \dml.listname;\[\1\]} | ||
| 331 | } | ||
| 332 | } | ||
| 333 | } | ||
| 334 | \def{dml.broadcast}{x}{ | ||
| 335 | %(node) - mail this node to group | ||
| 336 | \db{DML}{ | ||
| 337 | \find.rec{\1}{ | ||
| 338 | \if(!BROADCAST){ | ||
| 339 | \log{dml: broadcasting \dml.listname\[[INDEX]\]} | ||
| 340 | [ | ||
| 341 | femail:=\su(AUTHOR){\user.email}; | ||
| 342 | fname:=\su(AUTHOR){\user.name}; | ||
| 343 | fsubj:="*"++\dml.listname++"["++INDEX++"]* "++SUBJECT; | ||
| 344 | watchers:=\dml.watchers; | ||
| 345 | BROADCAST=count watchers; | ||
| 346 | ]; | ||
| 347 | \forall{i}(watchers){ | ||
| 348 | [ | ||
| 349 | temail:=\su(i){\user.email}; | ||
| 350 | talias:=\su(i){\user.alias}; | ||
| 351 | tname:=\su(i){\user.name}; | ||
| 352 | tpin:=\su(i){\user.pin}; | ||
| 353 | tbody:=\replace(BODY){\recipient.email}(temail); | ||
| 354 | tbody=\replace(tbody){\recipient.alias}(talias); | ||
| 355 | tbody=\replace(tbody){\recipient.name}(tname); | ||
| 356 | tbody=\replace(tbody){\recipient.pin}(tpin); | ||
| 357 | tbody=\replace(tbody){\recipient.id}(i); | ||
| 358 | ]; | ||
| 359 | \mail(femail){\dml.listname <\dml.address>}(temail)(fname) | ||
| 360 | (TIME)(fsubj)(MIME){\dml.layout(i)(tbody)}; | ||
| 361 | \sleep(2); | ||
| 362 | } | ||
| 363 | } | ||
| 364 | } | ||
| 365 | } | ||
| 366 | } | ||
| 367 | \def{dml.addbroad}{x}{ | ||
| 368 | [node:=\dml.addnode{\1}]; | ||
| 369 | \if(node){ | ||
| 370 | \dml.broadcast(node) | ||
| 371 | }{ | ||
| 372 | \dml.error{Could not add to \dml.listname;\[\1\]} | ||
| 373 | } | ||
| 374 | } | ||
| 375 | \def{dml.addsilent}{x}{ | ||
| 376 | [node:=\dml.addnode{\1}]; | ||
| 377 | \if(node){ | ||
| 378 | \dml.confirm{Added \dml.listname\[[node]\] to \dml.listname\[\1\]} | ||
| 379 | }{ | ||
| 380 | \dml.error{Could not add to \dml.listname;\[\1\]} | ||
| 381 | } | ||
| 382 | } | ||
