\include{system.htc}
\include{html.htc}
\const{dml.address}{nobody}
\def{dml.init}{xxxx}{
%{listname}{group}{path}{http}
\global{dml.listname}{\1}
\global{dml.group}{\2}
\global{dml.path}{\3}
\global{dml.http}{\4}
\if(count \dml.group){\open{DML}{\dml.path/data/dml.hdb}{1}}
}
\def{dml.mailuser}{xx}{
\if{\user.id}{
\log{mail user: \1}
\mail{\dml.address}{}{\user.email}{DML Server}{\now}{\1}{text/plain}{\2}
}
}
\def{dml.dfs}{xr}{
\find.rec{\1}{
\2;
\query(PARENT==\1){
\dml.dfs(INDEX){\2}
}
}
}
\def{dml.bfs}{xr}{
[cur:="";bfs:=\1];
\while(count bfs){
[cur=first bfs];
\find.rec(cur){\2};
\query(PARENT==cur)(bfs=bfs+++INDEX);
[bfs=rest bfs];
}
}
\def{dml.ups}{xr}{
[cur:=\1];
\while(cur){
\find.rec(cur){\2;[cur=PARENT]}(cur=0)
}
}
\def{dml.watchers}{}{
\if(count \dml.group){
[
m.<-@;
break:=\dml.ups(m.INDEX){[BREAK] };
attime:=\if(m.PROTECT)(m.TIME){\now};
people:=\db{USERS}{\query(\allowed{\dml.group}(attime)){[UID] }}
];
[people---break];
}
}
\def{dml.resubj}{x}{
[tmp:=first \1];\if(tmp nen "re" && tmp nen "re:"){Re: \1}{\1}
}
\def{dml.opennode}{x}{
\db{DML}{
\dml.ups{\1}(BREAK=BREAK---\user.id);
\dml.confirm{Opening \dml.listname\[\1\]};
}
}
\def{dml.closenode}{x}{
\db{DML}{
\find.rec{\1}{
[BREAK=BREAK|||\user.id];
\dml.confirm{Closing \dml.listname\[\1\]};
}
}
}
\def{dml.addnode}{x}{
%(node) - add to this node
%T.from - mail address
%T.reply - reply address
%T.name - user name
%T.subject - subject
%T.mime - MIME type
%T.body - message
%T.parts - attachments
%T.mime[i] - attachment MIME type
%T.body[i] - attachment body
%RETURN - node number
\db{DML}{
[
t.TIME:=\now;
t.PARENT:=\1;
t.AUTHOR:=\user.id;
t.MIME:=\T.mime;
t.SUBJECT:=\T.subject;
t.BODY:=\T.body;
t.INDEX:=\lastkey+1;
t.PROTECT:=1;
@<-t.;
];
\log{dml: adding \dml.listname\[[INDEX]\]};
[t.INDEX];
\for(i:=0)(i<\T.parts)(i+=1){
[file:="A"++INDEX++"_"++\filesafe{\T.body[i]}];
\log{dml: uploading \dml.listname\[[file]\]};
\save{\dml.path/attach/[file]}{T.body[i]}{385};
[ATTACH=ATTACH|||file];
}
}
}
\def{dml.footer}{x}{
\if(\1 eq "text/html"){
}{----------------------------------------------}
Help: send email to \dml.address with subject 'help \dml.listname'
}
\def{dml.quickguide}{}{
QUICK GUIDE
Mailing-lists on this server (\dml.address):
\getlists;[ex:=\dml.listname]
Mails received from the server ALWAYS starts with the listname
enclosed in stars (*). For example,
*[ex]\[7\]* hello world
means you've received a message from the list '[ex]' with
subject 'hello world'. The message is identified by its
message number, in this case 7.
EXAMPLES
To post a new message on '[ex]' with subject 'hello world',
mail to \dml.address with subject
new [ex] hello world
To post a new message on a particular message number, e.g. 7,
mail to \dml.address with subject
new [ex]\[7\] hello world
Note that message number 1 is the message root, and is the same
as issuing new without the \[\].
To reply to a message from the list, use 'reply' in your mailing program,
but DO NOT REMOVE anything before the subject. The server will
insert the appropriate 'Re:'. For instance, replying to the first example
above would normally give a reply-subject in your mailprogram like
Re: *[ex]\[7\]* hello world
which will be sent from the server as
*[ex]\[n\]* Re: hello world
where n is some new number assigned to your message.
}
\def{dml.message}{}{
HELP ON USAGE OF THE *\dml.listname* MAILING LIST AT \dml.address.
The address handles multiple mailinglists, and takes commands on the form:
\[\]
or
*\[\]*
where is a command, is a mailinglist,
is a message number, and is the subject
line. The brackets \[\] should however be there as is.
Mailing-lists on this server (\dml.address):
\getlists
You are \user.name, and your user name at \dml.address
is \user.email. You may have clearance to several of
the lists above.
\if(\dml.listname eq "demo"){
\n;
This is a demo mailing list and will not work to send mails to.
You will need to know the name of a list to which you belong.
}
Commands are not case sensitive. Available commands are:
HELP \dml.listname
Displays this message.
WHO \dml.listname\[\]
Retrieve which people are registered at the list.
If a node number is given, it tells which people
will receive a new message from that node.
Note that this command may be restricted on some lists.
SILENT \dml.listname\[\]
Adds a new message to message number on \dml.listname,
without broadcasting.
NEW \dml.listname\[\]
Adds a new message to message number on \dml.listname,
and broadcasts to \dml.listname.
REPLY \dml.listname\[\]
Replies to message number on \dml.listname.
Possible acronyms are Re, Re:, Sv, Sv:.
Note that this command is issued when you do
a normal reply, whether it be on a swedish or
american mail program.
OPEN \dml.listname\[\]
Opens a . When a is open, you recieve
broadcast messages descending from that .
CLOSE \dml.listname\[\]
Closes a . When a is closed, you do not
recieve the broadcast messages descending from that .
The obvious usage of this command is to turn off
uninteresting of lengthy threads. Also, since everything
added to this node will pass unnoticed, it may be used
to structure e.q. news in topics, together with the
SILENT command.
MAIL \dml.listname\[\]
Retrieve message number from \dml.listname.
This command may not serve certain messages on the basis of your
clearance and when you first entered the list.
\if(\dml.listname ne "demo"){
To get additional help on how to use this system, how to
view or protect message trees, you may visit the
\dml.http/ web page. Of course the commands listed
above can be issued from there as well. You PIN code
at the server is \user.pin.
}
}
\def{dml.layout}{?xx}{
[mime:=\on.arg{0}{\0}(MIME)];
\2
\if(ATTACH ne ""){
\if(mime eq "text/html"){
Attachments (PIN: \su{\1}{\user.pin})
\forall{i}(ATTACH){
\href{\dml.http/attach/[i]?alias=\su{\1}{\user.alias}}(i)\n;
}
}{
----------------------------------------------
Attachments (PIN: \su{\1}{\user.pin})
\forall{i}(ATTACH){
\dml.http/attach/[i]?alias=\su{\1}{\user.alias}\n;
}
}
};
\dml.footer(mime)
}
\def{dml.error}{x}{
%T.cmd
%T.list
%T.node
%T.subject
\mail.root{mailer: \1}{
check <\T.cmd> \T.list\[\T.node\] \T.subject
};
\dml.mailuser{error}{
An error occurred while processing your command
\T.cmd \T.list\[\T.node\] \T.subject
\1
----------------------------------------------
\dml.quickguide
\dml.footer(MIME)
}
}
\def{dml.help}{}{
\dml.mailuser{help \dml.listname}{
\dml.quickguide
----------------------------------------------
\dml.message
}
}
\def{dml.who}{x}{
%(node) - mail this node to group
\db{DML}{
\find.rec{\1}{
\dml.mailuser{who \dml.listname}{
PEOPLE LISTENING TO \dml.listname;\[\1\] at \dml.address
\forall{i}{\dml.watchers}{
\su(i){\user.name <\user.email>}\n
}
}
}{
\dml.error{Could not find node \dml.listname;\[\1\]}
}
}
}
\def{dml.confirm}{x}{
%T.cmd
%T.list
%T.node
%T.subject
\dml.mailuser{\dml.listname: confirmation}{
Your command
\1
was processed sucessfully.
}
}
\def{dml.mail}{x}{
%(node) - mail this node to user
\db{DML}{
\find.rec{\1}{
[attime:=\if(PROTECT)(TIME){\now}];
\if{\user.allow{\dml.group}(attime)}{
\log{dml: mailing \dml.listname\[[INDEX]\] to (\user.id)};
\mail{\su(AUTHOR){\user.email}}{}{\user.email}{\su(AUTHOR){\user.name}}
(TIME){*\dml.listname\[[INDEX]\]* [SUBJECT]}(MIME){\dml.layout{\user.id}(BODY)};
}{
\log{dml: denying \dml.listname\[[INDEX]\] to (\user.id)};
\dml.mailuser{\dml.listname\[[INDEX]\]: not found}{
The node you requested could not be found
(or may be protected)
}
}
}{
\dml.error{Could not find node \dml.listname;\[\1\]}
}
}
}
\def{dml.broadcast}{x}{
%(node) - mail this node to group
\db{DML}{
\find.rec{\1}{
\if(!BROADCAST){
\log{dml: broadcasting \dml.listname\[[INDEX]\]}
[
femail:=\su(AUTHOR){\user.email};
fname:=\su(AUTHOR){\user.name};
fsubj:="*"++\dml.listname++"["++INDEX++"]* "++SUBJECT;
watchers:=\dml.watchers;
BROADCAST=count watchers;
];
\forall{i}(watchers){
[
temail:=\su(i){\user.email};
talias:=\su(i){\user.alias};
tname:=\su(i){\user.name};
tpin:=\su(i){\user.pin};
tbody:=\replace(BODY){\recipient.email}(temail);
tbody=\replace(tbody){\recipient.alias}(talias);
tbody=\replace(tbody){\recipient.name}(tname);
tbody=\replace(tbody){\recipient.pin}(tpin);
tbody=\replace(tbody){\recipient.id}(i);
];
\mail(femail){\dml.listname <\dml.address>}(temail)(fname)
(TIME)(fsubj)(MIME){\dml.layout(i)(tbody)};
\sleep(2);
}
}
}
}
}
\def{dml.addbroad}{x}{
[node:=\dml.addnode{\1}];
\if(node){
\dml.broadcast(node)
}{
\dml.error{Could not add to \dml.listname;\[\1\]}
}
}
\def{dml.addsilent}{x}{
[node:=\dml.addnode{\1}];
\if(node){
\dml.confirm{Added \dml.listname\[[node]\] to \dml.listname\[\1\]}
}{
\dml.error{Could not add to \dml.listname;\[\1\]}
}
}