blob: fc51e853a7ad9a18e562774bd440d4ede7870424 [file] [log] [blame]
<?php
/*******************************************************************************
* Copyright (c) 2010,2011 Eclipse Foundation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Wayne Beaton (Eclipse Foundation)- initial API and implementation
* Wayne Beaton (Eclipse Foundation) - Bug 355885.
*******************************************************************************/
require_once(dirname(__FILE__) . '/common.inc');
mustBeEclipseFoundationCaller();
require_once($_SERVER['DOCUMENT_ROOT'] . "/eclipse.org-common/system/app.class.php");
$App = new App();
header("Content-type: text/plain");
$result = $App->foundation_sql("SELECT distinct People.PersonID as id, People.EMail as email, People.Comments as comment FROM People join PeopleProjects on (People.PersonID = PeopleProjects.PersonId) where relation='CM'");
while($row = mysql_fetch_assoc($result)) {
$emails = extractEmails($row['email'], $row['comment']);
$id = $row['id'];
foreach($emails as $email) {
echo "$email\t$id\n";
}
}
/**
* This function extract the email addresses from the comment and returns
* them--along with the provided primary email address--in an array.
*
* This is a stop-gap solution for the need to represent multiple email addresses
* for some users in some contexts. Alternative email addresses are represented in
* the comment field in the form 'alt-email:somebody@someplace.com'. Multiple
* alternative addresses can be provided. The tag can occur anywhere in the comment
* and--while it is not always required--it is good practice to leave a space
* between multiple entries.
*
* WTB Bug 355885
*/
function extractEmails($primary, $comment) {
preg_match_all('/alt-email:(\S*)/i', $comment, $matches);
$emails = array();
$emails[] = $primary;
foreach($matches[1] as $email) {
if ($primary == $email) continue;
$emails[] = $email;
}
return $emails;
}
?>