1 | <?php |
||
16 | class ChangeSetItem extends DataObject { |
||
17 | |||
18 | const EXPLICITLY = 'explicitly'; |
||
19 | |||
20 | const IMPLICITLY = 'implicitly'; |
||
21 | |||
22 | /** Represents an object deleted */ |
||
23 | const CHANGE_DELETED = 'deleted'; |
||
24 | |||
25 | /** Represents an object which was modified */ |
||
26 | const CHANGE_MODIFIED = 'modified'; |
||
27 | |||
28 | /** Represents an object added */ |
||
29 | const CHANGE_CREATED = 'created'; |
||
30 | |||
31 | /** Represents an object which hasn't been changed directly, but owns a modified many_many relationship. */ |
||
32 | //const CHANGE_MANYMANY = 'manymany'; |
||
|
|||
33 | |||
34 | /** |
||
35 | * Represents that an object has not yet been changed, but |
||
36 | * should be included in this changeset as soon as any changes exist |
||
37 | */ |
||
38 | const CHANGE_NONE = 'none'; |
||
39 | |||
40 | private static $db = array( |
||
41 | 'VersionBefore' => 'Int', |
||
42 | 'VersionAfter' => 'Int', |
||
43 | 'Added' => "Enum('explicitly, implicitly', 'implicitly')" |
||
44 | ); |
||
45 | |||
46 | private static $has_one = array( |
||
47 | 'ChangeSet' => 'ChangeSet', |
||
48 | 'Object' => 'DataObject', |
||
49 | ); |
||
50 | |||
51 | private static $many_many = array( |
||
52 | 'ReferencedBy' => 'ChangeSetItem' |
||
53 | ); |
||
54 | |||
55 | private static $belongs_many_many = array( |
||
56 | 'References' => 'ChangeSetItem.ReferencedBy' |
||
57 | ); |
||
58 | |||
59 | private static $indexes = array( |
||
60 | 'ObjectUniquePerChangeSet' => array( |
||
61 | 'type' => 'unique', |
||
62 | 'value' => '"ObjectID", "ObjectClass", "ChangeSetID"' |
||
63 | ) |
||
64 | ); |
||
65 | |||
66 | /** |
||
67 | * Get the type of change: none, created, deleted, modified, manymany |
||
68 | * |
||
69 | * @return string |
||
70 | */ |
||
71 | public function getChangeType() { |
||
96 | |||
97 | /** |
||
98 | * Find version of this object in the given stage |
||
99 | * |
||
100 | * @param string $stage |
||
101 | * @return Versioned|DataObject |
||
102 | */ |
||
103 | private function getObjectInStage($stage) { |
||
106 | |||
107 | /** |
||
108 | * Get all implicit objects for this change |
||
109 | * |
||
110 | * @return SS_List |
||
111 | */ |
||
112 | public function findReferenced() { |
||
124 | |||
125 | /** |
||
126 | * Publish this item, then close it. |
||
127 | * |
||
128 | * Note: Unlike Versioned::doPublish() and Versioned::doUnpublish, this action is not recursive. |
||
129 | */ |
||
130 | public function publish() { |
||
168 | |||
169 | /** Reverts this item, then close it. **/ |
||
170 | public function revert() { |
||
173 | |||
174 | public function canView($member = null) { |
||
177 | |||
178 | public function canEdit($member = null) { |
||
181 | |||
182 | public function canCreate($member = null, $context = array()) { |
||
185 | |||
186 | public function canDelete($member = null) { |
||
189 | |||
190 | /** |
||
191 | * Check if the BeforeVersion of this changeset can be restored to draft |
||
192 | * |
||
193 | * @param Member $member |
||
194 | * @return bool |
||
195 | */ |
||
196 | public function canRevert($member) { |
||
225 | |||
226 | /** |
||
227 | * Check if this ChangeSetItem can be published |
||
228 | * |
||
229 | * @param Member $member |
||
230 | * @return bool |
||
231 | */ |
||
232 | public function canPublish($member = null) { |
||
256 | |||
257 | /** |
||
258 | * Default permissions for this ChangeSetItem |
||
259 | * |
||
260 | * @param string $perm |
||
261 | * @param Member $member |
||
262 | * @param array $context |
||
263 | * @return bool |
||
264 | */ |
||
265 | public function can($perm, $member = null, $context = array()) { |
||
280 | |||
281 | } |
||
282 |
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.