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( |
|
|
|
|
17
|
|
|
'MySQLDatabase' => 'ENGINE=MyISAM' |
18
|
|
|
); |
19
|
|
|
|
20
|
|
|
private static $db = array( |
|
|
|
|
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( |
|
|
|
|
32
|
|
|
"CopyCausingClassName" => true, |
33
|
|
|
"CopyCausingClassNameID" => true, |
34
|
|
|
"CopyFromClassNameID" => true, |
35
|
|
|
"CopyIntoClassName" => true, |
36
|
|
|
"CopyIntoClassNameID" => true |
37
|
|
|
); |
38
|
|
|
|
39
|
|
|
private static $summary_fields = array( |
|
|
|
|
40
|
|
|
"StartTime", |
41
|
|
|
"Type", |
42
|
|
|
"CopyCause", |
43
|
|
|
"CopyFrom", |
44
|
|
|
"CopyInto", |
45
|
|
|
"FormattedShortAction" |
46
|
|
|
); |
47
|
|
|
|
48
|
|
|
private static $field_labels = array( |
|
|
|
|
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( |
|
|
|
|
58
|
|
|
"Type" => "PartialMatchFilter", |
59
|
|
|
"Action" => "PartialMatchFilter" |
60
|
|
|
); |
61
|
|
|
|
62
|
|
|
private static $casting = array( |
|
|
|
|
63
|
|
|
"CopyCause" => "Varchar", |
64
|
|
|
"CopyFrom" => "Varchar", |
65
|
|
|
"CopyInto" => "Varchar", |
66
|
|
|
"FormattedShortAction" => "HTMLText" |
67
|
|
|
); |
68
|
|
|
|
69
|
|
|
private static $default_sort = "Created ASC"; |
|
|
|
|
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>" |
|
|
|
|
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() |
|
|
|
|
127
|
|
|
{ |
128
|
|
|
$className = $this->CopyCausingClassName; |
|
|
|
|
129
|
|
|
if ($className) { |
130
|
|
|
$obj = $className::get()->byID($this->CopyCausingClassNameID); |
|
|
|
|
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() |
|
|
|
|
144
|
|
|
{ |
145
|
|
|
$className = $this->CopyIntoClassName; |
|
|
|
|
146
|
|
|
if ($className) { |
147
|
|
|
$obj = $className::get()->byID($this->CopyFromClassNameID); |
|
|
|
|
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() |
|
|
|
|
161
|
|
|
{ |
162
|
|
|
$className = $this->CopyIntoClassName; |
|
|
|
|
163
|
|
|
if ($className) { |
164
|
|
|
$obj = $className::get()->byID($this->CopyIntoClassNameID); |
|
|
|
|
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 |
|
|
|
|
177
|
|
|
*/ |
178
|
|
|
public function getFormattedShortAction() |
179
|
|
|
{ |
180
|
|
|
return DBField::create_field("HTMLText", str_replace("\n", "<br />", trim(substr($this->Action, 0, 799)))); |
|
|
|
|
181
|
|
|
} |
182
|
|
|
} |
183
|
|
|
|