Kit Lo | 3c7ce14 | 2013-03-02 18:22:40 -0500 | [diff] [blame] | 1 | <?php |
| 2 | /******************************************************************************* |
| 3 | * Copyright (c) 2013 IBM Corporation and others. |
| 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 | * Kit Lo (IBM) - [402192] Extract project source files from Git repositories for translation |
| 11 | *******************************************************************************/ |
| 12 | |
| 13 | include("global.php"); |
| 14 | |
| 15 | InitPage(""); |
| 16 | |
| 17 | global $User; |
| 18 | global $dbh; |
| 19 | |
| 20 | if(!isset($User->userid)) { |
| 21 | exitTo("importing.php"); |
| 22 | } |
| 23 | |
Kit Lo | 3c7ce14 | 2013-03-02 18:22:40 -0500 | [diff] [blame] | 24 | require(dirname(__FILE__) . "/../classes/file/file.class.php"); |
| 25 | |
| 26 | |
| 27 | $pageTitle = "Babel - Define Project Source Locations"; |
| 28 | $pageKeywords = ""; |
| 29 | $incfile = "content/en_project_source_locations.php"; |
| 30 | |
| 31 | $PROJECT_ID = getHTTPParameter("project_id"); |
| 32 | $VERSION = getHTTPParameter("version"); |
| 33 | $TRAIN_ID = getHTTPParameter("train_id"); |
| 34 | $FILE_FLD = getHTTPParameter("fileFld"); |
| 35 | $PATTERNS = getHTTPParameter("patterns"); |
| 36 | $FILENAME = getHTTPParameter("filename"); |
| 37 | $SUBMIT = getHTTPParameter("submit"); |
| 38 | |
| 39 | $VERSION = preg_replace("/^\* /", "", $VERSION); |
| 40 | |
| 41 | if($SUBMIT == "Save") { |
| 42 | if($PROJECT_ID != "" && $VERSION != "" && $FILE_FLD != "") { |
| 43 | # Delete old project_source_locations for this project version |
| 44 | $sql = "DELETE FROM project_source_locations WHERE project_id = " |
| 45 | . returnQuotedString(sqlSanitize($PROJECT_ID, $dbh)) |
| 46 | . " AND version = " . returnQuotedString(sqlSanitize($VERSION, $dbh)); |
kitlo | 2c8d8a9 | 2018-04-19 13:25:09 -0400 | [diff] [blame] | 47 | mysqli_query($dbh, $sql); |
Kit Lo | 3c7ce14 | 2013-03-02 18:22:40 -0500 | [diff] [blame] | 48 | |
| 49 | # Insert new project_source_locations for this project version |
| 50 | $list = explode("\n", $FILE_FLD); |
| 51 | foreach ($list as $file) { |
| 52 | $file = str_replace("\r", "", $file); |
| 53 | if(strlen($file) > 8) { |
| 54 | $sql = "INSERT INTO project_source_locations VALUES (" |
| 55 | . returnQuotedString(sqlSanitize($PROJECT_ID, $dbh)) |
| 56 | . "," . returnQuotedString(sqlSanitize($VERSION, $dbh)) |
| 57 | . "," . returnQuotedString(sqlSanitize($file, $dbh)) |
| 58 | . ")"; |
kitlo | 2c8d8a9 | 2018-04-19 13:25:09 -0400 | [diff] [blame] | 59 | mysqli_query($dbh, $sql); |
Kit Lo | 3c7ce14 | 2013-03-02 18:22:40 -0500 | [diff] [blame] | 60 | } |
| 61 | } |
| 62 | |
| 63 | # Delete old plugin exclude patterns for this project version |
| 64 | $sql = "DELETE FROM plugin_exclude_patterns WHERE project_id = " |
| 65 | . returnQuotedString(sqlSanitize($PROJECT_ID, $dbh)) |
| 66 | . " AND version = " . returnQuotedString(sqlSanitize($VERSION, $dbh)); |
kitlo | 2c8d8a9 | 2018-04-19 13:25:09 -0400 | [diff] [blame] | 67 | mysqli_query($dbh, $sql); |
Kit Lo | 3c7ce14 | 2013-03-02 18:22:40 -0500 | [diff] [blame] | 68 | |
| 69 | # Insert new plugin exclude patterns for this project version |
| 70 | $list = explode("\n", $PATTERNS); |
| 71 | foreach ($list as $pattern) { |
| 72 | $pattern = str_replace("\r", "", $pattern); |
| 73 | if (strlen($pattern) > 0) { |
| 74 | if (strlen($pattern) > 26 && strcmp(substr($pattern, 0, 26), "No plugin exclude patterns") == 0) { |
| 75 | } else { |
| 76 | $sql = "INSERT INTO plugin_exclude_patterns VALUES (" |
| 77 | . returnQuotedString(sqlSanitize($PROJECT_ID, $dbh)) |
| 78 | . "," . returnQuotedString(sqlSanitize($VERSION, $dbh)) |
| 79 | . "," . returnQuotedString(sqlSanitize($pattern, $dbh)) . ")"; |
kitlo | 2c8d8a9 | 2018-04-19 13:25:09 -0400 | [diff] [blame] | 80 | mysqli_query($dbh, $sql); |
Kit Lo | 3c7ce14 | 2013-03-02 18:22:40 -0500 | [diff] [blame] | 81 | } |
| 82 | } |
| 83 | } |
| 84 | |
| 85 | # Save the project/train association |
| 86 | $sql = "DELETE FROM release_train_projects WHERE project_id = " |
| 87 | . returnQuotedString(sqlSanitize($PROJECT_ID, $dbh)) |
| 88 | . " AND version = " . returnQuotedString(sqlSanitize($VERSION, $dbh)); |
kitlo | 2c8d8a9 | 2018-04-19 13:25:09 -0400 | [diff] [blame] | 89 | mysqli_query($dbh, $sql); |
Kit Lo | 3c7ce14 | 2013-03-02 18:22:40 -0500 | [diff] [blame] | 90 | $sql = "INSERT INTO release_train_projects SET project_id = " |
| 91 | . returnQuotedString(sqlSanitize($PROJECT_ID, $dbh)) |
| 92 | . ", version = " . returnQuotedString(sqlSanitize($VERSION, $dbh)) |
| 93 | . ", train_id = " . returnQuotedString(sqlSanitize($TRAIN_ID, $dbh)); |
kitlo | 2c8d8a9 | 2018-04-19 13:25:09 -0400 | [diff] [blame] | 94 | mysqli_query($dbh, $sql); |
Kit Lo | 3c7ce14 | 2013-03-02 18:22:40 -0500 | [diff] [blame] | 95 | $GLOBALS['g_ERRSTRS'][0] = "Project source locations saved."; |
| 96 | } |
| 97 | else { |
| 98 | $GLOBALS['g_ERRSTRS'][0] = "Project, version and URL cannot be empty."; |
| 99 | } |
| 100 | } |
| 101 | |
| 102 | $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] | 103 | $rs_project_list = mysqli_query($dbh, $sql); |
Kit Lo | 3c7ce14 | 2013-03-02 18:22:40 -0500 | [diff] [blame] | 104 | |
| 105 | $sql = "SELECT pv.project_id, pv.version, count(m.location) AS map_count FROM project_versions as pv left join project_source_locations 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] | 106 | $rs_version_list = mysqli_query($dbh, $sql); |
Kit Lo | 3c7ce14 | 2013-03-02 18:22:40 -0500 | [diff] [blame] | 107 | |
| 108 | $sql = "SELECT train_id FROM release_trains ORDER BY train_id ASC"; |
kitlo | 2c8d8a9 | 2018-04-19 13:25:09 -0400 | [diff] [blame] | 109 | $rs_train_list = mysqli_query($dbh, $sql); |
Kit Lo | 3c7ce14 | 2013-03-02 18:22:40 -0500 | [diff] [blame] | 110 | |
| 111 | $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] | 112 | $rs_train_project_list = mysqli_query($dbh, $sql); |
Kit Lo | 3c7ce14 | 2013-03-02 18:22:40 -0500 | [diff] [blame] | 113 | |
| 114 | global $addon; |
| 115 | $addon->callHook("head"); |
| 116 | include($incfile); |
| 117 | $addon->callHook("footer"); |
| 118 | |
| 119 | ?> |