| 1 |
<?php |
<?php |
| 2 |
|
|
| 3 |
// $Id: referral.module,v 1.16.2.10 2008/12/01 01:43:33 kbahey Exp $ |
// $Id: referral.module,v 1.16.2.11 2008/12/03 17:08:27 kbahey Exp $ |
| 4 |
|
|
| 5 |
/** |
/** |
| 6 |
* @file |
* @file |
| 24 |
define('REFERRAL_HEX_LENGTH', 4); |
define('REFERRAL_HEX_LENGTH', 4); |
| 25 |
define('REFERRAL_DISPLAY_MODE', 'referral_display_mode'); |
define('REFERRAL_DISPLAY_MODE', 'referral_display_mode'); |
| 26 |
define('REFERRAL_COOKIE', 'referral_data'); |
define('REFERRAL_COOKIE', 'referral_data'); |
| 27 |
|
define('REFERRAL_USERPOINTS', 'referral_userpoints'); |
| 28 |
define('REFERRAL_GOTO_PATH', 'referral_goto_path'); |
define('REFERRAL_GOTO_PATH', 'referral_goto_path'); |
| 29 |
|
|
| 30 |
|
|
| 184 |
return; |
return; |
| 185 |
} |
} |
| 186 |
|
|
| 187 |
|
if (module_exists('userpoints')) { |
| 188 |
|
$points = variable_get(REFERRAL_USERPOINTS, 1); |
| 189 |
|
// Build the userpoints params array |
| 190 |
|
$params = array( |
| 191 |
|
'points' => $points, |
| 192 |
|
'uid' => $cookie['uid'], |
| 193 |
|
'operation' => 'referral', |
| 194 |
|
'entity_id' => $cookie['uid'], |
| 195 |
|
'entity_type' => 'user', |
| 196 |
|
'reference' => 'referral' |
| 197 |
|
); |
| 198 |
|
|
| 199 |
|
// Award the points to the user |
| 200 |
|
userpoints_userpointsapi($params); |
| 201 |
|
} |
| 202 |
|
|
| 203 |
// Invoke other modules hooks ... |
// Invoke other modules hooks ... |
| 204 |
module_invoke_all('referral', $uid, $cookie['uid']); |
module_invoke_all('referral', $uid, $cookie['uid']); |
| 205 |
} |
} |
| 574 |
return $data; |
return $data; |
| 575 |
} |
} |
| 576 |
|
|
| 577 |
|
function referral_userpoints($op, $points = 0, $uid = 0, $event = '') { |
| 578 |
|
switch($op) { |
| 579 |
|
case 'setting': |
| 580 |
|
$group = 'referral'; |
| 581 |
|
$form[$group] = array( |
| 582 |
|
'#type' => 'fieldset', |
| 583 |
|
'#collapsible' => TRUE, |
| 584 |
|
'#collapsed' => TRUE, |
| 585 |
|
'#title' => t('!Points for referral', userpoints_translation()), |
| 586 |
|
); |
| 587 |
|
|
| 588 |
|
$form[$group][REFERRAL_USERPOINTS] = array( |
| 589 |
|
'#type' => 'textfield', |
| 590 |
|
'#title' => t('!Points for referring a user', userpoints_translation()), |
| 591 |
|
'#default_value' => variable_get(REFERRAL_USERPOINTS, 0), |
| 592 |
|
'#size' => 5, |
| 593 |
|
'#maxlength' => 5, |
| 594 |
|
); |
| 595 |
|
return $form; |
| 596 |
|
} |
| 597 |
|
} |
| 598 |
|
|