Ejegg has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/316493

Change subject: Horrible terrible drupal form workaround
......................................................................

Horrible terrible drupal form workaround

Flailing around till somehow bulk operations work whether or not
you've submitted the form previously.

Bug: T142058
Change-Id: I04ab90102572c3bb55fc2f53652c6619b8093c22
---
M sites/all/modules/wmf_common/wmf_common.module
1 file changed, 28 insertions(+), 7 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/wikimedia/fundraising/crm 
refs/changes/93/316493/1

diff --git a/sites/all/modules/wmf_common/wmf_common.module 
b/sites/all/modules/wmf_common/wmf_common.module
index 19b7ed6..5c64489 100644
--- a/sites/all/modules/wmf_common/wmf_common.module
+++ b/sites/all/modules/wmf_common/wmf_common.module
@@ -339,13 +339,20 @@
 }
 
 function wmf_common_damaged_search_form( $form, &$form_state ) {
-       if (
-               isset( $form_state['confirm_delete'] ) &&
-               isset( $form_state['values']['table'] )
-       ) {
-               return wmf_common_damaged_confirm_delete(
-                       $form, $form_state['values']['table']
-               );
+       if ( isset( $form_state['confirm_delete'] ) ) {
+               // WTF. If you try to do a bulk operation after loading the form
+               // once, the selected IDs go in $form_state['input']['table']. 
If
+               // you do the bulk operation after submitting a search, they go 
in
+               // $form_state['values']['table']
+               if ( isset( $form_state['values']['table'] ) ) {
+                       return wmf_common_damaged_confirm_delete(
+                               $form, $form_state['values']['table']
+                       );
+               } else if ( isset( $form_state['input']['table'] ) ) {
+                       return wmf_common_damaged_confirm_delete(
+                               $form, $form_state['input']['table']
+                       );
+               }
        }
 
        $form['gateway'] = array(
@@ -372,6 +379,20 @@
                empty( $form_state['input']['op'] ) // Run query on first load
        ) {
                return wmf_common_damaged_perform_query( $form, $form_state );
+       } else {
+               // Terrible hack. If these buttons are not added here, drupal
+               // assumes that the triggering button is always search.
+               $form['resend'] = array(
+                       '#type' => 'submit',
+                       '#value' => t( 'Resend' ),
+                       '#disabled' => 'disabled',
+                       '#hidden' => 'true',
+               );
+               $form['delete'] = array(
+                       '#type' => 'submit',
+                       '#value' => t( 'Delete' ),
+                       '#hidden' => 'true',
+               );
        }
 
        return $form;

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I04ab90102572c3bb55fc2f53652c6619b8093c22
Gerrit-PatchSet: 1
Gerrit-Project: wikimedia/fundraising/crm
Gerrit-Branch: master
Gerrit-Owner: Ejegg <eeggles...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to