function wfUserProfileFavoriteTeams( $user_profile ) { global $wgUser, $wgOut, $wgScriptPath, $wgUploadPath; $output = ''; $user_id = $user_profile->user_id; // Add JS if ( defined( 'MW_SUPPORTS_RESOURCE_MODULES' ) ) { $wgOut->addModuleScripts( 'ext.sportsTeams.userProfile' ); } else { $wgOut->addScriptFile( $wgScriptPath . '/extensions/SportsTeams/SportsTeamsUserProfile.js' ); } $add_networks_title = SpecialPage::getTitleFor( 'UpdateFavoriteTeams' ); $favs = SportsTeams::getUserFavorites( $user_id ); if ( $favs ) { $output .= '<div class="user-section-heading"> <div class="user-section-title">' . wfMsg( 'sportsteams-profile-networks' ) . '</div> <div class="user-section-actions"> <div class="action-right">'; if ( $user_profile->isOwner() ) { $output .= '<a href="' . $add_networks_title->escapeFullURL() . '">' . wfMsg( 'sportsteams-profile-add-network' ) . '</a>'; } $output .= '</div> <div class="cleared"></div> </div> </div> <div class="network-container">'; foreach( $favs as $fav ) { $homepage_title = SpecialPage::getTitleFor( 'FanHome' ); $status_link = ''; if ( $wgUser->getId() == $user_id ) { $onclick = "SportsTeamsUserProfile.showMessageBox({$fav['order']},{$fav['sport_id']},{$fav['team_id']})"; $status_link = ' <span class="status-message-add"> - <a href="javascript:void(0);" onclick="' . $onclick . '" rel="nofollow">' . wfMsg( 'sportsteams-profile-add-thought' ) . '</a></span>'; } $network_update_message = ''; // Originally the following two lines of code were not present and // thus $user_updates was always undefined $s = new UserStatus(); $user_updates = $s->getStatusMessages( $user_id, $fav['sport_id'], $fav['team_id'], 1, 1 ); // Added empty() check if ( !empty( $user_updates[$fav['sport_id'] . '-' . $fav['team_id']] ) ) { $network_update_message = $user_updates[$fav['sport_id'] . '-' . $fav['team_id']]; } if ( $fav['team_name'] ) { $display_name = $fav['team_name']; $logo = "<img src=\"{$wgUploadPath}/team_logos/" . SportsTeams::getTeamLogo( $fav['team_id'], 's' ) . '" border="0" alt="" />'; } else { $display_name = $fav['sport_name']; $logo = "<img src=\"{$wgUploadPath}/sport_logos/" . SportsTeams::getSportLogo( $fav['sport_id'], 's' ) . '" border="0" alt="" />'; } $output .= "<div class=\"network\"> {$logo} <a href=\"" . $homepage_title->escapeFullURL( 'sport_id=' . $fav['sport_id'] . '&team_id=' . $fav['team_id'] ) . "\" rel=\"nofollow\">{$display_name}</a> {$status_link} </div> <div class=\"status-update-box\" id=\"status-update-box-{$fav['order']}\" style=\"display:none\"></div>"; } $output .= '<div class="cleared"></div> </div>'; } elseif ( $user_profile->isOwner() ) { $output .= '<div class="user-section-heading"> <div class="user-section-title">' . wfMsg( 'sportsteams-profile-networks' ) . '</div> <div class="user-section-actions"> <div class="action-right"> <a href="' . $add_networks_title->escapeFullURL() . '">' . wfMsg( 'sportsteams-profile-add-network' ) . '</a> </div> <div class="cleared"></div> </div> </div> <div class="no-info-container">' . wfMsg( 'sportsteams-profile-no-networks' ) . '</div>'; } $wgOut->addHTML( $output ); return true; }