| <?php |
| |
| require_once("/home/data/httpd/eclipse-php-classes/system/dbconnection_ipzilla_rw.class.php"); |
| require_once("/home/data/httpd/eclipse-php-classes/system/app.class.php"); |
| require_once("/home/data/httpd/eclipse-php-classes/people/ldapperson.class.php"); |
| require_once("/home/data/httpd/eclipse-php-classes/menu/menu.class.php"); |
| |
| #***************************************************************************** |
| # |
| # cq_post.php |
| # |
| # Author: Denis Roy and others |
| # Date: 2005-01-21 |
| # |
| # Description: Process to store contribution questionnaires and e-mail EMO |
| # |
| # HISTORY: |
| # |
| #**************************************************************************** |
| |
| |
| $App = new App(); |
| $App->runStdWebAppCacheable(); |
| $ErrorMessage = ""; |
| |
| $LDAPPerson = new LDAPPerson(); |
| $LDAPPerson = $LDAPPerson->redirectIfNotLoggedIn(); |
| |
| $IPZillaHome = "https://dev.eclipse.org/ipzilla"; |
| $FoundationDBHome = "https://foundation.eclipse.org"; |
| |
| $disablemail = false; |
| |
| # Connect to the IPZilla database |
| $dbc = new DBConnectionIPZillaRW(); |
| $dbh = $dbc->connect(); |
| |
| |
| |
| $MasterIPZillaEntry = new IPZillaEntry(); |
| |
| $SubmitterProfile = new Profile(); |
| $SubmitterProfile->selectProfileFromExternID($LDAPPerson->getUid()); |
| |
| if($_POST['c'] == "") { |
| |
| # new (Master) contribution for IPZilla |
| |
| # Split product|component from the POST |
| $pc = explode("|", $_POST['component_id']); |
| $product_id = $pc[0]; $component_id = $pc[1]; |
| |
| $CommitterProfile = new Profile(); |
| $CommitterProfile->selectProfileFromUserID($_POST['committer_id']); |
| |
| $ProjectLeadProfile = new Profile(); |
| $ProjectLeadProfile->selectProfileFromUserID($_POST['projectlead_id']); |
| |
| $bug_id = $MasterIPZillaEntry->insertEntry( |
| $product_id, |
| $component_id, |
| $SubmitterProfile, |
| $_POST['contributionName'] . " Version: " . $_POST['contributionVersion'], |
| "container", |
| 0, |
| $_POST['cqtype'] |
| ); |
| |
| # Create directory to hold attachments > 20MB |
| mkdir("/home/data/common/ip/ipzilla-" . $bug_id, 0770); |
| |
| # Send e-mail |
| |
| $message = $SubmitterProfile->realname . " submitted a Contribution Questionnaire to IPZilla:\n\n"; |
| $message .= " " . $_POST['contributionName'] . " Version: " . $_POST['contributionVersion'] . "\n\n"; |
| $message .= " You can view the details at the following address:\n " . $IPZillaHome . "/show_bug.cgi?id=" . $bug_id . "\n\n"; |
| |
| $message .= " ** You're not done yet! **"; |
| $message .= " You need to attach the source code (not binary) for all the packages in this contribution.\n\n"; |
| $message .= " If the file size is 20MB or less, log in to IPZilla (using your bugs.eclipse.org committer account) and use the attachment feature.\n"; |
| $message .= " If the file size exceeds 20MB, please use an SFTP or SCP client to transfer the file to the correct ipzilla subdirectory of dev.eclipse.org:/home/data/common/ip, according the the IP Bug number. Log into IPZilla and submit the file name in a comment.\n\n"; |
| $message .= " Once the source is attached or transferred, your PMC must approve this package by having one representative of the PMC vote +1 on the IPZilla entry. The Eclipse IP team will NOT review your contribution until this is done.\n\n"; |
| |
| |
| $message .= "-------------\nThe raw entry is as follows:\n\n" . $MasterIPZillaEntry->comment0; |
| |
| $watchlist = selectWatchlist($MasterIPZillaEntry->initialowner); |
| |
| # include PMC |
| if(!is_numeric(array_search($ProjectLeadProfile->login_name, $watchlist))) { |
| $watchlist[count($watchlist)] = $ProjectLeadProfile->login_name; |
| } |
| |
| # include the submitter |
| if(!is_numeric(array_search($SubmitterProfile->login_name, $watchlist))) { |
| $watchlist[count($watchlist)] = $SubmitterProfile->login_name; |
| } |
| foreach ($watchlist as $watcher) { |
| if(! $disablemail) { |
| mail($watcher, "[IPZilla CQ: " . $bug_id . "]: " . $_POST['contributionName'] . " " . $_POST['contributionVersion'], $message, "From: IPZilla <emo-ip-team@eclipse.org>"); |
| } |
| } |
| # End: send e-mail |
| |
| |
| if($_POST['preExistPkgList'] != "") { |
| # count this and send as param: $_POST['preExistPkgList'] |
| setcookie("preExistPkgList", $_POST['preExistPkgList']); |
| setcookie("bug_id", $bug_id); |
| setcookie("projectlead_id", $_POST['projectlead_id']); |
| header("Location: cq_part2.php?i=" . $bug_id); |
| } |
| else { |
| header("Location: cq_out.php?bug_ids=" . $bug_id ); |
| } |
| } |
| else { |
| |
| |
| # existing contribution |
| # get number of packages and save this info. |
| |
| if($_POST['c'] != $_COOKIE['bug_id']) { |
| die("An internal error has occurred. Your questionaire may not be complete. Please contact webmaster@eclipse.org."); |
| } |
| $MasterIPZillaEntry->selectEntry($_COOKIE['bug_id']); |
| |
| if($_POST['projectlead_id'] == "") { |
| die("An internal error has occurred while attempting to locate the PMC record for this questionnaire. Your questionaire may not be complete. Please contact webmaster@eclipse.org."); |
| } |
| |
| $ProjectLeadProfile = new Profile(); |
| $ProjectLeadProfile->selectProfileFromUserID($_POST['projectlead_id']); |
| |
| $preExistPkgList = $_COOKIE['preExistPkgList']; |
| |
| $pkgList = split("\n", $preExistPkgList); |
| |
| $relatedPackages = ""; |
| $relatedIPZillaBugIDs = ""; |
| |
| for($i = 0; $i < count($pkgList); $i++) { |
| if($pkgList[$i] != "") { |
| |
| $IPZillaEntry = new IPZillaEntry(); |
| $bug_id = $IPZillaEntry->insertEntry($MasterIPZillaEntry->product_id, |
| $MasterIPZillaEntry->component_id, |
| $SubmitterProfile, |
| $_POST['pkgName' . $i] . " Version: " . $_POST['pkgVersion' . $i], |
| "child", |
| $i, |
| $_POST['cqtype'] |
| ); |
| |
| if($relatedIPZillaBugIDs != "") { |
| $relatedIPZillaBugIDs .= ","; |
| } |
| $relatedIPZillaBugIDs .= $bug_id; |
| |
| |
| # Once it's done, make it depend on MasterIPZillaEntry->bug_id |
| $sql = "INSERT INTO dependencies |
| (blocked, dependson) |
| VALUES ( |
| " . $MasterIPZillaEntry->bug_id . ", |
| " . $bug_id . " |
| )"; |
| mysql_query($sql, $dbh); |
| |
| $relatedPackages .= " " . $_POST['pkgName' . $i] . "\n"; |
| $relatedPackages .= " -> " . $IPZillaHome . "/show_bug.cgi?id=" . $bug_id . "\n\n"; |
| |
| # Send the e-mail |
| $message = $SubmitterProfile->realname . " submitted a Contribution Questionnaire to IPZilla, with third party packages.\n\n"; |
| $message .= $_POST['pkgName' . $i] . " Version: " . $_POST['pkgVersion' . $i] . "\n\n"; |
| |
| $message .= " You can view the details at the following address:\n " . $IPZillaHome . "/show_bug.cgi?id=" . $bug_id . "\n\n"; |
| |
| $message .= " ** You're not done yet! **"; |
| $message .= " You need to attach the source code (not binary) to all packages in this contribution.\n\n"; |
| $message .= " If the file size is 20MB or less, log in to IPZilla (using your bugs.eclipse.org committer account) and use the attachment feature.\n"; |
| $message .= " If the file size exceeds 20MB, please use an SFTP or SCP client to transfer the file to the correct ipzilla subdirectory of dev.eclipse.org:/home/data/common/ip, according the the IP Bug number. Log into IPZilla and submit the file name in a comment.\n\n"; |
| $message .= " Once the source is attached or transferred, your PMC must approve this package by voting +1 to the IPZilla entry. The Eclipse IP team will NOT review your contribution until this is done.\n\n"; |
| |
| $message .= "-------------\nThe raw entry is as follows:\n\n" . $IPZillaEntry->comment0; |
| |
| $watchlist = selectWatchlist($MasterIPZillaEntry->initialowner); |
| if(!is_numeric(array_search($ProjectLeadProfile->login_name, $watchlist))) { |
| $watchlist[count($watchlist)] = $ProjectLeadProfile->login_name; |
| } |
| |
| # include the submitter |
| if(!is_numeric(array_search($SubmitterProfile->login_name, $watchlist))) { |
| $watchlist[count($watchlist)] = $SubmitterProfile->login_name; |
| } |
| foreach ($watchlist as $watcher) { |
| if(! $disablemail) { |
| mail($watcher, "[IPZilla CQ: " . $bug_id . "]: " . $_POST['pkgName' . $i] . " Version: " . $_POST['pkgVersion' . $i], $message, "From: IPZilla <emo-ip-team@eclipse.org>"); |
| } |
| } |
| } |
| } |
| |
| header("Location: cq_out.php?bug_ids=" . $relatedIPZillaBugIDs); |
| |
| } |
| |
| $dbc->disconnect(); |
| |
| |
| class Profile { |
| |
| var $userid; |
| var $realname; |
| var $login_name; |
| var $extern_id; |
| |
| |
| function selectProfileFromUserID($_userid) { |
| global $App; |
| global $dbc, $dbh; |
| global $_POST; |
| |
| # get submitter bugzilla id |
| $sql = "SELECT |
| PRF.userid, |
| PRF.realname, |
| PRF.login_name, |
| PRF.extern_id |
| FROM profiles AS PRF |
| WHERE PRF.userid = " . $_userid; |
| $rs = mysql_query($sql,$dbh); |
| $row = mysql_fetch_assoc($rs); |
| |
| $this->userid = $_userid; |
| $this->realname = $row['realname']; |
| $this->login_name = $row['login_name']; |
| $this->extern_id = $row['extern_id']; |
| } |
| |
| function selectProfileFromEMail($_email) { |
| global $App; |
| global $dbc, $dbh; |
| global $_POST; |
| |
| # get submitter bugzilla id |
| $sql = "SELECT |
| PRF.userid, |
| PRF.realname, |
| PRF.login_name, |
| PRF.extern_id |
| FROM profiles AS PRF |
| WHERE PRF.login_name = " . $App->returnQuotedString($_email); |
| $rs = mysql_query($sql,$dbh); |
| $row = mysql_fetch_assoc($rs); |
| |
| $this->userid = $row['userid']; |
| $this->realname = $row['realname']; |
| $this->login_name = $row['login_name']; |
| $this->extern_id = $row['extern_id']; |
| } |
| |
| |
| function selectProfileFromExternID($_extern_id) { |
| global $App; |
| global $dbc, $dbh; |
| global $_POST; |
| |
| # get submitter bugzilla id |
| $sql = "SELECT |
| PRF.userid, |
| PRF.realname, |
| PRF.login_name, |
| PRF.extern_id |
| FROM profiles AS PRF |
| WHERE PRF.extern_id = " . $App->returnQuotedString($_extern_id); |
| $rs = mysql_query($sql,$dbh); |
| $row = mysql_fetch_assoc($rs); |
| |
| $this->userid = $row['userid']; |
| $this->realname = $row['realname']; |
| $this->login_name = $row['login_name']; |
| $this->extern_id = $row['extern_id']; |
| } |
| } |
| |
| |
| |
| |
| |
| class IPZillaEntry { |
| |
| var $bug_id = 0; |
| var $reporter = 0; |
| var $product_id = 0; |
| var $component_id = 0; |
| var $initialowner = 0; |
| var $component_name = ""; |
| var $short_desc = ""; |
| var $comment0 = ""; |
| |
| function insertEntry($_product_id, $_component_id, $_SubmitterProfile, $_short_desc, $_type, $_iteration, $_cqtype) { |
| global $App; |
| global $dbc, $dbh; |
| global $_POST; |
| global $ProjectLeadProfile; |
| |
| $this->reporter = $_SubmitterProfile->userid; |
| $this->product_id = $_product_id; |
| $this->component_id = $_component_id; |
| $this->short_desc = $_short_desc; |
| |
| |
| # Get initial owner and name |
| $sql = "SELECT |
| CMP.initialowner, |
| CMP.name |
| FROM components AS CMP |
| WHERE CMP.id = " . $_component_id; |
| $rs = mysql_query($sql,$dbh); |
| $row = mysql_fetch_assoc($rs); |
| $this->initialowner = $row['initialowner']; |
| $this->component_name = $row['name']; |
| |
| #if($_SubmitterProfile->userid == "" || $this->initialowner == "") { |
| # die("Internal error - cannot get your IPZilla ID. Please contact webmaster@eclipse.org."); |
| #} |
| |
| # To protect the integrity of the data, the reporter is obfuscated (with Bugzilla, the reporter can |
| # essentially change all the bugs) |
| |
| $EMOProfile = new Profile(); |
| $EMOProfile->selectProfileFromEMail("emo-ip-team@eclipse.org"); |
| |
| $sql = "INSERT INTO bugs ( |
| bug_id, |
| assigned_to, |
| bug_severity, |
| bug_status, |
| creation_ts, |
| delta_ts, |
| lastdiffed, |
| short_desc, |
| op_sys, |
| priority, |
| product_id, |
| rep_platform, |
| reporter, |
| version, |
| everconfirmed, |
| component_id |
| ) |
| VALUES ( |
| NULL, |
| $this->initialowner, |
| 'new', |
| 'NEW', |
| NOW(), |
| NOW(), |
| NOW(), |
| " . $App->returnQuotedString($this->short_desc) . ", |
| 'Windows', |
| 'P3', |
| $this->product_id, |
| 'PC', |
| '" . $EMOProfile->userid . "', |
| 'unspecified', |
| 1, |
| $this->component_id |
| ); |
| "; |
| |
| mysql_query($sql, $dbh); |
| $this->bug_id = mysql_insert_id($dbh); |
| |
| $this->comment0 = generateComment0($this, $_type, $_iteration); |
| |
| # insert comment 0, which is a dump |
| $sql = "INSERT INTO longdescs ( |
| bug_id, |
| who, |
| bug_when, |
| thetext |
| ) |
| VALUES ( |
| $this->bug_id, |
| " . $this->reporter . ", |
| NOW(), |
| " . $App->returnQuotedString($this->comment0) . " |
| )"; |
| mysql_query($sql, $dbh); |
| |
| # insert keywords |
| $keywordCache = ""; |
| if($_POST['crypto'] == "yes") { |
| $this->addKeyword("cryptography"); |
| } |
| if($_cqtype == "epl" || $_cqtype == "nonepl") { |
| $this->addKeyword($_cqtype); |
| } |
| |
| |
| |
| # Add Reporter, PMC and EMO-IP-RECORDS@ as CC's to this bug |
| $sql = "INSERT INTO cc (bug_id, who) |
| SELECT " . $this->bug_id . ", userid FROM profiles |
| WHERE login_name ='emo-ip-team@eclipse.org' |
| OR userid = " . $this->reporter . " |
| OR userid = " . $ProjectLeadProfile->userid . " |
| OR userid = " . $this->initialowner; |
| mysql_query($sql, $dbh); |
| |
| return $this->bug_id; |
| } |
| |
| function addKeyword($_keyword){ |
| global $dbc, $dbh; |
| global $_POST; |
| |
| $sql = "SELECT id FROM keyworddefs WHERE name = '$_keyword'"; |
| $rs = mysql_query($sql, $dbh); |
| $row = mysql_fetch_assoc($rs); |
| $keyword_id = $row['id']; |
| |
| if($keyword_id != "" && $this->bug_id != "") { |
| $sql = "INSERT INTO keywords |
| (bug_id, keywordid) |
| VALUES ( |
| " . $this->bug_id . ", |
| " . $keyword_id . ")"; |
| mysql_query($sql, $dbh); |
| } |
| |
| # rebuild Keyword Cache |
| $sql = "SELECT keywords.bug_id, keyworddefs.name " . |
| "FROM keywords " . |
| "INNER JOIN keyworddefs " . |
| " ON keyworddefs.id = keywords.keywordid " . |
| " WHERE keywords.bug_id = " . $this->bug_id . |
| " ORDER BY keywords.bug_id, keyworddefs.name"; |
| |
| $str_kwc = ""; |
| $rs_kwc = mysql_query($sql,$dbh); |
| |
| while($row_kwc = mysql_fetch_assoc($rs_kwc)) { |
| if($str_kwc != "") { |
| $str_kwc .= ", "; |
| } |
| $str_kwc .= $row_kwc['name']; |
| } |
| |
| if($str_kwc != "") { |
| $sql = "UPDATE bugs SET keywords = '" . $str_kwc . "' WHERE bug_id = " . $this->bug_id; |
| mysql_query($sql,$dbh); |
| } |
| |
| } |
| |
| function selectEntry($_bug_id){ |
| global $App; |
| global $dbc, $dbh; |
| global $_POST; |
| |
| $this->bug_id = $_bug_id; |
| |
| $sql = "SELECT |
| bug_id, |
| assigned_to, |
| bug_severity, |
| bug_status, |
| creation_ts, |
| delta_ts, |
| short_desc, |
| op_sys, |
| priority, |
| product_id, |
| rep_platform, |
| reporter, |
| version, |
| component_id |
| FROM bugs WHERE bug_id = " . $this->bug_id; |
| $rs = mysql_query($sql,$dbh); |
| $row = mysql_fetch_assoc($rs); |
| $this->reporter = $row['reporter']; |
| $this->product_id = $row['product_id']; |
| $this->component_id = $row['component_id']; |
| $this->short_desc = $row['short_desc']; |
| |
| # Get initial owner and name |
| $sql = "SELECT |
| CMP.initialowner, |
| CMP.name |
| FROM components AS CMP |
| WHERE CMP.id = " . $this->component_id; |
| $rs = mysql_query($sql,$dbh); |
| $row = mysql_fetch_assoc($rs); |
| $this->initialowner = $row['initialowner']; |
| $this->component_name = $row['name']; |
| } |
| } |
| |
| |
| function selectWatchlist($_initialowner) { |
| global $App; |
| |
| global $dbc; |
| global $dbh; |
| global $_POST; |
| |
| # get mail addresses for the watchlist for initialowner |
| $sql = "SELECT |
| PRF.login_name |
| FROM profiles AS PRF |
| INNER JOIN watch AS WAT ON WAT.watcher = PRF.userid |
| WHERE WAT.watched = $_initialowner"; |
| $rs = mysql_query($sql,$dbh); |
| $watchlist = array(); |
| while($row = mysql_fetch_assoc($rs)) { |
| $watchlist[count($watchlist)] = $row['login_name']; |
| } |
| |
| # Add static entries here |
| $watchlist[count($watchlist)] = "mike.milinkovich@eclipse.org"; |
| $watchlist[count($watchlist)] = "bjorn.freeman-benson@eclipse.org"; |
| |
| return $watchlist; |
| } |
| |
| function generateComment0($_IPZillaEntry, $_type, $_iteration) { |
| global $App; |
| |
| global $dbc; |
| global $dbh; |
| global $_POST; |
| global $SubmitterProfile, $CommitterProfile, $ProjectLeadProfile; |
| global $bug_id; |
| global $_cqtype; |
| |
| if ($_type == "container") { |
| $mailStr = " |
| |
| Submitter: " . $SubmitterProfile->realname . " " . $SubmitterProfile->login_name . " |
| https://foundation.eclipse.org/people/people_edit.php?PersonID=" . $SubmitterProfile->extern_id . " |
| |
| |
| Committer: " . $CommitterProfile->realname . " " . $CommitterProfile->login_name . " |
| https://foundation.eclipse.org/people/people_edit.php?PersonID=" . $CommitterProfile->extern_id . " |
| |
| |
| To be Approved by |
| |
| PMC: " . $ProjectLeadProfile->realname . " " . $ProjectLeadProfile->login_name . " |
| https://foundation.eclipse.org/people/people_edit.php?PersonID=" . $ProjectLeadProfile->extern_id . " |
| |
| |
| Contribution |
| |
| Project: " . $_IPZillaEntry->component_name . " |
| http://foundation.eclipse.org/projects/projects_edit.php?ProjectID=" . $_IPZillaEntry->component_name . " |
| |
| Component: " . $_POST['component'] . " |
| |
| Name: " . $_POST['contributionName'] . " |
| Version: " . $_POST['contributionVersion'] . " |
| Size: " . $_POST['contributionSize'] . " |
| Description: " . $_POST['contributionDescription'] . " |
| |
| Pre-existing Packages: " . $_POST['preExistPkgs'] . " |
| |
| Support Info: " . $_POST['contributionSupportInfo'] . " |
| |
| Requirement is: " . $_POST['requirement']; |
| |
| if($_cqtype == "nonepl") { |
| $mailStr .= " |
| Contributor |
| |
| Submitter wrote 100% of the code: " . $_POST['allMyCode'] . " |
| Name: " . $_POST['contributorName'] . " |
| Organization: " . $_POST['contributorOrganization'] . " |
| Phone: " . $_POST['contributorPhone'] . " |
| E-Mail: " . $_POST['contributorEmail'] . " |
| |
| Contribution Percentage: " . $_POST['contributorPercentage'] . " |
| Other Contributors: " . $_POST['otherContributors']; |
| } |
| |
| $mailStr .= " |
| |
| Cryptography involved: " . $_POST['crypto'] . " |
| Cryptography: " . $_POST['cryptography'] . " |
| Algorithm: " . $_POST['cryptographyAlgorithm'] . " |
| |
| "; |
| |
| } |
| else { |
| |
| $committer = explode("|", $_POST['committer_id' . $_iteration]); |
| |
| $mailStr = " |
| Pre-existing Packages |
| |
| Package: " . $_POST['pkgName' . $_iteration] . " |
| Version: " . $_POST['pkgVersion' . $_iteration] . " |
| Source: " . $_POST['pkgSource' . $_iteration] . " |
| |
| License: " . $_POST['pkgLicense' . $_iteration] . " |
| License Type: " . $_POST['pkgLicenseType' . $_iteration] . " |
| |
| Other authors: " . $_POST['otherAuthors' . $_iteration] . " |
| |
| Committer Name: " . $committer[1] . " |
| https://foundation.eclipse.org/people/people_edit.php?PersonID=" . $committer[0]; |
| } |
| return $mailStr; |
| |
| } |
| |
| ?> |