r21943 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r21942‎ | r21943 | r21944 >
Date:20:51, 6 May 2007
Author:aaron
Status:old
Tags:
Comment:
*Let users with 'reupload-own' upload over image where they are the last uploader, right is not assigned by default (bug 5057)
Modified paths:
  • /trunk/phase3/includes/SpecialUpload.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/SpecialUpload.php
@@ -1285,7 +1285,7 @@
12861286 if( $img->exists() ) {
12871287 global $wgUser, $wgOut;
12881288 if( $img->isLocal() ) {
1289 - if( !$wgUser->isAllowed( 'reupload' ) ) {
 1289+ if( !$this->userCanReUpload( $wgUser, $img->name ) ) {
12901290 $error = 'fileexists-forbidden';
12911291 }
12921292 } else {
@@ -1304,6 +1304,31 @@
13051305 // Rockin', go ahead and upload
13061306 return true;
13071307 }
 1308+
 1309+ /**
 1310+ * Check if a user is the last uploader
 1311+ *
 1312+ * @param User $user
 1313+ * @param string $img, image name
 1314+ * @return bool
 1315+ * @access private
 1316+ */
 1317+ function userCanReUpload( $user, $img ) {
 1318+ if( $user->isAllowed('reupload' ) )
 1319+ return true; // non-conditional
 1320+ if( !$user->isAllowed('reupload-own') )
 1321+ return false;
 1322+
 1323+ $dbr = wfGetDB( DB_SLAVE );
 1324+ $row = $dbr->selectRow(
 1325+ /* FROM */ 'image',
 1326+ /* SELECT */ 'img_user',
 1327+ /* WHERE */ array( 'img_name' => $img )
 1328+ );
 1329+ if ( !$row )
 1330+ return false;
13081331
 1332+ return $user->getID() == $row->img_user;
 1333+ }
13091334 }
13101335 ?>

Follow-up revisions

RevisionCommit summaryAuthorDate
r22312*A bit of cleanup for bug 5057, make upload link consistent with reupload-own...aaron02:22, 22 May 2007