| 1 |
<?php |
<?php |
| 2 |
// $Id: affiliates.module,v 1.1.4.5.2.19 2009/07/20 17:04:49 paulbooker Exp $ |
// $Id: affiliates.module,v 1.1.4.5.2.20 2009/10/15 14:16:56 paulbooker Exp $ |
| 3 |
|
|
| 4 |
// Portions Copyright 2006 http://2bits.com |
// Portions Copyright 2006 http://2bits.com |
| 5 |
define ('AFFILIATE_BUTTONS_DIRECTORY_RELATIVE_FILES', '/affiliates'); |
define ('AFFILIATE_BUTTONS_DIRECTORY_RELATIVE_FILES', '/affiliates'); |
| 48 |
'access arguments' => array('administer site configuration'), |
'access arguments' => array('administer site configuration'), |
| 49 |
); |
); |
| 50 |
|
|
| 51 |
$items['affiliates/admin'] = array( |
$items['admin/affiliates'] = array( |
| 52 |
'title' => 'Affiliates', |
'title' => 'Affiliates', |
| 53 |
'access arguments' => array('administer affiliates'), |
'access arguments' => array('administer affiliates'), |
| 54 |
'page callback' => 'affiliates_ad_button_list', |
'page callback' => 'affiliates_ad_button_list', |
| 55 |
); |
); |
| 56 |
|
|
| 57 |
$items['affiliates/admin/list/buttons'] = array( |
$items['admin/affiliates/list/buttons'] = array( |
| 58 |
'title' => 'List Buttons', |
'title' => 'List Buttons', |
| 59 |
'access arguments' => array('administer affiliates'), |
'access arguments' => array('administer affiliates'), |
| 60 |
'page callback' => 'affiliates_ad_button_list', |
'page callback' => 'affiliates_ad_button_list', |
| 62 |
'weight' => 1, |
'weight' => 1, |
| 63 |
); |
); |
| 64 |
|
|
| 65 |
$items['affiliates/admin/list/categories'] = array( |
$items['admin/affiliates/list/categories'] = array( |
| 66 |
'title' => 'List Categories', |
'title' => 'List Categories', |
| 67 |
'access arguments' => array('administer affiliates'), |
'access arguments' => array('administer affiliates'), |
| 68 |
'page callback' => 'affiliates_ad_category_list', |
'page callback' => 'affiliates_ad_category_list', |
| 70 |
'weight' => 1, |
'weight' => 1, |
| 71 |
); |
); |
| 72 |
|
|
| 73 |
$items['affiliates/admin/add/button'] = array( |
$items['admin/affiliates/add/button'] = array( |
| 74 |
'title' => t('Add Button'), |
'title' => t('Add Button'), |
| 75 |
'access arguments' => array('administer affiliates'), |
'access arguments' => array('administer affiliates'), |
| 76 |
'page callback' => 'affiliates_affiliate', |
'page callback' => 'affiliates_affiliate', |
| 78 |
'weight' => 5, |
'weight' => 5, |
| 79 |
); |
); |
| 80 |
|
|
| 81 |
$items['affiliates/admin/add/category'] = array( |
$items['admin/affiliates/add/category'] = array( |
| 82 |
'title' => t('Add Category'), |
'title' => t('Add Category'), |
| 83 |
'access arguments' => array('administer affiliates'), |
'access arguments' => array('administer affiliates'), |
| 84 |
'page callback' => 'affiliates_affiliate', |
'page callback' => 'affiliates_affiliate', |
| 86 |
'weight' => 5, |
'weight' => 5, |
| 87 |
); |
); |
| 88 |
|
|
| 89 |
$items['affiliates/admin/edit/button'] = array( |
$items['admin/affiliates/edit/button'] = array( |
| 90 |
'title' => 'Edit button', |
'title' => 'Edit button', |
| 91 |
'access arguments' => array('administer affiliates'), |
'access arguments' => array('administer affiliates'), |
| 92 |
'page callback' => 'affiliates_affiliate', |
'page callback' => 'affiliates_affiliate', |
| 93 |
'type' => MENU_HIDE, |
'type' => MENU_HIDE, |
| 94 |
); |
); |
| 95 |
|
|
| 96 |
$items['affiliates/admin/edit/category'] = array( |
$items['admin/affiliates/edit/category'] = array( |
| 97 |
'title' => 'Edit Category', |
'title' => 'Edit Category', |
| 98 |
'access arguments' => array('administer affiliates'), |
'access arguments' => array('administer affiliates'), |
| 99 |
'page callback' => 'affiliates_affiliate', |
'page callback' => 'affiliates_affiliate', |
| 100 |
'type' => MENU_HIDE, |
'type' => MENU_HIDE, |
| 101 |
); |
); |
| 102 |
|
|
| 103 |
$items['affiliates/admin/delete/button'] = array( |
$items['admin/affiliates/delete/button'] = array( |
| 104 |
'title' => t('Delete affiliate button'), |
'title' => t('Delete affiliate button'), |
| 105 |
'access arguments' => array('administer affiliates'), |
'access arguments' => array('administer affiliates'), |
| 106 |
'page callback' => 'affiliates_affiliate', |
'page callback' => 'affiliates_affiliate', |
| 107 |
'type' => MENU_HIDE, |
'type' => MENU_HIDE, |
| 108 |
); |
); |
| 109 |
|
|
| 110 |
$items['affiliates/admin/delete/category'] = array( |
$items['admin/affiliates/delete/category'] = array( |
| 111 |
'title' => t('Delete affiliate category'), |
'title' => t('Delete affiliate category'), |
| 112 |
'access arguments' => array('administer affiliates'), |
'access arguments' => array('administer affiliates'), |
| 113 |
'page callback' => 'affiliates_affiliate', |
'page callback' => 'affiliates_affiliate', |
| 135 |
); |
); |
| 136 |
|
|
| 137 |
$items['affiliates'] = array( |
$items['affiliates'] = array( |
| 138 |
'title' => t('Affiliates Home'), |
'title' => t('Affiliates'), |
| 139 |
'page callback' => 'affiliates_list', |
'page callback' => 'affiliates_list', |
| 140 |
'access arguments' => array('affiliate view'), |
'access arguments' => array('affiliate view'), |
| 141 |
); |
); |
| 574 |
drupal_set_message('Affiliate button has been saved.'); |
drupal_set_message('Affiliate button has been saved.'); |
| 575 |
break; |
break; |
| 576 |
} |
} |
| 577 |
drupal_goto('affiliates/admin'); |
drupal_goto('admin/affiliates'); |
| 578 |
} |
} |
| 579 |
|
|
| 580 |
function affiliate_form_button_delete_submit($form, &$form_state) { |
function affiliate_form_button_delete_submit($form, &$form_state) { |
| 584 |
|
|
| 585 |
db_query("DELETE FROM {affiliates_ads} WHERE ad_id = %d", $id); |
db_query("DELETE FROM {affiliates_ads} WHERE ad_id = %d", $id); |
| 586 |
drupal_set_message('Affiliate button has been deleted.'); |
drupal_set_message('Affiliate button has been deleted.'); |
| 587 |
drupal_goto('affiliates/admin/list/buttons'); |
drupal_goto('admin/affiliates/list/buttons'); |
| 588 |
} |
} |
| 589 |
|
|
| 590 |
function affiliate_form_category_add_edit(&$form_state, $affiliate_category = array()) { |
function affiliate_form_category_add_edit(&$form_state, $affiliate_category = array()) { |
| 656 |
drupal_set_message('Affiliate category has been saved.'); |
drupal_set_message('Affiliate category has been saved.'); |
| 657 |
break; |
break; |
| 658 |
} |
} |
| 659 |
drupal_goto('affiliates/admin/list/categories'); |
drupal_goto('admin/affiliates/list/categories'); |
| 660 |
} |
} |
| 661 |
|
|
| 662 |
function affiliate_form_category_delete($id) { |
function affiliate_form_category_delete($id) { |
| 679 |
db_query("DELETE FROM {affiliates_cats} WHERE cat_id = %d", $cat_id); |
db_query("DELETE FROM {affiliates_cats} WHERE cat_id = %d", $cat_id); |
| 680 |
db_query("DELETE FROM {affiliates_ads} WHERE cat_id = %d", $cat_id); |
db_query("DELETE FROM {affiliates_ads} WHERE cat_id = %d", $cat_id); |
| 681 |
drupal_set_message('Affiliate category has been deleted and all of its buttons.'); |
drupal_set_message('Affiliate category has been deleted and all of its buttons.'); |
| 682 |
drupal_goto('affiliates/admin/list/categories'); |
drupal_goto('admin/affiliates/list/categories'); |
| 683 |
} |
} |
| 684 |
|
|
| 685 |
function affiliates_ad_button_list($cat_id = NULL) { |
function affiliates_ad_button_list($cat_id = NULL) { |
| 713 |
array('data' => $data->cat_name), |
array('data' => $data->cat_name), |
| 714 |
array('data' => $status[$data->status]), |
array('data' => $status[$data->status]), |
| 715 |
array('data' => |
array('data' => |
| 716 |
l('edit', 'affiliates/admin/edit/button/' . $data->ad_id) . " " . |
l('edit', 'admin/affiliates/edit/button/' . $data->ad_id) . " " . |
| 717 |
l('delete', 'affiliates/admin/delete/button/' . $data->ad_id) |
l('delete', 'admin/affiliates/delete/button/' . $data->ad_id) |
| 718 |
), |
), |
| 719 |
); |
); |
| 720 |
} |
} |
| 746 |
array('data' => $data->active), |
array('data' => $data->active), |
| 747 |
array('data' => $data->weight), |
array('data' => $data->weight), |
| 748 |
array('data' => |
array('data' => |
| 749 |
l('show buttons', 'affiliates/admin/list/buttons/' . $data->cat_id) . " " . |
l('show buttons', 'admin/affiliates/list/buttons/' . $data->cat_id) . " " . |
| 750 |
l('edit', 'affiliates/admin/edit/category/' . $data->cat_id) . " " . |
l('edit', 'admin/affiliates/edit/category/' . $data->cat_id) . " " . |
| 751 |
l('delete', 'affiliates/admin/delete/category/' . $data->cat_id) |
l('delete', 'admin/affiliates/delete/category/' . $data->cat_id) |
| 752 |
), |
), |
| 753 |
); |
); |
| 754 |
} |
} |
| 777 |
$name = ($data->homepage) ? l($data->name, $data->homepage) : $data->name; |
$name = ($data->homepage) ? l($data->name, $data->homepage) : $data->name; |
| 778 |
$rows[] = array( |
$rows[] = array( |
| 779 |
array('data' => $rank++), |
array('data' => $rank++), |
| 780 |
array('data' => $name), |
array('data' => l($name, 'user/' . $data->user_id)), |
| 781 |
array('data' => $data->total_points), |
array('data' => $data->total_points), |
| 782 |
array('data' => $data->period_points), |
array('data' => $data->period_points), |
|
array('data' => l('view profile', 'user/' . $data->user_id)), |
|
| 783 |
); |
); |
| 784 |
} |
} |
| 785 |
|
|
| 787 |
$rows[] = array(array('data' => t('No clicks yet'), 'colspan' => '2')); |
$rows[] = array(array('data' => t('No clicks yet'), 'colspan' => '2')); |
| 788 |
} |
} |
| 789 |
|
|
| 790 |
$header = array('Rank', 'User', 'Total', 'Period', 'Profile'); |
$header = array('Rank', 'User', 'Total', 'Period'); |
| 791 |
|
|
| 792 |
$output = theme('table', $header, $rows); |
$output = theme('table', $header, $rows); |
| 793 |
|
|
| 1098 |
$ip = ip_address(); |
$ip = ip_address(); |
| 1099 |
$denied_ips = explode(",", variable_get(AFFILIATE_DENIED_IPS,'')); |
$denied_ips = explode(",", variable_get(AFFILIATE_DENIED_IPS,'')); |
| 1100 |
if (in_array($ip, $denied_ips)) return TRUE; |
if (in_array($ip, $denied_ips)) return TRUE; |
| 1101 |
$denied_uri_referrers = explode(",", variable_get(AFFILIATE_DENIED_URI_REFERRERS,'')); // TODO: Empty delimiter bug. |
$denied_uri_referrers = explode(",", variable_get(AFFILIATE_DENIED_URI_REFERRERS,'')); |
| 1102 |
if (empty($_SERVER['HTTP_REFERER'])) return TRUE; |
if (empty($_SERVER['HTTP_REFERER'])) return TRUE; |
| 1103 |
if (count($denied_uri_referrers)) { |
if (count($denied_uri_referrers)) { |
| 1104 |
foreach ($denied_uri_referrers as $referrer) { |
foreach ($denied_uri_referrers as $referrer) { |
| 1105 |
if (strpos($_SERVER['HTTP_REFERER'], $referrer)) return TRUE; |
if (!empty($referrer) && strpos($_SERVER['HTTP_REFERER'], $referrer)) return TRUE; |
| 1106 |
} |
} |
| 1107 |
} |
} |
| 1108 |
$timeout_flag = _check_timeout_query(); |
$timeout_flag = _check_timeout_query(); |
| 1185 |
'#title' => t('Category'), |
'#title' => t('Category'), |
| 1186 |
'#default_value' => variable_get(AFFILIATE_USERPOINTS_TID, 0), |
'#default_value' => variable_get(AFFILIATE_USERPOINTS_TID, 0), |
| 1187 |
'#options' => userpoints_get_categories(), |
'#options' => userpoints_get_categories(), |
| 1188 |
'#description' => t('Points for Affilates button click-throughs will be assigned to this category. You can modify what categories are available by modifying the <a href="!url"><b>Userpoints taxonomy</b></a>. Points values are set in the <a href="' . $base_url . '/affiliates/admin"><b>Affiliates Admin</b></a> section on a per button basis.', |
'#description' => t('Points for Affilates button click-throughs will be assigned to this category. You can modify what categories are available by modifying the <a href="!url"><b>Userpoints taxonomy</b></a>. Points values are set in the <a href="' . $base_url . '/admin/affiliates"><b>Affiliates Admin</b></a> section on a per button basis.', |
| 1189 |
array('!url' => url('admin/content/taxonomy/'. variable_get(USERPOINTS_CATEGORY_DEFAULT_VID, '')))), |
array('!url' => url('admin/content/taxonomy/'. variable_get(USERPOINTS_CATEGORY_DEFAULT_VID, '')))), |
| 1190 |
); |
); |
| 1191 |
|
|