Nischayn22 has uploaded a new change for review. https://gerrit.wikimedia.org/r/54702
Change subject: (bug 36914) Make Special:UploadCampaigns visible to all. ...................................................................... (bug 36914) Make Special:UploadCampaigns visible to all. Show Special:UploadCampaigns to people without editing rights, just don't show hide the edit and delete buttons from them. * I know this is a dirty hack; but I couldn't think anything better. Change-Id: Ifa970268a5a4e18200b4dc1fddfa45d27c74eac5 --- M includes/specials/SpecialUploadCampaigns.php 1 file changed, 63 insertions(+), 51 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/UploadWizard refs/changes/02/54702/1 diff --git a/includes/specials/SpecialUploadCampaigns.php b/includes/specials/SpecialUploadCampaigns.php index 3cf24b9..197862c 100644 --- a/includes/specials/SpecialUploadCampaigns.php +++ b/includes/specials/SpecialUploadCampaigns.php @@ -46,19 +46,14 @@ $req = $this->getRequest(); $user = $this->getUser(); - // If the user is authorized, display the page, if not, show an error. - if ( $this->userCanExecute( $user ) ) { - if ( $req->wasPosted() - && $user->matchEditToken( $req->getVal( 'wpEditToken' ) ) - && $req->getCheck( 'newcampaign' ) ) { - $this->getOutput()->redirect( SpecialPage::getTitleFor( 'UploadCampaign', $req->getVal( 'newcampaign' ) )->getLocalURL() ); - } - else { - $this->displayUploadCamaigns(); - } + if ( $req->wasPosted() + && $user->matchEditToken( $req->getVal( 'wpEditToken' ) ) + && $req->getCheck( 'newcampaign' ) ) { + $this->getOutput()->redirect( SpecialPage::getTitleFor( 'UploadCampaign', $req->getVal( 'newcampaign' ) )->getLocalURL() ); } else { - $this->displayRestrictionError(); + $this->displayUploadCamaigns(); } + } /** @@ -67,7 +62,9 @@ * @since 1.2 */ protected function displayUploadCamaigns() { - $this->displayAddNewControl(); + if ( $this->userCanExecute( $this->getUser() ) ) { + $this->displayAddNewControl(); + } // If the refresh flag is set, fetch from the master. // This is to ensure changes show up right away for the person that makes then @@ -144,20 +141,36 @@ array( 'class' => 'wikitable sortable', 'style' => 'width:400px' ) ) ); - $out->addHTML( - '<thead><tr>' . - Html::element( 'th', array(), $this->msg( 'mwe-upwiz-campaigns-name' )->text() ) . - Html::element( 'th', array(), $this->msg( 'mwe-upwiz-campaigns-status' )->text() ) . - Html::element( 'th', array( 'class' => 'unsortable' ), $this->msg( 'mwe-upwiz-campaigns-edit' )->text() ) . - Html::element( 'th', array( 'class' => 'unsortable' ), $this->msg( 'mwe-upwiz-campaigns-delete' )->text() ) . - '</tr></thead>' - ); + $out->addHTML( $this->getTableHeadersHtml() ); $out->addHTML( '<tbody>' ); foreach ( $campaigns as $campaign ) { - $out->addHTML( - '<tr>' . + $out->addHTML( $this->getTableContentsHtml( $campaign ) ); + } + + $out->addHTML( '</tbody>' ); + $out->addHTML( '</table>' ); + + $out->addModules( 'ext.uploadWizard.campaigns' ); + } + + private function getTableHeadersHtml() { + $html = '<thead><tr>' . + Html::element( 'th', array(), $this->msg( 'mwe-upwiz-campaigns-name' )->text() ) . + Html::element( 'th', array(), $this->msg( 'mwe-upwiz-campaigns-status' )->text() ); + + if ( $this->userCanExecute( $this->getUser() ) ) { + $html = $html . Html::element( 'th', array( 'class' => 'unsortable' ), $this->msg( 'mwe-upwiz-campaigns-edit' )->text() ) . + Html::element( 'th', array( 'class' => 'unsortable' ), $this->msg( 'mwe-upwiz-campaigns-delete' )->text() ); + } + $html = $html . '</tr></thead>'; + + return $html; + } + + private function getTableContentsHtml( $campaign ) { + $html = '<tr>' . '<td>' . Html::element( 'a', @@ -167,36 +180,35 @@ $campaign->campaign_name ) . '</td>' . - Html::element( 'td', array(), $this->msg( 'mwe-upwiz-campaigns-' . ( $campaign->campaign_enabled ? 'enabled' : 'disabled' ) )->text() ) . - '<td>' . - Html::element( - 'a', - array( - 'href' => SpecialPage::getTitleFor( 'UploadCampaign', $campaign->campaign_name )->getLocalURL() - ), - $this->msg( 'mwe-upwiz-campaigns-edit' )->text() - ) . - '</td>' . - '<td>' . - Html::element( - 'a', - array( - 'href' => '#', - 'class' => 'campaign-delete', - 'data-campaign-id' => $campaign->campaign_id, - 'data-campaign-token' => $this->getUser()->getEditToken( 'deletecampaign' . $campaign->campaign_id ) - ), - $this->msg( 'mwe-upwiz-campaigns-delete' )->text() - ) . - '</td>' . - '</tr>' - ); + Html::element( 'td', array(), $this->msg( 'mwe-upwiz-campaigns-' . ( $campaign->campaign_enabled ? 'enabled' : 'disabled' ) )->text() ); + + if ( $this->userCanExecute( $this->getUser() ) ) { + $html = $html . '<td>' . + Html::element( + 'a', + array( + 'href' => SpecialPage::getTitleFor( 'UploadCampaign', $campaign->campaign_name )->getLocalURL() + ), + $this->msg( 'mwe-upwiz-campaigns-edit' )->text() + ) . + '</td>' . + '<td>' . + Html::element( + 'a', + array( + 'href' => '#', + 'disabled' => 'disabled', + 'class' => 'campaign-delete', + 'data-campaign-id' => $campaign->campaign_id, + 'data-campaign-token' => $this->getUser()->getEditToken( 'deletecampaign' . $campaign->campaign_id ) + ), + $this->msg( 'mwe-upwiz-campaigns-delete' )->text() + ) . + '</td>'; + } - $out->addHTML( '</tbody>' ); - $out->addHTML( '</table>' ); - - $out->addModules( 'ext.uploadWizard.campaigns' ); + $html = $html . '</tr>'; + return $html; } - } -- To view, visit https://gerrit.wikimedia.org/r/54702 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ifa970268a5a4e18200b4dc1fddfa45d27c74eac5 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/UploadWizard Gerrit-Branch: master Gerrit-Owner: Nischayn22 <nischay...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits