MediaWiki REL1_39
EditRightConstraint.php
Go to the documentation of this file.
1<?php
22
24use StatusValue;
25
35
37 private $performer;
38
40 private $result;
41
45 public function __construct(
46 Authority $performer
47 ) {
48 $this->performer = $performer;
49 }
50
51 public function checkConstraint(): string {
52 // Check isn't simple enough to just repeat when getting the status
53 if ( !$this->performer->isAllowed( 'edit' ) ) {
54 $this->result = self::CONSTRAINT_FAILED;
55 return self::CONSTRAINT_FAILED;
56 }
57
58 $this->result = self::CONSTRAINT_PASSED;
59 return self::CONSTRAINT_PASSED;
60 }
61
62 public function getLegacyStatus(): StatusValue {
63 $statusValue = StatusValue::newGood();
64
65 if ( $this->result === self::CONSTRAINT_FAILED ) {
66 if ( !$this->performer->getUser()->isRegistered() ) {
67 $statusValue->setResult( false, self::AS_READ_ONLY_PAGE_ANON );
68 } else {
69 $statusValue->fatal( 'readonlytext' );
70 $statusValue->value = self::AS_READ_ONLY_PAGE_LOGGED;
71 }
72 }
73
74 return $statusValue;
75 }
76
77}
if(!defined('MW_SETUP_CALLBACK'))
The persistent session ID (if any) loaded at startup.
Definition WebStart.php:82
Verify user permissions: Must have edit rights.
getLegacyStatus()
Get the legacy status for failure (or success)
Generic operation result class Has warning/error list, boolean status and arbitrary value.
setResult( $ok, $value=null)
Change operation result.
Interface for all constraints that can prevent edits.
This interface represents the authority associated the current execution context, such as a web reque...
Definition Authority.php:37