AdvertisementController::deletealladvertisements()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
4
class AdvertisementController extends Controller
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
5
{
6
    private static $allowed_actions = array(
0 ignored issues
show
Comprehensibility introduced by
Consider using a different property name as you override a private property of the parent class.
Loading history...
Unused Code introduced by
The property $allowed_actions is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
7
        "removealladvertisements" => "ADMIN",
8
        "deletealladvertisements" => "ADMIN"
9
    );
10
11
    public function removealladvertisements($request)
12
    {
13
        $id = intval($request->param("ID"))-0;
14
        $page = SiteTree::get()->byID($id);
15
        if (!$page) {
16
            return "this page does not exist";
17
        }
18
        DB::query("DELETE FROM SiteTree_Advertisements WHERE SiteTreeID = ".$id);
19
        DB::query("UPDATE SiteTree SET AdvertisementsFolderID = 0 WHERE SiteTree.ID = ".$id);
20
        DB::query("UPDATE SiteTree_Live SET AdvertisementsFolderID = 0 WHERE SiteTree_Live.ID = ".$id);
21
        return sprintf(
22
            _t("AdvertisementController.REMOVEDALL", 'Removed all %1$s from this page, please reload page to see results.'),
23
            Config::inst()->get("Advertisement", "plural_name")
24
        );
25
    }
26
27
    public function deletealladvertisements($request)
0 ignored issues
show
Unused Code introduced by
The parameter $request is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
28
    {
29
        DB::query("DELETE FROM \"Advertisement\"");
30
        return sprintf(
31
            _t("AdvertisementController.DELETEDALL", 'Deleted all %1$s from this website, please reload page to see results.'),
32
            Config::inst()->get("Advertisement", "plural_name")
33
        );
34
    }
35
}
36