| @@ 1066-1084 (lines=19) @@ | ||
| 1063 | * @param Member $member |
|
| 1064 | * @return bool |
|
| 1065 | */ |
|
| 1066 | public function canPublish($member = null) |
|
| 1067 | { |
|
| 1068 | if (!$member) { |
|
| 1069 | $member = Security::getCurrentUser(); |
|
| 1070 | } |
|
| 1071 | ||
| 1072 | // Check extension |
|
| 1073 | $extended = $this->extendedCan('canPublish', $member); |
|
| 1074 | if ($extended !== null) { |
|
| 1075 | return $extended; |
|
| 1076 | } |
|
| 1077 | ||
| 1078 | if (Permission::checkMember($member, "ADMIN")) { |
|
| 1079 | return true; |
|
| 1080 | } |
|
| 1081 | ||
| 1082 | // Default to relying on edit permission |
|
| 1083 | return $this->canEdit($member); |
|
| 1084 | } |
|
| 1085 | ||
| 1086 | /** |
|
| 1087 | * This function should return true if the current user can delete this page. It can be overloaded to customise the |
|
| @@ 1200-1220 (lines=21) @@ | ||
| 1197 | * unit tests) |
|
| 1198 | * @return bool True if the current user can edit this page |
|
| 1199 | */ |
|
| 1200 | public function canEdit($member = null) |
|
| 1201 | { |
|
| 1202 | if (!$member) { |
|
| 1203 | $member = Security::getCurrentUser(); |
|
| 1204 | } |
|
| 1205 | ||
| 1206 | // Standard mechanism for accepting permission changes from extensions |
|
| 1207 | $extended = $this->extendedCan('canEdit', $member); |
|
| 1208 | if ($extended !== null) { |
|
| 1209 | return $extended; |
|
| 1210 | } |
|
| 1211 | ||
| 1212 | // Default permissions |
|
| 1213 | if (Permission::checkMember($member, "SITETREE_EDIT_ALL")) { |
|
| 1214 | return true; |
|
| 1215 | } |
|
| 1216 | ||
| 1217 | // Check inherited permissions |
|
| 1218 | return static::getPermissionChecker() |
|
| 1219 | ->canEdit($this->ID, $member); |
|
| 1220 | } |
|
| 1221 | ||
| 1222 | /** |
|
| 1223 | * Stub method to get the site config, unless the current class can provide an alternate. |
|