jenkins-bot has submitted this change and it was merged.

Change subject: Allow unarchiving of campaigns
......................................................................


Allow unarchiving of campaigns

Change-Id: I3f00228245d6f744a9951f6228f8775a936fd401
---
M special/SpecialCentralNotice.php
1 file changed, 23 insertions(+), 5 deletions(-)

Approvals:
  Awight: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/special/SpecialCentralNotice.php b/special/SpecialCentralNotice.php
index a1b52ea..3b8a2f7 100644
--- a/special/SpecialCentralNotice.php
+++ b/special/SpecialCentralNotice.php
@@ -83,13 +83,31 @@
                                                $allInitialCampaignSettings[ 
$campaignName ] = $settings;
                                        }
 
-                                       // Handle archiving campaigns
-                                       $toArchive = $request->getArray( 
'archiveCampaigns' );
-                                       if ( $toArchive ) {
-                                               // Archive campaigns in list
-                                               foreach ( $toArchive as $notice 
) {
+                                       // FIXME The following three blocks of 
code are similar.
+                                       // They might be refactored as part of 
a bigger refactoring
+                                       // of code for changing campaign 
settings via the list of
+                                       // campaigns. If not, refactor this 
following the current
+                                       // logic.
+
+                                       // Handle archiving/unarchiving 
campaigns
+                                       $archived = $request->getArray( 
'archiveCampaigns' );
+                                       if ( $archived ) {
+                                               // Build list of campaigns to 
archive
+                                               $notArchived = array_diff( 
Campaign::getAllCampaignNames(), $archived );
+
+                                               // Set archived/not archived 
flag accordingly
+                                               foreach ( $archived as $notice 
) {
                                                        
Campaign::setBooleanCampaignSetting( $notice, 'archived', 1 );
                                                }
+                                               foreach ( $notArchived as 
$notice ) {
+                                                       
Campaign::setBooleanCampaignSetting( $notice, 'archived', 0 );
+                                               }
+                                               // Handle updates if no post 
content came through (all checkboxes unchecked)
+                                       } else {
+                                               $allNotices = 
Campaign::getAllCampaignNames();
+                                               foreach ( $allNotices as 
$notice ) {
+                                                       
Campaign::setBooleanCampaignSetting( $notice, 'archived', 0 );
+                                               }
                                        }
 
                                        // Handle locking/unlocking campaigns

-- 
To view, visit https://gerrit.wikimedia.org/r/158652
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I3f00228245d6f744a9951f6228f8775a936fd401
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/CentralNotice
Gerrit-Branch: master
Gerrit-Owner: AndyRussG <[email protected]>
Gerrit-Reviewer: Awight <[email protected]>
Gerrit-Reviewer: Mwalker <[email protected]>
Gerrit-Reviewer: Ssmith <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to