Issues (1963)

html/user/manage.php (5 issues)

1
<?php
2
// This file is part of BOINC.
3
// http://boinc.berkeley.edu
4
// Copyright (C) 2011 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
// top-level management page;
20
// shows links to the various functions available to the user.
21
// If the only option is managing a particular app,
22
// redirect to that page
23
24
require_once("../inc/submit_db.inc");
25
require_once("../inc/util.inc");
26
27
$user = get_logged_in_user();
0 ignored issues
show
Are you sure the assignment to $user is correct as get_logged_in_user() seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
28
29
$bus = BoincUserSubmit::lookup_userid($user->id);
30
if (!$bus) die("no access");
31
32
if ($bus->manage_all) {
33
    page_head("Management functions");
34
    echo "
35
        <a href=manage_project.php>Project-wide management</a>
36
    ";
37
    $apps = BoincApp::enum(null);
38
    echo "
39
        <p>Application-specific management:
40
        <ul>
41
    ";
42
    foreach ($apps as $app) {
43
        echo "
44
            <li><a href=manage_app.php?app_id=$app->id>$app->name</a>
45
        ";
46
    }
47
    echo "</ul>\n";
48
    page_tail();
49
    exit;
50
}
51
52
$apps = BoincUserSubmit::enum("user_id=$user->id and manage<>1");
53
switch (count($apps)) {
54
case 0:
55
    error_page("Nothing to manage");
0 ignored issues
show
Coding Style Comprehensibility introduced by
Consider adding a comment if this fall-through is intended.
Loading history...
56
case 1:
57
    $app = $apps[0];
58
    Header("Location: manage_app.php?app_id=$app->id");
0 ignored issues
show
Calls to inbuilt PHP functions must be lowercase; expected "header" but found "Header"
Loading history...
59
    exit;
60
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...
61
    page_head("Management functions");
62
    foreach ($apps as $app) {
63
        echo "
64
            <p><a href=manage_app.php?app_id=$app->id>Manage $app->name</a>
65
        ";
66
    }
67
    page_tail();
68
}
69
70
?>
71