Issues (1964)

html/user/add_venue.php (3 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.inc");
20
require_once("../inc/prefs.inc");
21
require_once("../inc/prefs_project.inc");
22
23
$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...
24
check_tokens($user->authenticator);
25
26
$action = sanitize_tags(get_str("action", true));
27
$subset = sanitize_tags(get_str("subset"));
28
$venue = sanitize_tags(get_str("venue"));
29
$columns = get_int("cols", true);
30
$c = $columns?"&cols=$columns":"";
31
check_venue($venue);
32
check_subset($subset);
33
34
if ($action) {
35
    if ($subset == "global") {
36
        $prefs = prefs_parse_global($user->global_prefs);
37
        $prefs->$venue = $prefs;
38
39
        $new_prefs = new stdClass();
40
        $error = prefs_global_parse_form($new_prefs);
41
        if ($error != false) {
42
            $title = tra("Edit %1 preferences", subset_name($subset));
43
            if ($venue) $title = "$title for $venue";
44
            page_head($title);
45
            $x = $venue?"&venue=$venue":"";
46
47
            echo PREFS_FORM_DESC1;
48
            echo PREFS_FORM_ERROR_DESC;
49
50
            print_prefs_form(
51
                "add", $subset, $venue, $user, $new_prefs, $columns, $error
52
            );
53
        } else {
54
            $prefs->$venue = $new_prefs;
55
            global_prefs_update($user, $prefs);
56
            Header("Location: prefs.php?subset=$subset$c");
0 ignored issues
show
Calls to inbuilt PHP functions must be lowercase; expected "header" but found "Header"
Loading history...
57
        }
58
    } else {
59
        $prefs = prefs_parse_project($user->project_prefs);
60
        $prefs->$venue = $prefs;
61
62
        $new_prefs = new stdClass();
63
        $project_error = prefs_project_parse_form($new_prefs);
64
        $error = prefs_resource_parse_form($new_prefs);
65
66
        if ($error != false || $project_error != false) {
67
            $title = tra("Edit %1 preferences", subset_name($subset));
68
            if ($venue) $title = "$title for $venue";
69
            page_head($title);
70
            $x = $venue?"&venue=$venue":"";
71
72
            echo PREFS_FORM_ERROR_DESC;
73
74
            print_prefs_form(
75
                "add", $subset, $venue, $user, $new_prefs, $columns,
76
                $error, $project_error
77
            );
78
        } else {
79
            $prefs->$venue = $new_prefs;
80
            project_prefs_update($user, $prefs);
81
            Header("Location: prefs.php?subset=$subset$c");
0 ignored issues
show
Calls to inbuilt PHP functions must be lowercase; expected "header" but found "Header"
Loading history...
82
        }
83
    }
84
} else {
85
    $title = tra("Add %1 preferences for %2", subset_name($subset), $venue);
86
    page_head($title);
87
88
    if ($subset == "global") {
89
        $prefs = default_prefs_global();
90
        set_niu_prefs($prefs);
91
    } else {
92
        $prefs = default_prefs_project();
93
    }
94
    print_prefs_form("add", $subset, $venue, $user, $prefs, $columns);
95
}
96
page_tail();
97
?>
98