Subject: Developers of Sympa
List archive
- From: Giorgio Donnini <address@concealed>
- To: address@concealed
- Subject: [sympa-dev] mysql scenario
- Date: Wed, 29 Dec 2004 17:23:58 +0100 (CET)
Hello,
I'm from University of Milan, we've been using sympa with
satisfaction for more than two years, and just from the beginning we
had the need for a more complex send scenario.
We had mailing lists with two kind of senders, people who could
freely send to the list and people who need an editor authorization.
This could be accomplished by a scenario like
search(auth.ldap,[sender]) md5,smime -> do_it,notify
search(auth.ldap,[sender]) smtp -> request_auth
search(request.ldap,[sender]) md5,smime,smtp -> editor
true() smtp,smime,md5 -> reject
But there where two problems: first of all we should create a filter and
an attribute for each list, but also we had many email addresses with
domain extraneous to our ldap, and that would mean adding spurious
branches to it.
So we added a filter scenario
searchsql(list,sender,kind)
which make a sqlsearch in a table for the list, the sender and the
kind of permission this way:
select count(*) from LIST_AUTH where LIST_SUBSCRIBER='list',
SENDER_SUBSCRIBER='sender', IS_AUTH='kind';
so our scenario became
searchsql([listname],[sender],Y) md5,smime -> do_it
searchsql([listname],[sender],Y) smtp -> request_auth
searchsql([listname],[sender],M) smtp,smime,md5 -> editor
true() smtp,smime,md5 -> reject
And the maintenance of the people allowed to send was kept in mysql
table.
The modification are just in List.pm, and are very few (see the diff file
in attachment).
Is anyone interested in this feature or is it possible to add it to the
main source of sympa?
Best Regards
Giorgio Donnini
diff -e List.pm Listnew.pm
4745a
## Verify if a given user is part of an sql search filter
sub searchsql{
my $list=shift;
my $sender=shift;
my $condition=shift;
&do_log('debug2', 'List::searchsql(%s,%s,%s)', $list, $sender,
$condition);
## Check database connection
unless ($dbh and $dbh->ping) {
return undef unless &db_connect();
}
my $sql_query = "SELECT count(*) from list_auth where list_subscriber=? and
sender_auth=? and is_auth=?";
unless ($sth = $dbh->prepare($sql_query)) {
do_log('notice','Unable to prepare SQL query : %s', $dbh->errstr);
return undef;
}
unless ($sth->execute($list,$sender,$condition)) {
do_log('notice','Unable to perform SQL query %s : %s ',$sql_query,
$dbh->errstr);
return undef;
}
## Counters.
my $total_first = 0;
## Process the SQL results
return $sth->fetchrow;
}
.
4643a
##searchsql
if ($condition_key eq 'searchsql') {
my $val_search_sql = &searchsql($args[0],$args[1],$args[2]);
if($val_search_sql == 1) {
return $negation;
}else {
return -1 * $negation;
}
}
.
4528c
}elsif ($condition_key =~ /^searchsql$/i){
unless ($#args == 2) {
do_log('err',"error rule syntaxe : incorrect argument number for
condition $condition_key") ;
return undef ;
}
}else{
.
4377c
unless ($condition =~
/(\!)?\s*(true|is_listmaster|is_editor|is_owner|is_subscriber|match|equal|message|older|newer|all|search|searchsql)\s*\(\s*(.*)\s*\)\s*/i)
{
.
- [sympa-dev] mysql scenario, Giorgio Donnini, 12/29/2004
Archive powered by MHonArc 2.6.19+.