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) { |
gobrien | 1a8e02f | 2008-01-30 01:46:26 +0000 | [diff] [blame] | 26 | exitTo("login.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)); |
droy | 8aedeec | 2008-01-25 19:04:14 +0000 | [diff] [blame] | 58 | mysql_query($sql, $dbh); |
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)"; |
droy | ebd025c | 2009-10-08 20:42:48 +0000 | [diff] [blame] | 71 | mysql_query($sql, $dbh); |
| 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)); |
| 79 | mysql_query($sql, $dbh); |
| 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) { |
| 86 | $sql = "INSERT INTO plugin_exclude_patterns VALUES (" |
| 87 | . returnQuotedString(sqlSanitize($PROJECT_ID, $dbh)) |
| 88 | . "," . returnQuotedString(sqlSanitize($VERSION, $dbh)) |
| 89 | . "," . returnQuotedString(sqlSanitize($pattern, $dbh)) . ")"; |
| 90 | mysql_query($sql, $dbh); |
| 91 | } |
| 92 | } |
| 93 | |
droy | 0a2317a | 2008-12-17 16:25:15 +0000 | [diff] [blame] | 94 | # Save the project/train association |
| 95 | $sql = "DELETE FROM release_train_projects WHERE project_id = " |
atoulme | 3e5e934 | 2009-01-23 17:34:30 +0000 | [diff] [blame] | 96 | . returnQuotedString(sqlSanitize($PROJECT_ID, $dbh)) |
| 97 | . " AND version = " . returnQuotedString(sqlSanitize($VERSION, $dbh)); |
droy | 0a2317a | 2008-12-17 16:25:15 +0000 | [diff] [blame] | 98 | mysql_query($sql, $dbh); |
| 99 | $sql = "INSERT INTO release_train_projects SET project_id = " |
atoulme | 3e5e934 | 2009-01-23 17:34:30 +0000 | [diff] [blame] | 100 | . returnQuotedString(sqlSanitize($PROJECT_ID, $dbh)) |
| 101 | . ", version = " . returnQuotedString(sqlSanitize($VERSION, $dbh)) |
| 102 | . ", train_id = " . returnQuotedString(sqlSanitize($TRAIN_ID, $dbh)); |
droy | 0a2317a | 2008-12-17 16:25:15 +0000 | [diff] [blame] | 103 | mysql_query($sql, $dbh); |
droy | ebd025c | 2009-10-08 20:42:48 +0000 | [diff] [blame] | 104 | $GLOBALS['g_ERRSTRS'][0] = "Map files saved."; |
droy | 8aedeec | 2008-01-25 19:04:14 +0000 | [diff] [blame] | 105 | } |
| 106 | else { |
| 107 | $GLOBALS['g_ERRSTRS'][0] = "Project, version and URL cannot be empty."; |
| 108 | } |
| 109 | } |
| 110 | if($SUBMIT == "delete") { |
| 111 | $SUBMIT = "showfiles"; |
| 112 | $sql = "DELETE FROM map_files WHERE |
atoulme | 3e5e934 | 2009-01-23 17:34:30 +0000 | [diff] [blame] | 113 | project_id = " . returnQuotedString(sqlSanitize($PROJECT_ID, $dbh)) . " |
| 114 | AND version = " . returnQuotedString(sqlSanitize($VERSION, $dbh)) . " |
| 115 | AND filename = ". returnQuotedString(sqlSanitize($FILENAME, $dbh)) . " LIMIT 1"; |
droy | 8aedeec | 2008-01-25 19:04:14 +0000 | [diff] [blame] | 116 | mysql_query($sql, $dbh); |
| 117 | } |
| 118 | |
droy | 0a2317a | 2008-12-17 16:25:15 +0000 | [diff] [blame] | 119 | |
droy | ebd025c | 2009-10-08 20:42:48 +0000 | [diff] [blame] | 120 | $sql = "SELECT project_id FROM projects WHERE is_active = 1 ORDER BY project_id"; |
| 121 | $rs_project_list = mysql_query($sql, $dbh); |
droy | 8aedeec | 2008-01-25 19:04:14 +0000 | [diff] [blame] | 122 | |
droy | 6e22cf5 | 2009-10-09 17:11:49 +0000 | [diff] [blame] | 123 | $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;"; |
droy | ebd025c | 2009-10-08 20:42:48 +0000 | [diff] [blame] | 124 | $rs_version_list = mysql_query($sql, $dbh); |
| 125 | |
| 126 | $sql = "SELECT DISTINCT train_id FROM release_train_projects ORDER BY train_id ASC"; |
| 127 | $rs_train_list = mysql_query($sql, $dbh); |
| 128 | |
| 129 | $sql = "SELECT train_id, project_id, version FROM release_train_projects ORDER BY project_id, version ASC"; |
| 130 | $rs_train_project_list = mysql_query($sql, $dbh); |
| 131 | |
| 132 | global $addon; |
| 133 | $addon->callHook("head"); |
| 134 | include($incfile); |
| 135 | $addon->callHook("footer"); |
droy | 8aedeec | 2008-01-25 19:04:14 +0000 | [diff] [blame] | 136 | |
kitlo | d66aa99 | 2010-01-22 17:18:19 +0000 | [diff] [blame] | 137 | ?> |