Code Duplication    Length = 18-18 lines in 3 locations

api/v1/areas.php 2 locations

@@ 26-43 (lines=18) @@
23
    echo json_encode($areas);
24
}
25
26
function create_area()
27
{
28
    global $app;
29
    if(!$app->user)
30
    {
31
        throw new Exception('Must be logged in', ACCESS_DENIED);
32
    }
33
    if(!$app->user->isInGroupNamed("LDAPAdmins"))
34
    {
35
        throw new Exception('Must be Admin', ACCESS_DENIED);
36
    }
37
    $body = $app->request->getBody();
38
    $obj  = json_decode($body);
39
    $data_set = DataSetFactory::getDataSetByName('profiles');
40
    $data_table = $data_set['area'];
41
    $ret = $data_table->create($obj);
42
    echo json_encode($ret);
43
}
44
45
function get_area($name)
46
{
@@ 62-79 (lines=18) @@
59
    echo json_encode($areas);
60
}
61
62
function update_area($name)
63
{
64
    global $app;
65
    if(!$app->user)
66
    {
67
        throw new Exception('Must be logged in', ACCESS_DENIED);
68
    }
69
    if(!$app->user->isInGroupNamed("LDAPAdmins"))
70
    {
71
        throw new Exception('Must be Admin', ACCESS_DENIED);
72
    }
73
    $body = $app->request->getBody();
74
    $obj  = json_decode($body);
75
    $data_set = DataSetFactory::getDataSetByName('profiles');
76
    $data_table = $data_set['area'];
77
    $ret = $data_table->update(new \Data\Filter("short_name eq $name"), $obj);
78
    echo json_encode($ret);
79
}
80
81
function get_area_leads($name)
82
{

api/v1/index.php 1 location

@@ 218-235 (lines=18) @@
215
    $app->post('', 'validate_post_code');
216
}
217
218
function addLead()
219
{
220
    global $app;
221
    if(!$app->user)
222
    {
223
        throw new Exception('Must be logged in', ACCESS_DENIED);
224
    }
225
    if(!$app->user->isInGroupNamed('LDAPAdmins'))
226
    {
227
        throw new Exception('Must be LDAPAdmins', ACCESS_DENIED);
228
    }
229
    $body = $app->request->getBody();
230
    $obj  = json_decode($body);
231
    $data_set = DataSetFactory::getDataSetByName('profiles');
232
    $data_table = $data_set['position'];
233
    $ret = $data_table->create($obj);
234
    echo json_encode($ret);
235
}
236
237
$app->run();
238
/* vim: set tabstop=4 shiftwidth=4 expandtab: */