Index: trunk/phase3/docs/hooks.txt |
— | — | @@ -594,6 +594,9 @@ |
595 | 595 | $action: Action being checked |
596 | 596 | $result: User permissions error to add. If none, return true. |
597 | 597 | |
| 598 | +'getUserPermissionsErrorsExpensive': Absolutely the same, but is called only |
| 599 | + if expensive checks are enabled. |
| 600 | + |
598 | 601 | 'ImageOpenShowImageInlineBefore': Call potential extension just before showing the image on an image page |
599 | 602 | $imagePage: ImagePage object ($this) |
600 | 603 | $output: $wgOut |
Index: trunk/phase3/includes/Title.php |
— | — | @@ -1130,6 +1130,16 @@ |
1131 | 1131 | else if ($result === false ) |
1132 | 1132 | $errors[] = array('badaccess-group0'); # a generic "We don't want them to do that" |
1133 | 1133 | } |
| 1134 | + if ($doExpensiveQueries && !wfRunHooks( 'getUserPermissionsErrorsExpensive', array( &$this, &$user, $action, &$result ) ) ) { |
| 1135 | + if ($result != array() && is_array($result) && !is_array($result[0])) |
| 1136 | + $errors[] = $result; # A single array representing an error |
| 1137 | + else if (is_array($result) && is_array($result[0])) |
| 1138 | + $errors = array_merge( $errors, $result ); # A nested array representing multiple errors |
| 1139 | + else if ($result != '' && $result != null && $result !== true && $result !== false) |
| 1140 | + $errors[] = array($result); # A string representing a message-id |
| 1141 | + else if ($result === false ) |
| 1142 | + $errors[] = array('badaccess-group0'); # a generic "We don't want them to do that" |
| 1143 | + } |
1134 | 1144 | |
1135 | 1145 | if( NS_SPECIAL == $this->mNamespace ) { |
1136 | 1146 | $errors[] = array('ns-specialprotected'); |
— | — | @@ -2279,6 +2289,7 @@ |
2280 | 2290 | * @return mixed true on success, message name on failure |
2281 | 2291 | */ |
2282 | 2292 | public function isValidMoveOperation( &$nt, $auth = true ) { |
| 2293 | + global $wgUser; |
2283 | 2294 | if( !$this or !$nt ) { |
2284 | 2295 | return 'badtitletext'; |
2285 | 2296 | } |
— | — | @@ -2303,7 +2314,8 @@ |
2304 | 2315 | |
2305 | 2316 | if ( $auth && ( |
2306 | 2317 | !$this->userCan( 'edit' ) || !$nt->userCan( 'edit' ) || |
2307 | | - !$this->userCan( 'move' ) || !$nt->userCan( 'move' ) ) ) { |
| 2318 | + !$this->userCan( 'move' ) || !$nt->userCan( 'move' ) || |
| 2319 | + $this->getNamespace() == NS_IMAGE && !$wgUser->isAllowed( 'upload' ) ) ) { |
2308 | 2320 | return 'protectedpage'; |
2309 | 2321 | } |
2310 | 2322 | |
— | — | @@ -2346,6 +2358,17 @@ |
2347 | 2359 | return $err; |
2348 | 2360 | } |
2349 | 2361 | |
| 2362 | + // If it's existent image, move it as image |
| 2363 | + if( $this->getNamespace() == NS_IMAGE && $nt->getNamespace() == NS_IMAGE && wfFindFile( $this ) ) { |
| 2364 | + $oldfile = wfFindFile( $this ); |
| 2365 | + $newfile = wfFindFile( $nt ); |
| 2366 | + var_dump( array( $oldfile, $newfile ) ); |
| 2367 | + if( $newfile ) { |
| 2368 | + return 'articleexists'; |
| 2369 | + } |
| 2370 | + return 'a'; |
| 2371 | + } |
| 2372 | + |
2350 | 2373 | $pageid = $this->getArticleID(); |
2351 | 2374 | if( $nt->exists() ) { |
2352 | 2375 | $this->moveOverExistingRedirect( $nt, $reason, $createRedirect ); |
— | — | @@ -2585,6 +2608,11 @@ |
2586 | 2609 | } |
2587 | 2610 | |
2588 | 2611 | /** |
| 2612 | + * Moves image to new title |
| 2613 | + */ |
| 2614 | + //private function moveImage |
| 2615 | + |
| 2616 | + /** |
2589 | 2617 | * Checks if $this can be moved to a given Title |
2590 | 2618 | * - Selects for update, so don't call it unless you mean business |
2591 | 2619 | * |