| @@ 135-150 (lines=16) @@ | ||
| 132 | /** |
|
| 133 | * @deprecated since 1.24 |
|
| 134 | */ |
|
| 135 | public static function getEditToken( $pageid, $title ) { |
|
| 136 | // We could check for $title->userCan('edit') here, |
|
| 137 | // but that's too expensive for this purpose |
|
| 138 | // and would break caching |
|
| 139 | global $wgUser; |
|
| 140 | if ( !$wgUser->isAllowed( 'edit' ) ) { |
|
| 141 | return false; |
|
| 142 | } |
|
| 143 | ||
| 144 | // The token is always the same, let's exploit that |
|
| 145 | if ( !isset( ApiQueryInfo::$cachedTokens['edit'] ) ) { |
|
| 146 | ApiQueryInfo::$cachedTokens['edit'] = $wgUser->getEditToken(); |
|
| 147 | } |
|
| 148 | ||
| 149 | return ApiQueryInfo::$cachedTokens['edit']; |
|
| 150 | } |
|
| 151 | ||
| 152 | /** |
|
| 153 | * @deprecated since 1.24 |
|
| @@ 155-167 (lines=13) @@ | ||
| 152 | /** |
|
| 153 | * @deprecated since 1.24 |
|
| 154 | */ |
|
| 155 | public static function getDeleteToken( $pageid, $title ) { |
|
| 156 | global $wgUser; |
|
| 157 | if ( !$wgUser->isAllowed( 'delete' ) ) { |
|
| 158 | return false; |
|
| 159 | } |
|
| 160 | ||
| 161 | // The token is always the same, let's exploit that |
|
| 162 | if ( !isset( ApiQueryInfo::$cachedTokens['delete'] ) ) { |
|
| 163 | ApiQueryInfo::$cachedTokens['delete'] = $wgUser->getEditToken(); |
|
| 164 | } |
|
| 165 | ||
| 166 | return ApiQueryInfo::$cachedTokens['delete']; |
|
| 167 | } |
|
| 168 | ||
| 169 | /** |
|
| 170 | * @deprecated since 1.24 |
|
| @@ 172-184 (lines=13) @@ | ||
| 169 | /** |
|
| 170 | * @deprecated since 1.24 |
|
| 171 | */ |
|
| 172 | public static function getProtectToken( $pageid, $title ) { |
|
| 173 | global $wgUser; |
|
| 174 | if ( !$wgUser->isAllowed( 'protect' ) ) { |
|
| 175 | return false; |
|
| 176 | } |
|
| 177 | ||
| 178 | // The token is always the same, let's exploit that |
|
| 179 | if ( !isset( ApiQueryInfo::$cachedTokens['protect'] ) ) { |
|
| 180 | ApiQueryInfo::$cachedTokens['protect'] = $wgUser->getEditToken(); |
|
| 181 | } |
|
| 182 | ||
| 183 | return ApiQueryInfo::$cachedTokens['protect']; |
|
| 184 | } |
|
| 185 | ||
| 186 | /** |
|
| 187 | * @deprecated since 1.24 |
|
| @@ 189-201 (lines=13) @@ | ||
| 186 | /** |
|
| 187 | * @deprecated since 1.24 |
|
| 188 | */ |
|
| 189 | public static function getMoveToken( $pageid, $title ) { |
|
| 190 | global $wgUser; |
|
| 191 | if ( !$wgUser->isAllowed( 'move' ) ) { |
|
| 192 | return false; |
|
| 193 | } |
|
| 194 | ||
| 195 | // The token is always the same, let's exploit that |
|
| 196 | if ( !isset( ApiQueryInfo::$cachedTokens['move'] ) ) { |
|
| 197 | ApiQueryInfo::$cachedTokens['move'] = $wgUser->getEditToken(); |
|
| 198 | } |
|
| 199 | ||
| 200 | return ApiQueryInfo::$cachedTokens['move']; |
|
| 201 | } |
|
| 202 | ||
| 203 | /** |
|
| 204 | * @deprecated since 1.24 |
|
| @@ 206-218 (lines=13) @@ | ||
| 203 | /** |
|
| 204 | * @deprecated since 1.24 |
|
| 205 | */ |
|
| 206 | public static function getBlockToken( $pageid, $title ) { |
|
| 207 | global $wgUser; |
|
| 208 | if ( !$wgUser->isAllowed( 'block' ) ) { |
|
| 209 | return false; |
|
| 210 | } |
|
| 211 | ||
| 212 | // The token is always the same, let's exploit that |
|
| 213 | if ( !isset( ApiQueryInfo::$cachedTokens['block'] ) ) { |
|
| 214 | ApiQueryInfo::$cachedTokens['block'] = $wgUser->getEditToken(); |
|
| 215 | } |
|
| 216 | ||
| 217 | return ApiQueryInfo::$cachedTokens['block']; |
|
| 218 | } |
|
| 219 | ||
| 220 | /** |
|
| 221 | * @deprecated since 1.24 |
|
| @@ 231-243 (lines=13) @@ | ||
| 228 | /** |
|
| 229 | * @deprecated since 1.24 |
|
| 230 | */ |
|
| 231 | public static function getEmailToken( $pageid, $title ) { |
|
| 232 | global $wgUser; |
|
| 233 | if ( !$wgUser->canSendEmail() || $wgUser->isBlockedFromEmailuser() ) { |
|
| 234 | return false; |
|
| 235 | } |
|
| 236 | ||
| 237 | // The token is always the same, let's exploit that |
|
| 238 | if ( !isset( ApiQueryInfo::$cachedTokens['email'] ) ) { |
|
| 239 | ApiQueryInfo::$cachedTokens['email'] = $wgUser->getEditToken(); |
|
| 240 | } |
|
| 241 | ||
| 242 | return ApiQueryInfo::$cachedTokens['email']; |
|
| 243 | } |
|
| 244 | ||
| 245 | /** |
|
| 246 | * @deprecated since 1.24 |
|
| @@ 248-260 (lines=13) @@ | ||
| 245 | /** |
|
| 246 | * @deprecated since 1.24 |
|
| 247 | */ |
|
| 248 | public static function getImportToken( $pageid, $title ) { |
|
| 249 | global $wgUser; |
|
| 250 | if ( !$wgUser->isAllowedAny( 'import', 'importupload' ) ) { |
|
| 251 | return false; |
|
| 252 | } |
|
| 253 | ||
| 254 | // The token is always the same, let's exploit that |
|
| 255 | if ( !isset( ApiQueryInfo::$cachedTokens['import'] ) ) { |
|
| 256 | ApiQueryInfo::$cachedTokens['import'] = $wgUser->getEditToken(); |
|
| 257 | } |
|
| 258 | ||
| 259 | return ApiQueryInfo::$cachedTokens['import']; |
|
| 260 | } |
|
| 261 | ||
| 262 | /** |
|
| 263 | * @deprecated since 1.24 |
|
| @@ 265-277 (lines=13) @@ | ||
| 262 | /** |
|
| 263 | * @deprecated since 1.24 |
|
| 264 | */ |
|
| 265 | public static function getWatchToken( $pageid, $title ) { |
|
| 266 | global $wgUser; |
|
| 267 | if ( !$wgUser->isLoggedIn() ) { |
|
| 268 | return false; |
|
| 269 | } |
|
| 270 | ||
| 271 | // The token is always the same, let's exploit that |
|
| 272 | if ( !isset( ApiQueryInfo::$cachedTokens['watch'] ) ) { |
|
| 273 | ApiQueryInfo::$cachedTokens['watch'] = $wgUser->getEditToken( 'watch' ); |
|
| 274 | } |
|
| 275 | ||
| 276 | return ApiQueryInfo::$cachedTokens['watch']; |
|
| 277 | } |
|
| 278 | ||
| 279 | /** |
|
| 280 | * @deprecated since 1.24 |
|
| @@ 282-294 (lines=13) @@ | ||
| 279 | /** |
|
| 280 | * @deprecated since 1.24 |
|
| 281 | */ |
|
| 282 | public static function getOptionsToken( $pageid, $title ) { |
|
| 283 | global $wgUser; |
|
| 284 | if ( !$wgUser->isLoggedIn() ) { |
|
| 285 | return false; |
|
| 286 | } |
|
| 287 | ||
| 288 | // The token is always the same, let's exploit that |
|
| 289 | if ( !isset( ApiQueryInfo::$cachedTokens['options'] ) ) { |
|
| 290 | ApiQueryInfo::$cachedTokens['options'] = $wgUser->getEditToken(); |
|
| 291 | } |
|
| 292 | ||
| 293 | return ApiQueryInfo::$cachedTokens['options']; |
|
| 294 | } |
|
| 295 | ||
| 296 | public function execute() { |
|
| 297 | $this->params = $this->extractRequestParams(); |
|