Revision: 1073
          http://mrbs.svn.sourceforge.net/mrbs/?rev=1073&view=rev
Author:   cimorrison
Date:     2009-03-25 14:22:05 +0000 (Wed, 25 Mar 2009)

Log Message:
-----------
Moved the email address validation for areas and rooms into a function.

Modified Paths:
--------------
    mrbs/trunk/web/edit_area_room.php
    mrbs/trunk/web/functions.inc

Modified: mrbs/trunk/web/edit_area_room.php
===================================================================
--- mrbs/trunk/web/edit_area_room.php   2009-03-25 13:30:48 UTC (rev 1072)
+++ mrbs/trunk/web/edit_area_room.php   2009-03-25 14:22:05 UTC (rev 1073)
@@ -99,22 +99,9 @@
 <?php
 if (!empty($room))
 {
-  require_once 'Mail/RFC822.php';
-  (!isset($room_admin_email)) ? $room_admin_email = '': '';
-  $emails = explode(',', $room_admin_email);
-  $valid_email = TRUE;
-  $email_validator = new Mail_RFC822();
-  foreach ($emails as $email)
-  {
-    // if no email address is entered, this is OK, even if isValidInetAddress
-    // does not return TRUE
-    if ( !$email_validator->isValidInetAddress($email, $strict = FALSE)
-         && ('' != $room_admin_email) )
-    {
-      $valid_email = FALSE;
-    }
-  }
-  //
+  // validate the email addresses
+  $valid_email = validate_email_list($room_admin_email);
+  
   if ( isset($change_room) && (FALSE != $valid_email) )
   {
     if (empty($capacity))
@@ -200,21 +187,7 @@
   if (isset($change_area))  // we're on the second pass through
   {
     // validate email addresses
-    require_once 'Mail/RFC822.php';
-    (!isset($area_admin_email)) ? $area_admin_email = '': '';
-    $emails = explode(',', $area_admin_email);
-    $email_validator = new Mail_RFC822();
-    foreach ($emails as $email)
-    {
-      // if no email address is entered, this is OK, even if isValidInetAddress
-      // does not return TRUE
-      if ( !$email_validator->isValidInetAddress($email, $strict = FALSE)
-           && ('' != $area_admin_email) )
-      {
-        $valid_email = FALSE;
-      }
-    }
-    //
+    $valid_email = validate_email_list($area_admin_email);
     
     if (!$enable_periods)
     {

Modified: mrbs/trunk/web/functions.inc
===================================================================
--- mrbs/trunk/web/functions.inc        2009-03-25 13:30:48 UTC (rev 1072)
+++ mrbs/trunk/web/functions.inc        2009-03-25 14:22:05 UTC (rev 1073)
@@ -645,6 +645,27 @@
   }
 }
 
+// validates a comma separated list of email addresses
+// returns FALSE if any one of them is invalid, otherwise TRUE
+function validate_email_list($list)
+{
+  require_once 'Mail/RFC822.php';
+  (!isset($list)) ? $list = '': '';
+  $emails = explode(',', $list);
+  $email_validator = new Mail_RFC822();
+  foreach ($emails as $email)
+  {
+    // if no email address is entered, this is OK, even if isValidInetAddress
+    // does not return TRUE
+    if ( !$email_validator->isValidInetAddress($email, $strict = FALSE)
+         && ('' != $list) )
+    {
+      return FALSE;
+    }
+  }
+  return TRUE;
+}
+
 // Output a start table cell tag <td> with color class.
 // $colclass is an entry type (A-J), zebra stripes if
 // empty or row_highlight if highlighted.


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
_______________________________________________
Mrbs-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mrbs-commits

Reply via email to