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