blob: b9d6e0e207e61ad1a27646f46300abad564a6690 [file] [log] [blame]
droy8aedeec2008-01-25 19:04:14 +00001<?php
2/*******************************************************************************
droyebd025c2009-10-08 20:42:48 +00003 * Copyright (c) 2008-2009 Eclipse Foundation and others.
droy8aedeec2008-01-25 19:04:14 +00004 * 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
kitloe8ed9b22009-02-24 19:33:37 +000011 * Kit Lo (IBM) - patch, bug 266010, Map file table does not show release train and file name info
kitlod66aa992010-01-22 17:18:19 +000012 * Kit Lo (IBM) - Bug 299402, Extract properties files from Eclipse project update sites for translation
droy8aedeec2008-01-25 19:04:14 +000013*******************************************************************************/
14include("global.php");
gobrien1a8e02f2008-01-30 01:46:26 +000015
16InitPage("");
droy8aedeec2008-01-25 19:04:14 +000017
18global $User;
atoulme3e5e9342009-01-23 17:34:30 +000019global $dbh;
gobrien1a8e02f2008-01-30 01:46:26 +000020
21if(!isset($User->userid)) {
22 exitTo("importing.php");
23}
24
droy673b24c2008-01-30 16:30:46 +000025if($User->is_committer != 1) {
Paul Pazderski10ba3f32019-08-28 13:47:44 +020026 exitTo("login_oauth.php?errNo=3214","error: 3214 - you must be an Eclipse committer to access this page.");
droy8aedeec2008-01-25 19:04:14 +000027}
28
atoulme12882d52009-01-26 18:39:17 +000029require(dirname(__FILE__) . "/../classes/file/file.class.php");
droy8aedeec2008-01-25 19:04:14 +000030
31
kitlod66aa992010-01-22 17:18:19 +000032$pageTitle = "Babel - Define Map Files or Update Sites";
droy8aedeec2008-01-25 19:04:14 +000033$pageKeywords = "";
34$incfile = "content/en_map_files.php";
35
atoulme3e5e9342009-01-23 17:34:30 +000036$PROJECT_ID = getHTTPParameter("project_id");
37$VERSION = getHTTPParameter("version");
38$TRAIN_ID = getHTTPParameter("train_id");
droyebd025c2009-10-08 20:42:48 +000039$FILE_FLD = getHTTPParameter("fileFld");
kitlod66aa992010-01-22 17:18:19 +000040$PATTERNS = getHTTPParameter("patterns");
atoulme3e5e9342009-01-23 17:34:30 +000041$FILENAME = getHTTPParameter("filename");
42$SUBMIT = getHTTPParameter("submit");
droy8aedeec2008-01-25 19:04:14 +000043
droy6e22cf52009-10-09 17:11:49 +000044$VERSION = preg_replace("/^\* /", "", $VERSION);
droy6e22cf52009-10-09 17:11:49 +000045
droy8aedeec2008-01-25 19:04:14 +000046if($SUBMIT == "Save") {
droyebd025c2009-10-08 20:42:48 +000047 if($PROJECT_ID != "" && $VERSION != "" && $FILE_FLD != "") {
kitlod66aa992010-01-22 17:18:19 +000048 # 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
droyebd025c2009-10-08 20:42:48 +000055 $sql = "DELETE FROM map_files WHERE project_id = "
56 . returnQuotedString(sqlSanitize($PROJECT_ID, $dbh))
57 . " AND version = " . returnQuotedString(sqlSanitize($VERSION, $dbh));
kitlo2c8d8a92018-04-19 13:25:09 -040058 mysqli_query($dbh, $sql);
droyebd025c2009-10-08 20:42:48 +000059
kitlod66aa992010-01-22 17:18:19 +000060 # Insert new map files for this project version
droyebd025c2009-10-08 20:42:48 +000061 $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))
kitlod66aa992010-01-22 17:18:19 +000070 . ", 1, $is_Map_file)";
kitlo2c8d8a92018-04-19 13:25:09 -040071 mysqli_query($dbh, $sql);
droyebd025c2009-10-08 20:42:48 +000072 }
73 }
kitlod66aa992010-01-22 17:18:19 +000074
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));
kitlo2c8d8a92018-04-19 13:25:09 -040079 mysqli_query($dbh, $sql);
kitlod66aa992010-01-22 17:18:19 +000080
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) {
kitlo7e9b1c12010-02-11 22:44:53 +000086 if (strlen($pattern) > 26 && strcmp(substr($pattern, 0, 26), "No plugin exclude patterns") == 0) {
kitlo503e3942010-02-11 22:05:33 +000087 } 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)) . ")";
kitlo2c8d8a92018-04-19 13:25:09 -040092 mysqli_query($dbh, $sql);
kitlo503e3942010-02-11 22:05:33 +000093 }
kitlod66aa992010-01-22 17:18:19 +000094 }
95 }
96
droy0a2317a2008-12-17 16:25:15 +000097 # Save the project/train association
98 $sql = "DELETE FROM release_train_projects WHERE project_id = "
atoulme3e5e9342009-01-23 17:34:30 +000099 . returnQuotedString(sqlSanitize($PROJECT_ID, $dbh))
100 . " AND version = " . returnQuotedString(sqlSanitize($VERSION, $dbh));
kitlo2c8d8a92018-04-19 13:25:09 -0400101 mysqli_query($dbh, $sql);
droy0a2317a2008-12-17 16:25:15 +0000102 $sql = "INSERT INTO release_train_projects SET project_id = "
atoulme3e5e9342009-01-23 17:34:30 +0000103 . returnQuotedString(sqlSanitize($PROJECT_ID, $dbh))
104 . ", version = " . returnQuotedString(sqlSanitize($VERSION, $dbh))
105 . ", train_id = " . returnQuotedString(sqlSanitize($TRAIN_ID, $dbh));
kitlo2c8d8a92018-04-19 13:25:09 -0400106 mysqli_query($dbh, $sql);
droyebd025c2009-10-08 20:42:48 +0000107 $GLOBALS['g_ERRSTRS'][0] = "Map files saved.";
droy8aedeec2008-01-25 19:04:14 +0000108 }
109 else {
110 $GLOBALS['g_ERRSTRS'][0] = "Project, version and URL cannot be empty.";
111 }
112}
113if($SUBMIT == "delete") {
114 $SUBMIT = "showfiles";
115 $sql = "DELETE FROM map_files WHERE
atoulme3e5e9342009-01-23 17:34:30 +0000116 project_id = " . returnQuotedString(sqlSanitize($PROJECT_ID, $dbh)) . "
117 AND version = " . returnQuotedString(sqlSanitize($VERSION, $dbh)) . "
118 AND filename = ". returnQuotedString(sqlSanitize($FILENAME, $dbh)) . " LIMIT 1";
kitlo2c8d8a92018-04-19 13:25:09 -0400119 mysqli_query($dbh, $sql);
droy8aedeec2008-01-25 19:04:14 +0000120}
121
droy0a2317a2008-12-17 16:25:15 +0000122
droyebd025c2009-10-08 20:42:48 +0000123$sql = "SELECT project_id FROM projects WHERE is_active = 1 ORDER BY project_id";
kitlo2c8d8a92018-04-19 13:25:09 -0400124$rs_project_list = mysqli_query($dbh, $sql);
droy8aedeec2008-01-25 19:04:14 +0000125
droy6e22cf52009-10-09 17:11:49 +0000126$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;";
kitlo2c8d8a92018-04-19 13:25:09 -0400127$rs_version_list = mysqli_query($dbh, $sql);
droyebd025c2009-10-08 20:42:48 +0000128
droyc6cc0072012-07-03 20:19:50 +0000129$sql = "SELECT train_id FROM release_trains ORDER BY train_id ASC";
kitlo2c8d8a92018-04-19 13:25:09 -0400130$rs_train_list = mysqli_query($dbh, $sql);
droyebd025c2009-10-08 20:42:48 +0000131
132$sql = "SELECT train_id, project_id, version FROM release_train_projects ORDER BY project_id, version ASC";
kitlo2c8d8a92018-04-19 13:25:09 -0400133$rs_train_project_list = mysqli_query($dbh, $sql);
droyebd025c2009-10-08 20:42:48 +0000134
135global $addon;
136$addon->callHook("head");
137include($incfile);
138$addon->callHook("footer");
droy8aedeec2008-01-25 19:04:14 +0000139
kitlod66aa992010-01-22 17:18:19 +0000140?>