Index: trunk/extensions/CentralNotice/SpecialCentralNotice.php |
— | — | @@ -573,65 +573,61 @@ |
574 | 574 | |
575 | 575 | function listNoticeDetail( $notice ) { |
576 | 576 | global $wgOut, $wgRequest, $wgUser; |
577 | | - |
578 | | - if ( $wgRequest->wasPosted() ) { |
| 577 | + |
| 578 | + // Make sure notice exists |
| 579 | + if ( !$this->noticeExists( $notice ) ) { |
| 580 | + $wgOut->wrapWikiMsg( "<div class='cn-error'>\n$1\n</div>", 'centralnotice-notice-doesnt-exist' ); |
| 581 | + } else { |
| 582 | + |
| 583 | + if ( $wgRequest->wasPosted() ) { |
| 584 | + |
| 585 | + // Check authentication token |
| 586 | + if ( $wgUser->matchEditToken( $wgRequest->getVal( 'authtoken' ) ) ) { |
| 587 | + |
| 588 | + // Handle adding of banners to the campaign |
| 589 | + $templatesToAdd = $wgRequest->getArray( 'addTemplates' ); |
| 590 | + if ( $templatesToAdd ) { |
| 591 | + $weight = $wgRequest->getArray( 'weight' ); |
| 592 | + foreach ( $templatesToAdd as $templateName ) { |
| 593 | + $templateId = $this->getTemplateId( $templateName ); |
| 594 | + $this->addTemplateTo( $notice, $templateName, $weight[$templateId] ); |
| 595 | + } |
| 596 | + } |
579 | 597 | |
580 | | - // Check authentication token |
581 | | - if ( $wgUser->matchEditToken( $wgRequest->getVal( 'authtoken' ) ) ) { |
582 | | - |
583 | | - // Handle adding of banners to the campaign |
584 | | - $templatesToAdd = $wgRequest->getArray( 'addTemplates' ); |
585 | | - if ( $templatesToAdd ) { |
586 | | - $weight = $wgRequest->getArray( 'weight' ); |
587 | | - foreach ( $templatesToAdd as $templateName ) { |
588 | | - $templateId = $this->getTemplateId( $templateName ); |
589 | | - $this->addTemplateTo( $notice, $templateName, $weight[$templateId] ); |
| 598 | + // Handle removing of banners from the campaign |
| 599 | + $templateToRemove = $wgRequest->getArray( 'removeTemplates' ); |
| 600 | + if ( $templateToRemove ) { |
| 601 | + foreach ( $templateToRemove as $template ) { |
| 602 | + $this->removeTemplateFor( $notice, $template ); |
| 603 | + } |
590 | 604 | } |
591 | | - } |
| 605 | + |
| 606 | + // Handle weight changes |
| 607 | + $updatedWeights = $wgRequest->getArray( 'weight' ); |
| 608 | + if ( $updatedWeights ) { |
| 609 | + foreach ( $updatedWeights as $templateId => $weight ) { |
| 610 | + $this->updateWeight( $notice, $templateId, $weight ); |
| 611 | + } |
| 612 | + } |
592 | 613 | |
593 | | - // Handle removing of banners from the campaign |
594 | | - $templateToRemove = $wgRequest->getArray( 'removeTemplates' ); |
595 | | - if ( $templateToRemove ) { |
596 | | - foreach ( $templateToRemove as $template ) { |
597 | | - $this->removeTemplateFor( $notice, $template ); |
| 614 | + // Handle new project name |
| 615 | + $projectName = $wgRequest->getVal( 'project_name' ); |
| 616 | + if ( $projectName ) { |
| 617 | + $this->updateProjectName ( $notice, $projectName ); |
598 | 618 | } |
599 | | - } |
600 | | - |
601 | | - // Handle weight changes |
602 | | - $updatedWeights = $wgRequest->getArray( 'weight' ); |
603 | | - if ( $updatedWeights ) { |
604 | | - foreach ( $updatedWeights as $templateId => $weight ) { |
605 | | - $this->updateWeight( $notice, $templateId, $weight ); |
| 619 | + |
| 620 | + // Handle new project languages |
| 621 | + $projectLangs = $wgRequest->getArray( 'project_languages' ); |
| 622 | + if ( $projectLangs ) { |
| 623 | + $this->updateProjectLanguages( $notice, $projectLangs ); |
606 | 624 | } |
| 625 | + |
| 626 | + } else { |
| 627 | + $wgOut->wrapWikiMsg( "<div class='cn-error'>\n$1\n</div>", 'sessionfailure' ); |
607 | 628 | } |
608 | | - |
609 | | - // Handle new project name |
610 | | - $projectName = $wgRequest->getVal( 'project_name' ); |
611 | | - if ( $projectName ) { |
612 | | - $this->updateProjectName ( $notice, $projectName ); |
613 | | - } |
614 | | - |
615 | | - // Handle new project languages |
616 | | - $projectLangs = $wgRequest->getArray( 'project_languages' ); |
617 | | - if ( $projectLangs ) { |
618 | | - $this->updateProjectLanguages( $notice, $projectLangs ); |
619 | | - } |
620 | | - |
621 | | - $wgOut->redirect( $this->getTitle()->getLocalUrl( "method=listNoticeDetail¬ice=$notice" ) ); |
622 | | - return; |
623 | 629 | |
624 | | - } else { |
625 | | - $wgOut->wrapWikiMsg( "<div class='cn-error'>\n$1\n</div>", 'sessionfailure' ); |
626 | 630 | } |
627 | | - |
628 | | - } |
629 | 631 | |
630 | | - $noticeId = $this->getNoticeId( $notice ); |
631 | | - |
632 | | - // Make sure notice exists |
633 | | - if ( !$noticeId ) { |
634 | | - $wgOut->wrapWikiMsg( "<div class='cn-error'>\n$1\n</div>", 'centralnotice-notice-doesnt-exist' ); |
635 | | - } else { |
636 | 632 | $htmlOut = ''; |
637 | 633 | |
638 | 634 | // Begin Campaign detail fieldset |