CopyFactoryLog::canEdit()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
/**
4
 * keeps track of any changes being made, fake or real
5
 *
6
 *
7
 */
8
9
class CopyFactoryLog extends DataObject
10
{
11
12
    /**
13
     * we can write faster to MyISAM?
14
     *
15
     */
16
    private static $create_table_options = 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...
17
        'MySQLDatabase' => 'ENGINE=MyISAM'
18
    );
19
20
    private static $db = 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...
21
        "StartTime" => "SS_Datetime",
22
        "Type" => "Enum('Unknown,Fake,Real', 'Unknown')",
23
        "CopyCausingClassName" => "Varchar(200)",
24
        "CopyCausingClassNameID" => "Int",
25
        "CopyFromClassNameID" => "Int",
26
        "CopyIntoClassName" => "Varchar(200)",
27
        "CopyIntoClassNameID" => "Int",
28
        "Action" => "Text"
29
    );
30
31
    private static $indexes = 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...
32
        "CopyCausingClassName" => true,
33
        "CopyCausingClassNameID" => true,
34
        "CopyFromClassNameID" => true,
35
        "CopyIntoClassName" => true,
36
        "CopyIntoClassNameID" => true
37
    );
38
39
    private static $summary_fields = 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...
40
        "StartTime",
41
        "Type",
42
        "CopyCause",
43
        "CopyFrom",
44
        "CopyInto",
45
        "FormattedShortAction"
46
    );
47
48
    private static $field_labels = 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...
49
        "StartTime" => "Started",
50
        "Type" => "Real or Fake",
51
        "CopyCause" => "Started by",
52
        "CopyFrom" => "From",
53
        "CopyInto" => "Into",
54
        "Action" => "Description"
55
    );
56
57
    private static $searchable_fields = 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...
58
        "Type" => "PartialMatchFilter",
59
        "Action" => "PartialMatchFilter"
60
    );
61
62
    private static $casting = 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...
63
        "CopyCause" => "Varchar",
64
        "CopyFrom" => "Varchar",
65
        "CopyInto" => "Varchar",
66
        "FormattedShortAction" => "HTMLText"
67
    );
68
69
    private static $default_sort = "Created ASC";
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...
70
71
    public function canEdit($member = null)
72
    {
73
        return false;
74
    }
75
76
    public function canDelete($member = null)
77
    {
78
        return false;
79
    }
80
81
    public function getCMSFields()
82
    {
83
        $fields = parent::getCMSFields();
84
        $fields->addFieldToTab(
85
            "Root.Main",
86
            new ReadonlyField(
87
                "CopyCause",
88
                _t("CopyFactory.COPY_CAUSE", "Copy initiated by"),
89
                $this->getCopyCause()
90
            ),
91
            "CopyCausingClassName"
92
        );
93
        $fields->addFieldToTab(
94
            "Root.Main",
95
            new ReadonlyField(
96
                "CopyFrom",
97
                _t("CopyFactory.COPY_FROM", "Copying from"),
98
                $this->getCopyFrom()
99
            ),
100
            "CopyFromClassNameID"
101
        );
102
        $fields->addFieldToTab(
103
            "Root.Main",
104
            new ReadonlyField(
105
                "CopyInto",
106
                _t("CopyFactory.COPY_INTO", "Copying into"),
107
                $this->getCopyInto()
108
            ),
109
            "CopyIntoClassName"
110
        );
111
        $fields->addFieldToTab(
112
            "Root.Main",
113
            new LiteralField(
114
                "Action",
115
                "<pre>$this->Action</pre>"
0 ignored issues
show
Bug introduced by
The property Action does not seem to exist. Did you mean allowed_actions?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
116
            )
117
        );
118
        return $fields;
119
    }
120
121
    /**
122
     * Copy Causer Description
123
     * @casted
124
     * @return Str
125
     */
126 View Code Duplication
    public function getCopyCause()
0 ignored issues
show
Duplication introduced by
This method 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...
127
    {
128
        $className = $this->CopyCausingClassName;
0 ignored issues
show
Bug introduced by
The property CopyCausingClassName does not seem to exist. Did you mean ClassName?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
129
        if ($className) {
130
            $obj = $className::get()->byID($this->CopyCausingClassNameID);
0 ignored issues
show
Bug introduced by
The property CopyCausingClassNameID does not seem to exist. Did you mean ClassName?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
131
            if ($obj) {
132
                return CopyFactory::title_for_object($obj)." (".$className.")";
133
            }
134
        }
135
        return _t("CopyFactory.N_A", "n/a");
136
    }
137
138
    /**
139
     * Copy From Description
140
     * @casted
141
     * @return Str
142
     */
143 View Code Duplication
    public function getCopyFrom()
0 ignored issues
show
Duplication introduced by
This method 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...
144
    {
145
        $className = $this->CopyIntoClassName;
0 ignored issues
show
Bug introduced by
The property CopyIntoClassName does not seem to exist. Did you mean ClassName?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
146
        if ($className) {
147
            $obj = $className::get()->byID($this->CopyFromClassNameID);
0 ignored issues
show
Bug introduced by
The property CopyFromClassNameID does not seem to exist. Did you mean ClassName?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
148
            if ($obj) {
149
                return CopyFactory::title_for_object($obj)." (".$className.")";
150
            }
151
        }
152
        return _t("CopyFactory.N_A", "n/a");
153
    }
154
155
    /**
156
     * Copy Into Description
157
     * @casted
158
     * @return Str
159
     */
160 View Code Duplication
    public function getCopyInto()
0 ignored issues
show
Duplication introduced by
This method 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...
161
    {
162
        $className = $this->CopyIntoClassName;
0 ignored issues
show
Bug introduced by
The property CopyIntoClassName does not seem to exist. Did you mean ClassName?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
163
        if ($className) {
164
            $obj = $className::get()->byID($this->CopyIntoClassNameID);
0 ignored issues
show
Bug introduced by
The property CopyIntoClassNameID does not seem to exist. Did you mean ClassName?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
165
            if ($obj) {
166
                return CopyFactory::title_for_object($obj)." (".$className.")";
167
            }
168
        }
169
        return _t("CopyFactory.N_A", "n/a");
170
    }
171
172
173
    /**
174
     * Copy Into Description
175
     * @casted
176
     * @return Str
0 ignored issues
show
Documentation introduced by
Should the return type not be DBField?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
177
     */
178
    public function getFormattedShortAction()
179
    {
180
        return DBField::create_field("HTMLText", str_replace("\n", "<br />", trim(substr($this->Action, 0, 799))));
0 ignored issues
show
Bug introduced by
The property Action does not seem to exist. Did you mean allowed_actions?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
181
    }
182
}
183