[Fusionforge-commits] r7617 - in trunk/gforge: common/include common/mail deb-specific www/mail/admin

Roland Mas lolando at libremir.placard.fr.eu.org
Wed May 6 17:11:26 CEST 2009


Author: lolando
Date: 2009-05-06 17:11:26 +0200 (Wed, 06 May 2009)
New Revision: 7617

Modified:
   trunk/gforge/common/include/constants.php
   trunk/gforge/common/mail/MailingList.class.php
   trunk/gforge/deb-specific/create-mailing-lists.pl
   trunk/gforge/www/mail/admin/index.php
Log:
New feature for project admins: reset mailing-list password

Modified: trunk/gforge/common/include/constants.php
===================================================================
--- trunk/gforge/common/include/constants.php	2009-05-06 10:17:17 UTC (rev 7616)
+++ trunk/gforge/common/include/constants.php	2009-05-06 15:11:26 UTC (rev 7617)
@@ -60,6 +60,8 @@
 
 define('MAIL__MAILING_LIST_IS_REQUESTED', '1');
 define('MAIL__MAILING_LIST_IS_CREATED', '2');
+define('MAIL__MAILING_LIST_IS_CONFIGURED', '3');
+define('MAIL__MAILING_LIST_PW_RESET_REQUESTED', '4');
 
 define('MAIL__MAILING_LIST_NAME_MIN_LENGTH', 4);
 

Modified: trunk/gforge/common/mail/MailingList.class.php
===================================================================
--- trunk/gforge/common/mail/MailingList.class.php	2009-05-06 10:17:17 UTC (rev 7616)
+++ trunk/gforge/common/mail/MailingList.class.php	2009-05-06 15:11:26 UTC (rev 7617)
@@ -229,16 +229,21 @@
 	 *	@param	int	Pass (1) if it should be public (0) for private
 	 *	@return	boolean	success.
 	 */
-	function update($description, $isPublic = MAIL__MAILING_LIST_IS_PUBLIC) {
+	function update($description, $isPublic = MAIL__MAILING_LIST_IS_PUBLIC, $status = 'xyzzy') {
 		if(! $this->userIsAdmin()) {
 			$this->setPermissionDeniedError();
 			return false;
 		}
+
+		if ($status == 'xyzzy') {
+			$status = $this->getStatus();
+		}
 		
-		$res = db_query_params ('UPDATE mail_group_list SET is_public=$1, description=$2
-			                 WHERE group_list_id=$3 AND group_id=$4',
+		$res = db_query_params ('UPDATE mail_group_list SET is_public=$1, description=$2, status=$3
+			                 WHERE group_list_id=$4 AND group_id=$5',
 					array ($isPublic,
 					       $description,
+					       $status,
 					       $this->groupMailingListId,
 					       $this->Group->getID())) ;
 		

Modified: trunk/gforge/deb-specific/create-mailing-lists.pl
===================================================================
--- trunk/gforge/deb-specific/create-mailing-lists.pl	2009-05-06 10:17:17 UTC (rev 7616)
+++ trunk/gforge/deb-specific/create-mailing-lists.pl	2009-05-06 15:11:26 UTC (rev 7617)
@@ -98,6 +98,40 @@
 	#debug "Committing." ;
 	$dbh->commit () ;
     }
+
+    $query = "SELECT mail_group_list.group_list_id,
+                     mail_group_list.list_name,
+                     users.user_name,
+                     mail_group_list.password,
+                     mail_group_list.description,
+                     mail_group_list.is_public
+              FROM mail_group_list, users
+              WHERE mail_group_list.status = 4
+                    AND mail_group_list.list_admin = users.user_id" ; # Status = 4: password reset requested
+    $sth = $dbh->prepare ($query) ;
+    $sth->execute () ;
+    while (my @myarray = $sth->fetchrow_array ()) {
+	push @lines, \@myarray ;
+    }
+    $sth->finish () ;
+
+    foreach $line (@lines) {
+	@array = @{$line} ;
+	my ($group_list_id, $listname, $user_name, $password, $description, $is_public) ;
+	my ($tmp) ;
+
+	($group_list_id, $listname, $user_name, $password, $description, $is_public)= @array ;
+	my $cmd = "/usr/lib/mailman/bin/change_pw -l $listname >/dev/null 2>&1" ;
+	system ($cmd) ;
+
+	$query = "UPDATE mail_group_list SET status = 3 where group_list_id = group_list_id" ; # Status = 3: list configured on Mailman
+	$sth = $dbh->prepare ($query) ;
+	$sth->execute () ;
+	$sth->finish () ;
+
+	#debug "Committing." ;
+	$dbh->commit () ;
+    }
     
     # There should be a commit at the end of every block above.
     # If there is not, then it might be symptomatic of a problem.

Modified: trunk/gforge/www/mail/admin/index.php
===================================================================
--- trunk/gforge/www/mail/admin/index.php	2009-05-06 10:17:17 UTC (rev 7616)
+++ trunk/gforge/www/mail/admin/index.php	2009-05-06 15:11:26 UTC (rev 7617)
@@ -30,9 +30,9 @@
 		exit_permission_denied();
 	}
 	
-//
-//	Post Changes to database
-//
+	//
+	//	Post Changes to database
+	//
 	if (getStringFromRequest('post_changes') == 'y') {
 		//
 		//	Add list
@@ -82,9 +82,34 @@
 				$feedback .= _('List updated');
 			}
 		}
+	}
 
+	//
+	//	Reset admin password
+	//
+	if (getIntFromRequest('reset_pw') == 1) {
+		$mailingList = new MailingList($Group, getIntFromGet('group_list_id'));
+		
+		if(!$mailingList || !is_object($mailingList)) {
+			exit_error(_('Error'), _('Error getting the list'));
+		} elseif($mailingList->isError()) {
+			exit_error(_('Error'), $mailingList->getErrorMessage());
+		}
+		
+		if($mailingList->getStatus() == MAIL__MAILING_LIST_IS_CONFIGURED) {
+			if(!$mailingList->update(
+				   $mailingList->getDescription(),
+				   $mailingList->isPublic(),
+				   MAIL__MAILING_LIST_PW_RESET_REQUESTED
+				   )) {
+				exit_error(_('Error'), $mailingList->getErrorMessage());
+			} else {
+				$feedback .= _('Password reset requested');
+			}
+		}
 	}
 
+
 //
 //	Form to add list
 //
@@ -214,26 +239,32 @@
 			$tableHeaders = array(
 				_('Mailing list'),
 				'',
+				'',
 				''
 			);
 			echo $HTML->listTableTop($tableHeaders);
 			for ($i = 0; $i < $mlCount; $i++) {
 				$currentList =& $mlArray[$i];
 				if ($currentList->isError()) {
-					echo '<tr '. $HTML->boxGetAltRowStyle($i) .'><td colspan="3">';
+					echo '<tr '. $HTML->boxGetAltRowStyle($i) .'><td colspan="4">';
 					echo $currentList->getErrorMessage();
 					echo '</td></tr>';
 				} else {
 					echo '<tr '. $HTML->boxGetAltRowStyle($i) . '><td width="60%">'.
 					'<strong>'.$currentList->getName().'</strong><br />'.
 					htmlspecialchars($currentList->getDescription()).'</td>'.
-					'<td width="20%" style="text-align:center"><a href="'.getStringFromServer('PHP_SELF').'?group_id='.$group_id.'&amp;group_list_id='.$currentList->getID().'&amp;change_status=1">'._('Update').'</a></td>'.
-					'<td width="20%" style="text-align:center">';
+						'<td width="15%" style="text-align:center"><a href="'.getStringFromServer('PHP_SELF').'?group_id='.$group_id.'&amp;group_list_id='.$currentList->getID().'&amp;change_status=1">'._('Update').'</a></td>' ;
+					echo '<td width="15%" style="text-align:center">';
 					if($currentList->getStatus() == MAIL__MAILING_LIST_IS_REQUESTED) {
 						echo _('Not activated yet');
 					} else {
 						echo '<a href="'.$currentList->getExternalAdminUrl().'">'._('Administrate').'</a></td>';
 					}
+					echo '<td width="15%" style="text-align:center">';
+					if($currentList->getStatus() == MAIL__MAILING_LIST_IS_CONFIGURED) {
+						print '<a href="'.getStringFromServer('PHP_SELF').'?group_id='.$group_id.'&amp;group_list_id='.$currentList->getID().'&amp;reset_pw=1">'._('Reset admin password').'</a></td>' ;
+
+					}
 					echo '</tr>';
 				}
 			}




More information about the Fusionforge-commits mailing list