[pLog-svn] r2061 - in plugins/trunk/mailcentre: class/action class/view locale templates

oscar at devel.plogworld.net oscar at devel.plogworld.net
Mon May 23 16:35:42 GMT 2005


Author: oscar
Date: 2005-05-23 16:35:42 +0000 (Mon, 23 May 2005)
New Revision: 2061

Modified:
   plugins/trunk/mailcentre/class/action/mailcentresendmessage.class.php
   plugins/trunk/mailcentre/class/view/mailcentreuserselectorview.class.php
   plugins/trunk/mailcentre/locale/locale_en_UK.php
   plugins/trunk/mailcentre/templates/userselector.template
Log:
final improvements


Modified: plugins/trunk/mailcentre/class/action/mailcentresendmessage.class.php
===================================================================
--- plugins/trunk/mailcentre/class/action/mailcentresendmessage.class.php	2005-05-23 16:09:07 UTC (rev 2060)
+++ plugins/trunk/mailcentre/class/action/mailcentresendmessage.class.php	2005-05-23 16:35:42 UTC (rev 2061)
@@ -7,7 +7,8 @@
 	include_once( PLOG_CLASS_PATH."class/mail/emailmessage.class.php" );	
 	include_once( PLOG_CLASS_PATH."plugins/mailcentre/class/view/mailcentresendmessageview.class.php" );
 	include_once( PLOG_CLASS_PATH."plugins/mailcentre/class/view/mailcentremessagelistview.class.php" );
-	include_once( PLOG_CLASS_PATH."plugins/mailcentre/class/dao/mailmessages.class.php" );
+	include_once( PLOG_CLASS_PATH."plugins/mailcentre/class/dao/mailmessages.class.php" );
+	include_once( PLOG_CLASS_PATH."class/dao/users.class.php" );
 	
 	class MailCentreSendMessage extends SiteAdminAction
 	{
@@ -24,6 +25,43 @@
 			$view = new MailCentreSendMessageView( $this->_blogInfo );
 			$view->setErrorMessage( $this->_locale->tr("mailcentre_error_sending_message" ));
 			$this->setValidationErrorView( $view );		
+		}
+		
+		/** 
+		 * given a special recipient name, expand to a fully-featured list.
+		 */
+		function _expandRecipients( $recipientId )
+		{
+		      $users = new Users();
+		      $userList = null;
+		      
+		      print("expanding $recipientId...<br/>");
+		      
+		      switch( strtoupper($recipientId)) {
+		          case "[ALL]":
+		              $userList = $users->getAllUsers();
+		              break;
+		          case "[ALL_ACTIVE]":
+		              $userList = $users->getAllUsers( USER_STATUS_ACTIVE );
+		              break;
+		          case "[ALL_DISABLED]":
+		              $userList = $users->getAllUsers( USER_STATUS_DISABLED );
+		          case "[ALL_UNCONFIRMED]":
+		              $userList = $users->getAllUsers( USER_STATUS_UNCONFIRMED );
+		              break;
+		      }
+		      
+		      // return an array with the same element
+		      if( $userList == null )
+		          return( Array( $recipientId ));
+		      
+		      // process the list
+		      $recipients = Array();
+		      foreach( $userList as $user ) {
+		          $recipients[] = $user->getEmail();
+		      }
+		      
+		      return( $recipients );
 		}
 		
 		function perform()
@@ -50,10 +88,27 @@
 		    $recipientsBcc = str_replace ( " ", "", $recipientsBcc );		    
 		    
 		    // and get the list of recipients
-		    $list = explode( ",", $recipients );
-		    $listCc = explode( ",", $recipientsCc );
-		    $listBcc = explode( ",", $recipientsBcc );
+		    $listUnexpanded = explode( ",", $recipients );
+		    $list = Array();
+		    foreach( $listUnexpanded as $recipient ) {
+		      $result = $this->_expandRecipients( $recipient );
+		      $list = array_merge( $list, $result );
+		    }
 		    
+		    $listCcUnexpanded = explode( ",", $recipientsCc );
+		    $listCc = Array();
+		    foreach( $listCcUnexpanded as $recipient ) {
+		      $result = $this->_expandRecipients( $recipient );
+		      $listCc = array_merge( $listCc, $result );
+		    }
+		    
+		    $listBccUnexpanded = explode( ",", $recipientsBcc );
+		    $listBcc = Array();
+		    foreach( $listBccUnexpanded as $recipient ) {
+		      $result = $this->_expandRecipients( $recipient );
+		      $listBcc = array_merge( $listBcc, $result );
+		    }		  		    
+		    
 		    // create a mail message that includes all the recipients
 		    $message = new EmailMessage();
 		    $val = new EmailValidator();
@@ -112,6 +167,10 @@
 		      $this->setCommonData( true );
 		    }
 		    
+		    $recipients = implode ( ",", $list );
+		    $recipientsCc = implode( ",", $listCc );
+		    $recipientsBcc = implode( ",", $listBcc );
+		    
 		    // if everything went ok, create our own MailMessage object and save it to the database
 		    $mailMessage = new MailMessage( $subject,
 		                                    $text,

Modified: plugins/trunk/mailcentre/class/view/mailcentreuserselectorview.class.php
===================================================================
--- plugins/trunk/mailcentre/class/view/mailcentreuserselectorview.class.php	2005-05-23 16:09:07 UTC (rev 2060)
+++ plugins/trunk/mailcentre/class/view/mailcentreuserselectorview.class.php	2005-05-23 16:35:42 UTC (rev 2061)
@@ -76,7 +76,7 @@
             $this->notifyEvent( EVENT_USERS_LOADED, Array( "users" => &$blogUsers ));
             
 			// calculate the links to the different pages
-			$pager = new Pager( "?op=mailcentreUserSelector&amp;&dest=".$this->_page."&amp;status=".$this->_status."&amp;page=",
+			$pager = new Pager( "?op=mailcentreUserSelector&amp;&dest=".$this->_dest."&amp;status=".$this->_status."&amp;page=",
 			                    $this->_page, 
 								$numUsers, 
 								DEFAULT_ITEMS_PER_PAGE );

Modified: plugins/trunk/mailcentre/locale/locale_en_UK.php
===================================================================
--- plugins/trunk/mailcentre/locale/locale_en_UK.php	2005-05-23 16:09:07 UTC (rev 2060)
+++ plugins/trunk/mailcentre/locale/locale_en_UK.php	2005-05-23 16:35:42 UTC (rev 2061)
@@ -26,4 +26,11 @@
 $messages["cc"] = "Cc";
 $messages["mailcentre_bcc_help"] = "Blind carbon copy";
 $messages["mailcentre_cc_help"] = "Carbon copy";
+$messages["mailcentre_all_active_users"] = "To Active Users";
+$messages["mailcentre_all_disabled_users"] = "To Disabled Users";
+$messages["mailcentre_all_unconfirmed_users"] = "To Unconfirmed Users";
+$messages["mailcentre_all_blogowners"] = "To Blog Owners";
+$messages["mailcentre_all_nonblogowners"] = "To Non-blog Owners";
+$messages["mailcentre_special_recipients"] = "Special recipients";
+$messages["viewMessage"] = "View Message";
 ?>
\ No newline at end of file

Modified: plugins/trunk/mailcentre/templates/userselector.template
===================================================================
--- plugins/trunk/mailcentre/templates/userselector.template	2005-05-23 16:09:07 UTC (rev 2060)
+++ plugins/trunk/mailcentre/templates/userselector.template	2005-05-23 16:35:42 UTC (rev 2061)
@@ -76,8 +76,27 @@
   </fieldset> 
  </form> 
  </div>
+ <br style="clear:both"> 
+ <form>
+ <fieldset>
+  <legend>{$locale->tr("mailcentre_special_recipients")}</legend>
+   <div class="list_nav_option">
+    <table cols="2" border="0" width="100%">
+     <tr>
+      <td><a href="javascript:setEmailAddress('[ALL]','{$dest}')">{$locale->tr("all")}</a></td>
+      <td><a href="javascript:setEmailAddress('[ALL_ACTIVE]','{$dest}')">{$locale->tr("mailcentre_all_active_users")}</a></td>
+     </tr>
+     <tr> 
+      <td><a href="javascript:setEmailAddress('[ALL_DISABLED]','{$dest}')">{$locale->tr("mailcentre_all_disabled_users")}</a></td>
+      <td><a href="javascript:setEmailAddress('[ALL_UNCONFIRMED]','{$dest}')">{$locale->tr("mailcentre_all_unconfirmed_users")}</a></td>
+     </tr>
+    </table>
+   </div>
+  </fieldset>
+ </form> 
+ </div>
  <br style="clear:both">
- </div>             
+ </div>            
  
         <form id="siteUsers" action="admin.php" method="post">
         <div id="list">




More information about the pLog-svn mailing list