blob: efc113c6b99f7e70cc29c8bf553a4b24090d0173 [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) {
gobrien1a8e02f2008-01-30 01:46:26 +000026 exitTo("login.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));
droy8aedeec2008-01-25 19:04:14 +000058 mysql_query($sql, $dbh);
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)";
droyebd025c2009-10-08 20:42:48 +000071 mysql_query($sql, $dbh);
72 }
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));
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
droy0a2317a2008-12-17 16:25:15 +000094 # Save the project/train association
95 $sql = "DELETE FROM release_train_projects WHERE project_id = "
atoulme3e5e9342009-01-23 17:34:30 +000096 . returnQuotedString(sqlSanitize($PROJECT_ID, $dbh))
97 . " AND version = " . returnQuotedString(sqlSanitize($VERSION, $dbh));
droy0a2317a2008-12-17 16:25:15 +000098 mysql_query($sql, $dbh);
99 $sql = "INSERT INTO release_train_projects SET project_id = "
atoulme3e5e9342009-01-23 17:34:30 +0000100 . returnQuotedString(sqlSanitize($PROJECT_ID, $dbh))
101 . ", version = " . returnQuotedString(sqlSanitize($VERSION, $dbh))
102 . ", train_id = " . returnQuotedString(sqlSanitize($TRAIN_ID, $dbh));
droy0a2317a2008-12-17 16:25:15 +0000103 mysql_query($sql, $dbh);
droyebd025c2009-10-08 20:42:48 +0000104 $GLOBALS['g_ERRSTRS'][0] = "Map files saved.";
droy8aedeec2008-01-25 19:04:14 +0000105 }
106 else {
107 $GLOBALS['g_ERRSTRS'][0] = "Project, version and URL cannot be empty.";
108 }
109}
110if($SUBMIT == "delete") {
111 $SUBMIT = "showfiles";
112 $sql = "DELETE FROM map_files WHERE
atoulme3e5e9342009-01-23 17:34:30 +0000113 project_id = " . returnQuotedString(sqlSanitize($PROJECT_ID, $dbh)) . "
114 AND version = " . returnQuotedString(sqlSanitize($VERSION, $dbh)) . "
115 AND filename = ". returnQuotedString(sqlSanitize($FILENAME, $dbh)) . " LIMIT 1";
droy8aedeec2008-01-25 19:04:14 +0000116 mysql_query($sql, $dbh);
117}
118
droy0a2317a2008-12-17 16:25:15 +0000119
droyebd025c2009-10-08 20:42:48 +0000120$sql = "SELECT project_id FROM projects WHERE is_active = 1 ORDER BY project_id";
121$rs_project_list = mysql_query($sql, $dbh);
droy8aedeec2008-01-25 19:04:14 +0000122
droy6e22cf52009-10-09 17:11:49 +0000123$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;";
droyebd025c2009-10-08 20:42:48 +0000124$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
132global $addon;
133$addon->callHook("head");
134include($incfile);
135$addon->callHook("footer");
droy8aedeec2008-01-25 19:04:14 +0000136
kitlod66aa992010-01-22 17:18:19 +0000137?>