Issues (1963)

html/ops/assign.php (4 issues)

1
<?php
2
// This file is part of BOINC.
3
// http://boinc.berkeley.edu
4
// Copyright (C) 2008 University of California
5
//
6
// BOINC is free software; you can redistribute it and/or modify it
7
// under the terms of the GNU Lesser General Public License
8
// as published by the Free Software Foundation,
9
// either version 3 of the License, or (at your option) any later version.
10
//
11
// BOINC is distributed in the hope that it will be useful,
12
// but WITHOUT ANY WARRANTY; without even the implied warranty of
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14
// See the GNU Lesser General Public License for more details.
15
//
16
// You should have received a copy of the GNU Lesser General Public License
17
// along with BOINC.  If not, see <http://www.gnu.org/licenses/>.
18
19
require_once("../inc/util_ops.inc");
20
21
function show_assign($asgn) {
22
    $when = time_str($asgn->create_time);
23
    switch ($asgn->target_type) {
24
    case 0:
25
        $x = "All hosts";
26
        break;
27
    case 1:
28
        $x = "<a href=db_action.php?table=host&id=$asgn->id>Host $asgn->target_id</a>";
29
        break;
30
    case 2:
31
        if ($asgn->multi) {
32
            $y = "All hosts belonging to ";
33
        } else {
34
            $y = "One host belonging to ";
35
        }
36
        $x = "$y<a href=db_action.php?table=user&id=$asgn->target_id>User $asgn->target_id</a>";
37
        break;
38
    case 3:
39
        if ($asgn->multi) {
40
            $y = "All hosts belonging to ";
41
        } else {
42
            $y = "One host belonging to ";
43
        }
44
        $x = "$y<a href=db_action.php?table=team&id=$asgn->target_id>Team $asgn->target_id</a>";
45
        break;
46
    }
47
    echo "<tr>
48
        <td>$asgn->id (created $when)</td>
49
        <td>$x</td>
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $x does not seem to be defined for all execution paths leading up to this point.
Loading history...
50
        <td><a href=db_action.php?table=workunit&id=$asgn->workunitid>$asgn->workunitid</a></td>
51
        <td><a href=db_action.php?table=result&id=$asgn->resultid>$asgn->resultid</a></td>
52
        </tr>
53
    ";
54
}
55
56
function show_assigns() {
57
    admin_page_head("Assignments");
58
    $asgns = BoincAssignment::enum();
59
    if (count($asgns)) {
60
        start_table();
61
        table_header("Assignment ID/time", "target", "workunit", "result");
62
        foreach ($asgns as $asgn) {
63
            show_assign($asgn);
64
        }
65
        end_table();
66
    } else {
67
        echo "No assignments";
68
    }
69
    admin_page_tail();
70
}
71
72
$action = get_str('action', true);
73
switch ($action) {
0 ignored issues
show
SWITCH statements must contain at least one CASE statement
Loading history...
74
default:
0 ignored issues
show
DEFAULT keyword must be indented 4 spaces from SWITCH keyword
Loading history...
DEFAULT case must have a breaking statement
Loading history...
75
    show_assigns();
76
}
77
78
?>
79