Debian Codegraph @

includes/user/TempUser/TempUserConfig.php

raw symbols SCIP
1 <?php
2
3 namespace MediaWiki\User\TempUser;
4
5 use MediaWiki\Permissions\Authority;
6 use Wikimedia\Rdbms\IExpression;
7 use Wikimedia\Rdbms\IReadableDatabase;
8
9 /**
10 * Interface for temporary user creation config and name matching.
11 *
12 * This is separate from TempUserCreator to avoid dependency loops during
13 * service construction, since TempUserCreator needs UserNameUtils which
14 * needs TempUserConfig.
15 *
16 * @since 1.39
17 */
18 interface TempUserConfig {
19 /**
20 * Is temp user creation enabled?
21 *
22 * @return bool
23 */
24 public function isEnabled();
25
26 /**
27 * Are temporary accounts a known concept on the wiki?
28 * This should return true if any temporary accounts exist.
29 *
30 * @return bool
31 */
32 public function isKnown();
33
34 /**
35 * Is the action valid for user auto-creation?
36 *
37 * @param string $action
38 * @return bool
39 */
40 public function isAutoCreateAction( string $action );
41
42 /**
43 * Should/would auto-create be performed if the user attempts to perform
44 * the given action?
45 *
46 * @since 1.41
47 * @param Authority $authority
48 * @param string $action
49 * @return bool
50 */
51 public function shouldAutoCreate( Authority $authority, string $action );
52
53 /**
54 * Does the name match the configured pattern indicating that it is a
55 * temporary auto-created user?
56 *
57 * @param string $name
58 * @return bool
59 */
60 public function isTempName( string $name );
61
62 /**
63 * Does the name match a configured pattern which indicates that it
64 * conflicts with temporary user names? Should manual user creation
65 * be denied?
66 *
67 * @param string $name
68 * @return mixed
69 */
70 public function isReservedName( string $name );
71
72 /**
73 * Get a placeholder name which matches the reserved prefix
74 *
75 * @return string
76 */
77 public function getPlaceholderName(): string;
78
79 /**
80 * Get a Pattern indicating how temporary account can be detected
81 *
82 * Used to avoid selecting a temp account via select queries.
83 *
84 * @deprecated since 1.42. Use ::getMatchPatterns as multiple patterns may be defined.
85 * @return Pattern
86 */
87 public function getMatchPattern(): Pattern;
88
89 /**
90 * Get Patterns indicating how temporary account can be detected
91 *
92 * Used to avoid selecting a temp account via select queries.
93 *
94 * @since 1.42
95 * @return Pattern[]
96 */
97 public function getMatchPatterns(): array;
98
99 /**
100 * Get a SQL query condition that will match (or not match) temporary accounts.
101 *
102 * @since 1.42
103 * @param IReadableDatabase $db
104 * @param string $field Database field to match against
105 * @param string $op Operator: IExpression::LIKE or IExpression::NOT_LIKE
106 * @return IExpression
107 */
108 public function getMatchCondition( IReadableDatabase $db, string $field, string $op ): IExpression;
109
110 /**
111 * After how many days do temporary users expire?
112 *
113 * @note expireTemporaryAccounts.php maintenance script needs to be periodically executed for
114 * temp account expiry to work.
115 * @since 1.42
116 * @return int|null Null if temp accounts should never expire
117 */
118 public function getExpireAfterDays(): ?int;
119
120 /**
121 * How many days before expiration should temporary users be notified?
122 *
123 * @note expireTemporaryAccounts.php maintenance script needs to be periodically executed for
124 * temp account expiry to work.
125 * @since 1.42
126 * @return int|null Null if temp accounts should never be notified before expiration
127 */
128 public function getNotifyBeforeExpirationDays(): ?int;
129 }