| <?php | |
| /******************************************************************************* | |
| * Copyright (c) 2010, 2015 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 | |
| ******************************************************************************/ | |
| require_once(dirname(__FILE__) . "../../eclipse.org-common/system/app.class.php"); | |
| require_once(dirname(__FILE__)) . '/classes/Project.class.php'; | |
| require_once(dirname(__FILE__) . "/classes/common.php"); | |
| require_once(dirname(__FILE__) . "/classes/debug.php"); | |
| mustBeEclipseFoundationCaller(); | |
| //mustBeFoundationEmployee(); | |
| $App = new App(); | |
| /* | |
| * WTB: Define some functions in a particular way depending on mode so that we | |
| * don't have to keep checking the "debug" flag. | |
| */ | |
| if (!$App->devmode) { | |
| function execute($sql) { | |
| global $App; | |
| $App->portal_sql($sql); | |
| } | |
| function send_mail($CEMailDest, $CEMailSubject, $cmailstr, $EMailHeaders) { | |
| mail($CEMailDest, $CEMailSubject, $cmailstr, $EMailHeaders); | |
| } | |
| } else { | |
| function execute($sql) { | |
| echo "<div style=\"border-style:solid;border-width:1px\">$sql</div>"; | |
| return false; | |
| } | |
| function send_mail($CEMailDest, $CEMailSubject, $cmailstr, $EMailHeaders) { | |
| $content = str_replace("\n", "<br/>", $cmailstr); | |
| echo "<div style=\"border-style:solid;border-width:1px\">The following email was <em>NOT</em> sent since we are in debug mode. | |
| <p>Destination: $CEMailDest<br/> | |
| Subject: $CEMailSubject<br/> | |
| Headers: $EMailHeaders<p/> | |
| <blockquote>$content</blockquote> | |
| </div>"; | |
| } | |
| } | |
| function person_exists_in_portal_record($project, $email) { | |
| global $App; | |
| $email = $App->sqlSanitize($email); | |
| $projectid = $project->getId(); | |
| $sql = "SELECT count(1) AS found | |
| FROM committer_votes | |
| WHERE candidateemail = '$email' | |
| AND projectid = '$projectid'"; | |
| $result = execute($sql); | |
| if (!$result) return false; | |
| $row = mysql_fetch_assoc($result); | |
| return $row['found']; | |
| } | |
| function notify_portal_about_committer($project, $name, $email) { | |
| $email = strtolower(addslashes($email)); | |
| $projectid = $project->getId(); | |
| // Make sure we only make one record even if the form is re-submitted | |
| if(!person_exists_in_portal_record($project, $email)) { | |
| $name = ucwords(strtolower(addslashes($name))); | |
| $parentproj = $project->getTopLevelProject()->getId(); | |
| // WTB: Protect against SQL injection | |
| global $App; | |
| $parentproj = $App->sqlSanitize($parentproj); | |
| $projectid = $App->sqlSanitize($projectid); | |
| $name = $App->sqlSanitize($name); | |
| $email = $App->sqlSanitize($email); | |
| $sql = "INSERT INTO committer_votes " . | |
| "(nominator, status, topid, projectid, candidate, candidateemail, startdate, enddate) " . | |
| "VALUES('NPPR_FORM','need_candidate_paperwork','$parentproj','$projectid','$name','$email',now(),now())"; | |
| execute($sql); | |
| } | |
| } | |
| $EMailHeaders = "From: \"Eclipse WebMaster (Automated)\"<webmaster@eclipse.org>\n"; | |
| $EMailHeaders .= "X-Mailer: Eclipse.org automailer process\n"; | |
| function email_committer($project, $name, $email){ | |
| global $EMailHeaders; | |
| $cmailstr = " | |
| Dear " . $name . ", | |
| If you do not already have a dev.eclipse.org unix account, | |
| please do the following: | |
| 1. Create a Bugzilla account for yourself using your same | |
| email address: " . $email . " | |
| If you do not use this same email address, your Bugzilla | |
| permissions will not be set correctly. | |
| 2. Follow the instructions in item 5 \"Paperwork\" of: | |
| http://www.eclipse.org/projects/dev_process/new-committer.php | |
| If you have not already done so, you need to fill out a web | |
| form questionnaire and possibly one or two paper agreements. | |
| Your committer account cannot be processed until these | |
| forms are received. | |
| If you are currently an Eclipse committer, you need not do anything at | |
| this time. If further paperwork is required to cover these subsequent | |
| rights, you will be contacted shortly. | |
| Thank you. | |
| ------------------------------------------------- | |
| New Committer Request | |
| New Committer Info: | |
| =================== | |
| initial project creation | |
| Name: " . $name . " | |
| Project: " . $project->getId() . " | |
| Email: " . $email; | |
| $CEMailDest = "emo-records@eclipse.org"; | |
| if ($email != ""){ | |
| $CEMailDest .= "," . $email; | |
| } | |
| $CEMailSubject = $name . " - New Committer Request Form"; | |
| send_mail($CEMailDest, $CEMailSubject, $cmailstr, $EMailHeaders); | |
| } | |
| class CommitterInfo { | |
| var $project, $name, $email; | |
| function __construct($project, $name, $email) { | |
| $this->project = $project; | |
| $this->name = $name; | |
| $this->email = $email; | |
| } | |
| } | |
| function getCommitterInfo() { | |
| if (!$project = get_project_from_pmi($_GET['id'])) return null; | |
| if (!$name = htmlentities($_GET['name'])) return null; | |
| if (!$email = htmlentities($_GET['email'])) return null; | |
| return new CommitterInfo($project, $name, $email); | |
| } | |
| if ($info = getCommitterInfo()) { | |
| if (!person_exists_in_portal_record($info->project, $info->email)) { | |
| email_committer($info->project, $info->name, $info->email); | |
| notify_portal_about_committer($info->project, $info->name, $info->email); | |
| echo "Committer paperwork request submitted."; | |
| } else { | |
| echo "Record exists. No action has been taken."; | |
| } | |
| } else { | |
| echo "Eclipse Foundation use only. Submit paperwork request for new committer."; | |
| echo "<form>"; | |
| echo "Project Id: <input type=text name=id /><br/>"; | |
| echo "Committer name: <input type=text name=name /><br/>"; | |
| echo "Committer email: <input type=text name=email /><br/>"; | |
| echo "Committer name: <input type=submit />"; | |
| echo "</form>"; | |
| } | |
| ?> |