<?php /** Limit Logs Display Module */ cp_module_register(__('Limit Logs Display', 'cp'), 'limitlogs', '1.0', 'CubePoints', 'http://cubepoints.com', 'http://cubepoints.com', __('This module allows you to limit the number of log items being displayed in the logs page.', 'cp'), 1); function cp_module_limitlogs_install() { add_option('cp_module_limitlogs_max', 100); } add_action('cp_module_limitlogs_activate', 'cp_module_limitlogs_install'); if (cp_module_activated('limitlogs')) { function cp_module_limitlogs_config() { ?> <br /> <h3><?php _e('Limit Logs Display', 'cp'); ?> </h3> <table class="form-table"> <tr valign="top"> <th scope="row"><label for="cp_module_limitlogs_max"><?php _e('Number of log entries to show', 'cp'); ?> :</label></th> <td valign="middle"><input type="text" id="cp_module_limitlogs_max" name="cp_module_limitlogs_max" value="<?php echo get_option('cp_module_limitlogs_max'); ?> " size="30" /></td> </tr> </table> <?php
<?php /** My Points Module */ cp_module_register(__('My Points', 'cp'), 'mypoints', '1.0', 'CubePoints', 'http://cubepoints.com', 'http://cubepoints.com', __('Allow users to see a history of their point transactions.', 'cp'), 1); function cp_module_mypoints_install() { //add_option('cp_module_mypoints_points', 5); } add_action('cp_module_mypoints_activate', 'cp_module_mypoints_install'); if (cp_module_activated('mypoints')) { add_action('admin_print_scripts-cubepoints_page_cp_modules_mypoints_admin', 'cp_datatables_script'); add_action('admin_print_styles-cubepoints_page_cp_modules_mypoints_admin', 'cp_datatables_style'); function cp_module_mypoints_add_admin_page() { add_submenu_page('cp_admin_manage', 'CubePoints - ' . __('My Points', 'cp'), __('My Points', 'cp'), 0, 'cp_modules_mypoints_admin', 'cp_modules_mypoints_admin'); } add_action('cp_admin_pages', 'cp_module_mypoints_add_admin_page'); function cp_modules_mypoints_admin() { echo '<div class="wrap">'; echo '<h2>CubePoints - ' . __('My Points', 'cp') . '</h2>'; echo __('Manage and view information about your points.', 'cp'); echo '<br /><br />'; echo '<div style="background:#EFEFEF;display:inline-block;margin-right:25px;"><div style="float:left;font-size:17px;font-weight:bold;background:#E0E0E0;padding:18px;color:#565656;">' . __('My Points', 'cp') . ':</div><div style="float:left;padding:18px;font-size:20px;">' . cp_getPoints(cp_currentUser()) . '</div></div>'; if (cp_module_activated('ranks')) { echo '<div style="background:#EFEFEF;display:inline-block;"><div style="float:left;font-size:17px;font-weight:bold;background:#E0E0E0;padding:18px;color:#565656;">' . __('My Rank', 'cp') . ':</div><div style="float:left;padding:18px;font-size:20px;">' . cp_module_ranks_getRank(cp_currentUser()) . '</div></div>'; } echo '<div style="clear:both;"></div><br />'; echo '<p style="font-weight:bold;">' . __('Your recent point transactions:', 'cp') . '</p>'; cp_show_logs(cp_currentUser(), 15, false); echo '</div>';
<?php /** Notify Module */ cp_module_register(__('Notify', 'cp'), 'notify', '1.1', 'CubePoints', 'http://cubepoints.com', 'http://cubepoints.com', __('After activating this module, a growl-like pop up will appear to your users each time they earn points.', 'cp'), 1); function cp_module_notify_install() { global $wpdb; if ($wpdb->get_var("SHOW TABLES LIKE '" . CP_DB . "_notify'") != CP_DB . '_notify' || (int) get_option('cp_module_notify_db_version') < 1) { $sql = "CREATE TABLE " . CP_DB . "_notify (\r\n\t\t\t id bigint(20) NOT NULL AUTO_INCREMENT,\r\n\t\t\t uid bigint(20) NOT NULL,\r\n\t\t\t notice text NOT NULL,\r\n\t\t\t UNIQUE KEY id (id)\r\n\t\t\t);"; require_once ABSPATH . 'wp-admin/includes/upgrade.php'; dbDelta($sql); add_option("cp_module_notify_db_version'", "1.0"); } } add_action('cp_module_notify_activate', 'cp_module_notify_install'); function cp_module_notify_uninstall() { global $wpdb; $wpdb->query('DROP TABLE `' . CP_DB . '_notify`'); } add_action('cp_module_notify_deactivate', 'cp_module_notify_uninstall'); if (cp_module_activated('notify')) { /********************** * Enqueuing Scripts ***********************/ wp_register_script('jQuery_notice', WP_PLUGIN_URL . '/' . str_replace(basename(__FILE__), "", plugin_basename(__FILE__)) . 'jquery.notice.js', array('jquery'), '1.0.1'); wp_register_style('jQuery_notice', WP_PLUGIN_URL . '/' . str_replace(basename(__FILE__), "", plugin_basename(__FILE__)) . 'jquery.notice.css'); function cp_notify_script() { wp_enqueue_script('jquery'); wp_enqueue_script('jQuery_notice');
<?php /** Donate Module */ cp_module_register(__('Donate', 'cp'), 'donate', '1.1', 'CubePoints', 'http://cubepoints.com', 'http://cubepoints.com', __('This module allows your users to donate points to each other.', 'cp'), 1); if (cp_module_activated('donate')) { function cp_module_donate_scripts() { wp_register_script('boxy', CP_PATH . 'assets/boxy/javascripts/jquery.boxy.js', array('jquery'), '0.1.4'); wp_register_style('boxy', CP_PATH . 'assets/boxy/stylesheets/boxy.css'); wp_enqueue_script('boxy'); wp_enqueue_style('boxy'); } add_action('init', 'cp_module_donate_scripts'); function cp_module_donate_do() { $recipient = $_POST['recipient']; $points = $_POST['points']; $message = htmlentities(stripslashes($_POST['message']), ENT_QUOTES, 'UTF-8'); $user = get_userdatabylogin($recipient); if (!is_user_logged_in()) { $r['success'] = false; $r['message'] = __('You must be logged in to make a donation!', 'cp'); } else { if ($recipient == '') { $r['success'] = false; $r['message'] = __('Please enter the username of the recipient!', 'cp'); } else { if ($user->ID == '') { $r['success'] = false; $r['message'] = __('You have entered an invalid recipient!', 'cp'); } else {
<?php /** Post Author Points Module */ cp_module_register(__('Post Author Points', 'cp'), 'post_author_points', '1.2', 'xBerry Labs', 'http://xBerryLabs.com', 'http://xBerryLabs.com', __('Gives points to authors when people comment on their posts', 'cp'), 1); function cp_module_post_author_points_install() { add_option('cp_post_author_points', 1); } add_action('cp_module_post_author_points_activate', 'cp_module_post_author_points_install'); if (cp_module_activated('post_author_points')) { function cp_module_post_author_points_config() { ?> <br /> <h3><?php _e('Post Author Points', 'cp'); ?> </h3> <table class="form-table"> <tr valign="top"> <th scope="row"><label for="cp_post_author_points"><?php _e('Points for comments on author posts', 'cp'); ?> :</label></th> <td valign="middle"><input type="text" id="cp_post_author_points" name="cp_post_author_points" value="<?php echo get_option('cp_post_author_points'); ?> " size="30" /></td> </tr> </table> <?php
<?php /** Paid Content Module */ cp_module_register(__('Paid Content', 'cp'), 'pcontent', '1.1', 'CubePoints', 'http://cubepoints.com', 'http://cubepoints.com', __('This module lets you deduct point from users to view a page or post.', 'cp'), 1); function cp_module_pcontent_install() { add_option('cp_module_pcontent_default_points', 10); add_option('cp_module_pcontent_default', false); add_option('cp_module_pcontent_payauthor', false); add_option('cp_module_pcontent_text_pay', __('You need to pay %points% to access this page.', 'cp')); add_option('cp_module_pcontent_text_button', __('Pay %points%', 'cp')); add_option('cp_module_pcontent_text_logout', __('You must be logged in to access this page.', 'cp')); add_option('cp_module_pcontent_text_insufficient', __('You have insufficient points to purchase access for this page.', 'cp')); } add_action('cp_module_pcontent_activate', 'cp_module_pcontent_install'); if (cp_module_activated('pcontent')) { /* Config for this module */ function cp_module_pcontent_config() { ?> <br /> <h3><?php _e('Paid Content', 'cp'); ?> </h3> <table class="form-table"> <tr valign="top"> <th scope="row"><label for="cp_module_pcontent_default_points"><?php _e('Default number of points', 'cp'); ?>
<?php /** Custom Points Module */ cp_module_register(__('Custom Points', 'cp'), 'customp', '1.0', 'CubePoints', 'http://cubepoints.com', 'http://cubepoints.com', __('This module gives you the ability to set custom points earned for comments for each post.', 'cp'), 1); if (cp_module_activated('customp')) { /* Define the custom box */ add_action('admin_init', 'cp_module_customp_add_custom_box', 1); /* Do something with the data entered */ add_action('save_post', 'cp_module_customp_save_postdata'); /* Adds a box to the main column on the Post and Page edit screens */ function cp_module_customp_add_custom_box() { add_meta_box('cp_module_customp_set', 'CubePoints - Custom Points', 'cp_module_customp_box', 'post', 'normal', 'high'); add_meta_box('cp_module_customp_set', 'CubePoints - Custom Points', 'cp_module_customp_box', 'page', 'normal', 'high'); } /* Prints the box content */ function cp_module_customp_box() { global $post; // Use nonce for verification wp_nonce_field(plugin_basename(__FILE__), 'cp_module_customp_nonce'); // The actual fields for data entry echo '<br /><input type="checkbox" id="cp_module_customp_enable" name="cp_module_customp_enable" value="1" size="25" ' . ((bool) get_post_meta($post->ID, 'cp_points_enable', 1) ? 'checked="yes"' : '') . ' /> '; echo '<label for="cp_module_customp_enable">' . __("Set custom points for comments on this page", 'cp') . '</label> '; echo '<br /><br />'; echo '<label for="cp_module_customp_points">' . __("Number of points per comment", 'cp') . ':</label> '; echo '<input type="text" id= "cp_module_customp_points" name="cp_module_customp_points" value="' . (int) get_post_meta($post->ID, 'cp_points', 1) . '" size="25" /><br /><br />'; } /* When the post is saved, saves our custom data */ function cp_module_customp_save_postdata($post_id) {
<?php /** Backup and Restore Module */ cp_module_register(__('Backup and Restore', 'cp'), 'backup', '1.0', 'CubePoints', 'http://cubepoints.com', 'http://cubepoints.com', __('Backup and restore the points of your users. Exports points in JSON or CSV format.', 'cp'), 1); if (cp_module_activated('backup')) { add_action('wp_ajax_cp_module_backup_down', 'wp_ajax_cp_module_backup_down'); function wp_ajax_cp_module_backup_down() { if (!current_user_can('manage_options')) { $response = json_encode(array()); echo $response; exit; } global $wpdb; $data = $wpdb->get_results('SELECT ' . $wpdb->base_prefix . 'users.id, ' . $wpdb->base_prefix . 'users.user_login, ' . $wpdb->base_prefix . 'users.user_email, ' . $wpdb->base_prefix . 'usermeta.meta_value FROM `' . $wpdb->base_prefix . 'users` LEFT JOIN `' . $wpdb->base_prefix . 'usermeta` ON ' . $wpdb->base_prefix . 'users.id = ' . $wpdb->base_prefix . 'usermeta.user_id AND ' . $wpdb->base_prefix . 'usermeta.meta_key=\'' . 'cpoints' . '\'' . $extraquery . ' ORDER BY ' . $wpdb->base_prefix . 'users.id ASC' . $limit . ';', ARRAY_N); foreach ($data as $x => $y) { $data[$x][3] = (int) $data[$x][3]; } switch ($_GET['fmt']) { default: case 'json': header("Content-Type: application/json"); header('Content-Disposition: attachment; filename="' . __('backup', 'cp') . '_' . time() . '.json"'); echo json_encode($data); exit; break; case 'csv':
<?php /** Daily Points Module */ cp_module_register(__('Daily Points', 'cp'), 'dailypoints', '1.0', 'CubePoints', 'http://cubepoints.com', 'http://cubepoints.com', __('Give your users points for visiting your site everyday or every fixed interval.', 'cp'), 1); function cp_module_dailypoints_install() { add_option('cp_module_dailypoints_points', 5); add_option('cp_module_dailypoints_time', 86400); } add_action('cp_module_dailypoints_activate', 'cp_module_dailypoints_install'); if (cp_module_activated('dailypoints')) { function cp_module_dailypoints_checkTimer() { if (!is_user_logged_in()) { return; } $uid = cp_currentUser(); $time = get_option('cp_module_dailypoints_time'); $difference = time() - $time; global $wpdb; $count = (int) $wpdb->get_var("SELECT COUNT(*) FROM " . CP_DB . " WHERE `uid`={$uid} AND `timestamp`>{$difference} AND `type`='dailypoints'"); if ($count != 0) { return; } cp_points('dailypoints', $uid, get_option('cp_module_dailypoints_points'), ''); } add_action('init', 'cp_module_dailypoints_checkTimer', 1); function cp_module_dailypoints_config() { ?> <br />
Description: Adds CubePoints support to Buddypress. Reward members using your BuddyPress portion of your website by giving them points and awards! Version: 1.9.8.9 Revision Date: Sep 14, 2012 Requires at least: WP 3.1, BuddyPress 1.2.5.2, Cubepoints 3.0.1 Tested up to: WP 3.4.1, BuddyPress 1.6.1, CubePoints 3.1.1 License: GNU General Public License 2.0 (GPL) http://www.gnu.org/licenses/gpl.html Author: Tosh Hatch Author URI: http://www.SlySpyder.com Contributors: @xberserker Network: false */ define('BP_CUBEPOINT_VERSION', '1.9.8.9'); define('CP_BUDDYPRESS_PATH', WP_PLUGIN_URL . '/' . str_replace(basename(__FILE__), "", plugin_basename(__FILE__))); if (in_array('cubepoints/cubepoints.php', apply_filters('active_plugins', get_option('active_plugins')))) { require_once WP_PLUGIN_DIR . '/cubepoints/cp_core.php'; cp_module_register('BuddyPress Integration', 'cpbpintegration', BP_CUBEPOINT_VERSION, 'Tosh Hatch', 'http://www.SlySpyder.com', 'http://buddypress.org/community/groups/cubepoints-buddypress-integration/activity/', 'Adds CubePoints support to Buddypress. Reward members using your BuddyPress portion of your website by giving them points and awards!', false); } /** * Attaches plugin to Buddypress and starts the BuddyPress CubePoints core. * * This function is REQUIRED to prevent WordPress from white-screening if plugin is activated on a * system that does not have an active copy of BuddyPress. * */ function bp_cubepoint_init() { require dirname(__FILE__) . '/includes/bp-cubepoint-core.php'; do_action('bp_cubepoint_init'); } if (function_exists('cp_ready')) { add_action('bp_include', 'bp_cubepoint_init');
<?php /** Ranks Module */ cp_module_register(__('Ranks', 'cp'), 'ranks', '1.0', 'CubePoints', 'http://cubepoints.com', 'http://cubepoints.com', __('Create and display user ranks based on the number of points they have.', 'cp'), 1); function cp_module_ranks_data_install() { add_option('cp_module_ranks_data', array(0 => __('Newbie', 'cp'))); } add_action('cp_module_ranks_activate', 'cp_module_ranks_data_install'); if (cp_module_activated('ranks')) { function cp_module_ranks_data_add_admin_page() { add_submenu_page('cp_admin_manage', 'CubePoints - ' . __('Ranks', 'cp'), __('Ranks', 'cp'), 8, 'cp_modules_ranks_admin', 'cp_modules_ranks_admin'); } add_action('cp_admin_pages', 'cp_module_ranks_data_add_admin_page'); function cp_modules_ranks_admin() { // handles form submissions if ($_POST['cp_module_ranks_data_form_submit'] == 'Y') { $cp_module_ranks_data_rank = trim($_POST['cp_module_ranks_data_rank']); $cp_module_ranks_data_points = (int) trim($_POST['cp_module_ranks_data_points']); $ranks = get_option('cp_module_ranks_data'); if ($cp_module_ranks_data_rank == '' || $_POST['cp_module_ranks_data_points'] == '') { echo '<div class="error"><p><strong>' . __('Rank name or points cannot be empty!', 'cp') . '</strong></p></div>'; } else { if (!is_numeric($_POST['cp_module_ranks_data_points']) || $cp_module_ranks_data_points < 0 || (int) $_POST['cp_module_ranks_data_points'] != (double) $_POST['cp_module_ranks_data_points']) { echo '<div class="error"><p><strong>' . __('Please enter only positive integers for the points!', 'cp') . '</strong></p></div>'; } else { if ($ranks[$cp_module_ranks_data_points] != '') { echo '<div class="updated"><p><strong>' . __('Rank Updated', 'cp') . '</strong></p></div>'; } else {
<?php /** YouTube Module */ cp_module_register(__('YouTube', 'cp'), 'youtube', '1.0', 'CubePoints', 'http://cubepoints.com', 'http://cubepoints.com', __('Let users earn points for watching YouTube videos.', 'cp'), 1); function cp_module_youtube_points_install() { add_option('cp_module_youtube_points', 10); } add_action('cp_module_youtube_activate', 'cp_module_youtube_points_install'); if (cp_module_activated('youtube')) { function cp_module_youtube_config() { ?> <br /> <h3><?php _e('YouTube', 'cp'); ?> </h3> <table class="form-table"> <tr valign="top"> <th scope="row"><label for="cp_module_youtube_points"><?php _e('Default number of points for watching a YouTube video', 'cp'); ?> :</label></th> <td valign="middle"><input type="text" id="cp_module_youtube_points" name="cp_module_youtube_points" value="<?php echo get_option('cp_module_youtube_points'); ?> " size="30" /></td> </tr> </table> <?php
<?php /** Reset Data Module */ cp_module_register(__('Reset Data', 'cp'), 'resetdata', '1.0', 'CubePoints', 'http://cubepoints.com', 'http://cubepoints.com', __('Erases all point data from the database.', 'cp'), 1); if (cp_module_activated('resetdata')) { function cp_module_resetdata_add_admin_page() { add_submenu_page('cp_admin_manage', 'CubePoints - ' . __('Reset Data', 'cp'), __('Reset Data', 'cp'), 'manage_options', 'cp_modules_resetdata_admin', 'cp_modules_resetdata_admin'); } add_action('cp_admin_pages', 'cp_module_resetdata_add_admin_page'); function cp_modules_resetdata_admin() { // handles form submissions if ($_POST['cp_module_resetdata_form_submit'] == 'Y') { global $wpdb; $wpdb->query('TRUNCATE TABLE `' . CP_DB . '`'); $wpdb->query('UPDATE `' . $wpdb->base_prefix . 'usermeta` SET `meta_value` = 0 WHERE `meta_key` = \'cpoints\''); echo '<div class="updated"><p><strong>' . __('Database reseted!', 'cp') . '</strong></p></div>'; } ?> <div class="wrap"> <h2>CubePoints - <?php _e('CubePoints - Reset Data', 'cp'); ?> </h2> <?php _e('Erase all point data from the database.', 'cp'); ?> <br /><br />
<?php /** Comment Spam Control Module */ cp_module_register(__('Comment Spam Control', 'cp'), 'cp_csc', '1.1', 'CubePoints', 'http://cubepoints.com', 'http://cubepoints.com', __('When enabled, this module would only allow users to receive points for one comment per post.', 'cp'), 1); if (cp_module_activated('cp_csc')) { add_action('cp_comment_add', 'cp_module_csc_newComment'); function cp_module_csc_newComment($cid) { if (is_user_logged_in()) { $cdata = get_comment($cid); $uid = $cdata->user_id; $pid = $cdata->comment_post_ID; global $wpdb; if ((int) $wpdb->get_var("SELECT COUNT(*) FROM {$wpdb->comments} WHERE `user_id`={$uid} AND `comment_post_ID`={$pid} AND comment_approved=1") != 1) { add_filter('cp_comment_points', create_function('$points', 'return 0;'), 10); } } } }
<?php /** PayPal Top-up Module */ cp_module_register(__('PayPal Top-up', 'cp'), 'paypal', '1.2', 'CubePoints', 'http://cubepoints.com', 'http://cubepoints.com', __('Allow users to buy points using PayPal.', 'cp'), 1); function cp_module_paypal_install() { add_option('cp_module_paypal_account', ''); add_option('cp_module_paypal_sandbox', false); add_option('cp_module_paypal_currency', 'USD'); add_option('cp_module_paypal_item', '%npoints% ' . get_bloginfo('name') . ' ' . __('Points', 'cp')); add_option('cp_module_paypal_cancel', get_bloginfo('url') . '/?cp_module_paypal_return=0'); add_option('cp_module_paypal_thankyou', get_bloginfo('url') . '/?cp_module_paypal_return=1'); add_option('cp_module_paypal_price', 0.05); add_option('cp_module_paypal_min', 1); add_option('cp_module_paypal_form', "<form method=\"post\">\n<input type=\"hidden\" name=\"cp_module_paypal_pay\" value=\"1\" />\nNumber of points to purchase:<br />\n<input type=\"text\" name=\"points\" /><br />\n<input type=\"submit\" value=\"Buy!\" />\n</form>"); } add_action('cp_module_paypal_activate', 'cp_module_paypal_install'); if (cp_module_activated('paypal')) { function cp_module_paypal_shortcode($atts) { $r = get_option('cp_module_paypal_form'); $r = str_replace('%min%', get_option('cp_module_paypal_min'), $r); return $r; } add_shortcode('cp_paypal', 'cp_module_paypal_shortcode'); /** PayPal top-up logs hook */ add_action('cp_logs_description', 'cp_module_paypal_logs', 10, 4); function cp_module_paypal_logs($type, $uid, $points, $data) { if ($type != 'paypal') { return;
<?php /** Points Multiplier Module */ cp_module_register(__('Points Multiplier', 'cp'), 'pmultiply', '1.0', 'CubePoints', 'http://cubepoints.com', 'http://cubepoints.com', __('This module allows you to temporarily double, triple points earned by users. Useful if you wish to increase user activity in a particular week. You may also use this module to temporarily disable points from being earned.', 'cp'), 1); function cp_module_pmultiply_install() { add_option('cp_module_pmultiply_multiplier', 2); } add_action('cp_module_pmultiply_activate', 'cp_module_pmultiply_install'); if (cp_module_activated('pmultiply')) { function cp_module_pmultiply_config() { ?> <br /> <h3><?php _e('Points Multiplier', 'cp'); ?> </h3> <table class="form-table"> <tr valign="top"> <th scope="row"><label for="cp_module_pmultiply_multiplier"><?php _e('Multiply points earned by', 'cp'); ?> :</label></th> <td valign="middle"><input type="text" id="cp_module_pmultiply_multiplier" name="cp_module_pmultiply_multiplier" value="<?php echo get_option('cp_module_pmultiply_multiplier'); ?> " size="30" /></td> </tr> </table> <?php
<?php /** Limit Comment Points Module */ cp_module_register(__('Limit Comment Points', 'cp'), 'lcpoints', '1.0', 'CubePoints', 'http://cubepoints.com', 'http://cubepoints.com', __('Limits the number of comments that would earn points for users across all posts.', 'cp'), 1); function cp_module_lcpoints_install() { add_option('cp_module_lcpoints_limit', 5); } add_action('cp_module_lcpoints_activate', 'cp_module_lcpoints_install'); if (cp_module_activated('lcpoints')) { function cp_module_lcpoints_config() { ?> <br /> <h3><?php _e('Limit Comment Points', 'cp'); ?> </h3> <table class="form-table"> <tr valign="top"> <th scope="row"><label for="cp_module_lcpoints_limit"><?php _e('Max number of comments earning points', 'cp'); ?> :</label></th> <td valign="middle"><input type="text" id="cp_module_lcpoints_limit" name="cp_module_lcpoints_limit" value="<?php echo get_option('cp_module_lcpoints_limit'); ?> " size="30" /></td> </tr> </table> <?php