BETA: Referrals Mod

Started by karlbenson, May 29, 2007, 10:09:38 PM

Previous topic - Next topic

karlbenson

Quote from: assasinkilla on May 30, 2007, 04:09:10 PM
WOrks on the latest SMF? Fully work? When do the test ends?

Part of being a BETA is that it hasnt been tested in a proper environment (with other mods) and whether any parts of the code are buggy or there are security issues with.

The code gets refined, bugs get fixed, changes for integration along with other mods will follow before a proper 1.0 release.

~Unkn0wn~

K, i will wait for release, thanks =) :)

Oldiesmann

Great to see someone has finally made this mod. I'll have to play with it when I have more time.
Michael Eshom
Christian Metal Fans

karlbenson

^ me too.

I have been waiting for it for a long time.

I'm about to upgrade my board and I so I decided to have a go.
it was actually alot easier than i thought.

kerrang!

Hey Karl,

Wonderful mod here buddy. Excellent work! Small question though (if you don't mind)

I have it installed on a site which i've got an integrated script with joomla. The problem is that the link wouldn't work with this, would it be possible to allow the link to be altered to what my sites link is?

example... www.mysite.com/community/index.php?referredby=9
which isn't the path my site links with

which is www.mysite.com/forum/

Would it be possible to take the "referredby=9" and get it to work with the link above? Thanks very much for this mod.

~Kerrang!
I'm my own worst enemy! :P

Css Help <--Having difficulty matching the look of the code function with the style of "quote".. =)

SlammedDime

kerrang! - this should work with a Joomla integration without issue... the link would be, more or less, http://www.mysite.com/index.php?option=com_smf&Itemid=1&referredby=9
SlammedDime
Former Lead Customizer
BitBucket Projects
GeekStorage.com Hosting
                      My Mods
SimpleSEF
Ajax Quick Reply
Sitemap
more...
                     

karlbenson

I've never used an integration/bridge myself.

The link which appears in each persons profile is made up from the $scripturl. with the rest added on.

You could modify in the install.xml (or post install on the profile.template)
echo '<tr>
<td colspan="2"><b>'.$txt['referrals_link'].'</b></td></tr>
<tr><td colspan="2" style="text-align:center;">'.$scripturl.'?referredby='. $context['member']['id'] .'</td>
</tr>';

And replace the $script url with your modified version.

Hope that helps.

kerrang!

Quote from: karlbenson on June 03, 2007, 04:28:25 PM
I've never used an integration/bridge myself.

The link which appears in each persons profile is made up from the $scripturl. with the rest added on.

You could modify in the install.xml (or post install on the profile.template)
echo '<tr>
<td colspan="2"><b>'.$txt['referrals_link'].'</b></td></tr>
<tr><td colspan="2" style="text-align:center;">'.$scripturl.'?referredby='. $context['member']['id'] .'</td>
</tr>';

And replace the $script url with your modified version.

Hope that helps.

Sorry for sounding like a newbie here..
Quote$scripturl.
what would this be changed to? the url?

Thanks for your help :)
I'm my own worst enemy! :P

Css Help <--Having difficulty matching the look of the code function with the style of "quote".. =)

SlammedDime

kerrang! - before trying to mess with and change things, why don't you install the mod and try the link as I suggested above.
SlammedDime
Former Lead Customizer
BitBucket Projects
GeekStorage.com Hosting
                      My Mods
SimpleSEF
Ajax Quick Reply
Sitemap
more...
                     

SMdot™

I get an error for Display.template.php

I have these modules installed

1.     vWarn Mod      1.10      
2.    Googlebot & Spiders Mod    2.0.3    
3.    Frequency Bars    1.0    
4.    Referrals    1.0    
5.    Global Headers Footers    1.3    
6.    SMF Arcade    2.0.8    
7.    SMFShop    3.0    
8.    PM On Registration    1.0.2
9.    TinyPortal    0.983    
10.    Media Center    1.0    
11.    Who Voted What?    1.1.2

I've attached my Display.template.php file.



Display.template.php (35.38 KB - downloaded 0 times.)

ArkServer

sounds like a mod we can use, once this mod is a bit "matured" im sure we will use it.

kerrang!

Sorry to be annoying here. :)

Any clues what I change the script link to? (I'm not exactly sure what code goes their) kudos,~Kerrang!
I'm my own worst enemy! :P

Css Help <--Having difficulty matching the look of the code function with the style of "quote".. =)

SlammedDime

#32
Quote from: Matt @ ARTcom on June 03, 2007, 05:18:23 PM
kerrang! - before trying to mess with and change things, why don't you install the mod and try the link as I suggested above.

kerrand! - if you have a bridged site, you should not be accessing the standalone forum... ie: if your bridge link is http://www.myurl.com/index.php?option=com_smf&Itemid=26, and your standalone forum link is http://www.myurl.com/forum, you should not be linking users to http://www.myurl.com/forum
SlammedDime
Former Lead Customizer
BitBucket Projects
GeekStorage.com Hosting
                      My Mods
SimpleSEF
Ajax Quick Reply
Sitemap
more...
                     

kerrang!

Quote from: Matt @ ARTcom on June 08, 2007, 04:32:36 AM
Quote from: Matt @ ARTcom on June 03, 2007, 05:18:23 PM
kerrang! - before trying to mess with and change things, why don't you install the mod and try the link as I suggested above.

kerrand! - if you have a bridged site, you should not be accessing the standalone forum... ie: if your bridge link is http://www.myurl.com/index.php?option=com_smf&Itemid=26, and your standalone forum link is http://www.myurl.com/forum, you should not be linking users to http://www.myurl.com/forum

I have SEF urls setup so it's changed the link from /options=com_smf&itemid=26/ - /forum/

:)
I'm my own worst enemy! :P

Css Help <--Having difficulty matching the look of the code function with the style of "quote".. =)

Fustrate

#34
Are there any plans to have it be a referral by name?

If not, where could I manually make that modification to the code?

Thanks :)

Oh, and it works fine on a forum with 5 other mods -

1.     Country Flags
2.    SMF Arcade
3.    Create Topic on Report to Moderator
4.    Topic Solved
5.    Admin Notepad

and a fairly heavily modified custom theme (though I only had to change that one line in Display.template.php)

oh, and what about a referral field in the registration area, so they can just manually type a name?
Steven Hoffman
Former Team Member, 2009-2012

nitins60

It's not possible to do via name! Because in SMF, you can change your name (user), so how can you give referral to him?

Fustrate

#36
I thought you could only change your display name, not your login name...

is it possible if you have name changes turned off?

(Just looked in MySQL. There's two rows in the smf_members table that have to do with the name, memberName and realName - is it possible to go by one of those? As I recall, only one of those changes when a name is changed. I'll test it in a minute.)

EDIT: memberName stays the same :) realName changes.
Steven Hoffman
Former Team Member, 2009-2012

xxkylexx

Using this mod. Works good so far.

Fustrate

#38
I'm going to go ahead and try to make the changes for it to work with memberName from the database ;)

I'll reply here with what happens.

Part 1 (Show <select> with names): Done!
Part 2 (Make it do the referral): Done!

It uses a <select> in this format:
<select name="referredby">
<option></option>
<option value="ID_MEMBER">memberName</option>
<option value="ID_MEMBER">memberName</option>
<option value="ID_MEMBER">memberName</option>
</select>
<input type="hidden" name="referredon" value="time()" />

to allow members to select a referrer.

It's then a little modification to the Sources/Register.php file and you're done!

This can be used even if you allow members to change their names, because it works off of their login name, and changes dynamically along with login name changes.

I'll post the changes here in a minute, I need to clean up the code, it has akward spacing.

Changes to $themedir/Register.template.php or default/Register.template.php
// IF REFERRAL INFORMATION IS SET IT WILL HAVE BEEN PASSED USING THIS VARIABLE
global $referrals;
if (isset($referrals))
{
echo ' <tr>
<td width="40%"><b>'.$txt['referrals_information'].'</b></td>
<td>'. $txt['referrals_youwerereferredby'].' '. $referrals['referredbyname'].
' '.$txt['referrals_on'].' '. date('d-m-Y',$referrals['referredon']);

// NOW WRITE THE INFORMATION INTO HIDDEN INPUTS TO BE PASSED TO THE NEXT FUNCTION
echo ' <input type="hidden" name="referredby" value="'.$referrals['referredbyid'].'"/>
<input type="hidden" name="referredon" value="'.$referrals['referredon'].'"/>
</td>
</tr>';
}
}

change to
// IF REFERRAL INFORMATION IS SET IT WILL HAVE BEEN PASSED USING THIS VARIABLE
global $referrals;
if (isset($referrals))
{
echo ' <tr>
<td width="40%"><b>'.$txt['referrals_information'].'</b></td>
<td>'. $txt['referrals_youwerereferredby'].' '. $referrals['referredbyname'].
' '.$txt['referrals_on'].' '. date('d-m-Y',$referrals['referredon']);

// NOW WRITE THE INFORMATION INTO HIDDEN INPUTS TO BE PASSED TO THE NEXT FUNCTION
echo ' <input type="hidden" name="referredby" value="'.$referrals['referredbyid'].'"/>
<input type="hidden" name="referredon" value="'.$referrals['referredon'].'"/>
</td>
</tr>';
} else {



// MODIFICATION


echo '
<tr valign="top" width="100%">
<td width="40%" align="top">
<b>Referred by: </b></td>
<td>
<select name="referredby">
<option value="0"></option>';

$con = mysql_connect($db_server, $db_user, $db_passwd);
if (!$con)  echo 'Could not connect: ' . mysql_error();

mysql_select_db($db_name, $con);

$result = mysql_query("SELECT * FROM {$db_prefix}members ORDER BY memberName");

while($row = mysql_fetch_array($result))
  {
  echo "
<option value=\"{$row['ID_MEMBER']}\">" . $row['memberName'] . "</option>";
  }

mysql_close($con);

echo '
</select>
<input type="hidden" value="' . time() . '" name="referredon"/>
</td>
</tr>';
}


Changes to $sourcedir/Register.php
// CHECKS FOR OUR COOKIE
global $referrals;
if(isset($_COOKIE['smfreferrals']))
{
$referrals = array();
$temp = explode("#", $_COOKIE['smfreferrals']);
$referrals['referredbyid'] = (int) $temp[0];
$referrals['referredon'] = (int) $temp[1];

if ($referrals['referredbyid'] != 0)
{
// QUERY IF THE USER ACTUALLY EXISTS
$request = db_query("
SELECT memberName
FROM {$db_prefix}members
WHERE ID_MEMBER = " . (int) $referrals['referredbyid'] . "
", __FILE__, __LINE__);

if (mysql_num_rows($request) != 0) {
// SET THE MEMBERNAME INTO THE ARRAY AS WE WILL SHOW THAT ON THE FORM
list ($referrals['referredbyname']) = mysql_fetch_row($request);
} else {
// NO USER EXISTS BY THAT NAME, SO UNSET IT
unset($referrals);
}
mysql_free_result($request);
}
}}

change to
    // CHECKS FOR OUR COOKIE
    global $referrals;

    if(isset($_POST['referredby'])){
        $referrals = array();
        if(isset($_COOKIE['smfreferrals'])){
            $temp = explode("#", $_COOKIE['smfreferrals']);
            $referrals['referredbyid'] = (int) $temp[0];
            $referrals['referredon'] = (int) $temp[1];
        } else {
            // MODIFICATION
            $referrals['referredbyid'] = (int) $_POST['referredby'];
            $referrals['referredon'] = (int) $_POST['referredon'];
        }
        if ($referrals['referredbyid'] != 0){
            // QUERY IF THE USER ACTUALLY EXISTS
            $request = db_query("SELECT memberName FROM {$db_prefix}members WHERE ID_MEMBER = " . (int) $referrals['referredbyid'] . "", __FILE__, __LINE__);
            if (mysql_num_rows($request) != 0) {
                // SET THE MEMBERNAME INTO THE ARRAY
                list ($referrals['referredbyname']) = mysql_fetch_row($request);     } else {
                // NO USER EXISTS BY THAT NAME, SO UNSET IT
                unset($referrals);
            }
            mysql_free_result($request);
        }
    }
}


I can't guarantee that those were the starting pieces of code, but they're going to be damn close. If you're going to try this, PLEASE BACK UP YOUR FILES. I can't guarantee that this will work for everyone, just that it worked for me.

Example (please don't register, this is for a game)
http://www.yodaofdarkness.com/forums/index.php?action=register
Steven Hoffman
Former Team Member, 2009-2012

Fustrate

I've now gone through a dozen referrals on my site, from both the cookie and the dropdown list.

I've also tried changing people's display names, and the list changes with them (but still refers the right person). If you wanted to change this to something like the popup box for PMs (where it inputs the most likely name), I'm willing to bet it's possible. Heck, anything's possible, I guess...

Hopefully this will make it into the final release of the mod, as I'm sure it would be used :) Thanks for the awesome mod btw!
Steven Hoffman
Former Team Member, 2009-2012

Advertisement: