r90516 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r90515‎ | r90516 | r90517 >
Date:10:13, 21 June 2011
Author:nad
Status:deferred
Tags:
Comment:
checkbox values were always being set to true when forms saved from edit view
Modified paths:
  • /trunk/extensions/RecordAdmin/RecordAdmin.php (modified) (history)
  • /trunk/extensions/RecordAdmin/RecordAdmin_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/RecordAdmin/RecordAdmin.php
@@ -10,7 +10,7 @@
1111 * @author Siebrand Mazeland
1212 * @licence GNU General Public Licence 2.0 or later
1313 */
14 -define( 'RECORDADMIN_VERSION', '1.2.3, 2011-06-08' );
 14+define( 'RECORDADMIN_VERSION', '1.2.4, 2011-06-21' );
1515
1616 $dir = dirname( __FILE__ ) . '/';
1717 $wgExtensionMessagesFiles['RecordAdmin'] = $dir . 'RecordAdmin.i18n.php';
Index: trunk/extensions/RecordAdmin/RecordAdmin_body.php
@@ -118,14 +118,17 @@
119119 for( j = 0; j < tags.length; j++ ) {
120120 var inputs = form.getElementsByTagName( tags[j] );
121121 for( k = 0; k < inputs.length; k++ ) {
122 - var multi = jQuery( inputs[k] ).val();
123 - if( typeof( multi ) == 'object' ) multi = multi.join('\\n');
124 - var key = type + ':' + inputs[k].getAttribute('name');
125 - var hidden = jQuery( document.createElement( 'input' ) );
126 - hidden.attr( 'name', key );
127 - hidden.attr( 'type', 'hidden' );
128 - hidden.val( multi );
129 - jQuery( '#editform' ).append( hidden );
 122+ var input = jQuery( inputs[k] );
 123+ if( input.attr('type') != 'checkbox' || input.attr('checked') ) {
 124+ var multi = input.val();
 125+ if( typeof( multi ) == 'object' ) multi = multi.join('\\n');
 126+ var key = type + ':' + inputs[k].getAttribute('name');
 127+ var hidden = jQuery( document.createElement( 'input' ) );
 128+ hidden.attr( 'name', key );
 129+ hidden.attr( 'type', 'hidden' );
 130+ hidden.val( multi );
 131+ jQuery( '#editform' ).append( hidden );
 132+ }
130133 }
131134 }
132135 }
@@ -149,8 +152,6 @@
150153
151154 # Organise the posted record data
152155 $data = array();
153 -#print_r($_REQUEST);
154 -#die;
155156 foreach( $_REQUEST as $key => $value ) {
156157 if( preg_match( "|(.+):ra_(.+)|", $key, $m ) ) {
157158 if( is_array( $value ) ) $value = join( "\n", $value );

Status & tagging log