Completed
Pull Request — master (#2472)
by Kevin
23:34 queued 05:01
created

BoincUserSubmit::delete_user()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
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
// Tables related to job submission
20
21
require_once("../inc/common_defs.inc");
22
23 View Code Duplication
class BoincBatch {
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
24
    static function lookup_id($id) {
25
        $db = BoincDb::get();
26
        return $db->lookup_id($id, 'batch', 'BoincBatch');
27
    }
28
    static function lookup_name($name) {
29
        $db = BoincDb::get();
30
        $name = BoincDb::escape_string($name);
31
        return $db->lookup('batch', 'BoincBatch', "name='$name'");
32
    }
33
    static function enum($clause) {
34
        $db = BoincDb::get();
35
        return $db->enum('batch', 'BoincBatch', $clause);
36
    }
37
    static function insert($clause) {
38
        $db = BoincDb::get();
39
        $ret = $db->insert('batch', $clause);
40
        if (!$ret) return $ret;
41
        return $db->insert_id();
42
    }
43
    function update($clause) {
44
        $db = BoincDb::get();
45
        return $db->update($this, 'batch', $clause);
46
    }
47
    static function update_aux($clause) {
48
        $db = BoincDb::get();
49
        return $db->update_aux('batch', $clause);
50
    }
51
    function get_cpu_time() {
52
        $db = BoincDb::get();
53
        $x = $db->get_double(
54
            "select sum(result.cpu_time) as total_cpu_time from workunit join result on workunit.id = result.workunitid where workunit.batch=$this->id",
0 ignored issues
show
Bug introduced by
The property id does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
55
            "total_cpu_time"
56
        );
57
        return $x;
58
    }
59
}
60
61
class BoincUserSubmit {
62
    static function enum($clause) {
63
        $db = BoincDb::get();
64
        return $db->enum('user_submit', 'BoincUserSubmit', $clause);
65
    }
66
    static function insert($clause) {
67
        $db = BoincDb::get();
68
        $ret = $db->insert('user_submit', $clause);
69
        if (!$ret) return false;
70
        return true;
71
    }
72
    static function lookup_userid($user_id) {
73
        $db = BoincDb::get();
74
        return $db->lookup('user_submit', 'BoincUserSubmit', "user_id=$user_id");
75
    }
76
    function update($clause) {
77
        $db = BoincDb::get();
78
        return $db->update_aux('user_submit', "$clause where user_id=$this->user_id");
0 ignored issues
show
Bug introduced by
The property user_id does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
79
    }
80
    static function update_aux($clause) {
81
        $db = BoincDb::get();
82
        return $db->update_aux('user_submit', $clause);
83
    }
84
    
85
    static function delete_user($user_id) {
86
        $db = BoincDb::get();
87
        return $db->delete_aux('user_submit', "user_id = $user_id");
88
    }
89
90
}
91
92
class BoincUserSubmitApp {
93
    static function enum($clause) {
94
        $db = BoincDb::get();
95
        return $db->enum('user_submit_app', 'BoincUserSubmitApp', $clause);
96
    }
97
    static function lookup($clause) {
98
        $db = BoincDb::get();
99
        return $db->lookup('user_submit_app', 'BoincUserSubmitApp', $clause);
100
    }
101
    static function insert($clause) {
102
        $db = BoincDb::get();
103
        $ret = $db->insert('user_submit_app', $clause);
104
        if (!$ret) return false;
105
        return true;
106
    }
107
    static function delete_user($user_id) {
108
        $db = BoincDb::get();
109
        return $db->delete_aux('user_submit_app', "user_id=$user_id");
110
    }
111
    function update($clause) {
112
        $db = BoincDb::get();
113
        return $db->update_aux('user_submit_app', "$clause where user_id=$this->user_id and app_id=$this->app_id");
0 ignored issues
show
Bug introduced by
The property user_id does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
Bug introduced by
The property app_id does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
114
    }
115
}
116
117 View Code Duplication
class BoincJobFile {
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
118
    static function insert($clause) {
119
        $db = BoincDb::get();
120
        $ret = $db->insert('job_file', $clause);
121
        if (!$ret) return false;
122
        return $db->insert_id();
123
    }
124
    static function lookup_name($name) {
125
        $db = BoincDb::get();
126
        return $db->lookup('job_file', 'BoincJobFile', "name='$name'");
127
    }
128
    function delete() {
129
        $db = BoincDb::get();
130
        return $db->delete($this, 'job_file');
131
    }
132
    function update($clause) {
133
        $db = BoincDb::get();
134
        return $db->update($this, 'job_file', $clause);
135
    }
136
}
137
138 View Code Duplication
class BoincBatchFileAssoc {
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
139
    static function insert($clause) {
140
        $db = BoincDb::get();
141
        $ret = $db->insert('batch_file_assoc', $clause);
142
        if (!$ret) return false;
143
        return true;
144
    }
145
    static function lookup($clause) {
146
        $db = BoincDb::get();
147
        return $db->lookup('batch_file_assoc', 'BoincBatchFileAssoc', $clause);
148
    }
149
    function delete() {
150
        $db = BoincDb::get();
151
        return $db->delete_aux('batch_file_assoc',
152
            "job_file_id=$this->job_file_id and batch_id=$this->batch_id"
0 ignored issues
show
Bug introduced by
The property job_file_id does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
Bug introduced by
The property batch_id does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
153
        );
154
    }
155
    static function delete_batch($batch_id) {
156
        $db = BoincDb::get();
157
        return $db->delete_aux('batch_file_assoc',
158
            "batch_id=$batch_id"
159
        );
160
    }
161
}
162
163
?>
164