MediaWiki REL1_37
UserBlockConstraint.php
Go to the documentation of this file.
1<?php
22
25use StatusValue;
26use User;
27
37
40
42 private $title;
43
45 private $user;
46
48 private $result;
49
55 public function __construct(
59 ) {
60 $this->permissionManager = $permissionManager;
61 $this->title = $title;
62 $this->user = $user;
63 }
64
65 public function checkConstraint(): string {
66 // Check isn't simple enough to just repeat when getting the status
67 if ( $this->permissionManager->isBlockedFrom( $this->user, $this->title ) ) {
68 $this->result = self::CONSTRAINT_FAILED;
69 return self::CONSTRAINT_FAILED;
70 }
71
72 $this->result = self::CONSTRAINT_PASSED;
73 return self::CONSTRAINT_PASSED;
74 }
75
76 public function getLegacyStatus(): StatusValue {
77 $statusValue = StatusValue::newGood();
78
79 if ( $this->result === self::CONSTRAINT_FAILED ) {
80 $statusValue->setResult( false, self::AS_BLOCKED_PAGE_FOR_USER );
81 }
82
83 return $statusValue;
84 }
85
86}
if(ini_get('mbstring.func_overload')) if(!defined('MW_ENTRY_POINT'))
Pre-config setup: Before loading LocalSettings.php.
Definition Setup.php:88
Verify user permissions: Must not be blocked from the page.
getLegacyStatus()
Get the legacy status for failure (or success)
__construct(PermissionManager $permissionManager, LinkTarget $title, User $user)
A service class for checking permissions To obtain an instance, use MediaWikiServices::getInstance()-...
Generic operation result class Has warning/error list, boolean status and arbitrary value.
setResult( $ok, $value=null)
Change operation result.
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
Definition User.php:69
Interface for all constraints that can prevent edits.