forked from Kitware/CDash
-
Notifications
You must be signed in to change notification settings - Fork 0
/
manageMeasurements.php
138 lines (120 loc) · 4.32 KB
/
manageMeasurements.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
<?php
/*=========================================================================
Program: CDash - Cross-Platform Dashboard System
Module: $Id$
Language: PHP
Date: $Date$
Copyright (c) 2002 Kitware, Inc. All rights reserved.
See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
Copyright (c) 2012 Volkan Gezer <[email protected]>
=========================================================================*/
include("cdash/config.php");
require_once("cdash/pdo.php");
include('login.php');
include_once("cdash/common.php");
include_once("models/project.php");
if ($session_OK)
{
$projectid = pdo_real_escape_numeric($_REQUEST["projectid"]);
checkUserPolicy(@$_SESSION['cdash']['loginid'],$projectid);
// Checks
if(!isset($projectid) || !is_numeric($projectid))
{
echo "Not a valid projectid!";
return;
}
$project = pdo_query("SELECT * FROM project WHERE id='$projectid'");
if(pdo_num_rows($project)>0)
{
$project_array = pdo_fetch_array($project);
$projectname = $project_array["name"];
$nightlytime = $project_array["nightlytime"];
}
$submit=$_POST['submit'];
$nameN = htmlspecialchars(pdo_real_escape_string($_POST['nameN']));
$showTN = htmlspecialchars(pdo_real_escape_string($_POST['showTN']));
$showSN = htmlspecialchars(pdo_real_escape_string($_POST['showSN']));
$id=$_POST['id'];
$name=$_POST['name'];
// Start operation if it is submitted
if($submit=="Save")
{
if($nameN)
{
pdo_query("INSERT INTO measurement (projectid,name,testpage,summarypage) VALUES ('$projectid','$nameN','$showTN','$showSN')"); // only write a new entry if new field is filled
}
$i=0;
if(count($_POST['name']))
{
foreach($name as $newName)
{ // everytime update all test attributes
$showT=$_POST["showT"];
$showS=$_POST["showS"];
if($showT[$id[$i]]=='') $showT[$id[$i]]=0;
if($showS[$id[$i]]=='') $showS[$id[$i]]=0;
pdo_query("UPDATE measurement SET name='$newName', testpage='".$showT[$id[$i]]."', summarypage='".$showS[$id[$i]]."' WHERE id='".$id[$i]."'");
$i++;
}
}
}
$selection=$_POST['select'];
if($_POST['del'] && count($selection)>0)
{ // if user chose any named measurement delete them
foreach($selection as $del)
{
pdo_query("DELETE FROM measurement WHERE id='$del'");
}
}
$xml = begin_XML_for_XSLT();
$xml .= "<backurl>user.php</backurl>";
$xml .= "<title>CDash - ".$projectname." Measurements</title>";
$xml .= "<menutitle>".$projectname."</menutitle>";
$xml .= "<menusubtitle>Measurements</menusubtitle>";
if($projectid>0)
{
$Project = new Project;
$Project->Id = $projectid;
$xml .= "<project>";
$xml .= add_XML_value("id",$projectid);
$xml .= add_XML_value("name",$Project->GetName());
$xml .= add_XML_value("name_encoded",urlencode($Project->GetName()));
$xml .= "</project>";
}
// Menu
$xml .= "<menu>";
$nightlytime = get_project_property($projectname,"nightlytime");
$xml .= add_XML_value("back","index.php?project=".urlencode($projectname)."&date=".get_dashboard_date_from_build_starttime($build_array["starttime"],$nightlytime));
$xml .= add_XML_value("noprevious","1");
$xml .= add_XML_value("nonext","1");
$xml .= "</menu>";
{
$xml .= "<user>";
$userid = $_SESSION['cdash']['loginid'];
$user = pdo_query("SELECT admin FROM ".qid("user")." WHERE id='$userid'");
$user_array = pdo_fetch_array($user);
$xml .= add_XML_value("id",$userid);
$xml .= add_XML_value("admin",$user_array["admin"]);
$xml .= "</user>";
}
//get any measurements associated with this test
$xml .= "<measurements>";
$query = "SELECT id,name,testpage,summarypage FROM measurement WHERE projectid='$projectid' ORDER BY name ASC";
$result = pdo_query($query);
while($row = pdo_fetch_array($result))
{
$xml .= "<measurement>";
$xml .= add_XML_value("id", $row["id"]);
$xml .= add_XML_value("name", $row["name"]);
$xml .= add_XML_value("showT", $row["testpage"]);
$xml .= add_XML_value("showS", $row["summarypage"]);
$xml .= "</measurement>";
}
$xml .= "</measurements>";
$xml .= "</cdash>";
// Now doing the xslt transition
generate_XSLT($xml,"manageMeasurements");
} // end if session
?>