@@ -18,34 +18,34 @@ |
||
18 | 18 | */ |
19 | 19 | class FakeGlobalStateProvider extends GlobalStateProvider implements IGlobalStateProvider |
20 | 20 | { |
21 | - var $server = array(); |
|
22 | - var $get = array(); |
|
23 | - var $post = array(); |
|
24 | - var $session = array(); |
|
25 | - var $cookie = array(); |
|
21 | + var $server = array(); |
|
22 | + var $get = array(); |
|
23 | + var $post = array(); |
|
24 | + var $session = array(); |
|
25 | + var $cookie = array(); |
|
26 | 26 | |
27 | - public function &getServerSuperGlobal() |
|
28 | - { |
|
29 | - return $this->server; |
|
30 | - } |
|
27 | + public function &getServerSuperGlobal() |
|
28 | + { |
|
29 | + return $this->server; |
|
30 | + } |
|
31 | 31 | |
32 | - public function &getGetSuperGlobal() |
|
33 | - { |
|
34 | - return $this->get; |
|
35 | - } |
|
32 | + public function &getGetSuperGlobal() |
|
33 | + { |
|
34 | + return $this->get; |
|
35 | + } |
|
36 | 36 | |
37 | - public function &getPostSuperGlobal() |
|
38 | - { |
|
39 | - return $this->post; |
|
40 | - } |
|
37 | + public function &getPostSuperGlobal() |
|
38 | + { |
|
39 | + return $this->post; |
|
40 | + } |
|
41 | 41 | |
42 | - public function &getSessionSuperGlobal() |
|
43 | - { |
|
44 | - return $this->session; |
|
45 | - } |
|
42 | + public function &getSessionSuperGlobal() |
|
43 | + { |
|
44 | + return $this->session; |
|
45 | + } |
|
46 | 46 | |
47 | - public function &getCookieSuperGlobal() |
|
48 | - { |
|
49 | - return $this->cookie; |
|
50 | - } |
|
47 | + public function &getCookieSuperGlobal() |
|
48 | + { |
|
49 | + return $this->cookie; |
|
50 | + } |
|
51 | 51 | } |
52 | 52 | \ No newline at end of file |
@@ -21,141 +21,141 @@ |
||
21 | 21 | */ |
22 | 22 | class SessionAlert |
23 | 23 | { |
24 | - private $message; |
|
25 | - private $title; |
|
26 | - private $type; |
|
27 | - private $closable; |
|
28 | - private $block; |
|
29 | - |
|
30 | - /** |
|
31 | - * @param string $message |
|
32 | - * @param string $title |
|
33 | - * @param string $type |
|
34 | - * @param bool $closable |
|
35 | - * @param bool $block |
|
36 | - */ |
|
37 | - public function __construct($message, $title, $type = "alert-info", $closable = true, $block = true) |
|
38 | - { |
|
39 | - $this->message = $message; |
|
40 | - $this->title = $title; |
|
41 | - $this->type = $type; |
|
42 | - $this->closable = $closable; |
|
43 | - $this->block = $block; |
|
44 | - } |
|
45 | - |
|
46 | - /** |
|
47 | - * Shows a quick one-liner message |
|
48 | - * |
|
49 | - * @param string $message |
|
50 | - * @param string $type |
|
51 | - */ |
|
52 | - public static function quick($message, $type = "alert-info") |
|
53 | - { |
|
54 | - self::append(new SessionAlert($message, "", $type, true, false)); |
|
55 | - } |
|
56 | - |
|
57 | - /** |
|
58 | - * @param SessionAlert $alert |
|
59 | - */ |
|
60 | - public static function append(SessionAlert $alert) |
|
61 | - { |
|
62 | - $data = WebRequest::getSessionAlertData(); |
|
63 | - $data[] = serialize($alert); |
|
64 | - WebRequest::setSessionAlertData($data); |
|
65 | - } |
|
66 | - |
|
67 | - /** |
|
68 | - * Shows a quick one-liner success message |
|
69 | - * |
|
70 | - * @param string $message |
|
71 | - */ |
|
72 | - public static function success($message) |
|
73 | - { |
|
74 | - self::append(new SessionAlert($message, "", "alert-success", true, true)); |
|
75 | - } |
|
76 | - |
|
77 | - /** |
|
78 | - * Shows a quick one-liner warning message |
|
79 | - * |
|
80 | - * @param string $message |
|
81 | - * @param string $title |
|
82 | - */ |
|
83 | - public static function warning($message, $title = "Warning!") |
|
84 | - { |
|
85 | - self::append(new SessionAlert($message, $title, "alert-warning", true, true)); |
|
86 | - } |
|
87 | - |
|
88 | - /** |
|
89 | - * Shows a quick one-liner error message |
|
90 | - * |
|
91 | - * @param string $message |
|
92 | - * @param string $title |
|
93 | - */ |
|
94 | - public static function error($message, $title = "Error!") |
|
95 | - { |
|
96 | - self::append(new SessionAlert($message, $title, "alert-danger", true, true)); |
|
97 | - } |
|
98 | - |
|
99 | - /** |
|
100 | - * Retrieves the alerts which have been saved to the session |
|
101 | - * @return array |
|
102 | - */ |
|
103 | - public static function getAlerts() |
|
104 | - { |
|
105 | - $alertData = array(); |
|
106 | - |
|
107 | - foreach (WebRequest::getSessionAlertData() as $a) { |
|
108 | - $alertData[] = unserialize($a); |
|
109 | - } |
|
110 | - |
|
111 | - return $alertData; |
|
112 | - } |
|
113 | - |
|
114 | - /** |
|
115 | - * Clears the alerts from the session |
|
116 | - */ |
|
117 | - public static function clearAlerts() |
|
118 | - { |
|
119 | - WebRequest::clearSessionAlertData(); |
|
120 | - } |
|
121 | - |
|
122 | - /** |
|
123 | - * @return boolean |
|
124 | - */ |
|
125 | - public function isBlock() |
|
126 | - { |
|
127 | - return $this->block; |
|
128 | - } |
|
129 | - |
|
130 | - /** |
|
131 | - * @return boolean |
|
132 | - */ |
|
133 | - public function isClosable() |
|
134 | - { |
|
135 | - return $this->closable; |
|
136 | - } |
|
137 | - |
|
138 | - /** |
|
139 | - * @return string |
|
140 | - */ |
|
141 | - public function getType() |
|
142 | - { |
|
143 | - return $this->type; |
|
144 | - } |
|
145 | - |
|
146 | - /** |
|
147 | - * @return string |
|
148 | - */ |
|
149 | - public function getTitle() |
|
150 | - { |
|
151 | - return $this->title; |
|
152 | - } |
|
153 | - |
|
154 | - /** |
|
155 | - * @return string |
|
156 | - */ |
|
157 | - public function getMessage() |
|
158 | - { |
|
159 | - return $this->message; |
|
160 | - } |
|
24 | + private $message; |
|
25 | + private $title; |
|
26 | + private $type; |
|
27 | + private $closable; |
|
28 | + private $block; |
|
29 | + |
|
30 | + /** |
|
31 | + * @param string $message |
|
32 | + * @param string $title |
|
33 | + * @param string $type |
|
34 | + * @param bool $closable |
|
35 | + * @param bool $block |
|
36 | + */ |
|
37 | + public function __construct($message, $title, $type = "alert-info", $closable = true, $block = true) |
|
38 | + { |
|
39 | + $this->message = $message; |
|
40 | + $this->title = $title; |
|
41 | + $this->type = $type; |
|
42 | + $this->closable = $closable; |
|
43 | + $this->block = $block; |
|
44 | + } |
|
45 | + |
|
46 | + /** |
|
47 | + * Shows a quick one-liner message |
|
48 | + * |
|
49 | + * @param string $message |
|
50 | + * @param string $type |
|
51 | + */ |
|
52 | + public static function quick($message, $type = "alert-info") |
|
53 | + { |
|
54 | + self::append(new SessionAlert($message, "", $type, true, false)); |
|
55 | + } |
|
56 | + |
|
57 | + /** |
|
58 | + * @param SessionAlert $alert |
|
59 | + */ |
|
60 | + public static function append(SessionAlert $alert) |
|
61 | + { |
|
62 | + $data = WebRequest::getSessionAlertData(); |
|
63 | + $data[] = serialize($alert); |
|
64 | + WebRequest::setSessionAlertData($data); |
|
65 | + } |
|
66 | + |
|
67 | + /** |
|
68 | + * Shows a quick one-liner success message |
|
69 | + * |
|
70 | + * @param string $message |
|
71 | + */ |
|
72 | + public static function success($message) |
|
73 | + { |
|
74 | + self::append(new SessionAlert($message, "", "alert-success", true, true)); |
|
75 | + } |
|
76 | + |
|
77 | + /** |
|
78 | + * Shows a quick one-liner warning message |
|
79 | + * |
|
80 | + * @param string $message |
|
81 | + * @param string $title |
|
82 | + */ |
|
83 | + public static function warning($message, $title = "Warning!") |
|
84 | + { |
|
85 | + self::append(new SessionAlert($message, $title, "alert-warning", true, true)); |
|
86 | + } |
|
87 | + |
|
88 | + /** |
|
89 | + * Shows a quick one-liner error message |
|
90 | + * |
|
91 | + * @param string $message |
|
92 | + * @param string $title |
|
93 | + */ |
|
94 | + public static function error($message, $title = "Error!") |
|
95 | + { |
|
96 | + self::append(new SessionAlert($message, $title, "alert-danger", true, true)); |
|
97 | + } |
|
98 | + |
|
99 | + /** |
|
100 | + * Retrieves the alerts which have been saved to the session |
|
101 | + * @return array |
|
102 | + */ |
|
103 | + public static function getAlerts() |
|
104 | + { |
|
105 | + $alertData = array(); |
|
106 | + |
|
107 | + foreach (WebRequest::getSessionAlertData() as $a) { |
|
108 | + $alertData[] = unserialize($a); |
|
109 | + } |
|
110 | + |
|
111 | + return $alertData; |
|
112 | + } |
|
113 | + |
|
114 | + /** |
|
115 | + * Clears the alerts from the session |
|
116 | + */ |
|
117 | + public static function clearAlerts() |
|
118 | + { |
|
119 | + WebRequest::clearSessionAlertData(); |
|
120 | + } |
|
121 | + |
|
122 | + /** |
|
123 | + * @return boolean |
|
124 | + */ |
|
125 | + public function isBlock() |
|
126 | + { |
|
127 | + return $this->block; |
|
128 | + } |
|
129 | + |
|
130 | + /** |
|
131 | + * @return boolean |
|
132 | + */ |
|
133 | + public function isClosable() |
|
134 | + { |
|
135 | + return $this->closable; |
|
136 | + } |
|
137 | + |
|
138 | + /** |
|
139 | + * @return string |
|
140 | + */ |
|
141 | + public function getType() |
|
142 | + { |
|
143 | + return $this->type; |
|
144 | + } |
|
145 | + |
|
146 | + /** |
|
147 | + * @return string |
|
148 | + */ |
|
149 | + public function getTitle() |
|
150 | + { |
|
151 | + return $this->title; |
|
152 | + } |
|
153 | + |
|
154 | + /** |
|
155 | + * @return string |
|
156 | + */ |
|
157 | + public function getMessage() |
|
158 | + { |
|
159 | + return $this->message; |
|
160 | + } |
|
161 | 161 | } |
@@ -17,9 +17,9 @@ |
||
17 | 17 | */ |
18 | 18 | class OAuthRequestRouter extends RequestRouter |
19 | 19 | { |
20 | - protected function getRouteFromPath($pathInfo) |
|
21 | - { |
|
22 | - // Hardcode the route for this entry point |
|
23 | - return array(PageOAuthCallback::class, 'authorise'); |
|
24 | - } |
|
20 | + protected function getRouteFromPath($pathInfo) |
|
21 | + { |
|
22 | + // Hardcode the route for this entry point |
|
23 | + return array(PageOAuthCallback::class, 'authorise'); |
|
24 | + } |
|
25 | 25 | } |
26 | 26 | \ No newline at end of file |
@@ -16,51 +16,51 @@ discard block |
||
16 | 16 | |
17 | 17 | class OAuthIdentity extends DataObject |
18 | 18 | { |
19 | - #region Fields |
|
20 | - /** @var int */ |
|
21 | - private $user; |
|
22 | - /** @var string */ |
|
23 | - private $iss; |
|
24 | - /** @var int */ |
|
25 | - private $sub; |
|
26 | - /** @var string */ |
|
27 | - private $aud; |
|
28 | - /** @var int */ |
|
29 | - private $exp; |
|
30 | - /** @var int */ |
|
31 | - private $iat; |
|
32 | - /** @var string */ |
|
33 | - private $username; |
|
34 | - /** @var int */ |
|
35 | - private $editcount; |
|
36 | - /** @var int */ |
|
37 | - private $confirmed_email; |
|
38 | - /** @var int */ |
|
39 | - private $blocked; |
|
40 | - /** @var string */ |
|
41 | - private $registered; |
|
42 | - /** @var int */ |
|
43 | - private $checkuser; |
|
44 | - /** @var int */ |
|
45 | - private $grantbasic; |
|
46 | - /** @var int */ |
|
47 | - private $grantcreateaccount; |
|
48 | - /** @var int */ |
|
49 | - private $granthighvolume; |
|
50 | - /** @var int */ |
|
51 | - private $grantcreateeditmovepage; |
|
52 | - #endregion |
|
53 | - |
|
54 | - /** |
|
55 | - * Saves a data object to the database, either updating or inserting a record. |
|
56 | - * @return void |
|
57 | - * @throws Exception |
|
58 | - * @throws OptimisticLockFailedException |
|
59 | - */ |
|
60 | - public function save() |
|
61 | - { |
|
62 | - if ($this->isNew()) { |
|
63 | - $statement = $this->dbObject->prepare(<<<SQL |
|
19 | + #region Fields |
|
20 | + /** @var int */ |
|
21 | + private $user; |
|
22 | + /** @var string */ |
|
23 | + private $iss; |
|
24 | + /** @var int */ |
|
25 | + private $sub; |
|
26 | + /** @var string */ |
|
27 | + private $aud; |
|
28 | + /** @var int */ |
|
29 | + private $exp; |
|
30 | + /** @var int */ |
|
31 | + private $iat; |
|
32 | + /** @var string */ |
|
33 | + private $username; |
|
34 | + /** @var int */ |
|
35 | + private $editcount; |
|
36 | + /** @var int */ |
|
37 | + private $confirmed_email; |
|
38 | + /** @var int */ |
|
39 | + private $blocked; |
|
40 | + /** @var string */ |
|
41 | + private $registered; |
|
42 | + /** @var int */ |
|
43 | + private $checkuser; |
|
44 | + /** @var int */ |
|
45 | + private $grantbasic; |
|
46 | + /** @var int */ |
|
47 | + private $grantcreateaccount; |
|
48 | + /** @var int */ |
|
49 | + private $granthighvolume; |
|
50 | + /** @var int */ |
|
51 | + private $grantcreateeditmovepage; |
|
52 | + #endregion |
|
53 | + |
|
54 | + /** |
|
55 | + * Saves a data object to the database, either updating or inserting a record. |
|
56 | + * @return void |
|
57 | + * @throws Exception |
|
58 | + * @throws OptimisticLockFailedException |
|
59 | + */ |
|
60 | + public function save() |
|
61 | + { |
|
62 | + if ($this->isNew()) { |
|
63 | + $statement = $this->dbObject->prepare(<<<SQL |
|
64 | 64 | INSERT INTO oauthidentity ( |
65 | 65 | user, iss, sub, aud, exp, iat, username, editcount, confirmed_email, blocked, registered, checkuser, |
66 | 66 | grantbasic, grantcreateaccount, granthighvolume, grantcreateeditmovepage |
@@ -69,34 +69,34 @@ discard block |
||
69 | 69 | :checkuser, :grantbasic, :grantcreateaccount, :granthighvolume, :grantcreateeditmovepage |
70 | 70 | ) |
71 | 71 | SQL |
72 | - ); |
|
73 | - |
|
74 | - $statement->bindValue(':user', $this->user); |
|
75 | - $statement->bindValue(':iss', $this->iss); |
|
76 | - $statement->bindValue(':sub', $this->sub); |
|
77 | - $statement->bindValue(':aud', $this->aud); |
|
78 | - $statement->bindValue(':exp', $this->exp); |
|
79 | - $statement->bindValue(':iat', $this->iat); |
|
80 | - $statement->bindValue(':username', $this->username); |
|
81 | - $statement->bindValue(':editcount', $this->editcount); |
|
82 | - $statement->bindValue(':confirmed_email', $this->confirmed_email); |
|
83 | - $statement->bindValue(':blocked', $this->blocked); |
|
84 | - $statement->bindValue(':registered', $this->registered); |
|
85 | - $statement->bindValue(':checkuser', $this->checkuser); |
|
86 | - $statement->bindValue(':grantbasic', $this->grantbasic); |
|
87 | - $statement->bindValue(':grantcreateaccount', $this->grantcreateaccount); |
|
88 | - $statement->bindValue(':granthighvolume', $this->granthighvolume); |
|
89 | - $statement->bindValue(':grantcreateeditmovepage', $this->grantcreateeditmovepage); |
|
90 | - |
|
91 | - if ($statement->execute()) { |
|
92 | - $this->id = (int)$this->dbObject->lastInsertId(); |
|
93 | - } |
|
94 | - else { |
|
95 | - throw new Exception($statement->errorInfo()); |
|
96 | - } |
|
97 | - } |
|
98 | - else { |
|
99 | - $statement = $this->dbObject->prepare(<<<SQL |
|
72 | + ); |
|
73 | + |
|
74 | + $statement->bindValue(':user', $this->user); |
|
75 | + $statement->bindValue(':iss', $this->iss); |
|
76 | + $statement->bindValue(':sub', $this->sub); |
|
77 | + $statement->bindValue(':aud', $this->aud); |
|
78 | + $statement->bindValue(':exp', $this->exp); |
|
79 | + $statement->bindValue(':iat', $this->iat); |
|
80 | + $statement->bindValue(':username', $this->username); |
|
81 | + $statement->bindValue(':editcount', $this->editcount); |
|
82 | + $statement->bindValue(':confirmed_email', $this->confirmed_email); |
|
83 | + $statement->bindValue(':blocked', $this->blocked); |
|
84 | + $statement->bindValue(':registered', $this->registered); |
|
85 | + $statement->bindValue(':checkuser', $this->checkuser); |
|
86 | + $statement->bindValue(':grantbasic', $this->grantbasic); |
|
87 | + $statement->bindValue(':grantcreateaccount', $this->grantcreateaccount); |
|
88 | + $statement->bindValue(':granthighvolume', $this->granthighvolume); |
|
89 | + $statement->bindValue(':grantcreateeditmovepage', $this->grantcreateeditmovepage); |
|
90 | + |
|
91 | + if ($statement->execute()) { |
|
92 | + $this->id = (int)$this->dbObject->lastInsertId(); |
|
93 | + } |
|
94 | + else { |
|
95 | + throw new Exception($statement->errorInfo()); |
|
96 | + } |
|
97 | + } |
|
98 | + else { |
|
99 | + $statement = $this->dbObject->prepare(<<<SQL |
|
100 | 100 | UPDATE oauthidentity SET |
101 | 101 | iss = :iss |
102 | 102 | , sub = :sub |
@@ -116,211 +116,211 @@ discard block |
||
116 | 116 | , updateversion = updateversion + 1 |
117 | 117 | WHERE id = :id AND updateversion = :updateversion |
118 | 118 | SQL |
119 | - ); |
|
120 | - |
|
121 | - $statement->bindValue(':iss', $this->iss); |
|
122 | - $statement->bindValue(':sub', $this->sub); |
|
123 | - $statement->bindValue(':aud', $this->aud); |
|
124 | - $statement->bindValue(':exp', $this->exp); |
|
125 | - $statement->bindValue(':iat', $this->iat); |
|
126 | - $statement->bindValue(':username', $this->username); |
|
127 | - $statement->bindValue(':editcount', $this->editcount); |
|
128 | - $statement->bindValue(':confirmed_email', $this->confirmed_email); |
|
129 | - $statement->bindValue(':blocked', $this->blocked); |
|
130 | - $statement->bindValue(':registered', $this->registered); |
|
131 | - $statement->bindValue(':checkuser', $this->checkuser); |
|
132 | - $statement->bindValue(':grantbasic', $this->grantbasic); |
|
133 | - $statement->bindValue(':grantcreateaccount', $this->grantcreateaccount); |
|
134 | - $statement->bindValue(':granthighvolume', $this->granthighvolume); |
|
135 | - $statement->bindValue(':grantcreateeditmovepage', $this->grantcreateeditmovepage); |
|
136 | - |
|
137 | - $statement->bindValue(':id', $this->id); |
|
138 | - $statement->bindValue(':updateversion', $this->updateversion); |
|
139 | - |
|
140 | - if (!$statement->execute()) { |
|
141 | - throw new Exception($statement->errorInfo()); |
|
142 | - } |
|
143 | - |
|
144 | - if ($statement->rowCount() !== 1) { |
|
145 | - throw new OptimisticLockFailedException(); |
|
146 | - } |
|
147 | - |
|
148 | - $this->updateversion++; |
|
149 | - } |
|
150 | - } |
|
151 | - |
|
152 | - #region Properties |
|
153 | - |
|
154 | - /** |
|
155 | - * @return int |
|
156 | - */ |
|
157 | - public function getUserId() |
|
158 | - { |
|
159 | - return $this->user; |
|
160 | - } |
|
161 | - |
|
162 | - /** |
|
163 | - * @param int $user |
|
164 | - */ |
|
165 | - public function setUserId($user) |
|
166 | - { |
|
167 | - $this->user = $user; |
|
168 | - } |
|
169 | - |
|
170 | - /** |
|
171 | - * @return string |
|
172 | - */ |
|
173 | - public function getIssuer() |
|
174 | - { |
|
175 | - return $this->iss; |
|
176 | - } |
|
177 | - |
|
178 | - /** |
|
179 | - * @return int |
|
180 | - */ |
|
181 | - public function getSubject() |
|
182 | - { |
|
183 | - return $this->sub; |
|
184 | - } |
|
185 | - |
|
186 | - /** |
|
187 | - * @return string |
|
188 | - */ |
|
189 | - public function getAudience() |
|
190 | - { |
|
191 | - return $this->aud; |
|
192 | - } |
|
193 | - |
|
194 | - /** |
|
195 | - * @return int |
|
196 | - */ |
|
197 | - public function getExpirationTime() |
|
198 | - { |
|
199 | - return $this->exp; |
|
200 | - } |
|
201 | - |
|
202 | - /** |
|
203 | - * @return int |
|
204 | - */ |
|
205 | - public function getIssuedAtTime() |
|
206 | - { |
|
207 | - return $this->iat; |
|
208 | - } |
|
209 | - |
|
210 | - /** |
|
211 | - * @return string |
|
212 | - */ |
|
213 | - public function getUsername() |
|
214 | - { |
|
215 | - return $this->username; |
|
216 | - } |
|
217 | - |
|
218 | - /** |
|
219 | - * @return int |
|
220 | - */ |
|
221 | - public function getEditCount() |
|
222 | - { |
|
223 | - return $this->editcount; |
|
224 | - } |
|
225 | - |
|
226 | - /** |
|
227 | - * @return bool |
|
228 | - */ |
|
229 | - public function getConfirmedEmail() |
|
230 | - { |
|
231 | - return $this->confirmed_email == 1; |
|
232 | - } |
|
233 | - |
|
234 | - /** |
|
235 | - * @return bool |
|
236 | - */ |
|
237 | - public function getBlocked() |
|
238 | - { |
|
239 | - return $this->blocked == 1; |
|
240 | - } |
|
241 | - |
|
242 | - /** |
|
243 | - * @return string |
|
244 | - */ |
|
245 | - public function getRegistered() |
|
246 | - { |
|
247 | - return $this->registered; |
|
248 | - } |
|
249 | - |
|
250 | - public function getRegistrationDate() |
|
251 | - { |
|
252 | - return DateTimeImmutable::createFromFormat('YmdHis', $this->registered)->format('r'); |
|
253 | - } |
|
254 | - |
|
255 | - public function getAccountAge() |
|
256 | - { |
|
257 | - $regDate = DateTimeImmutable::createFromFormat('YmdHis', $this->registered); |
|
258 | - $interval = $regDate->diff(new DateTimeImmutable(), true); |
|
259 | - |
|
260 | - return $interval->days; |
|
261 | - } |
|
262 | - |
|
263 | - /** |
|
264 | - * @return bool |
|
265 | - */ |
|
266 | - public function getCheckuser() |
|
267 | - { |
|
268 | - return $this->checkuser == 1; |
|
269 | - } |
|
270 | - |
|
271 | - /** |
|
272 | - * @return bool |
|
273 | - */ |
|
274 | - public function getGrantBasic() |
|
275 | - { |
|
276 | - return $this->grantbasic == 1; |
|
277 | - } |
|
278 | - |
|
279 | - /** |
|
280 | - * @return bool |
|
281 | - */ |
|
282 | - public function getGrantCreateAccount() |
|
283 | - { |
|
284 | - return $this->grantcreateaccount == 1; |
|
285 | - } |
|
286 | - |
|
287 | - /** |
|
288 | - * @return bool |
|
289 | - */ |
|
290 | - public function getGrantHighVolume() |
|
291 | - { |
|
292 | - return $this->granthighvolume == 1; |
|
293 | - } |
|
294 | - |
|
295 | - /** |
|
296 | - * @return bool |
|
297 | - */ |
|
298 | - public function getGrantCreateEditMovePage() |
|
299 | - { |
|
300 | - return $this->grantcreateeditmovepage == 1; |
|
301 | - } |
|
302 | - |
|
303 | - #endregion Properties |
|
304 | - |
|
305 | - /** |
|
306 | - * Populates the fields of this instance from a provided JSON Web Token |
|
307 | - * |
|
308 | - * @param stdClass $jwt |
|
309 | - */ |
|
310 | - public function populate($jwt) |
|
311 | - { |
|
312 | - $this->iss = $jwt->iss; |
|
313 | - $this->sub = $jwt->sub; |
|
314 | - $this->aud = $jwt->aud; |
|
315 | - $this->exp = $jwt->exp; |
|
316 | - $this->iat = $jwt->iat; |
|
317 | - $this->username = $jwt->username; |
|
318 | - $this->editcount = $jwt->editcount; |
|
319 | - $this->confirmed_email = $jwt->confirmed_email ? 1 : 0; |
|
320 | - $this->blocked = $jwt->blocked ? 1 : 0; |
|
321 | - $this->registered = $jwt->registered; |
|
322 | - |
|
323 | - /* |
|
119 | + ); |
|
120 | + |
|
121 | + $statement->bindValue(':iss', $this->iss); |
|
122 | + $statement->bindValue(':sub', $this->sub); |
|
123 | + $statement->bindValue(':aud', $this->aud); |
|
124 | + $statement->bindValue(':exp', $this->exp); |
|
125 | + $statement->bindValue(':iat', $this->iat); |
|
126 | + $statement->bindValue(':username', $this->username); |
|
127 | + $statement->bindValue(':editcount', $this->editcount); |
|
128 | + $statement->bindValue(':confirmed_email', $this->confirmed_email); |
|
129 | + $statement->bindValue(':blocked', $this->blocked); |
|
130 | + $statement->bindValue(':registered', $this->registered); |
|
131 | + $statement->bindValue(':checkuser', $this->checkuser); |
|
132 | + $statement->bindValue(':grantbasic', $this->grantbasic); |
|
133 | + $statement->bindValue(':grantcreateaccount', $this->grantcreateaccount); |
|
134 | + $statement->bindValue(':granthighvolume', $this->granthighvolume); |
|
135 | + $statement->bindValue(':grantcreateeditmovepage', $this->grantcreateeditmovepage); |
|
136 | + |
|
137 | + $statement->bindValue(':id', $this->id); |
|
138 | + $statement->bindValue(':updateversion', $this->updateversion); |
|
139 | + |
|
140 | + if (!$statement->execute()) { |
|
141 | + throw new Exception($statement->errorInfo()); |
|
142 | + } |
|
143 | + |
|
144 | + if ($statement->rowCount() !== 1) { |
|
145 | + throw new OptimisticLockFailedException(); |
|
146 | + } |
|
147 | + |
|
148 | + $this->updateversion++; |
|
149 | + } |
|
150 | + } |
|
151 | + |
|
152 | + #region Properties |
|
153 | + |
|
154 | + /** |
|
155 | + * @return int |
|
156 | + */ |
|
157 | + public function getUserId() |
|
158 | + { |
|
159 | + return $this->user; |
|
160 | + } |
|
161 | + |
|
162 | + /** |
|
163 | + * @param int $user |
|
164 | + */ |
|
165 | + public function setUserId($user) |
|
166 | + { |
|
167 | + $this->user = $user; |
|
168 | + } |
|
169 | + |
|
170 | + /** |
|
171 | + * @return string |
|
172 | + */ |
|
173 | + public function getIssuer() |
|
174 | + { |
|
175 | + return $this->iss; |
|
176 | + } |
|
177 | + |
|
178 | + /** |
|
179 | + * @return int |
|
180 | + */ |
|
181 | + public function getSubject() |
|
182 | + { |
|
183 | + return $this->sub; |
|
184 | + } |
|
185 | + |
|
186 | + /** |
|
187 | + * @return string |
|
188 | + */ |
|
189 | + public function getAudience() |
|
190 | + { |
|
191 | + return $this->aud; |
|
192 | + } |
|
193 | + |
|
194 | + /** |
|
195 | + * @return int |
|
196 | + */ |
|
197 | + public function getExpirationTime() |
|
198 | + { |
|
199 | + return $this->exp; |
|
200 | + } |
|
201 | + |
|
202 | + /** |
|
203 | + * @return int |
|
204 | + */ |
|
205 | + public function getIssuedAtTime() |
|
206 | + { |
|
207 | + return $this->iat; |
|
208 | + } |
|
209 | + |
|
210 | + /** |
|
211 | + * @return string |
|
212 | + */ |
|
213 | + public function getUsername() |
|
214 | + { |
|
215 | + return $this->username; |
|
216 | + } |
|
217 | + |
|
218 | + /** |
|
219 | + * @return int |
|
220 | + */ |
|
221 | + public function getEditCount() |
|
222 | + { |
|
223 | + return $this->editcount; |
|
224 | + } |
|
225 | + |
|
226 | + /** |
|
227 | + * @return bool |
|
228 | + */ |
|
229 | + public function getConfirmedEmail() |
|
230 | + { |
|
231 | + return $this->confirmed_email == 1; |
|
232 | + } |
|
233 | + |
|
234 | + /** |
|
235 | + * @return bool |
|
236 | + */ |
|
237 | + public function getBlocked() |
|
238 | + { |
|
239 | + return $this->blocked == 1; |
|
240 | + } |
|
241 | + |
|
242 | + /** |
|
243 | + * @return string |
|
244 | + */ |
|
245 | + public function getRegistered() |
|
246 | + { |
|
247 | + return $this->registered; |
|
248 | + } |
|
249 | + |
|
250 | + public function getRegistrationDate() |
|
251 | + { |
|
252 | + return DateTimeImmutable::createFromFormat('YmdHis', $this->registered)->format('r'); |
|
253 | + } |
|
254 | + |
|
255 | + public function getAccountAge() |
|
256 | + { |
|
257 | + $regDate = DateTimeImmutable::createFromFormat('YmdHis', $this->registered); |
|
258 | + $interval = $regDate->diff(new DateTimeImmutable(), true); |
|
259 | + |
|
260 | + return $interval->days; |
|
261 | + } |
|
262 | + |
|
263 | + /** |
|
264 | + * @return bool |
|
265 | + */ |
|
266 | + public function getCheckuser() |
|
267 | + { |
|
268 | + return $this->checkuser == 1; |
|
269 | + } |
|
270 | + |
|
271 | + /** |
|
272 | + * @return bool |
|
273 | + */ |
|
274 | + public function getGrantBasic() |
|
275 | + { |
|
276 | + return $this->grantbasic == 1; |
|
277 | + } |
|
278 | + |
|
279 | + /** |
|
280 | + * @return bool |
|
281 | + */ |
|
282 | + public function getGrantCreateAccount() |
|
283 | + { |
|
284 | + return $this->grantcreateaccount == 1; |
|
285 | + } |
|
286 | + |
|
287 | + /** |
|
288 | + * @return bool |
|
289 | + */ |
|
290 | + public function getGrantHighVolume() |
|
291 | + { |
|
292 | + return $this->granthighvolume == 1; |
|
293 | + } |
|
294 | + |
|
295 | + /** |
|
296 | + * @return bool |
|
297 | + */ |
|
298 | + public function getGrantCreateEditMovePage() |
|
299 | + { |
|
300 | + return $this->grantcreateeditmovepage == 1; |
|
301 | + } |
|
302 | + |
|
303 | + #endregion Properties |
|
304 | + |
|
305 | + /** |
|
306 | + * Populates the fields of this instance from a provided JSON Web Token |
|
307 | + * |
|
308 | + * @param stdClass $jwt |
|
309 | + */ |
|
310 | + public function populate($jwt) |
|
311 | + { |
|
312 | + $this->iss = $jwt->iss; |
|
313 | + $this->sub = $jwt->sub; |
|
314 | + $this->aud = $jwt->aud; |
|
315 | + $this->exp = $jwt->exp; |
|
316 | + $this->iat = $jwt->iat; |
|
317 | + $this->username = $jwt->username; |
|
318 | + $this->editcount = $jwt->editcount; |
|
319 | + $this->confirmed_email = $jwt->confirmed_email ? 1 : 0; |
|
320 | + $this->blocked = $jwt->blocked ? 1 : 0; |
|
321 | + $this->registered = $jwt->registered; |
|
322 | + |
|
323 | + /* |
|
324 | 324 | * Rights we need: |
325 | 325 | * Account creation |
326 | 326 | * createaccount => createaccount |
@@ -342,11 +342,11 @@ discard block |
||
342 | 342 | * Any antispoof conflicts will still have to be resolved manually using the normal creation form. |
343 | 343 | */ |
344 | 344 | |
345 | - $this->grantbasic = in_array('basic', $jwt->grants) ? 1 : 0; |
|
346 | - $this->grantcreateaccount = in_array('createaccount', $jwt->grants) ? 1 : 0; |
|
347 | - $this->grantcreateeditmovepage = in_array('createeditmovepage', $jwt->grants) ? 1 : 0; |
|
348 | - $this->granthighvolume = in_array('highvolume', $jwt->grants) ? 1 : 0; |
|
345 | + $this->grantbasic = in_array('basic', $jwt->grants) ? 1 : 0; |
|
346 | + $this->grantcreateaccount = in_array('createaccount', $jwt->grants) ? 1 : 0; |
|
347 | + $this->grantcreateeditmovepage = in_array('createeditmovepage', $jwt->grants) ? 1 : 0; |
|
348 | + $this->granthighvolume = in_array('highvolume', $jwt->grants) ? 1 : 0; |
|
349 | 349 | |
350 | - $this->checkuser = in_array('checkuser-log', $jwt->rights) ? 1 : 0; |
|
351 | - } |
|
350 | + $this->checkuser = in_array('checkuser-log', $jwt->rights) ? 1 : 0; |
|
351 | + } |
|
352 | 352 | } |
@@ -90,12 +90,10 @@ |
||
90 | 90 | |
91 | 91 | if ($statement->execute()) { |
92 | 92 | $this->id = (int)$this->dbObject->lastInsertId(); |
93 | - } |
|
94 | - else { |
|
93 | + } else { |
|
95 | 94 | throw new Exception($statement->errorInfo()); |
96 | 95 | } |
97 | - } |
|
98 | - else { |
|
96 | + } else { |
|
99 | 97 | $statement = $this->dbObject->prepare(<<<SQL |
100 | 98 | UPDATE oauthidentity SET |
101 | 99 | iss = :iss |
@@ -15,187 +15,187 @@ discard block |
||
15 | 15 | |
16 | 16 | class Credential extends DataObject |
17 | 17 | { |
18 | - /** @var int */ |
|
19 | - private $user; |
|
20 | - /** @var int */ |
|
21 | - private $factor; |
|
22 | - /** @var string */ |
|
23 | - private $type; |
|
24 | - /** @var string */ |
|
25 | - private $data; |
|
26 | - /** @var int */ |
|
27 | - private $version; |
|
28 | - private $timeout; |
|
29 | - /** @var int */ |
|
30 | - private $disabled = 0; |
|
31 | - /** @var int */ |
|
32 | - private $priority; |
|
33 | - |
|
34 | - /** |
|
35 | - * @return int |
|
36 | - */ |
|
37 | - public function getUserId() |
|
38 | - { |
|
39 | - return $this->user; |
|
40 | - } |
|
41 | - |
|
42 | - /** |
|
43 | - * @param int $user |
|
44 | - */ |
|
45 | - public function setUserId($user) |
|
46 | - { |
|
47 | - $this->user = $user; |
|
48 | - } |
|
49 | - |
|
50 | - /** |
|
51 | - * @return int |
|
52 | - */ |
|
53 | - public function getFactor() |
|
54 | - { |
|
55 | - return $this->factor; |
|
56 | - } |
|
57 | - |
|
58 | - /** |
|
59 | - * @param int $factor |
|
60 | - */ |
|
61 | - public function setFactor($factor) |
|
62 | - { |
|
63 | - $this->factor = $factor; |
|
64 | - } |
|
65 | - |
|
66 | - /** |
|
67 | - * @return string |
|
68 | - */ |
|
69 | - public function getType() |
|
70 | - { |
|
71 | - return $this->type; |
|
72 | - } |
|
73 | - |
|
74 | - /** |
|
75 | - * @param string $type |
|
76 | - */ |
|
77 | - public function setType($type) |
|
78 | - { |
|
79 | - $this->type = $type; |
|
80 | - } |
|
81 | - |
|
82 | - /** |
|
83 | - * @return string |
|
84 | - */ |
|
85 | - public function getData() |
|
86 | - { |
|
87 | - return $this->data; |
|
88 | - } |
|
89 | - |
|
90 | - /** |
|
91 | - * @param string $data |
|
92 | - */ |
|
93 | - public function setData($data) |
|
94 | - { |
|
95 | - $this->data = $data; |
|
96 | - } |
|
97 | - |
|
98 | - /** |
|
99 | - * @return int |
|
100 | - */ |
|
101 | - public function getVersion() |
|
102 | - { |
|
103 | - return $this->version; |
|
104 | - } |
|
105 | - |
|
106 | - /** |
|
107 | - * @param int $version |
|
108 | - */ |
|
109 | - public function setVersion($version) |
|
110 | - { |
|
111 | - $this->version = $version; |
|
112 | - } |
|
113 | - |
|
114 | - /** |
|
115 | - * @return mixed |
|
116 | - */ |
|
117 | - public function getTimeout() |
|
118 | - { |
|
119 | - if ($this->timeout === null) { |
|
120 | - return null; |
|
121 | - } |
|
122 | - |
|
123 | - return new DateTimeImmutable($this->timeout); |
|
124 | - } |
|
125 | - |
|
126 | - /** |
|
127 | - * @param mixed $timeout |
|
128 | - */ |
|
129 | - public function setTimeout(DateTimeImmutable $timeout = null) |
|
130 | - { |
|
131 | - if ($timeout === null) { |
|
132 | - $this->timeout = null; |
|
133 | - } |
|
134 | - else { |
|
135 | - $this->timeout = $timeout->format('Y-m-d H:i:s'); |
|
136 | - } |
|
137 | - } |
|
138 | - |
|
139 | - /** |
|
140 | - * @return int |
|
141 | - */ |
|
142 | - public function getDisabled() |
|
143 | - { |
|
144 | - return $this->disabled; |
|
145 | - } |
|
146 | - |
|
147 | - /** |
|
148 | - * @param int $disabled |
|
149 | - */ |
|
150 | - public function setDisabled($disabled) |
|
151 | - { |
|
152 | - $this->disabled = $disabled; |
|
153 | - } |
|
154 | - |
|
155 | - /** |
|
156 | - * @return int |
|
157 | - */ |
|
158 | - public function getPriority() |
|
159 | - { |
|
160 | - return $this->priority; |
|
161 | - } |
|
162 | - |
|
163 | - /** |
|
164 | - * @param int $priority |
|
165 | - */ |
|
166 | - public function setPriority($priority) |
|
167 | - { |
|
168 | - $this->priority = $priority; |
|
169 | - } |
|
170 | - |
|
171 | - public function save() |
|
172 | - { |
|
173 | - if ($this->isNew()) { |
|
174 | - // insert |
|
175 | - $statement = $this->dbObject->prepare(<<<SQL |
|
18 | + /** @var int */ |
|
19 | + private $user; |
|
20 | + /** @var int */ |
|
21 | + private $factor; |
|
22 | + /** @var string */ |
|
23 | + private $type; |
|
24 | + /** @var string */ |
|
25 | + private $data; |
|
26 | + /** @var int */ |
|
27 | + private $version; |
|
28 | + private $timeout; |
|
29 | + /** @var int */ |
|
30 | + private $disabled = 0; |
|
31 | + /** @var int */ |
|
32 | + private $priority; |
|
33 | + |
|
34 | + /** |
|
35 | + * @return int |
|
36 | + */ |
|
37 | + public function getUserId() |
|
38 | + { |
|
39 | + return $this->user; |
|
40 | + } |
|
41 | + |
|
42 | + /** |
|
43 | + * @param int $user |
|
44 | + */ |
|
45 | + public function setUserId($user) |
|
46 | + { |
|
47 | + $this->user = $user; |
|
48 | + } |
|
49 | + |
|
50 | + /** |
|
51 | + * @return int |
|
52 | + */ |
|
53 | + public function getFactor() |
|
54 | + { |
|
55 | + return $this->factor; |
|
56 | + } |
|
57 | + |
|
58 | + /** |
|
59 | + * @param int $factor |
|
60 | + */ |
|
61 | + public function setFactor($factor) |
|
62 | + { |
|
63 | + $this->factor = $factor; |
|
64 | + } |
|
65 | + |
|
66 | + /** |
|
67 | + * @return string |
|
68 | + */ |
|
69 | + public function getType() |
|
70 | + { |
|
71 | + return $this->type; |
|
72 | + } |
|
73 | + |
|
74 | + /** |
|
75 | + * @param string $type |
|
76 | + */ |
|
77 | + public function setType($type) |
|
78 | + { |
|
79 | + $this->type = $type; |
|
80 | + } |
|
81 | + |
|
82 | + /** |
|
83 | + * @return string |
|
84 | + */ |
|
85 | + public function getData() |
|
86 | + { |
|
87 | + return $this->data; |
|
88 | + } |
|
89 | + |
|
90 | + /** |
|
91 | + * @param string $data |
|
92 | + */ |
|
93 | + public function setData($data) |
|
94 | + { |
|
95 | + $this->data = $data; |
|
96 | + } |
|
97 | + |
|
98 | + /** |
|
99 | + * @return int |
|
100 | + */ |
|
101 | + public function getVersion() |
|
102 | + { |
|
103 | + return $this->version; |
|
104 | + } |
|
105 | + |
|
106 | + /** |
|
107 | + * @param int $version |
|
108 | + */ |
|
109 | + public function setVersion($version) |
|
110 | + { |
|
111 | + $this->version = $version; |
|
112 | + } |
|
113 | + |
|
114 | + /** |
|
115 | + * @return mixed |
|
116 | + */ |
|
117 | + public function getTimeout() |
|
118 | + { |
|
119 | + if ($this->timeout === null) { |
|
120 | + return null; |
|
121 | + } |
|
122 | + |
|
123 | + return new DateTimeImmutable($this->timeout); |
|
124 | + } |
|
125 | + |
|
126 | + /** |
|
127 | + * @param mixed $timeout |
|
128 | + */ |
|
129 | + public function setTimeout(DateTimeImmutable $timeout = null) |
|
130 | + { |
|
131 | + if ($timeout === null) { |
|
132 | + $this->timeout = null; |
|
133 | + } |
|
134 | + else { |
|
135 | + $this->timeout = $timeout->format('Y-m-d H:i:s'); |
|
136 | + } |
|
137 | + } |
|
138 | + |
|
139 | + /** |
|
140 | + * @return int |
|
141 | + */ |
|
142 | + public function getDisabled() |
|
143 | + { |
|
144 | + return $this->disabled; |
|
145 | + } |
|
146 | + |
|
147 | + /** |
|
148 | + * @param int $disabled |
|
149 | + */ |
|
150 | + public function setDisabled($disabled) |
|
151 | + { |
|
152 | + $this->disabled = $disabled; |
|
153 | + } |
|
154 | + |
|
155 | + /** |
|
156 | + * @return int |
|
157 | + */ |
|
158 | + public function getPriority() |
|
159 | + { |
|
160 | + return $this->priority; |
|
161 | + } |
|
162 | + |
|
163 | + /** |
|
164 | + * @param int $priority |
|
165 | + */ |
|
166 | + public function setPriority($priority) |
|
167 | + { |
|
168 | + $this->priority = $priority; |
|
169 | + } |
|
170 | + |
|
171 | + public function save() |
|
172 | + { |
|
173 | + if ($this->isNew()) { |
|
174 | + // insert |
|
175 | + $statement = $this->dbObject->prepare(<<<SQL |
|
176 | 176 | INSERT INTO credential ( updateversion, user, factor, type, data, version, timeout, disabled, priority ) |
177 | 177 | VALUES ( 0, :user, :factor, :type, :data, :version, :timeout, :disabled, :priority ); |
178 | 178 | SQL |
179 | - ); |
|
180 | - $statement->bindValue(":user", $this->user); |
|
181 | - $statement->bindValue(":factor", $this->factor); |
|
182 | - $statement->bindValue(":type", $this->type); |
|
183 | - $statement->bindValue(":data", $this->data); |
|
184 | - $statement->bindValue(":version", $this->version); |
|
185 | - $statement->bindValue(":timeout", $this->timeout); |
|
186 | - $statement->bindValue(":disabled", $this->disabled); |
|
187 | - $statement->bindValue(":priority", $this->priority); |
|
188 | - |
|
189 | - if ($statement->execute()) { |
|
190 | - $this->id = (int)$this->dbObject->lastInsertId(); |
|
191 | - } |
|
192 | - else { |
|
193 | - throw new Exception($statement->errorInfo()); |
|
194 | - } |
|
195 | - } |
|
196 | - else { |
|
197 | - // update |
|
198 | - $statement = $this->dbObject->prepare(<<<SQL |
|
179 | + ); |
|
180 | + $statement->bindValue(":user", $this->user); |
|
181 | + $statement->bindValue(":factor", $this->factor); |
|
182 | + $statement->bindValue(":type", $this->type); |
|
183 | + $statement->bindValue(":data", $this->data); |
|
184 | + $statement->bindValue(":version", $this->version); |
|
185 | + $statement->bindValue(":timeout", $this->timeout); |
|
186 | + $statement->bindValue(":disabled", $this->disabled); |
|
187 | + $statement->bindValue(":priority", $this->priority); |
|
188 | + |
|
189 | + if ($statement->execute()) { |
|
190 | + $this->id = (int)$this->dbObject->lastInsertId(); |
|
191 | + } |
|
192 | + else { |
|
193 | + throw new Exception($statement->errorInfo()); |
|
194 | + } |
|
195 | + } |
|
196 | + else { |
|
197 | + // update |
|
198 | + $statement = $this->dbObject->prepare(<<<SQL |
|
199 | 199 | UPDATE credential |
200 | 200 | SET factor = :factor |
201 | 201 | , data = :data |
@@ -206,27 +206,27 @@ discard block |
||
206 | 206 | , updateversion = updateversion + 1 |
207 | 207 | WHERE id = :id AND updateversion = :updateversion; |
208 | 208 | SQL |
209 | - ); |
|
209 | + ); |
|
210 | 210 | |
211 | - $statement->bindValue(':id', $this->id); |
|
212 | - $statement->bindValue(':updateversion', $this->updateversion); |
|
211 | + $statement->bindValue(':id', $this->id); |
|
212 | + $statement->bindValue(':updateversion', $this->updateversion); |
|
213 | 213 | |
214 | - $statement->bindValue(":factor", $this->factor); |
|
215 | - $statement->bindValue(":data", $this->data); |
|
216 | - $statement->bindValue(":version", $this->version); |
|
217 | - $statement->bindValue(":timeout", $this->timeout); |
|
218 | - $statement->bindValue(":disabled", $this->disabled); |
|
219 | - $statement->bindValue(":priority", $this->priority); |
|
214 | + $statement->bindValue(":factor", $this->factor); |
|
215 | + $statement->bindValue(":data", $this->data); |
|
216 | + $statement->bindValue(":version", $this->version); |
|
217 | + $statement->bindValue(":timeout", $this->timeout); |
|
218 | + $statement->bindValue(":disabled", $this->disabled); |
|
219 | + $statement->bindValue(":priority", $this->priority); |
|
220 | 220 | |
221 | - if (!$statement->execute()) { |
|
222 | - throw new Exception($statement->errorInfo()); |
|
223 | - } |
|
221 | + if (!$statement->execute()) { |
|
222 | + throw new Exception($statement->errorInfo()); |
|
223 | + } |
|
224 | 224 | |
225 | - if ($statement->rowCount() !== 1) { |
|
226 | - throw new OptimisticLockFailedException(); |
|
227 | - } |
|
225 | + if ($statement->rowCount() !== 1) { |
|
226 | + throw new OptimisticLockFailedException(); |
|
227 | + } |
|
228 | 228 | |
229 | - $this->updateversion++; |
|
230 | - } |
|
231 | - } |
|
229 | + $this->updateversion++; |
|
230 | + } |
|
231 | + } |
|
232 | 232 | } |
233 | 233 | \ No newline at end of file |
@@ -130,8 +130,7 @@ discard block |
||
130 | 130 | { |
131 | 131 | if ($timeout === null) { |
132 | 132 | $this->timeout = null; |
133 | - } |
|
134 | - else { |
|
133 | + } else { |
|
135 | 134 | $this->timeout = $timeout->format('Y-m-d H:i:s'); |
136 | 135 | } |
137 | 136 | } |
@@ -188,12 +187,10 @@ discard block |
||
188 | 187 | |
189 | 188 | if ($statement->execute()) { |
190 | 189 | $this->id = (int)$this->dbObject->lastInsertId(); |
191 | - } |
|
192 | - else { |
|
190 | + } else { |
|
193 | 191 | throw new Exception($statement->errorInfo()); |
194 | 192 | } |
195 | - } |
|
196 | - else { |
|
193 | + } else { |
|
197 | 194 | // update |
198 | 195 | $statement = $this->dbObject->prepare(<<<SQL |
199 | 196 | UPDATE credential |
@@ -14,42 +14,42 @@ discard block |
||
14 | 14 | |
15 | 15 | class OAuthToken extends DataObject |
16 | 16 | { |
17 | - /** @var int */ |
|
18 | - private $user; |
|
19 | - /** @var string */ |
|
20 | - private $token; |
|
21 | - /** @var string */ |
|
22 | - private $secret; |
|
23 | - /** @var string */ |
|
24 | - private $type; |
|
25 | - /** @var string */ |
|
26 | - private $expiry; |
|
27 | - |
|
28 | - public function save() |
|
29 | - { |
|
30 | - if ($this->isNew()) { |
|
31 | - // insert |
|
32 | - $statement = $this->dbObject->prepare(<<<SQL |
|
17 | + /** @var int */ |
|
18 | + private $user; |
|
19 | + /** @var string */ |
|
20 | + private $token; |
|
21 | + /** @var string */ |
|
22 | + private $secret; |
|
23 | + /** @var string */ |
|
24 | + private $type; |
|
25 | + /** @var string */ |
|
26 | + private $expiry; |
|
27 | + |
|
28 | + public function save() |
|
29 | + { |
|
30 | + if ($this->isNew()) { |
|
31 | + // insert |
|
32 | + $statement = $this->dbObject->prepare(<<<SQL |
|
33 | 33 | INSERT INTO oauthtoken ( user, token, secret, type, expiry ) |
34 | 34 | VALUES ( :user, :token, :secret, :type, :expiry ); |
35 | 35 | SQL |
36 | - ); |
|
37 | - $statement->bindValue(":user", $this->user); |
|
38 | - $statement->bindValue(":token", $this->token); |
|
39 | - $statement->bindValue(":secret", $this->secret); |
|
40 | - $statement->bindValue(":type", $this->type); |
|
41 | - $statement->bindValue(":expiry", $this->expiry); |
|
42 | - |
|
43 | - if ($statement->execute()) { |
|
44 | - $this->id = (int)$this->dbObject->lastInsertId(); |
|
45 | - } |
|
46 | - else { |
|
47 | - throw new Exception($statement->errorInfo()); |
|
48 | - } |
|
49 | - } |
|
50 | - else { |
|
51 | - // update |
|
52 | - $statement = $this->dbObject->prepare(<<<SQL |
|
36 | + ); |
|
37 | + $statement->bindValue(":user", $this->user); |
|
38 | + $statement->bindValue(":token", $this->token); |
|
39 | + $statement->bindValue(":secret", $this->secret); |
|
40 | + $statement->bindValue(":type", $this->type); |
|
41 | + $statement->bindValue(":expiry", $this->expiry); |
|
42 | + |
|
43 | + if ($statement->execute()) { |
|
44 | + $this->id = (int)$this->dbObject->lastInsertId(); |
|
45 | + } |
|
46 | + else { |
|
47 | + throw new Exception($statement->errorInfo()); |
|
48 | + } |
|
49 | + } |
|
50 | + else { |
|
51 | + // update |
|
52 | + $statement = $this->dbObject->prepare(<<<SQL |
|
53 | 53 | UPDATE oauthtoken |
54 | 54 | SET token = :token |
55 | 55 | , secret = :secret |
@@ -58,109 +58,109 @@ discard block |
||
58 | 58 | , updateversion = updateversion + 1 |
59 | 59 | WHERE id = :id AND updateversion = :updateversion; |
60 | 60 | SQL |
61 | - ); |
|
62 | - |
|
63 | - $statement->bindValue(':id', $this->id); |
|
64 | - $statement->bindValue(':updateversion', $this->updateversion); |
|
65 | - |
|
66 | - $statement->bindValue(":token", $this->token); |
|
67 | - $statement->bindValue(":secret", $this->secret); |
|
68 | - $statement->bindValue(":type", $this->type); |
|
69 | - $statement->bindValue(":expiry", $this->expiry); |
|
70 | - |
|
71 | - if (!$statement->execute()) { |
|
72 | - throw new Exception($statement->errorInfo()); |
|
73 | - } |
|
74 | - |
|
75 | - if ($statement->rowCount() !== 1) { |
|
76 | - throw new OptimisticLockFailedException(); |
|
77 | - } |
|
78 | - |
|
79 | - $this->updateversion++; |
|
80 | - } |
|
81 | - } |
|
82 | - |
|
83 | - #region properties |
|
84 | - |
|
85 | - /** |
|
86 | - * @return mixed |
|
87 | - */ |
|
88 | - public function getUserId() |
|
89 | - { |
|
90 | - return $this->user; |
|
91 | - } |
|
92 | - |
|
93 | - /** |
|
94 | - * @param mixed $user |
|
95 | - */ |
|
96 | - public function setUserId($user) |
|
97 | - { |
|
98 | - $this->user = $user; |
|
99 | - } |
|
100 | - |
|
101 | - /** |
|
102 | - * @return mixed |
|
103 | - */ |
|
104 | - public function getToken() |
|
105 | - { |
|
106 | - return $this->token; |
|
107 | - } |
|
108 | - |
|
109 | - /** |
|
110 | - * @param mixed $token |
|
111 | - */ |
|
112 | - public function setToken($token) |
|
113 | - { |
|
114 | - $this->token = $token; |
|
115 | - } |
|
116 | - |
|
117 | - /** |
|
118 | - * @return mixed |
|
119 | - */ |
|
120 | - public function getSecret() |
|
121 | - { |
|
122 | - return $this->secret; |
|
123 | - } |
|
124 | - |
|
125 | - /** |
|
126 | - * @param mixed $secret |
|
127 | - */ |
|
128 | - public function setSecret($secret) |
|
129 | - { |
|
130 | - $this->secret = $secret; |
|
131 | - } |
|
132 | - |
|
133 | - /** |
|
134 | - * @return mixed |
|
135 | - */ |
|
136 | - public function getType() |
|
137 | - { |
|
138 | - return $this->type; |
|
139 | - } |
|
140 | - |
|
141 | - /** |
|
142 | - * @param mixed $type |
|
143 | - */ |
|
144 | - public function setType($type) |
|
145 | - { |
|
146 | - $this->type = $type; |
|
147 | - } |
|
148 | - |
|
149 | - /** |
|
150 | - * @return string |
|
151 | - */ |
|
152 | - public function getExpiry() |
|
153 | - { |
|
154 | - return $this->expiry; |
|
155 | - } |
|
156 | - |
|
157 | - /** |
|
158 | - * @param string $expiry |
|
159 | - */ |
|
160 | - public function setExpiry($expiry) |
|
161 | - { |
|
162 | - $this->expiry = $expiry; |
|
163 | - } |
|
164 | - #endregion |
|
61 | + ); |
|
62 | + |
|
63 | + $statement->bindValue(':id', $this->id); |
|
64 | + $statement->bindValue(':updateversion', $this->updateversion); |
|
65 | + |
|
66 | + $statement->bindValue(":token", $this->token); |
|
67 | + $statement->bindValue(":secret", $this->secret); |
|
68 | + $statement->bindValue(":type", $this->type); |
|
69 | + $statement->bindValue(":expiry", $this->expiry); |
|
70 | + |
|
71 | + if (!$statement->execute()) { |
|
72 | + throw new Exception($statement->errorInfo()); |
|
73 | + } |
|
74 | + |
|
75 | + if ($statement->rowCount() !== 1) { |
|
76 | + throw new OptimisticLockFailedException(); |
|
77 | + } |
|
78 | + |
|
79 | + $this->updateversion++; |
|
80 | + } |
|
81 | + } |
|
82 | + |
|
83 | + #region properties |
|
84 | + |
|
85 | + /** |
|
86 | + * @return mixed |
|
87 | + */ |
|
88 | + public function getUserId() |
|
89 | + { |
|
90 | + return $this->user; |
|
91 | + } |
|
92 | + |
|
93 | + /** |
|
94 | + * @param mixed $user |
|
95 | + */ |
|
96 | + public function setUserId($user) |
|
97 | + { |
|
98 | + $this->user = $user; |
|
99 | + } |
|
100 | + |
|
101 | + /** |
|
102 | + * @return mixed |
|
103 | + */ |
|
104 | + public function getToken() |
|
105 | + { |
|
106 | + return $this->token; |
|
107 | + } |
|
108 | + |
|
109 | + /** |
|
110 | + * @param mixed $token |
|
111 | + */ |
|
112 | + public function setToken($token) |
|
113 | + { |
|
114 | + $this->token = $token; |
|
115 | + } |
|
116 | + |
|
117 | + /** |
|
118 | + * @return mixed |
|
119 | + */ |
|
120 | + public function getSecret() |
|
121 | + { |
|
122 | + return $this->secret; |
|
123 | + } |
|
124 | + |
|
125 | + /** |
|
126 | + * @param mixed $secret |
|
127 | + */ |
|
128 | + public function setSecret($secret) |
|
129 | + { |
|
130 | + $this->secret = $secret; |
|
131 | + } |
|
132 | + |
|
133 | + /** |
|
134 | + * @return mixed |
|
135 | + */ |
|
136 | + public function getType() |
|
137 | + { |
|
138 | + return $this->type; |
|
139 | + } |
|
140 | + |
|
141 | + /** |
|
142 | + * @param mixed $type |
|
143 | + */ |
|
144 | + public function setType($type) |
|
145 | + { |
|
146 | + $this->type = $type; |
|
147 | + } |
|
148 | + |
|
149 | + /** |
|
150 | + * @return string |
|
151 | + */ |
|
152 | + public function getExpiry() |
|
153 | + { |
|
154 | + return $this->expiry; |
|
155 | + } |
|
156 | + |
|
157 | + /** |
|
158 | + * @param string $expiry |
|
159 | + */ |
|
160 | + public function setExpiry($expiry) |
|
161 | + { |
|
162 | + $this->expiry = $expiry; |
|
163 | + } |
|
164 | + #endregion |
|
165 | 165 | |
166 | 166 | } |
167 | 167 | \ No newline at end of file |
@@ -42,12 +42,10 @@ |
||
42 | 42 | |
43 | 43 | if ($statement->execute()) { |
44 | 44 | $this->id = (int)$this->dbObject->lastInsertId(); |
45 | - } |
|
46 | - else { |
|
45 | + } else { |
|
47 | 46 | throw new Exception($statement->errorInfo()); |
48 | 47 | } |
49 | - } |
|
50 | - else { |
|
48 | + } else { |
|
51 | 49 | // update |
52 | 50 | $statement = $this->dbObject->prepare(<<<SQL |
53 | 51 | UPDATE oauthtoken |
@@ -14,14 +14,14 @@ |
||
14 | 14 | |
15 | 15 | class UserCreationTask extends CreationTaskBase |
16 | 16 | { |
17 | - /** |
|
18 | - * @return IMediaWikiClient |
|
19 | - */ |
|
20 | - protected function getMediaWikiClient() |
|
21 | - { |
|
22 | - $oauth = new OAuthUserHelper($this->getTriggerUser(), $this->getDatabase(), $this->getOauthProtocolHelper(), |
|
23 | - $this->getSiteConfiguration()); |
|
17 | + /** |
|
18 | + * @return IMediaWikiClient |
|
19 | + */ |
|
20 | + protected function getMediaWikiClient() |
|
21 | + { |
|
22 | + $oauth = new OAuthUserHelper($this->getTriggerUser(), $this->getDatabase(), $this->getOauthProtocolHelper(), |
|
23 | + $this->getSiteConfiguration()); |
|
24 | 24 | |
25 | - return $oauth; |
|
26 | - } |
|
25 | + return $oauth; |
|
26 | + } |
|
27 | 27 | } |
28 | 28 | \ No newline at end of file |
@@ -15,22 +15,22 @@ |
||
15 | 15 | |
16 | 16 | class PageDropRequest extends PageCloseRequest |
17 | 17 | { |
18 | - protected function getTemplate(PdoDatabase $database) |
|
19 | - { |
|
20 | - return EmailTemplate::getDroppedTemplate(); |
|
21 | - } |
|
18 | + protected function getTemplate(PdoDatabase $database) |
|
19 | + { |
|
20 | + return EmailTemplate::getDroppedTemplate(); |
|
21 | + } |
|
22 | 22 | |
23 | - protected function confirmEmailAlreadySent(Request $request, EmailTemplate $template) |
|
24 | - { |
|
25 | - return false; |
|
26 | - } |
|
23 | + protected function confirmEmailAlreadySent(Request $request, EmailTemplate $template) |
|
24 | + { |
|
25 | + return false; |
|
26 | + } |
|
27 | 27 | |
28 | - protected function confirmAccountCreated(Request $request, EmailTemplate $template) |
|
29 | - { |
|
30 | - return false; |
|
31 | - } |
|
28 | + protected function confirmAccountCreated(Request $request, EmailTemplate $template) |
|
29 | + { |
|
30 | + return false; |
|
31 | + } |
|
32 | 32 | |
33 | - protected function sendMail(Request $request, $mailText, User $currentUser, $ccMailingList) |
|
34 | - { |
|
35 | - } |
|
33 | + protected function sendMail(Request $request, $mailText, User $currentUser, $ccMailingList) |
|
34 | + { |
|
35 | + } |
|
36 | 36 | } |
37 | 37 | \ No newline at end of file |
@@ -12,21 +12,21 @@ |
||
12 | 12 | |
13 | 13 | class Page404 extends InternalPageBase |
14 | 14 | { |
15 | - /** |
|
16 | - * Main function for this page, when no actions are called. |
|
17 | - */ |
|
18 | - protected function main() |
|
19 | - { |
|
20 | - if (!headers_sent()) { |
|
21 | - header("HTTP/1.1 404 Not Found"); |
|
22 | - } |
|
15 | + /** |
|
16 | + * Main function for this page, when no actions are called. |
|
17 | + */ |
|
18 | + protected function main() |
|
19 | + { |
|
20 | + if (!headers_sent()) { |
|
21 | + header("HTTP/1.1 404 Not Found"); |
|
22 | + } |
|
23 | 23 | |
24 | - $this->skipAlerts(); |
|
25 | - $this->setTemplate("404.tpl"); |
|
26 | - } |
|
24 | + $this->skipAlerts(); |
|
25 | + $this->setTemplate("404.tpl"); |
|
26 | + } |
|
27 | 27 | |
28 | - protected function isProtectedPage() |
|
29 | - { |
|
30 | - return false; |
|
31 | - } |
|
28 | + protected function isProtectedPage() |
|
29 | + { |
|
30 | + return false; |
|
31 | + } |
|
32 | 32 | } |