result_status web RPC: accept names as well as IDs

This commit is contained in:
David Anderson 2016-06-20 09:32:26 -07:00
parent 8300b08968
commit fc995ea829
2 changed files with 26 additions and 10 deletions

View File

@ -20,7 +20,7 @@ $sensing = array(
array(
array(
"Quake Catcher Network",
"http://qcn.caltech.edu/sensor",
"http://quakecatcher.net",
tra("Caltech"),
tra("Seismology"),
tra("Quake-Catcher Network uses sensors attached to computers and smartphones to detect seismic waves."),

View File

@ -17,13 +17,14 @@
// along with BOINC. If not, see <http://www.gnu.org/licenses/>.
// RPC handler for getting the status of one or more results
// args:
// ids=id1,id2...
// or
// names = name1,name2,...
require_once("../inc/util.inc");
require_once("../inc/xml.inc");
$ids = get_str("ids");
$ids = explode(",", $ids);
function result_xml($r) {
echo "
<result>
@ -58,12 +59,27 @@ function result_xml($r) {
xml_header();
echo "<results>\n";
foreach ($ids as $id) {
$result = BoincResult::lookup_id($id);
if ($result) {
result_xml($result);
} else {
echo "<error>ID $id unknown</error>\n";
$ids = get_str("ids", true);
if ($ids) {
$ids = explode(",", $ids);
foreach ($ids as $id) {
$result = BoincResult::lookup_id($id);
if ($result) {
result_xml($result);
} else {
echo "<error>ID $id unknown</error>\n";
}
}
} else {
$names = get_str("names", true);
$names = explode(",", $names);
foreach ($names as $name) {
$result = BoincResult::lookup_name($name);
if ($result) {
result_xml($result);
} else {
echo "<error>name $name unknown</error>\n";
}
}
}
echo "</results>\n";