MediaWiki REL1_39
UserBlockConstraint.php
Go to the documentation of this file.
1<?php
22
25use StatusValue;
26use User;
27
37
39 private $permissionManager;
40
42 private $title;
43
45 private $user;
46
48 private $result;
49
55 public function __construct(
56 PermissionManager $permissionManager,
57 LinkTarget $title,
58 User $user
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(!defined('MW_SETUP_CALLBACK'))
The persistent session ID (if any) loaded at startup.
Definition WebStart.php:82
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.
internal since 1.36
Definition User.php:70
Interface for all constraints that can prevent edits.