droy | 8aedeec | 2008-01-25 19:04:14 +0000 | [diff] [blame] | 1 | <?php |
| 2 | /******************************************************************************* |
droy | ebd025c | 2009-10-08 20:42:48 +0000 | [diff] [blame] | 3 | * Copyright (c) 2008-2009 Eclipse Foundation and others. |
droy | 8aedeec | 2008-01-25 19:04:14 +0000 | [diff] [blame] | 4 | * All rights reserved. This program and the accompanying materials |
| 5 | * are made available under the terms of the Eclipse Public License v1.0 |
| 6 | * which accompanies this distribution, and is available at |
| 7 | * http://www.eclipse.org/legal/epl-v10.html |
| 8 | * |
| 9 | * Contributors: |
| 10 | * Eclipse Foundation - Initial API and implementation |
kitlo | e8ed9b2 | 2009-02-24 19:33:37 +0000 | [diff] [blame] | 11 | * Kit Lo (IBM) - patch, bug 266010, Map file table does not show release train and file name info |
kitlo | d66aa99 | 2010-01-22 17:18:19 +0000 | [diff] [blame] | 12 | * Kit Lo (IBM) - Bug 299402, Extract properties files from Eclipse project update sites for translation |
droy | 8aedeec | 2008-01-25 19:04:14 +0000 | [diff] [blame] | 13 | *******************************************************************************/ |
| 14 | include("global.php"); |
gobrien | 1a8e02f | 2008-01-30 01:46:26 +0000 | [diff] [blame] | 15 | |
| 16 | InitPage(""); |
droy | 8aedeec | 2008-01-25 19:04:14 +0000 | [diff] [blame] | 17 | |
| 18 | global $User; |
atoulme | 3e5e934 | 2009-01-23 17:34:30 +0000 | [diff] [blame] | 19 | global $dbh; |
gobrien | 1a8e02f | 2008-01-30 01:46:26 +0000 | [diff] [blame] | 20 | |
| 21 | if(!isset($User->userid)) { |
| 22 | exitTo("importing.php"); |
| 23 | } |
| 24 | |
droy | 673b24c | 2008-01-30 16:30:46 +0000 | [diff] [blame] | 25 | if($User->is_committer != 1) { |
Paul Pazderski | 10ba3f3 | 2019-08-28 13:47:44 +0200 | [diff] [blame] | 26 | exitTo("login_oauth.php?errNo=3214","error: 3214 - you must be an Eclipse committer to access this page."); |
droy | 8aedeec | 2008-01-25 19:04:14 +0000 | [diff] [blame] | 27 | } |
| 28 | |
atoulme | 12882d5 | 2009-01-26 18:39:17 +0000 | [diff] [blame] | 29 | require(dirname(__FILE__) . "/../classes/file/file.class.php"); |
droy | 8aedeec | 2008-01-25 19:04:14 +0000 | [diff] [blame] | 30 | |
| 31 | |
kitlo | d66aa99 | 2010-01-22 17:18:19 +0000 | [diff] [blame] | 32 | $pageTitle = "Babel - Define Map Files or Update Sites"; |
droy | 8aedeec | 2008-01-25 19:04:14 +0000 | [diff] [blame] | 33 | $pageKeywords = ""; |
| 34 | $incfile = "content/en_map_files.php"; |
| 35 | |
atoulme | 3e5e934 | 2009-01-23 17:34:30 +0000 | [diff] [blame] | 36 | $PROJECT_ID = getHTTPParameter("project_id"); |
| 37 | $VERSION = getHTTPParameter("version"); |
| 38 | $TRAIN_ID = getHTTPParameter("train_id"); |
droy | ebd025c | 2009-10-08 20:42:48 +0000 | [diff] [blame] | 39 | $FILE_FLD = getHTTPParameter("fileFld"); |
kitlo | d66aa99 | 2010-01-22 17:18:19 +0000 | [diff] [blame] | 40 | $PATTERNS = getHTTPParameter("patterns"); |
atoulme | 3e5e934 | 2009-01-23 17:34:30 +0000 | [diff] [blame] | 41 | $FILENAME = getHTTPParameter("filename"); |
| 42 | $SUBMIT = getHTTPParameter("submit"); |
droy | 8aedeec | 2008-01-25 19:04:14 +0000 | [diff] [blame] | 43 | |
droy | 6e22cf5 | 2009-10-09 17:11:49 +0000 | [diff] [blame] | 44 | $VERSION = preg_replace("/^\* /", "", $VERSION); |
droy | 6e22cf5 | 2009-10-09 17:11:49 +0000 | [diff] [blame] | 45 | |
droy | 8aedeec | 2008-01-25 19:04:14 +0000 | [diff] [blame] | 46 | if($SUBMIT == "Save") { |
droy | ebd025c | 2009-10-08 20:42:48 +0000 | [diff] [blame] | 47 | if($PROJECT_ID != "" && $VERSION != "" && $FILE_FLD != "") { |
kitlo | d66aa99 | 2010-01-22 17:18:19 +0000 | [diff] [blame] | 48 | # Set URL type |
| 49 | $is_Map_file = 1; |
| 50 | if ($_POST["urlType"] == "updateSites") { |
| 51 | $is_Map_file = 0; |
| 52 | } |
| 53 | |
| 54 | # Delete old map files for this project version |
droy | ebd025c | 2009-10-08 20:42:48 +0000 | [diff] [blame] | 55 | $sql = "DELETE FROM map_files WHERE project_id = " |
| 56 | . returnQuotedString(sqlSanitize($PROJECT_ID, $dbh)) |
| 57 | . " AND version = " . returnQuotedString(sqlSanitize($VERSION, $dbh)); |
kitlo | 2c8d8a9 | 2018-04-19 13:25:09 -0400 | [diff] [blame] | 58 | mysqli_query($dbh, $sql); |
droy | ebd025c | 2009-10-08 20:42:48 +0000 | [diff] [blame] | 59 | |
kitlo | d66aa99 | 2010-01-22 17:18:19 +0000 | [diff] [blame] | 60 | # Insert new map files for this project version |
droy | ebd025c | 2009-10-08 20:42:48 +0000 | [diff] [blame] | 61 | $list = explode("\n", $FILE_FLD); |
| 62 | foreach ($list as $file) { |
| 63 | $file = str_replace("\r", "", $file); |
| 64 | if(strlen($file) > 8) { |
| 65 | $sql = "INSERT INTO map_files VALUES (" |
| 66 | . returnQuotedString(sqlSanitize($PROJECT_ID, $dbh)) |
| 67 | . "," . returnQuotedString(sqlSanitize($VERSION, $dbh)) |
| 68 | . "," . returnQuotedString(sqlSanitize(md5($file), $dbh)) |
| 69 | . "," . returnQuotedString(sqlSanitize($file, $dbh)) |
kitlo | d66aa99 | 2010-01-22 17:18:19 +0000 | [diff] [blame] | 70 | . ", 1, $is_Map_file)"; |
kitlo | 2c8d8a9 | 2018-04-19 13:25:09 -0400 | [diff] [blame] | 71 | mysqli_query($dbh, $sql); |
droy | ebd025c | 2009-10-08 20:42:48 +0000 | [diff] [blame] | 72 | } |
| 73 | } |
kitlo | d66aa99 | 2010-01-22 17:18:19 +0000 | [diff] [blame] | 74 | |
| 75 | # Delete old plugin exclude patterns for this project version |
| 76 | $sql = "DELETE FROM plugin_exclude_patterns WHERE project_id = " |
| 77 | . returnQuotedString(sqlSanitize($PROJECT_ID, $dbh)) |
| 78 | . " AND version = " . returnQuotedString(sqlSanitize($VERSION, $dbh)); |
kitlo | 2c8d8a9 | 2018-04-19 13:25:09 -0400 | [diff] [blame] | 79 | mysqli_query($dbh, $sql); |
kitlo | d66aa99 | 2010-01-22 17:18:19 +0000 | [diff] [blame] | 80 | |
| 81 | # Insert new plugin exclude patterns for this project version |
| 82 | $list = explode("\n", $PATTERNS); |
| 83 | foreach ($list as $pattern) { |
| 84 | $pattern = str_replace("\r", "", $pattern); |
| 85 | if (strlen($pattern) > 0) { |
kitlo | 7e9b1c1 | 2010-02-11 22:44:53 +0000 | [diff] [blame] | 86 | if (strlen($pattern) > 26 && strcmp(substr($pattern, 0, 26), "No plugin exclude patterns") == 0) { |
kitlo | 503e394 | 2010-02-11 22:05:33 +0000 | [diff] [blame] | 87 | } else { |
| 88 | $sql = "INSERT INTO plugin_exclude_patterns VALUES (" |
| 89 | . returnQuotedString(sqlSanitize($PROJECT_ID, $dbh)) |
| 90 | . "," . returnQuotedString(sqlSanitize($VERSION, $dbh)) |
| 91 | . "," . returnQuotedString(sqlSanitize($pattern, $dbh)) . ")"; |
kitlo | 2c8d8a9 | 2018-04-19 13:25:09 -0400 | [diff] [blame] | 92 | mysqli_query($dbh, $sql); |
kitlo | 503e394 | 2010-02-11 22:05:33 +0000 | [diff] [blame] | 93 | } |
kitlo | d66aa99 | 2010-01-22 17:18:19 +0000 | [diff] [blame] | 94 | } |
| 95 | } |
| 96 | |
droy | 0a2317a | 2008-12-17 16:25:15 +0000 | [diff] [blame] | 97 | # Save the project/train association |
| 98 | $sql = "DELETE FROM release_train_projects WHERE project_id = " |
atoulme | 3e5e934 | 2009-01-23 17:34:30 +0000 | [diff] [blame] | 99 | . returnQuotedString(sqlSanitize($PROJECT_ID, $dbh)) |
| 100 | . " AND version = " . returnQuotedString(sqlSanitize($VERSION, $dbh)); |
kitlo | 2c8d8a9 | 2018-04-19 13:25:09 -0400 | [diff] [blame] | 101 | mysqli_query($dbh, $sql); |
droy | 0a2317a | 2008-12-17 16:25:15 +0000 | [diff] [blame] | 102 | $sql = "INSERT INTO release_train_projects SET project_id = " |
atoulme | 3e5e934 | 2009-01-23 17:34:30 +0000 | [diff] [blame] | 103 | . returnQuotedString(sqlSanitize($PROJECT_ID, $dbh)) |
| 104 | . ", version = " . returnQuotedString(sqlSanitize($VERSION, $dbh)) |
| 105 | . ", train_id = " . returnQuotedString(sqlSanitize($TRAIN_ID, $dbh)); |
kitlo | 2c8d8a9 | 2018-04-19 13:25:09 -0400 | [diff] [blame] | 106 | mysqli_query($dbh, $sql); |
droy | ebd025c | 2009-10-08 20:42:48 +0000 | [diff] [blame] | 107 | $GLOBALS['g_ERRSTRS'][0] = "Map files saved."; |
droy | 8aedeec | 2008-01-25 19:04:14 +0000 | [diff] [blame] | 108 | } |
| 109 | else { |
| 110 | $GLOBALS['g_ERRSTRS'][0] = "Project, version and URL cannot be empty."; |
| 111 | } |
| 112 | } |
| 113 | if($SUBMIT == "delete") { |
| 114 | $SUBMIT = "showfiles"; |
| 115 | $sql = "DELETE FROM map_files WHERE |
atoulme | 3e5e934 | 2009-01-23 17:34:30 +0000 | [diff] [blame] | 116 | project_id = " . returnQuotedString(sqlSanitize($PROJECT_ID, $dbh)) . " |
| 117 | AND version = " . returnQuotedString(sqlSanitize($VERSION, $dbh)) . " |
| 118 | AND filename = ". returnQuotedString(sqlSanitize($FILENAME, $dbh)) . " LIMIT 1"; |
kitlo | 2c8d8a9 | 2018-04-19 13:25:09 -0400 | [diff] [blame] | 119 | mysqli_query($dbh, $sql); |
droy | 8aedeec | 2008-01-25 19:04:14 +0000 | [diff] [blame] | 120 | } |
| 121 | |
droy | 0a2317a | 2008-12-17 16:25:15 +0000 | [diff] [blame] | 122 | |
droy | ebd025c | 2009-10-08 20:42:48 +0000 | [diff] [blame] | 123 | $sql = "SELECT project_id FROM projects WHERE is_active = 1 ORDER BY project_id"; |
kitlo | 2c8d8a9 | 2018-04-19 13:25:09 -0400 | [diff] [blame] | 124 | $rs_project_list = mysqli_query($dbh, $sql); |
droy | 8aedeec | 2008-01-25 19:04:14 +0000 | [diff] [blame] | 125 | |
droy | 6e22cf5 | 2009-10-09 17:11:49 +0000 | [diff] [blame] | 126 | $sql = "SELECT pv.project_id, pv.version, count(m.is_active) AS map_count FROM project_versions as pv left join map_files as m on m.project_id = pv.project_id and m.version = pv.version WHERE pv.is_active = 1 and pv.version != 'unspecified' group by pv.project_id, pv.version ORDER BY pv.project_id ASC, pv.version DESC;"; |
kitlo | 2c8d8a9 | 2018-04-19 13:25:09 -0400 | [diff] [blame] | 127 | $rs_version_list = mysqli_query($dbh, $sql); |
droy | ebd025c | 2009-10-08 20:42:48 +0000 | [diff] [blame] | 128 | |
droy | c6cc007 | 2012-07-03 20:19:50 +0000 | [diff] [blame] | 129 | $sql = "SELECT train_id FROM release_trains ORDER BY train_id ASC"; |
kitlo | 2c8d8a9 | 2018-04-19 13:25:09 -0400 | [diff] [blame] | 130 | $rs_train_list = mysqli_query($dbh, $sql); |
droy | ebd025c | 2009-10-08 20:42:48 +0000 | [diff] [blame] | 131 | |
| 132 | $sql = "SELECT train_id, project_id, version FROM release_train_projects ORDER BY project_id, version ASC"; |
kitlo | 2c8d8a9 | 2018-04-19 13:25:09 -0400 | [diff] [blame] | 133 | $rs_train_project_list = mysqli_query($dbh, $sql); |
droy | ebd025c | 2009-10-08 20:42:48 +0000 | [diff] [blame] | 134 | |
| 135 | global $addon; |
| 136 | $addon->callHook("head"); |
| 137 | include($incfile); |
| 138 | $addon->callHook("footer"); |
droy | 8aedeec | 2008-01-25 19:04:14 +0000 | [diff] [blame] | 139 | |
kitlo | d66aa99 | 2010-01-22 17:18:19 +0000 | [diff] [blame] | 140 | ?> |