MarkTraceur has uploaded a new change for review. https://gerrit.wikimedia.org/r/155351
Change subject: Add beforeActive and afterActive to campaigns
......................................................................
Add beforeActive and afterActive to campaigns
Easy enough, just a copy/paste of the logic from whileActive mostly.
Bug: 64685
Change-Id: I28618b2a5edd6d010f3439a3f2379ca035ef8811
---
M includes/CampaignSchema.php
M includes/UploadWizardCampaign.php
2 files changed, 91 insertions(+), 2 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/UploadWizard
refs/changes/51/155351/1
diff --git a/includes/CampaignSchema.php b/includes/CampaignSchema.php
index 4c41396..22411fe 100644
--- a/includes/CampaignSchema.php
+++ b/includes/CampaignSchema.php
@@ -233,5 +233,71 @@
),
),
),
+ "beforeActive" => array(
+ "type" => "object",
+ "properties" => array(
+ "display" => array(
+ "type" => "object",
+ "properties" =>array(
+ "headerLabel" => array(
+ "type" => "string"
+ ),
+ "thanksLabel" => array(
+ "type" => "string"
+ ),
+ ),
+ ),
+
+ "autoAdd" => array(
+ "type" => "object",
+ "properties" => array(
+ "categories" => array(
+ "type" => "array",
+ "items" => array(
+ array(
+ "type"
=> "string"
+ ),
+ ),
+ ),
+ "wikitext" => array(
+ "type" => "string"
+ ),
+ ),
+ ),
+ ),
+ ),
+ "afterActive" => array(
+ "type" => "object",
+ "properties" => array(
+ "display" => array(
+ "type" => "object",
+ "properties" =>array(
+ "headerLabel" => array(
+ "type" => "string"
+ ),
+ "thanksLabel" => array(
+ "type" => "string"
+ ),
+ ),
+ ),
+
+ "autoAdd" => array(
+ "type" => "object",
+ "properties" => array(
+ "categories" => array(
+ "type" => "array",
+ "items" => array(
+ array(
+ "type"
=> "string"
+ ),
+ ),
+ ),
+ "wikitext" => array(
+ "type" => "string"
+ ),
+ ),
+ ),
+ ),
+ ),
)
);
diff --git a/includes/UploadWizardCampaign.php
b/includes/UploadWizardCampaign.php
index 78c5738..e5f4da3 100644
--- a/includes/UploadWizardCampaign.php
+++ b/includes/UploadWizardCampaign.php
@@ -312,7 +312,19 @@
}
break;
case "whileActive":
- $activeModifiers = $value;
+ if ( $this->isActive( $parsedConfig ) )
{
+ $activeModifiers = $value;
+ }
+ break;
+ case "afterActive":
+ if ( $this->wasActive( $parsedConfig )
&& !$this->isActive( $parsedConfig ) ) {
+ $activeModifiers = $value;
+ }
+ break;
+ case "beforeActive":
+ if ( !$this->wasActive( $parsedConfig )
&& !$this->isActive( $parsedConfig ) ) {
+ $activeModifiers = $value;
+ }
break;
default:
$parsedConfig[$key] = $value;
@@ -320,7 +332,7 @@
}
}
- if ( isset( $activeModifiers ) && $this->isActive(
$parsedConfig ) ) {
+ if ( isset( $activeModifiers ) ) {
foreach ( $activeModifiers as $cnf => $modifier
) {
switch ( $cnf ) {
case "display":
@@ -416,4 +428,15 @@
return ($start === null || $start <= $today ) && ($end === null
|| $end > $today );
}
+
+ /**
+ * Checks the current date against the configured start and end dates
to determine
+ * whether the campaign is currently active.
+ */
+ private function wasActive( $config ) {
+ $today = strtotime( date( "Y-m-d" ) );
+ $start = array_key_exists( 'start', $config ) ? strtotime(
$config['start'] ) : null;
+
+ return $start === null || $start <= $today;
+ }
}
--
To view, visit https://gerrit.wikimedia.org/r/155351
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I28618b2a5edd6d010f3439a3f2379ca035ef8811
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/UploadWizard
Gerrit-Branch: master
Gerrit-Owner: MarkTraceur <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
