예제 #1
0
function AM_Show_Affiliate_Settings($settings)
{
    if (isset($_POST['gateway_settings'])) {
        // Do processing here
        if (!empty($_POST['affiliate_mp_percentage']) && $_POST['affiliate_mp_percentage'] > 0) {
            aff_update_option('affiliate_mp_percentage', $_POST['affiliate_mp_percentage']);
        } else {
            aff_delete_option('affiliate_mp_percentage');
        }
    }
    ?>
		<div id="mp_gateways" class="postbox">
            <h3 class='hndle'><span><?php 
    _e('Affiliate Settings', 'mp');
    ?>
</span></h3>
            <div class="inside">
			  <span class="description"><?php 
    _e('You can set the global commision amount paid to affiliates for referred purchases below. Set it to 0 for no payments.', 'affiliate');
    ?>
</span>
              <table class="form-table">
                <tr>
        				<th scope="row"><?php 
    _e('Set percentage to be paid to affiliates', 'affiliate');
    ?>
</th>
        				<td>
							<?php 
    $percentage = aff_get_option('affiliate_mp_percentage', 0);
    ?>
							<input type='text' name='affiliate_mp_percentage' value='<?php 
    echo number_format($percentage, 2);
    ?>
' style='width:5em;'/>&nbsp;<?php 
    _e('%', 'affiliate');
    ?>
                			<?php 
    ?>
        				</td>
                </tr>
              </table>
            </div>
          </div>
	<?php 
}
예제 #2
0
 function __construct()
 {
     global $wpdb;
     // Grab our own local reference to the database class
     $this->db =& $wpdb;
     $this->detect_location(1);
     foreach ($this->tables as $table) {
         if (function_exists('is_plugin_active_for_network') && is_plugin_active_for_network('affiliate/affiliate.php') && (defined('AFFILIATE_USE_GLOBAL_IF_NETWORK_ACTIVATED') && AFFILIATE_USE_GLOBAL_IF_NETWORK_ACTIVATED == 'yes')) {
             // we're activated site wide
             $this->{$table} = $this->db->base_prefix . $table;
         } else {
             if (defined('AFFILIATE_USE_BASE_PREFIX_IF_EXISTS') && AFFILIATE_USE_BASE_PREFIX_IF_EXISTS == 'yes' && !empty($this->db->base_prefix)) {
                 $this->{$table} = $this->db->base_prefix . $table;
             } else {
                 // we're only activated on a blog level so put the admin menu in the main area
                 $this->{$table} = $this->db->prefix . $table;
             }
         }
     }
     $installed = aff_get_option('Aff_Installed', false);
     if ($installed === false || $installed != $this->build) {
         $this->install();
         aff_update_option('Aff_Installed', $this->build);
     }
     register_activation_hook(__FILE__, array(&$this, 'install'));
     add_action('init', array(&$this, 'handle_affiliate_link'));
     // Global generic functions
     add_action('affiliate_click', array(&$this, 'record_click'), 10, 1);
     add_action('affiliate_signup', array(&$this, 'record_signup'), 10);
     add_action('affiliate_purchase', array(&$this, 'record_complete'), 10, 5);
     add_action('affiliate_credit', array(&$this, 'record_credit'), 10, 2);
     add_action('affiliate_debit', array(&$this, 'record_debit'), 10, 2);
     add_action('affiliate_referrer', array(&$this, 'record_referrer'), 10, 2);
     // Include affiliate plugins
     load_affiliate_addons();
 }
예제 #3
0
 function handle_affiliate_settings_panel()
 {
     if (isset($_GET['action']) && addslashes($_GET['action']) == 'updateaffiliateoptions') {
         check_admin_referer('affiliateoptions');
         $headings = array();
         $headings[] = $_POST['uniqueclicks'];
         $headings[] = $_POST['signups'];
         $headings[] = $_POST['paidmembers'];
         aff_update_option('affiliateheadings', $headings);
         aff_update_option('affiliatesettingstext', $_POST['affiliatesettingstext']);
         aff_update_option('affiliateadvancedsettingstext', $_POST['affiliateadvancedsettingstext']);
         aff_update_option('affiliateenablebanners', $_POST['affiliateenablebanners']);
         $banners = split("\n", stripslashes($_POST['affiliatebannerlinks']));
         foreach ($banners as $key => $b) {
             $banners[$key] = trim($b);
         }
         aff_update_option('affiliatebannerlinks', $banners);
         do_action('affililate_settings_form_update');
         echo '<div id="message" class="updated fade"><p>' . __('Affiliate settings saved.', 'affiliate') . '</p></div>';
     }
     $page = isset($_GET['page']) ? addslashes($_GET['page']) : '';
     $subpage = isset($_GET['subpage']) ? addslashes($_GET['subpage']) : '';
     echo '<div  id="poststuff" class=class="metabox-holder m-settings">';
     echo '<form method="post" action="?page=' . $page . '&amp;subpage=' . $subpage . '&amp;action=updateaffiliateoptions">';
     wp_nonce_field("affiliateoptions");
     echo '<div class="postbox">';
     echo '<h3 class="hndle" style="cursor:auto;"><span>' . __('Column Settings', 'affiliate') . '</span></h3>';
     echo '<div class="inside">';
     $headings = aff_get_option('affiliateheadings', array(__('Unique Clicks', 'affiliate'), __('Sign ups', 'affiliate'), __('Paid members', 'affiliate')));
     echo '<table class="form-table">';
     echo '<tr>';
     echo '<th valign="top" scope="row">' . __('Unique Clicks', 'affiliate') . '</th>';
     echo '<td valign="top">';
     echo '<input name="uniqueclicks" type="text" id="uniqueclicks" style="width: 50%" value="' . htmlentities(stripslashes($headings[0]), ENT_QUOTES, 'UTF-8') . '" />';
     echo '</td>';
     echo '</tr>';
     echo '<tr>';
     echo '<th valign="top" scope="row">' . __('Sign ups', 'affiliate') . '</th>';
     echo '<td valign="top">';
     echo '<input name="signups" type="text" id="signups" style="width: 50%" value="' . htmlentities(stripslashes($headings[1]), ENT_QUOTES, 'UTF-8') . '" />';
     echo '</td>';
     echo '</tr>';
     echo '<tr>';
     echo '<th valign="top" scope="row">' . __('Paid members', 'affiliate') . '</th>';
     echo '<td valign="top">';
     echo '<input name="paidmembers" type="text" id="paidmembers" style="width: 50%" value="' . htmlentities(stripslashes($headings[2]), ENT_QUOTES, 'UTF-8') . '" />';
     echo '</td>';
     echo '</tr>';
     echo '</table>';
     echo '</div>';
     echo '</div>';
     echo '<div class="postbox">';
     echo '<h3 class="hndle" style="cursor:auto;"><span>' . __('Profile page text', 'affiliate') . '</span></h3>';
     echo '<div class="inside">';
     $settingstextdefault = __("<p>We love it when people talk about us, and even more so when they recommend us to their friends.</p>\n<p>As a thank you we would like to offer something back, which is why we have set up this affiliate program.</p>\n<p>To get started simply enable the links for your account and enter your PayPal email address below, for more details on our affiliate program please visit our main site.</p>", 'affiliate');
     echo '<table class="form-table">';
     echo '<tr valign="top">';
     echo '<th scope="row">' . __('Affiliate settings profile text', 'affiliate') . '</th>';
     echo '<td>';
     $args = array("textarea_name" => "affiliatesettingstext");
     wp_editor(stripslashes(aff_get_option('affiliatesettingstext', $settingstextdefault)), "affiliatesettingstext", $args);
     echo '</td>';
     echo '</tr>';
     $advsettingstextdefault = __("<p>There are times when you would rather hide your affiliate link, or simply not have to bother remembering the affiliate reference to put on the end of our URL.</p>\n<p>If this is the case, then you can enter the main URL of the site you will be sending requests from below, and we will sort out the tricky bits for you.</p>", 'affiliate');
     echo '<table class="form-table">';
     echo '<tr valign="top">';
     echo '<th scope="row">' . __('Affiliate advanced settings profile text', 'affiliate') . '</th>';
     echo '<td>';
     $args = array("textarea_name" => "affiliateadvancedsettingstext");
     wp_editor(stripslashes(aff_get_option('affiliateadvancedsettingstext', $advsettingstextdefault)), "affiliateadvancedsettingstext", $args);
     echo '</td>';
     echo '</tr>';
     echo '</table>';
     echo '</div>';
     echo '</div>';
     echo '<div class="postbox">';
     echo '<h3 class="hndle" style="cursor:auto;"><span>' . __('Banner Settings', 'affiliate') . '</span></h3>';
     echo '<div class="inside">';
     echo '<table class="form-table">';
     echo '<tr>';
     echo '<th valign="top" scope="row">' . __('Enable Banners', 'affiliate') . '</th>';
     echo '<td valign="top">';
     echo "<select name='affiliateenablebanners'>";
     echo "<option value='yes'";
     if (aff_get_option('affiliateenablebanners', 'no') == 'yes') {
         echo "selected = 'selected'";
     }
     echo '>' . __('Yes please', 'affiliate') . "</option>";
     echo "<option value='no'";
     if (aff_get_option('affiliateenablebanners', 'no') == 'no') {
         echo "selected = 'selected'";
     }
     echo '>' . __('No thanks', 'affiliate') . "</option>";
     echo "</select>";
     echo '</td>';
     echo '</tr>';
     $banners = aff_get_option('affiliatebannerlinks');
     if (is_array($banners)) {
         $banners = implode("\n", $banners);
     }
     echo '<tr valign="top">';
     echo '<th scope="row">' . __('Banner Image URLs (one per line)', 'affiliate') . '</th>';
     echo '<td>';
     echo '<textarea name="affiliatebannerlinks" id="affiliatebannerlinks" cols="60" rows="10">' . stripslashes($banners) . '</textarea>';
     echo '</td>';
     echo '</tr>';
     echo '</table>';
     echo '</div>';
     echo '</div>';
     do_action('affililate_settings_form');
     echo '<p class="submit">';
     echo '<input type="submit" name="Submit" value="' . __('Update Settings', 'affiliate') . '" class="button-primary" /></p>';
     echo '</form>';
     echo '</div>';
     echo "</div>";
 }
예제 #4
0
 function handle_addons_panel_updates()
 {
     global $action, $page;
     if (isset($_GET['doaction']) || isset($_GET['doaction2'])) {
         if (addslashes($_GET['action']) == 'toggle' || addslashes($_GET['action2']) == 'toggle') {
             $action = 'bulk-toggle';
         }
     }
     $active = aff_get_option('affiliate_activated_addons', array());
     switch (addslashes($action)) {
         case 'deactivate':
             $key = addslashes($_GET['addon']);
             if (!empty($key)) {
                 check_admin_referer('toggle-addon-' . $key);
                 $found = array_search($key, $active);
                 if ($found !== false) {
                     unset($active[$found]);
                     aff_update_option('affiliate_activated_addons', array_unique($active));
                     return 5;
                 } else {
                     return 6;
                 }
             }
             break;
         case 'activate':
             $key = addslashes($_GET['addon']);
             if (!empty($key)) {
                 check_admin_referer('toggle-addon-' . $key);
                 if (!in_array($key, $active)) {
                     $active[] = $key;
                     aff_update_option('affiliate_activated_addons', array_unique($active));
                     return 3;
                 } else {
                     return 4;
                 }
             }
             break;
         case 'bulk-toggle':
             check_admin_referer('bulk-addon');
             if (is_array($_GET['plugincheck'])) {
                 foreach ($_GET['plugincheck'] as $key) {
                     $found = array_search($key, $active);
                     if ($found !== false) {
                         unset($active[$found]);
                     } else {
                         $active[] = $key;
                     }
                 }
                 aff_update_option('affiliate_activated_addons', array_unique($active));
             }
             return 7;
             break;
     }
 }
예제 #5
0
 function install()
 {
     return;
     // The install is done via the admin class on plugin activation. WTF is this doing here?
     // This shouldn't really need to be called as the admin area will set up the tables - but just in case
     if ($this->db->get_var("SHOW TABLES LIKE '" . $this->affiliatedata . "' ") != $this->affiliatedata) {
         $charset_collate = '';
         if (!empty($this->db->charset)) {
             $charset_collate = "DEFAULT CHARACTER SET " . $this->db->charset;
         }
         if (!empty($this->db->collate)) {
             $charset_collate .= " COLLATE " . $this->db->collate;
         }
         $sql = "CREATE TABLE `" . $this->affiliatedata . "` (\n\t\t\t  \t`user_id` bigint(20) default NULL,\n\t\t\t  \t`period` varchar(6) default NULL,\n\t\t\t  \t`uniques` bigint(20) default '0',\n\t\t\t  \t`signups` bigint(20) default '0',\n\t\t\t  \t`completes` bigint(20) default '0',\n\t\t\t  \t`debits` decimal(10,2) default '0.00',\n\t\t\t  \t`credits` decimal(10,2) default '0.00',\n\t\t\t  \t`payments` decimal(10,2) default '0.00',\n\t\t\t  \t`lastupdated` datetime default '0000-00-00 00:00:00',\n\t\t\t  \tUNIQUE KEY `user_period` (`user_id`,`period`)\n\t\t\t\t) {$charset_collate};";
         $this->db->query($sql);
         $sql = "CREATE TABLE `" . $this->affiliatereferrers . "` (\n\t\t\t  \t`user_id` bigint(20) default NULL,\n\t\t\t  \t`period` varchar(6) default NULL,\n\t\t\t  \t`url` varchar(250) default NULL,\n\t\t\t  \t`referred` bigint(20) default '0',\n\t\t\t  \tUNIQUE KEY `user_id` (`user_id`,`period`,`url`)\n\t\t\t\t) {$charset_collate};";
         $this->db->query($sql);
     }
     if ($this->db->get_var("SHOW TABLES LIKE '" . $this->affiliaterecords . "' ") != $this->affiliaterecords) {
         $sql = "CREATE TABLE `" . $this->affiliaterecords . "` (\n\t\t\t  \t`user_id` bigint(20) unsigned NOT NULL,\n\t\t\t\t  `period` varchar(6) DEFAULT NULL,\n\t\t\t\t  `affiliatearea` varchar(50) DEFAULT NULL,\n\t\t\t\t  `area_id` bigint(20) DEFAULT NULL,\n\t\t\t\t  `affiliatenote` text,\n\t\t\t\t  `amount` decimal(10,2) DEFAULT NULL,\n\t\t\t\t  KEY `user_id` (`user_id`),\n\t\t\t\t  KEY `period` (`period`)\n\t\t\t\t) {$charset_collate};";
         $this->db->query($sql);
     }
     if (affiliate_is_plugin_active_for_network() && (defined('AFFILIATE_USE_GLOBAL_IF_NETWORK_ACTIVATED') && AFFILIATE_USE_GLOBAL_IF_NETWORK_ACTIVATED == 'yes')) {
         // We need to check for a transfer across from old options to new ones
         $option = aff_get_option('affiliateheadings', false);
         if ($option == false) {
             $option = get_blog_option(1, 'affiliateheadings');
             aff_update_option('affiliateheadings', $option);
         }
         $option = aff_get_option('affiliatesettingstext', false);
         if ($option == false) {
             $option = get_blog_option(1, 'affiliatesettingstext');
             aff_update_option('affiliatesettingstext', $option);
         }
         $option = aff_get_option('affiliateadvancedsettingstext', false);
         if ($option == false) {
             $option = get_blog_option(1, 'affiliateadvancedsettingstext');
             aff_update_option('affiliateadvancedsettingstext', $option);
         }
         $option = aff_get_option('affiliateenablebanners', false);
         if ($option == false) {
             $option = get_blog_option(1, 'affiliateenablebanners');
             aff_update_option('affiliateenablebanners', $option);
         }
         $option = aff_get_option('affiliatelinkurl', false);
         if ($option == false) {
             $option = get_blog_option(1, 'affiliatelinkurl');
             aff_update_option('affiliatelinkurl', $option);
         }
         $option = aff_get_option('affiliatebannerlinks', false);
         if ($option == false) {
             $option = get_blog_option(1, 'affiliatebannerlinks');
             aff_update_option('affiliatebannerlinks', $option);
         }
         $option = aff_get_option('affiliate_activated_addons', false);
         if ($option == false) {
             $option = get_blog_option(1, 'affiliate_activated_addons');
             aff_update_option('affiliate_activated_addons', $option);
         }
     }
 }