Modification Name: LastFM Button

Modification Version: 1.0

Modification Author: GuldantheWarlock (GuldantheWarlock@xmbgarage.com)

Modification Description:
This modification will allow you to specify your LastFM Username in your profile settings.
This modification will add a lastfm button to your posts that will popup a window with your lastfm playlist.

Supported Version: XMB 1.9.8 SP3

Notes: This modification is released under the GPL. You should have recieved a copy of it with this software package.

Please backup your files before installing this modification. Neither XMBGarage nor the author can be held responsible if your board stops functioning properly due to you installing this modification.
=======================================================================================================
=======
Step 1:
=======
==============================
Go To Admin Panel -> Insert Raw SQL
==============================
=================================
Paste The Following Code And Click Submit
=================================

ALTER TABLE `$table_members` ADD `lastfmname` VARCHAR(32) NOT NULL default '';

=======================================================================================================
=======
Step 2:
=======
=======================
Edit File: lang/English.lang.php
=======================
=======================
Add To End Of File Above ?>
=======================

// LastFM Button Mod Begin
$lang['lastfm'] = 'LastFM Username:';
$lang['lastfmalt'] = 'This User has a LastFM Playlist';
// LastFM Button Mod End

=======================================================================================================
=======
Step 3:
=======
===================
Edit File: editprofile.php
===================
==========
Find Code:
==========

    $sig = isset($_POST['newsig']) ? checkInput($_POST['newsig'], '', $SETTINGS['sightml'], '', false) : '';

===============
Add CodeBelow:
===============

    // LastFM Button Mod Begin
    $newlastfmname = formVar('newlastfmname');
    $lastfmname = $newlastfmname ? checkInput($newlastfmname, '', '', 'javascript', false) : '';
    // Custom Field: LastFM Button Mod End

==========
Find Code:
==========

    $sig = addslashes($sig);

===============
Add Code Below:
===============

    // LastFM Button Mod Begin
    $lastfmname = addslashes($lastfmname);
    // LastFM Button Mod End

==========
Find Code:
==========

    $db->query("UPDATE ".X_PREFIX."members SET email='$email',

=============================================
Add To End Of Statement Before WHERE username='$user'");
=============================================

, lastfmname='$newlastfmname'

=======================================================================================================
=======
Step 4:
=======
==============
Edit member.php
==============
==========
Find Code:
==========

                $sig = postedVar('sig', 'javascript', ($SETTINGS['sightml']=='off'), TRUE, TRUE);

===============
Add Code Below:
===============

               // LastFM Button Mod Begin
                $lastfmname = postedVar('lastfmname', 'javascript', TRUE, TRUE, TRUE);
                // LastFM Button Mod End

=================
Find Code (2 Times):
=================

) VALUES ('$username'

=======================
Replace Code With (2 Times):
=======================

, lastfmname) VALUES ('$username'

=============================
Find Code At End Of Both Statements:
=============================

)");

================
Replace Code With:
================

, '$lastfmname')");

=======================================================================================================

=======
Step 5:
=======
=================
Edit File: memcp.php
=================
==========
Find Code:
==========

        $sig = isset($_POST['newsig']) ? checkInput($_POST['newsig'], '', $SETTINGS['sightml'], '', false) : '';

===============
Add Code Below:
===============

        // LastFM Button Mod Begin
        $newlastfmname = formVar('newlastfmname');
        $lastfmname = $newlastfmname ? checkInput($newlastfmname, 'no', 'yes', 'javascript', false) : '';
        // LastFM Button Mod End

==========
Find Code:
==========

        $sig = addslashes($sig);

===============
Add Code Below:
===============

        // LastFM Button Mod Begin
        $lastfmname = addslashes($lastfmname);
        // LastFM Button Mod End

==========
Find Code:
==========

        $db->query("UPDATE ".X_PREFIX."members SET $pwtxt email='$email',

=================================================
Add To End Of Statement Before WHERE username='$xmbuser'");'
=================================================

, lastfmname='$newlastfmname'

=======================================================================================================
=======
Step 6:
=======
===================
Edit File: viewthread.php
===================
==========
Find Code:
==========

loadtemplates(

================
Replace Code With:
================

loadtemplates(
'viewthread_post_lastfm',

=====
Find:
=====

            $yahoo = '';
            if ($post['yahoo'] != '') {
                $post['yahoo'] = recodeOut($post['yahoo']);
                eval('$yahoo = "'.template('viewthread_post_yahoo').'";');
            }

===============
Add Code Below:
===============

            // LastFM Button Mod Begin
            $lastfm = '';
            if ($post['lastfmname'] != '') {
                $post['lastfmname'] = recodeOut($post['lastfmname']);
                eval('$lastfm = "'.template('viewthread_post_lastfm').'";');
            }
            // LastFM Button Mod End
            
==========
Find Code:
==========

            $location = '';
            $mood = '';
            
===============
Add Code Below:
===============

            // LastFM Button Mod Begin
            $lastfm = '';
            // LastFM Button Mod End
            
=======================================================================================================
=======
Step 7:
=======

==============================
Go to Administration Panel -> Templates
==============================
===========================
Edit Template: admintool_editprofile
===========================
==========
Find Code:
==========

<tr class="tablerow">
<td bgcolor="$altbg1" width="22%">$lang[textlocation]</td>
<td bgcolor="$altbg2"><input type="text" name="newlocation" size="25" value="$member[location]" /></td>
</tr>

==========
Add Below:
==========

<tr class="tablerow">
<td bgcolor="$altbg1" width="22%">$lang[lastfm]</td>
<td bgcolor="$altbg2"><input type="text" name="newlastfmname" size="25" value="$member[lastfmname]" /></td>
</tr>

=======================================================================================================
=======
Step 8:
=======
==============================
Go to Administration Panel -> Templates
==============================
============================
Edit Template: member_reg_optional
============================
==========
Find Code:
==========

<tr class="tablerow">
<td bgcolor="$altbg1" width="22%">$lang[textlocation]</td>
<td bgcolor="$altbg2"><input type="text" name="location" size="25" value="" /></td>
</tr>

===============
Add Code Below:
===============

<tr class="tablerow">
<td bgcolor="$altbg1" width="22%">$lang[lastfm]</td>
<td bgcolor="$altbg2"><input type="text" name="lastfmname" size="25" /></td>
</tr>

=======================================================================================================
=======
Step 9:
=======
==============================
Go to Administration Panel -> Templates
==============================
=======================
Edit Template: memcp_profile:
=======================
==========
Find Code:
==========

<tr class="tablerow">
<td bgcolor="$altbg1" width="22%">$lang[textlocation]</td>
<td bgcolor="$altbg2"><input type="text" name="newlocation" size="25" value="$member[location]" /></td>
</tr>

==========
Add Below:
==========

<tr class="tablerow">
<td bgcolor="$altbg1" width="22%">$lang[lastfm]</td>
<td bgcolor="$altbg2"><input type="text" name="newlastfmname" size="25" value="$member[lastfmname]" /></td>
</tr>

=======================================================================================================
========
Step 10:
========
==============================
Go to Administration Panel -> Templates
==============================
===============================
Create Template: viewthread_post_lastfm
===============================

===========================
Add code below and submit changes:
===========================

<a href="http://www.last.fm/widgets/popup/?colour=black&amp;size=regular&amp;autostart=0&amp;url=user%2F$post[lastfmname]%2Fplaylist&amp;user=$post[lastfmname]&amp;from=code&amp;widget=playlist&amp;resize=1" title="$lang[lastfmalt]" target="_blank" onclick="window.open(this.href + '&amp;resize=0','lfm_popup','height=384,width=234,resizable=yes,scrollbars=yes'); return false;"><img src="$imgdir/lastfm.gif" alt="$lang[lastfmalt]" border="0" /></a>

=======================================================================================================
=======
Step 9:
=======
==============================
Go to Administration Panel -> Templates
==============================
========================
Edit Template: viewthread_post
========================
==========
Find Code:
==========

$yahoo

==============
Add Code After:
==============

$lastfm

=======================================================================================================
========
Step 10:
========

Upload 'lastfm.gif' from the 'Contents' folder to your forum's theme directories.

=======================================================================================================
Enjoy!