Index: [Article Count Order] [Thread]

Date:  Sat, 10 May 2008 02:39:20 +0200
From:  Rickard Osser <rickard.osser (at mark) bluapp.com>
Subject:  [coba-e:12786] [PATCH] Changes maillist advanced options to handle multiple	administrators
To:  coba-e (at mark) bluequartz.org
Message-Id:  <1210379960.18242.0.camel (at mark) dragon.home.osser.se>
X-Mail-Count: 12786

Hi!

Here's a patch to the base-maillist.mod to make it possible to have
multiple administrators as well as adding another policy restricting
posting to those administrators as well. This is a very good expansion
for us who need to send out 1-way information and don't want the
recipients to be able to send mail to the list.

Best regards,

Rickard Osser

PATCH:
diff -ur org/base-maillist.mod/glue/handlers/listmod_aliases
base-maillist.mod/glue/handlers/listmod_aliases
--- org/base-maillist.mod/glue/handlers/listmod_aliases	2008-05-10
01:53:06.026005304 +0200
+++ base-maillist.mod/glue/handlers/listmod_aliases	2008-05-09
15:38:56.103045104 +0200
@@ -35,16 +35,18 @@
 my $Majordomo_dir = $Majordomo_real.'/sites/'.$vsite_obj->{name};
 $Majordomo_dir ||= $Majordomo_real;
 
-my $mod = $obj->{moderator};
-if ($mod !~ m/\@/) {
-	if (!getpwnam($mod)) {
-		$cce->baddata(0, 'moderator', 'Moderator-does-not-exist',
{ 'moderator' => $mod });
-		$cce->warn('Could-not-create-maillist');
-		$cce->bye('FAIL');
-		exit(1);
+my @mod = CCE->scalar_to_array($obj->{moderator});
+
+for(my $i = 0; $i < scalar(@mod); $i++) {
+    if ($mod[$i] !~ m/\@/) {
+	if (!getpwnam($mod[$i])) {
+	    $cce->baddata(0, 'moderator', 'Moderator-does-not-exist',
{ 'moderator' => $mod[$i] });
+	    $cce->warn('Could-not-create-maillist');
+	    $cce->bye('FAIL');
+	    exit(1);
 	}
+    }
 }
-
 # create aliases:
 # extract information about the list...
 my $list_external = $obj->{name};
diff -ur org/base-maillist.mod/glue/handlers/MailList.pm
base-maillist.mod/glue/handlers/MailList.pm
--- org/base-maillist.mod/glue/handlers/MailList.pm	2008-05-10
01:53:05.979012448 +0200
+++ base-maillist.mod/glue/handlers/MailList.pm	2008-05-10
01:54:43.925122376 +0200
@@ -138,16 +138,32 @@
   # configure posting policy
   $_ = $obj->{postPolicy};
   if (m/moderated/) {
-    my $mod = $obj->{moderator} || 'admin';
-    push (@data,
-      "moderate = yes",
-      "moderator = $mod",
-      );
+      my @mod = CCE->scalar_to_array($obj->{moderator});
+      my $moderators = "";
+      for(my $i = 0; $i < scalar(@mod)-1; $i++) {
+	  if($i eq 0) {
+	      $moderators = $mod[$i];
+	  } else {
+	      $moderators = "$moderators," . $mod[$i];
+	  }
+      }
+      push (@data,
+	    "moderate = yes",
+	    "moderator = $moderators",
+	    );
   }
   elsif (m/any/) {
   	# do nothing
 	push ( (at mark) data, "restrict_post = "); # majordomo needs this. :-b
   }  
+  elsif (m/admin/) {
+  	# policy = Only admins can post
+	my $str = "restrict_post = $obj->{name}.administrator";
+	if ($obj->{group}) {
+	  $str .= ':/etc/group.d/' . $obj->{group};
+	}
+    	push (@data, $str);
+  }  
   else {
   	# policy = members
 	my $str = "restrict_post = $obj->{name}:$obj->{name}.administrator";
@@ -195,17 +211,20 @@
 
   # update the admin file
   {
-  	my $fn = $listfile.".administrator";
-	my $mod = $obj->{moderator} || "";
-	Sauce::Util::editfile( $fn, 
-		sub { 
-			my ($fin, $fout) = (shift, shift);
-			print $fout $mod,"\n"; 
-		} );
-	Sauce::Util::chownfile($Majordomo_uid, $Majordomo_gid, $fn);
-	Sauce::Util::chmodfile(0640, $fn);
+      my $fn = $listfile.".administrator";
+      my @mod = CCE->scalar_to_array($obj->{moderator});
+      for(my $i = 0; $i < scalar(@mod)-1; $i++) {
+	  $moderators = $moderators . $mod[$i]."\n";
+      }
+      Sauce::Util::editfile( $fn, 
+			     sub { 
+				 my ($fin, $fout) = (shift, shift);
+				 print $fout $moderators;
+			     } );
+      Sauce::Util::chownfile($Majordomo_uid, $Majordomo_gid, $fn);
+      Sauce::Util::chmodfile(0640, $fn);
   };
-
+  
   return $ret;
 }
 
diff -ur org/base-maillist.mod/glue/schemas/MailList.schema
base-maillist.mod/glue/schemas/MailList.schema
--- org/base-maillist.mod/glue/schemas/MailList.schema	2008-05-10
01:53:05.840033576 +0200
+++ base-maillist.mod/glue/schemas/MailList.schema	2008-05-09
15:53:39.577736536 +0200
@@ -28,7 +28,7 @@
 <!-- FIXME: these should be enums eventually -->
 <typedef 
     name="postPolicy" type="re" 
-    data="^((moderated)|(any)|(members))?$" 
+    data="^((moderated)|(any)|(members)|(admin))?$" 
 />
 <typedef 
     name="subPolicy" type="re"
@@ -71,7 +71,7 @@
         writeacl="ruleCapable(adminUser) OR ( ruleCapable(siteAdmin)
AND ruleMailingLists )"
     />
     <property 
-        name="moderator" type="scalar" default="admin"
+        name="moderator" type="scalar" array="true" default="admin"
         writeacl="ruleCapable(adminUser) OR ( ruleCapable(siteAdmin)
AND ruleMailingLists )"
     />
     <property 
diff -ur org/base-maillist.mod/locale/en/maillist.po
base-maillist.mod/locale/en/maillist.po
--- org/base-maillist.mod/locale/en/maillist.po	2008-05-10
01:53:05.594070968 +0200
+++ base-maillist.mod/locale/en/maillist.po	2008-05-10
01:46:02.903329728 +0200
@@ -258,6 +273,9 @@
 msgid "moderated"
 msgstr "Moderator Confirms All Messages"
 
+msgid "admin"
+msgstr "Only Administrators Can Post Messages"
+
 msgid "subscriptionPolicy"
 msgstr "Subscription Policy"
 
diff -ur org/base-maillist.mod/Makefile base-maillist.mod/Makefile
--- org/base-maillist.mod/Makefile	2008-05-10 01:53:05.789041328 +0200
+++ base-maillist.mod/Makefile	2008-05-09 14:05:50.780143248 +0200
@@ -5,8 +5,8 @@
 SERVICE=maillist
 
 # MAJVERSION is 0 until alpha release.
-VERSION=1.4.0
-RELEASE=68BQ14
+VERSION=1.5.0
+RELEASE=69BQ1
 
 INSTALL=install
 
diff -ur org/base-maillist.mod/ui/web/maillistMod.php
base-maillist.mod/ui/web/maillistMod.php
--- org/base-maillist.mod/ui/web/maillistMod.php	2008-05-10
01:53:06.085996184 +0200
+++ base-maillist.mod/ui/web/maillistMod.php	2008-05-09
14:56:40.906453568 +0200
@@ -132,6 +132,14 @@
     
     $remote_recips = arrayToString($a);
   }
+  if ($moderator) {
+    $a = stringToArray($moderator);
+    //uniqify
+    $b = array_flip($a);
+    $a = array_keys($b);
+    
+    $moderator = arrayToString($a);
+  }
 
   $vals = array('name' => $listName,
 		'apassword' => $apassword,
@@ -265,11 +273,14 @@
 
   //advanced page
   if (!$moderator) {
-    $moderator = "admin";
+    $moderators = "admin";
+  } else {
+    $moderators = $factory->getEmailAddressList("moderator",
$moderator);
   }
-  $block->addFormField($factory->getEmailAddress("moderator",
$moderator),
+  $block->addFormField($moderators,
 		       $factory->getLabel("moderator"),
 		       $advancedId);
+
   $pass = $factory->getPassword("apassword", $apassword, false);
   $pass->setOptional("silent");
   $block->addFormField($pass,
@@ -285,6 +296,7 @@
   $posting->addOption($factory->getOption("members"));
   $posting->addOption($factory->getOption("any"));
   $posting->addOption($factory->getOption("moderated"));
+  $posting->addOption($factory->getOption("admin"));
   $posting->setSelected($postPolicy, true);
   $block->addFormField($posting,
 		       $factory->getLabel("postingPolicy"),




-- 
Rickard Osser
Manager
-----------------------------------------------------------------------
| Osser Lindist AB            | Swedens No 1 distributor of Linux     |
|                             | and Linux related products!           |
-----------------------------------------------------------------------
| Osser Brosoft AB            | Computer Consultants                  |
-----------------------------------------------------------------------
| Solberga Ängsväg 3          | S-125 44 Älvsjö, Sweden               |
| Tel: +46-8-669 75 75        | E-mail: rickard.osser (at mark)  (at mark) lindist.se     |
| Fax: +46-8-668 89 10        | http://www.lindist.se                 |
-----------------------------------------------------------------------

	

12786_2.x-patch (attatchment)(tag is disabled)