r86576 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r86575‎ | r86576 | r86577 >
Date:23:52, 20 April 2011
Author:awjrichards
Status:deferred
Tags:
Comment:
Added drush script to allocate unallocated contributions
Modified paths:
  • /civicrm/trunk/sites/all/modules/contribution_audit/allocate_unallocated_contribs.drush.inc (added) (history)

Diff [purge]

Index: civicrm/trunk/sites/all/modules/contribution_audit/allocate_unallocated_contribs.drush.inc
@@ -0,0 +1,50 @@
 2+<?php
 3+/**
 4+ * @file allocate_unallocated_contribs.drush.inc
 5+ * Find missing and otherwise unallocated transactions and aggregate
 6+ * contribs by country
 7+ * @author Arthur Richards <arichards@wikimedia.org>
 8+ * @TODO print some useful info to STDOUT
 9+ */
 10+
 11+/**
 12+ * Implementation of hook_drush_command()
 13+ */
 14+function allocate_unallocated_contribs_drush_command() {
 15+ $items = array();
 16+
 17+ $items['allocate-unallocated-contribs'] = array(
 18+ 'description' =>
 19+ 'Finds missing and otherwise unallocated transactions and aggregates the contrib amounts by country.',
 20+ 'options' => array(
 21+ 'start' => 'The start date from which you wish to find unallocated contribs. Can be anything interpretable by strtotime().',
 22+ 'end' => 'The end date for which you wish to find unallocated contribs. Can be anything interpretable by strtotime().'
 23+ ),
 24+ 'examples' => array( 'drush allocate-unallocated-contribs --start="3/1/2011" --end="3/31/2011"' ),
 25+ 'aliases' => array( 'auc' ),
 26+ );
 27+
 28+ return $items;
 29+}
 30+
 31+/**
 32+ * Implementation of hook_drush_help()
 33+ */
 34+function allocate_unallocated_contribs_drush_help( $section ) {
 35+ switch ( $section ) {
 36+ case 'drush:allocate-unallocated-contribs':
 37+ return dt( "Finds missing and otherwise unallocated transactions and aggregates the contrib amounts by country." );
 38+ }
 39+}
 40+
 41+/**
 42+ * Fires the 'contribution_audit_allocate_unallocated_contribs' method in the contribution_audit.
 43+ */
 44+function drush_allocate_unallocated_contribs() {
 45+ $start_date = drush_get_option( $start );
 46+ $end_date = drush_get_option( $end );
 47+ $allocated = module_invoke( 'contribution_audit', 'contribution_audit_allocate_unallocated_contribs', $start_date, $end_date );
 48+ foreach( $allocated as $key => $value ) {
 49+ print "'$key','$value'\n";
 50+ }
 51+}

Status & tagging log