r68271 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r68270‎ | r68271 | r68272 >
Date:12:55, 19 June 2010
Author:ashley
Status:ok
Tags:
Comment:
SocialProfile: version 1.5 -- YUI dependency removed, now uses jQuery. also added almost-but-not-quite-working Renameuser integration code (commented out for now)
Modified paths:
  • /trunk/extensions/SocialProfile/SocialProfile.php (modified) (history)
  • /trunk/extensions/SocialProfile/UserBoard/BoardBlast.js (modified) (history)
  • /trunk/extensions/SocialProfile/UserGifts/UserGifts.js (modified) (history)
  • /trunk/extensions/SocialProfile/UserRelationship/UserRelationship.js (modified) (history)
  • /trunk/extensions/SocialProfile/YUI (deleted) (history)

Diff [purge]

Index: trunk/extensions/SocialProfile/UserRelationship/UserRelationship.js
@@ -8,6 +8,8 @@
99 sajax_request_type = 'POST';
1010 sajax_do_call( 'wfRelationshipRequestResponse', [ response, id ], function( request ) {
1111 document.getElementById( 'request_action_' + id ).innerHTML = request.responseText;
12 - YAHOO.widget.Effects.Appear( 'request_action_' + id, { duration:2.0 } );
 12+ jQuery( '#request_action_' + id ).fadeIn( 2000 );
 13+ document.getElementById( 'request_action_' + id ).style.display = 'block';
 14+ document.getElementById( 'request_action_' + id ).style.visibility = 'visible';
1315 } );
1416 }
\ No newline at end of file
Index: trunk/extensions/SocialProfile/SocialProfile.php
@@ -3,13 +3,14 @@
44 * Protect against register_globals vulnerabilities.
55 * This line must be present before any global variable is referenced.
66 */
7 -if ( !defined( 'MEDIAWIKI' ) )
 7+if ( !defined( 'MEDIAWIKI' ) ) {
88 die();
 9+}
910
1011 /**
1112 * This is the *main* (but certainly not the only) loader file for SocialProfile extension.
1213 *
13 - * For more info about SocialProfile, please see the README file that was included with SocialProfile.
 14+ * For more info about SocialProfile, please see http://www.mediawiki.org/wiki/Extension:SocialProfile.
1415 */
1516 $dir = dirname( __FILE__ ) . '/';
1617
@@ -93,7 +94,7 @@
9495 'path' => __FILE__,
9596 'name' => 'SocialProfile',
9697 'author' => array( 'Aaron Wright', 'David Pean', 'Jack Phoenix' ),
97 - 'version' => '1.4',
 98+ 'version' => '1.5',
9899 'url' => 'http://www.mediawiki.org/wiki/Extension:SocialProfile',
99100 'description' => 'A set of Social Tools for MediaWiki',
100101 );
@@ -190,7 +191,6 @@
191192 $wgUserRelationshipScripts = "$wgScriptPath/extensions/SocialProfile/UserRelationship";
192193
193194 // Loader files
194 -require_once( "$IP/extensions/SocialProfile/YUI/YUI.php" ); // YUI stand-alone library
195195 require_once( "{$wgUserProfileDirectory}/UserProfile.php" ); // Profile page configuration loader file
196196 require_once( "$IP/extensions/SocialProfile/UserGifts/Gifts.php" ); // UserGifts (user-to-user gifting functionality) loader file
197197 require_once( "$IP/extensions/SocialProfile/SystemGifts/SystemGifts.php" ); // SystemGifts (awards functionality) loader file
@@ -216,4 +216,49 @@
217217 $wgExtNewTables[] = array( 'user_system_messages', "$dir/UserSystemMessages/user_system_messages.sql" );
218218 }
219219 return true;
220 -}
\ No newline at end of file
 220+}
 221+
 222+/*
 223+// For Renameuser extension
 224+$wgHooks['RenameUserSQL'][] = 'efSystemGiftsOnUserRename';
 225+$wgHooks['RenameUserSQL'][] = 'efUserBoardOnUserRename';
 226+$wgHooks['RenameUserSQL'][] = 'efUserGiftsOnUserRename';
 227+$wgHooks['RenameUserSQL'][] = 'efUserRelationshipOnUserRename';
 228+$wgHooks['RenameUserSQL'][] = 'efUserStatsOnUserRename';
 229+$wgHooks['RenameUserSQL'][] = 'efUserSystemMessagesOnUserRename';
 230+
 231+function efSystemGiftsOnUserRename( $renameUserSQL ) {
 232+ $renameUserSQL->tables['user_system_gift'] = array( 'sg_user_name', 'sg_user_id' );
 233+ return true;
 234+}
 235+
 236+function efUserBoardOnUserRename( $renameUserSQL ) {
 237+ $renameUserSQL->tables['user_board'] = array( 'ub_user_name_from', 'ub_user_id_from' );
 238+ return true;
 239+}
 240+
 241+function efUserGiftsOnUserRename( $renameUserSQL ) {
 242+ $renameUserSQL->tables['user_gift'] = array( 'ug_user_name_to', 'ug_user_id_to' );
 243+ $renameUserSQL->tables['gift'] = array( 'gift_creator_user_name', 'gift_creator_user_id' );
 244+ return true;
 245+}
 246+
 247+function efUserRelationshipOnUserRename( $renameUserSQL ) {
 248+ // <fixme> This sucks and only updates half of the rows...wtf?
 249+ $renameUserSQL->tables['user_relationship'] = array( 'r_user_name_relation', 'r_user_id_relation' );
 250+ $renameUserSQL->tables['user_relationship'] = array( 'r_user_name', 'r_user_id' );
 251+ // </fixme>
 252+ $renameUserSQL->tables['user_relationship_request'] = array( 'ur_user_name_from', 'ur_user_id_from' );
 253+ return true;
 254+}
 255+
 256+function efUserStatsOnUserRename( $renameUserSQL ) {
 257+ $renameUserSQL->tables['user_stats'] = array( 'stats_user_name', 'stats_user_id' );
 258+ return true;
 259+}
 260+
 261+function efUserSystemMessagesOnUserRename( $renameUserSQL ) {
 262+ $renameUserSQL->tables['user_system_messages'] = array( 'um_user_name', 'um_user_id' );
 263+ return true;
 264+}
 265+*/
\ No newline at end of file
Index: trunk/extensions/SocialProfile/UserBoard/BoardBlast.js
@@ -1,27 +1,27 @@
22 function toggle_user( user_id ) {
3 - if( YAHOO.util.Dom.hasClass( 'user-' + user_id, 'blast-friend-selected' ) ) {
4 - YAHOO.util.Dom.replaceClass( 'user-' + user_id, 'blast-friend-selected', 'blast-friend-unselected' );
5 - } else if( YAHOO.util.Dom.hasClass( 'user-' + user_id, 'blast-friend-unselected' ) ) {
6 - YAHOO.util.Dom.replaceClass( 'user-' + user_id, 'blast-friend-unselected', 'blast-friend-selected' );
 3+ if( jQuery( '#user-' + user_id ).hasClass( 'blast-friend-selected' ) ) {
 4+ jQuery( '#user-' + user_id ).removeClass( 'blast-friend-selected' ).addClass( 'blast-friend-unselected' );
 5+ } else if( jQuery( '#user-' + user_id ).hasClass( 'blast-friend-unselected' ) ) {
 6+ jQuery( '#user-' + user_id ).removeClass( 'blast-friend-unselected' ).addClass( 'blast-friend-selected' );
77 }
88
9 - if( YAHOO.util.Dom.hasClass( 'user-' + user_id, 'blast-foe-selected' ) ) {
10 - YAHOO.util.Dom.replaceClass( 'user-' + user_id, 'blast-foe-selected', 'blast-foe-unselected' );
11 - } else if( YAHOO.util.Dom.hasClass( 'user-' + user_id, 'blast-foe-unselected' ) ) {
12 - YAHOO.util.Dom.replaceClass( 'user-' + user_id, 'blast-foe-selected', 'blast-foe-unselected' );
 9+ if( jQuery( '#user-' + user_id ).hasClass( 'blast-foe-selected' ) ) {
 10+ jQuery( '#user-' + user_id ).removeClass( 'blast-foe-selected' ).addClass( 'blast-foe-unselected' );
 11+ } else if( jQuery( '#user-' + user_id ).hasClass( 'blast-foe-unselected' ) ) {
 12+ jQuery( '#user-' + user_id ).removeClass( 'blast-foe-unselected' ).addClass( 'blast-foe-selected' );
1313 }
1414 }
1515
1616 function toggle_type( method, on, off ) {
17 - list = YAHOO.util.Dom.getElementsByClassName( ( ( method == 1 ) ? off : on ), 'div', 'blast-friends-list' );
 17+ list = jQuery( '#blast-friends-list div.' + ( ( method == 1 ) ? off : on ) );
1818
1919 for( x = 0; x <= list.length - 1; x++ ) {
2020 el = list[x];
21 - if( YAHOO.util.Dom.hasClass( el, on ) || YAHOO.util.Dom.hasClass( el, off ) ) {
 21+ if( jQuery( el ).hasClass( on ) || jQuery( el ).hasClass( off ) ) {
2222 if( method == 1 ) {
23 - YAHOO.util.Dom.replaceClass( el, off, on );
 23+ jQuery( el ).removeClass( off ).addClass( on );
2424 } else {
25 - YAHOO.util.Dom.replaceClass( el, on, off );
 25+ jQuery( el ).removeClass( on ).addClass( off );
2626 }
2727 }
2828 }
@@ -54,7 +54,7 @@
5555 selected = 0;
5656 user_ids_to = '';
5757
58 - list = YAHOO.util.Dom.getElementsByClassName( 'blast-friend-selected', 'div', 'blast-friends-list' );
 58+ list = jQuery( '#blast-friends-list div.blast-friend-selected' );
5959 for( x = 0; x <= list.length - 1; x++ ) {
6060 el = list[x];
6161 selected++;
@@ -62,7 +62,7 @@
6363 user_ids_to += ( ( user_ids_to ) ? ',' : '' ) + user_id;
6464 }
6565
66 - list = YAHOO.util.Dom.getElementsByClassName( 'blast-foe-selected', 'div', 'blast-friends-list' );
 66+ list = jQuery( '#blast-friends-list div.blast-foe-selected' );
6767 for( x = 0; x <= list.length - 1; x++ ) {
6868 el = list[x];
6969 selected++;
@@ -76,16 +76,16 @@
7777 return 0;
7878 }
7979
80 - if( !document.getElementById('message').value ) {
 80+ if( !document.getElementById( 'message' ).value ) {
8181 alert( 'Please enter a message' );
8282 submitted = 0;
8383 return 0;
8484 }
8585
86 - document.getElementById('ids').value = user_ids_to;
 86+ document.getElementById( 'ids' ).value = user_ids_to;
8787
8888 document.blast.message.style.color = '#ccc';
8989 document.blast.message.readOnly = true;
90 - document.getElementById('blast-friends-list').innerHTML = 'Sending messages...';
 90+ document.getElementById( 'blast-friends-list' ).innerHTML = 'Sending messages...';
9191 document.blast.submit();
9292 }
Index: trunk/extensions/SocialProfile/UserGifts/UserGifts.js
@@ -3,21 +3,21 @@
44 function selectGift( id ) {
55 // Un-select previously selected gift
66 if( selected_gift ) {
7 - YAHOO.util.Dom.removeClass( 'give_gift_' + selected_gift, 'g-give-all-selected' );
 7+ jQuery( '#give_gift_' + selected_gift ).removeClass( 'g-give-all-selected' );
88 }
99
1010 // Select new gift
11 - YAHOO.util.Dom.addClass( 'give_gift_' + id, 'g-give-all-selected' );
 11+ jQuery( '#give_gift_' + id ).addClass( 'g-give-all-selected' );
1212
1313 selected_gift = id;
1414 }
1515
1616 function highlightGift( id ) {
17 - YAHOO.util.Dom.addClass( 'give_gift_' + id, 'g-give-all-highlight' );
 17+ jQuery( '#give_gift_' + id ).addClass( 'g-give-all-highlight' );
1818 }
1919
2020 function unHighlightGift( id ) {
21 - YAHOO.util.Dom.removeClass( 'give_gift_' + id, 'g-give-all-highlight' );
 21+ jQuery( '#give_gift_' + id ).removeClass( 'g-give-all-highlight' );
2222 }
2323
2424 function sendGift() {

Follow-up revisions

RevisionCommit summaryAuthorDate
r69045Drop support for YUI. Was removed in r68271.siebrand06:55, 5 July 2010

Status & tagging log