blob: e6c983418276d487ad102e49a9592eefaca4307d [file] [log] [blame]
Kit Lo3c7ce142013-03-02 18:22:40 -05001<?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
13include("global.php");
14
15InitPage("");
16
17global $User;
18global $dbh;
19
20if(!isset($User->userid)) {
21 exitTo("importing.php");
22}
23
Kit Lo3c7ce142013-03-02 18:22:40 -050024require(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
41if($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));
kitlo2c8d8a92018-04-19 13:25:09 -040047 mysqli_query($dbh, $sql);
Kit Lo3c7ce142013-03-02 18:22:40 -050048
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 . ")";
kitlo2c8d8a92018-04-19 13:25:09 -040059 mysqli_query($dbh, $sql);
Kit Lo3c7ce142013-03-02 18:22:40 -050060 }
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));
kitlo2c8d8a92018-04-19 13:25:09 -040067 mysqli_query($dbh, $sql);
Kit Lo3c7ce142013-03-02 18:22:40 -050068
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)) . ")";
kitlo2c8d8a92018-04-19 13:25:09 -040080 mysqli_query($dbh, $sql);
Kit Lo3c7ce142013-03-02 18:22:40 -050081 }
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));
kitlo2c8d8a92018-04-19 13:25:09 -040089 mysqli_query($dbh, $sql);
Kit Lo3c7ce142013-03-02 18:22:40 -050090 $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));
kitlo2c8d8a92018-04-19 13:25:09 -040094 mysqli_query($dbh, $sql);
Kit Lo3c7ce142013-03-02 18:22:40 -050095 $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";
kitlo2c8d8a92018-04-19 13:25:09 -0400103$rs_project_list = mysqli_query($dbh, $sql);
Kit Lo3c7ce142013-03-02 18:22:40 -0500104
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;";
kitlo2c8d8a92018-04-19 13:25:09 -0400106$rs_version_list = mysqli_query($dbh, $sql);
Kit Lo3c7ce142013-03-02 18:22:40 -0500107
108$sql = "SELECT train_id FROM release_trains ORDER BY train_id ASC";
kitlo2c8d8a92018-04-19 13:25:09 -0400109$rs_train_list = mysqli_query($dbh, $sql);
Kit Lo3c7ce142013-03-02 18:22:40 -0500110
111$sql = "SELECT train_id, project_id, version FROM release_train_projects ORDER BY project_id, version ASC";
kitlo2c8d8a92018-04-19 13:25:09 -0400112$rs_train_project_list = mysqli_query($dbh, $sql);
Kit Lo3c7ce142013-03-02 18:22:40 -0500113
114global $addon;
115$addon->callHook("head");
116include($incfile);
117$addon->callHook("footer");
118
119?>