Plugin Directory

Changeset 626094


Ignore:
Timestamp:
11/16/2012 12:05:52 PM (12 years ago)
Author:
lauweijie7715
Message:

version 3.2

Location:
cubepoints/trunk
Files:
15 edited

Legend:

Unmodified
Added
Removed
  • cubepoints/trunk/cp_admin_add_points.php

    r445086 r626094  
    5959        });
    6060        jQuery("#cp_add_points_user").autocomplete({
    61             url: "<?php echo bloginfo('url').'/wp-admin/admin-ajax.php'; ?>",
     61            url: ajaxurl,
    6262            extraParams: { action: 'cp_add_points_user_suggest' },
    6363            matchSubset: 0,
     
    9191            }
    9292            this.cp_add_points_ajax_query = jQuery.ajax({
    93                 url: "<?php echo bloginfo('url').'/wp-admin/admin-ajax.php'; ?>",
     93                url: ajaxurl,
    9494                data: { 'q': q, 'action': 'cp_add_points_user_query' },
    9595                cache: false,
     
    154154                jQuery('#cp_add_points_loading').show(100);
    155155                this.cp_add_points_ajax_query = jQuery.ajax({
    156                     url: "<?php echo bloginfo('url').'/wp-admin/admin-ajax.php'; ?>",
     156                    url: ajaxurl,
    157157                    type: "POST",
    158158                    data: { 'id': id, 'points': points, 'description': description, 'action': 'cp_add_points_user_update' },
  • cubepoints/trunk/cp_admin_manage.php

    r373336 r626094  
    7171
    7272                jQuery.post(
    73                     '<?php echo bloginfo('url').'/wp-admin/admin-ajax.php'; ?>',
     73                    ajaxurl,
    7474                    {
    7575                        action: 'cp_manage_form_submit',
  • cubepoints/trunk/cp_widgets.php

    r571698 r626094  
    44 */
    55
    6 add_action('widgets_init', 'cp_widgets');
    7 
    8 function cp_widgets(){
    9 
    10     /** CubePoints Widget */
    11     class cp_pointsWidget extends WP_Widget {
    12      
    13         // constructor
    14         function cp_pointsWidget() {
    15             parent::WP_Widget('cp_pointsWidget', 'CubePoints', array('description' => 'Display the points of the current logged in user.'));   
    16         }
    17      
    18         // widget main
    19         function widget($args, $instance) {
    20             extract($args, EXTR_SKIP);
    21             if (!(!is_user_logged_in()&&$instance['text_alt']=='')) {
     6/** CubePoints Points Widget declaration */
     7class cp_pointsWidget extends WP_Widget {
     8 
     9    // constructor
     10    function cp_pointsWidget() {
     11        parent::WP_Widget('cp_pointsWidget', 'CubePoints', array('description' => 'Display the points of the current logged in user.'));   
     12    }
     13 
     14    // widget main
     15    function widget($args, $instance) {
     16        extract($args, EXTR_SKIP);
     17        if (!(!is_user_logged_in() && $instance['text_alt']=='')) {
    2218            echo $before_widget;
    2319            $title = empty($instance['title']) ? '&nbsp;' : apply_filters('widget_title', $instance['title']);
    2420            if ( !empty( $title ) ) { echo $before_title . $title . $after_title; };
    25             if(is_user_logged_in()) {
     21            if (is_user_logged_in()) {
     22                // Set default text, in case something messes up and resets the text to display to be null
     23                if($instance['text'] == '') {
     24                    $instance['text'] = 'Points: %points%';
     25                }
    2626                $string = str_replace('%points%', '<span class="cp_points_display">'.cp_displayPoints(0,1,1).'</span>', $instance['text']);
    27             }
    28             else{
     27            } else {
    2928                $string = $instance['text_alt'];
    3029            }
     30           
     31            //start output
     32            do_action('cp_pointsWidget_before');
     33            if($instance['html']==''){
    3134            ?>
    32             <?php do_action('cp_pointsWidget_before'); ?>
    33             <?php if($instance['html']==''){ ?>
    34             <ul>
    35                     <li><?php echo $string; ?></li>
    36                     <?php do_action('cp_pointsWidget'); ?>
    37             </ul>
     35                <ul>
     36                        <li><?php echo $string; ?></li>
     37                        <?php do_action('cp_pointsWidget'); ?>
     38                </ul>
    3839            <?php
    3940            } else {
    4041                echo str_replace('%text%',$string,$instance['html']);
    4142            }
    42             ?>
    43             <?php do_action('cp_pointsWidget_after'); ?>
    44             <?php
     43            do_action('cp_pointsWidget_after');
    4544            echo $after_widget;
    46             }
    47         }
    48      
    49         // widget settings update
    50         function update($new_instance, $old_instance) {
    51             $instance = $old_instance;
    52             $instance['title'] = strip_tags($new_instance['title']);
    53             $instance['text'] = trim($new_instance['text']);
    54             $instance['text_alt'] = trim($new_instance['text_alt']);
    55             $instance['html'] = trim($new_instance['html']);
    56             return $instance;
    57         }
    58      
    59         // widget settings form
    60         function form($instance) {
    61             $default =  array( 'title' => __('My Points', 'cp') , 'text' => __('Points', 'cp') . ': %points%' , 'text_alt' => __('You need to be logged in to view your points.', 'cp'), 'advanced' => '' );
    62             $instance = wp_parse_args( (array) $instance, $default );
    63      
    64             $field = 'title';
    65             $field_id = $this->get_field_id($field);
    66             $field_name = $this->get_field_name($field);
    67             echo "\r\n".'<p><label for="'.$field_id.'">'.__('Title', 'cp').': <input type="text" class="widefat" id="'.$field_id.'" name="'.$field_name.'" value="'.esc_attr( $instance[$field] ).'" /><label></p>';
    68            
    69             $field = 'text';
    70             $field_id = $this->get_field_id($field);
    71             $field_name = $this->get_field_name($field);
    72             echo "\r\n".'<p><label for="'.$field_id.'">'.__('Text', 'cp').': <input type="text" class="widefat" id="'.$field_id.'" name="'.$field_name.'" value="'.esc_attr( $instance[$field] ).'" /><label></p>';
    73            
    74             echo "\r\n".'<small><strong>'.__('Note', 'cp').':</strong> '.__('%points% would be replaced with the points of the logged in user', 'cp').'</small><br /><br />';
    75            
    76             $field = 'text_alt';
    77             $field_id = $this->get_field_id($field);
    78             $field_name = $this->get_field_name($field);
    79             echo "\r\n".'<p><label for="'.$field_id.'">'.__('Text if user not logged in', 'cp').': <input type="text" class="widefat" id="'.$field_id.'" name="'.$field_name.'" value="'.esc_attr( $instance[$field] ).'" /><label></p>';
    80            
    81             echo "\r\n".'<small><strong>'.__('Note', 'cp').':</strong> '.__('Leave this field blank to hide the widget if no user is logged in', 'cp').'</small><br /><br />';
    82            
    83             $field = 'html';
    84             $field_id = $this->get_field_id($field);
    85             $field_name = $this->get_field_name($field);
    86       if ( !isset($instance[$field]) ) $instance[$field] = '';
    87             echo "\r\n".'<p><label for="'.$field_id.'">'.__('HTML Code (advanced)', 'cp').': <textarea class="widefat" id="'.$field_id.'" name="'.$field_name.'" >'.esc_attr( $instance[$field] ).'</textarea><label></p>';
    88 
    89             echo "\r\n".'<small><strong>'.__('Note', 'cp').':</strong> '.__('This field should be left blank for most users! You may use this field to customize the appearance of this widget.', 'cp').'<br /><br /><strong>'.__('Shortcode', 'cp').':</strong> %text%</small>';
    90            
    9145        }
    9246    }
    93     // register widget
     47 
     48    // widget settings update
     49    function update($new_instance, $old_instance) {
     50        $instance = $old_instance;
     51        $instance['title'] = strip_tags($new_instance['title']);
     52        $instance['text'] = trim($new_instance['text']);
     53        $instance['text_alt'] = trim($new_instance['text_alt']);
     54        $instance['html'] = trim($new_instance['html']);
     55        return $instance;
     56    }
     57 
     58    // widget settings form
     59    function form($instance) {
     60        $default =  array( 'title' => __('My Points', 'cp') , 'text' => __('Points', 'cp') . ': %points%' , 'text_alt' => __('You need to be logged in to view your points.', 'cp'), 'advanced' => '' );
     61        $instance = wp_parse_args( (array) $instance, $default );
     62 
     63        $field = 'title';
     64        $field_id = $this->get_field_id($field);
     65        $field_name = $this->get_field_name($field);
     66        echo "\r\n".'<p><label for="'.$field_id.'">'.__('Title', 'cp').': <input type="text" class="widefat" id="'.$field_id.'" name="'.$field_name.'" value="'.esc_attr( $instance[$field] ).'" /><label></p>';
     67       
     68        $field = 'text';
     69        $field_id = $this->get_field_id($field);
     70        $field_name = $this->get_field_name($field);
     71        echo "\r\n".'<p><label for="'.$field_id.'">'.__('Text', 'cp').': <input type="text" class="widefat" id="'.$field_id.'" name="'.$field_name.'" value="'.esc_attr( $instance[$field] ).'" /><label></p>';
     72       
     73        echo "\r\n".'<small><strong>'.__('Note', 'cp').':</strong> '.__('%points% would be replaced with the points of the logged in user', 'cp').'</small><br /><br />';
     74       
     75        $field = 'text_alt';
     76        $field_id = $this->get_field_id($field);
     77        $field_name = $this->get_field_name($field);
     78        echo "\r\n".'<p><label for="'.$field_id.'">'.__('Text if user not logged in', 'cp').': <input type="text" class="widefat" id="'.$field_id.'" name="'.$field_name.'" value="'.esc_attr( $instance[$field] ).'" /><label></p>';
     79       
     80        echo "\r\n".'<small><strong>'.__('Note', 'cp').':</strong> '.__('Leave this field blank to hide the widget if no user is logged in', 'cp').'</small><br /><br />';
     81       
     82        $field = 'html';
     83        $field_id = $this->get_field_id($field);
     84        $field_name = $this->get_field_name($field);
     85        if ( !isset($instance[$field]) ) $instance[$field] = '';
     86        echo "\r\n".'<p><label for="'.$field_id.'">'.__('HTML Code (advanced)', 'cp').': <textarea class="widefat" id="'.$field_id.'" name="'.$field_name.'" >'.esc_attr( $instance[$field] ).'</textarea><label></p>';
     87
     88        echo "\r\n".'<small><strong>'.__('Note', 'cp').':</strong> '.__('This field should be left blank for most users! You may use this field to customize the appearance of this widget.', 'cp').'<br /><br /><strong>'.__('Shortcode', 'cp').':</strong> %text%</small>';
     89    }
     90}
     91
     92/** CubePoints Top Users Widget */
     93class cp_topUsersWidget extends WP_Widget {
     94 
     95    // constructor
     96    function cp_topUsersWidget() {
     97        parent::WP_Widget('cp_topUsersWidget', 'CubePoints Top Users', array('description' => 'Use this widget to showcase the users with the most points.')); 
     98    }
     99 
     100    // widget main
     101    function widget($args, $instance) {
     102        extract($args, EXTR_SKIP);
     103        echo $before_widget;
     104        $title = empty($instance['title']) ? '&nbsp;' : apply_filters('widget_title', $instance['title']);
     105        if ( !empty( $title ) ) { echo $before_title . $title . $after_title; };
     106
     107        //set default values
     108        if($instance['num'] == '' || $instance['num'] == 0) { $instance['num'] = 1; }
     109        if($instance['text'] == '') { $instance['text'] = '%user% (%points%)';}
     110
     111        $top = cp_getAllPoints($instance['num'],get_option('cp_topfilter'));
     112        do_action('cp_topUsersWidget_before');
     113        echo apply_filters('cp_topUsersWidget_before','<ul>');
     114        $line = apply_filters('cp_topUsersWidget_line','<li class="cp_topUsersWidget top_%place%" style="%style%">%string%</li>');
     115        $line = str_replace('%style%', $instance['style'], $line);
     116        foreach($top as $x=>$y){
     117            $user = get_userdata($y['id']);
     118            $string = str_replace('%string%', '', $instance['text']);
     119            $string = str_replace('%string%',$string,$line);
     120            $string = apply_filters('cp_displayUserInfo',$string,$y,$x+1);
     121            echo $string;
     122        }
     123        echo apply_filters('cp_topUsersWidget_after','</ul>');
     124        do_action('cp_topUsersWidget_after');
     125        echo $after_widget;
     126    }
     127 
     128    // widget settings update
     129    function update($new_instance, $old_instance) {
     130        $instance = $old_instance;
     131        $instance['title'] = strip_tags($new_instance['title']);
     132        $instance['num'] = ((int) $new_instance['num'] > 0 ) ? (int) $new_instance['num'] : 1 ;
     133        $instance['text'] = trim($new_instance['text']);
     134        $instance['style'] = trim($new_instance['style']);
     135        return $instance;
     136    }
     137 
     138    // widget settings form
     139    function form($instance) {
     140        $default =  array( 'title' => __('Top Users', 'cp') , 'num' => 3 , 'text' => '%user% (%points%)', 'style' => 'list-style:none;' );
     141        $instance = wp_parse_args( (array) $instance, $default );
     142 
     143        $field = 'title';
     144        $field_id = $this->get_field_id($field);
     145        $field_name = $this->get_field_name($field);
     146        echo "\r\n".'<p><label for="'.$field_id.'">'.__('Title', 'cp').': <input type="text" class="widefat" id="'.$field_id.'" name="'.$field_name.'" value="'.esc_attr( $instance[$field] ).'" /><label></p>';
     147       
     148        $field = 'num';
     149        $field_id = $this->get_field_id($field);
     150        $field_name = $this->get_field_name($field);
     151        echo "\r\n".'<p><label for="'.$field_id.'">'.__('Number of top users to show', 'cp').': <input type="text" class="widefat" id="'.$field_id.'" name="'.$field_name.'" value="'.esc_attr( $instance[$field] ).'" /><label></p>';
     152       
     153        $field = 'text';
     154        $field_id = $this->get_field_id($field);
     155        $field_name = $this->get_field_name($field);
     156        echo "\r\n".'<p><label for="'.$field_id.'">'.__('Text', 'cp').': <input type="text" class="widefat" id="'.$field_id.'" name="'.$field_name.'" value="'.esc_attr( $instance[$field] ).'" /><label></p>';
     157
     158        echo "\r\n".'<small><strong>'.__('Shortcodes', 'cp') . ':</strong><br />';
     159        echo __('Number of points', 'cp') . ' - %points%' . '<br />';
     160        echo __('Points (number only)', 'cp') . ' - %npoints%' . '<br />';
     161        echo __('User display name', 'cp') . ' - %username%' . '<br />';
     162        echo __('User login ID', 'cp') . ' - %user%' . '<br />';
     163        echo __('User ID', 'cp') . ' - %userid%' . '<br />';
     164        echo __('User ranking', 'cp') . ' - %place%' . '<br />';
     165        echo __('Email MD5 hash', 'cp') . ' - %emailhash%' . '<br />';
     166        echo '<br /></small>';
     167       
     168        $field = 'style';
     169        $field_id = $this->get_field_id($field);
     170        $field_name = $this->get_field_name($field);
     171        echo "\r\n".'<p><label for="'.$field_id.'">'.__('Style', 'cp').': <input type="text" class="widefat" id="'.$field_id.'" name="'.$field_name.'" value="'.esc_attr( $instance[$field] ).'" /><label></p>';
     172        echo "\r\n".'<small><strong>'.__('Note', 'cp') . ':</strong> '.__('This adds the following style to the list element. Shortcodes from above may be used here. The %emailhash% shortcode, for example, could be used to display gravatars.', 'cp').'</small><br />';
     173    }
     174}
     175
     176add_action('widgets_init', 'cp_widgets');
     177
     178function cp_widgets(){ 
     179    // register points widget
    94180    register_widget("cp_pointsWidget");
    95181
    96    
    97     /** CubePoints Top Users Widget */
    98     class cp_topUsersWidget extends WP_Widget {
    99      
    100         // constructor
    101         function cp_topUsersWidget() {
    102             parent::WP_Widget('cp_topUsersWidget', 'CubePoints Top Users', array('description' => 'Use this widget to showcase the users with the most points.')); 
    103         }
    104      
    105         // widget main
    106         function widget($args, $instance) {
    107             extract($args, EXTR_SKIP);
    108             echo $before_widget;
    109             $title = empty($instance['title']) ? '&nbsp;' : apply_filters('widget_title', $instance['title']);
    110             if ( !empty( $title ) ) { echo $before_title . $title . $after_title; };
    111             $top = cp_getAllPoints($instance['num'],get_option('cp_topfilter'));
    112             do_action('cp_topUsersWidget_before');
    113             echo apply_filters('cp_topUsersWidget_before','<ul>');
    114             $line = apply_filters('cp_topUsersWidget_line','<li class="cp_topUsersWidget top_%place%" style="%style%">%string%</li>');
    115             $line = str_replace('%style%', $instance['style'], $line);
    116             foreach($top as $x=>$y){
    117                 $user = get_userdata($y['id']);
    118                 $string = str_replace('%string%', '', $instance['text']);
    119                 $string = str_replace('%string%',$string,$line);
    120                 $string = apply_filters('cp_displayUserInfo',$string,$y,$x+1);
    121                 echo $string;
    122             }
    123             echo apply_filters('cp_topUsersWidget_after','</ul>');
    124             do_action('cp_topUsersWidget_after');
    125             echo $after_widget;
    126         }
    127      
    128         // widget settings update
    129         function update($new_instance, $old_instance) {
    130             $instance = $old_instance;
    131             $instance['title'] = strip_tags($new_instance['title']);
    132             $instance['num'] = ((int) $new_instance['num'] > 0 ) ? (int) $new_instance['num'] : 1 ;
    133             $instance['text'] = trim($new_instance['text']);
    134             $instance['style'] = trim($new_instance['style']);
    135             return $instance;
    136         }
    137      
    138         // widget settings form
    139         function form($instance) {
    140             $default =  array( 'title' => __('Top Users', 'cp') , 'num' => 3 , 'text' => '%user% (%points%)', 'style' => 'list-style:none;' );
    141             $instance = wp_parse_args( (array) $instance, $default );
    142      
    143             $field = 'title';
    144             $field_id = $this->get_field_id($field);
    145             $field_name = $this->get_field_name($field);
    146             echo "\r\n".'<p><label for="'.$field_id.'">'.__('Title', 'cp').': <input type="text" class="widefat" id="'.$field_id.'" name="'.$field_name.'" value="'.esc_attr( $instance[$field] ).'" /><label></p>';
    147            
    148             $field = 'num';
    149             $field_id = $this->get_field_id($field);
    150             $field_name = $this->get_field_name($field);
    151             echo "\r\n".'<p><label for="'.$field_id.'">'.__('Number of top users to show', 'cp').': <input type="text" class="widefat" id="'.$field_id.'" name="'.$field_name.'" value="'.esc_attr( $instance[$field] ).'" /><label></p>';
    152            
    153             $field = 'text';
    154             $field_id = $this->get_field_id($field);
    155             $field_name = $this->get_field_name($field);
    156             echo "\r\n".'<p><label for="'.$field_id.'">'.__('Text', 'cp').': <input type="text" class="widefat" id="'.$field_id.'" name="'.$field_name.'" value="'.esc_attr( $instance[$field] ).'" /><label></p>';
    157 
    158             echo "\r\n".'<small><strong>'.__('Shortcodes', 'cp') . ':</strong><br />';
    159             echo __('Number of points', 'cp') . ' - %points%' . '<br />';
    160             echo __('Points (number only)', 'cp') . ' - %npoints%' . '<br />';
    161             echo __('User display name', 'cp') . ' - %username%' . '<br />';
    162             echo __('User login ID', 'cp') . ' - %user%' . '<br />';
    163             echo __('User ID', 'cp') . ' - %userid%' . '<br />';
    164             echo __('User ranking', 'cp') . ' - %place%' . '<br />';
    165             echo __('Email MD5 hash', 'cp') . ' - %emailhash%' . '<br />';
    166             echo '<br /></small>';
    167            
    168             $field = 'style';
    169             $field_id = $this->get_field_id($field);
    170             $field_name = $this->get_field_name($field);
    171             echo "\r\n".'<p><label for="'.$field_id.'">'.__('Style', 'cp').': <input type="text" class="widefat" id="'.$field_id.'" name="'.$field_name.'" value="'.esc_attr( $instance[$field] ).'" /><label></p>';
    172             echo "\r\n".'<small><strong>'.__('Note', 'cp') . ':</strong> '.__('This adds the following style to the list element. Shortcodes from above may be used here. The %emailhash% shortcode, for example, could be used to display gravatars.', 'cp').'</small><br />';
    173         }
    174     }
    175     // register widget
     182    // register top users widget
    176183    register_widget("cp_topUsersWidget");
    177184   
  • cubepoints/trunk/cubepoints.php

    r571698 r626094  
    44Plugin URI: http://cubepoints.com
    55Description: CubePoints is a point management system designed for WordPress blogs. Users can earn points by posting comments on your site. To display user's points, just put <code>&lt;?php cp_displayPoints(); ?&gt;</code> in your template or activate the sidebar widget.
    6 Version: 3.1.1
     6Version: 3.2
    77Author: Jonathan Lau & Peter Zhang
    88Author URI: http://cubepoints.com
     
    1212
    1313/** Define constants */
    14 define('CP_VER', '3.1.1');
     14define('CP_VER', '3.2');
    1515define('CP_DB', $wpdb->base_prefix . 'cp');
    1616define('CP_PATH', WP_PLUGIN_URL.'/'.str_replace(basename( __FILE__),"",plugin_basename(__FILE__)));
  • cubepoints/trunk/modules/backup.php

    r445086 r626094  
    5555
    5656    function cp_module_backup_data_add_admin_page(){
    57         add_submenu_page('cp_admin_manage', 'CubePoints - ' .__('Backup and Restore','cp'), __('Backup &amp; Restore','cp'), 8, 'cp_modules_backup_admin', 'cp_modules_backup_admin');
     57        add_submenu_page('cp_admin_manage', 'CubePoints - ' .__('Backup and Restore','cp'), __('Backup &amp; Restore','cp'), 'manage_options', 'cp_modules_backup_admin', 'cp_modules_backup_admin');
    5858    }
    5959    add_action('cp_admin_pages','cp_module_backup_data_add_admin_page');
  • cubepoints/trunk/modules/custom_points.php

    r373336 r626094  
    7171
    7272    /* Add CubePoints comment action hook */
    73     add_action('cp_newComment', 'cp_module_customp_newComment');
     73    add_action('cp_comment_add', 'cp_module_customp_newComment');
    7474        function cp_module_customp_newComment($cid) {
    7575            if (is_user_logged_in()) {
  • cubepoints/trunk/modules/donate/donate.js

    r384401 r626094  
    1 function cp_module_donate_do(){
    2     jQuery.ajax({
    3         url: cp_donate.ajax_url,
    4         type: "POST",
    5         cache: false,
    6         dataType: "json",
    7         data: {action: "cp_module_donate_do", recipient: jQuery('#cp_recipient').val(), points: jQuery('#cp_points').val(), message: jQuery('#cp_message').val()},
    8         success: function(data){
    9             if(data.success==true){
    10                 Boxy.alert(data.message);
    11                 thebox.hide();
    12                 thebox.unload();
    13                 jQuery('.cp_points_display').html(data.pointsd);
     1// Numeric only control handler
     2jQuery.fn.ForceNumericOnly =
     3function()
     4{
     5    return this.each(function()
     6    {
     7        jQuery(this).keydown(function(e)
     8        {
     9            var key = e.charCode || e.keyCode || 0;
     10            // allow backspace, tab, delete, arrows, numbers and keypad numbers ONLY
     11            return (
     12                key == 8 ||
     13                key == 9 ||
     14                key == 46 ||
     15                (key >= 37 && key <= 40) ||
     16                (key >= 48 && key <= 57) ||
     17                (key >= 96 && key <= 105));
     18        });
     19    });
     20};
     21
     22function cp_module_donate(s){
     23    showDropdownSearch(s);
     24}
     25
     26function showDropdownSearch(s){
     27    var html0 = '<div id="optionsearch">'+
     28                '<h3>' + cp_donate.title + '</h3>'+
     29                '<div class="textinput"><label for="cp_searchquery"> ' + cp_donate.searchText + ' <span id="optionsearchstatus">' + cp_donate.searchingText + '</span></label><input type="search" id="cp_searchquery" name="cp_searchquery" value="" placeholder="' + cp_donate.searchPlaceholder + '"></div>'+
     30                '<div id="searchoptionswrapper"><div id="searchnoresult">'+ cp_donate.nothingFound +'</div><table id="searchoptions" class="radioTable" cellpadding="0" cellspacing="0"><tbody></tbody></table></div>'+
     31            '</div>',
     32        html1 = '<h3>' + cp_donate.title + '</h3>' +
     33                '<div class="textinput"><label for="cp_donateAmount"> ' + cp_donate.amountToDonate + '</label><input type="search" id="cp_donateAmount" name="cp_donateAmount" value="" placeholder="' + cp_donate.donateAmountPlaceholder + '"></div>',
     34        html2 = '<h3>' + cp_donate.title + '</h3>' +
     35                '<div class="textinput"><label for="cp_donateComment"> ' + cp_donate.donateComment + '</label><input type="search" id="cp_donateComment" name="cp_donateComment" value="" placeholder="' + cp_donate.donateCommentPlaceholder + '"></div>',
     36        html3 = '<h3>' + cp_donate.title + '</h3>' +
     37                '<span id="cp_donateFeedback">Please wait...</span>';
     38   
     39    var donatePrompt = {
     40        state0: {
     41            html: html0,
     42            buttons: { Cancel:false,Next:true },
     43            submit: function(e,v,m,f){
     44                if(v){
     45                    if(f.selectedUser == undefined){
     46                        var e = jQuery.Event("keydown");
     47                        e.which = 13;
     48                        jQuery("#cp_searchquery").trigger(e);
     49                        return false;
     50                    }
     51                    jQuery.prompt.goToState('state1');
     52                    return false;
     53                }
    1454            }
    15             else{
    16                 Boxy.alert(data.message);
     55        },
     56        state1: {
     57            html: html1,
     58            buttons: { Cancel:false,Next:true },
     59            submit: function(e,v,m,f){
     60                if(v){
     61                    if(f.cp_donateAmount == ''){
     62                        $imp.find('input').focus();
     63                        return false;
     64                    }
     65                    jQuery.prompt.goToState('state2');
     66                    return false;
     67                }
     68            }
     69        },
     70        state2: {
     71            html: html2,
     72            buttons: { Cancel:false,Donate:true },
     73            submit: function(e,v,m,f){
     74                if(v){
     75                    jQuery.ajax({
     76                        url: cp_donate.ajax_url,
     77                        type: "POST",
     78                        cache: false,
     79                        dataType: "json",
     80                        data: {action: "cp_module_donate_do", recipient: f.selectedUser, points: f.cp_donateAmount, message: f.cp_donateComment},
     81                        success: function(data){
     82                            if(data.success==true){
     83                                jQuery.prompt.getStateContent('state3').find('#cp_donateFeedback').text(data.message);
     84                                jQuery('.cp_points_display').html(data.pointsd);
     85                                return false;
     86                            }
     87                            else{
     88                                jQuery.prompt.getStateContent('state3').find('#cp_donateFeedback').text(data.message);
     89                                return false;
     90                            }
     91                        }
     92                    });
     93                    jQuery.prompt.goToState('state3');
     94                    return false;
     95                }
     96            }
     97        },
     98        state3: {
     99            html: html3,
     100            buttons: { Ok:true },
     101            submit: function(e,v,m,f){
     102                if(v){
     103                    return true;
     104                }
    17105            }
    18106        }
     107    };
     108   
     109    var $imp = jQuery.prompt(donatePrompt);
     110
     111    if(cp_donate.logged_in != '1'){
     112        jQuery.prompt.getStateContent('state3').find('#cp_donateFeedback').text(cp_donate.notLoggedInText);
     113        jQuery.prompt.goToState('state3');
     114    }
     115   
     116    jQuery("#cp_donateAmount").ForceNumericOnly();
     117   
     118    var $so = jQuery('#searchoptions', $imp);
     119   
     120    $so.on('click', 'tr', function(){
     121        jQuery('tr.checked', $so).removeClass('checked');
     122        jQuery(this).addClass('checked');
     123        jQuery(this).find('input').attr('checked', true);
    19124    });
     125
     126    jQuery('#cp_searchquery', $imp).focus().keydown(function(event){
     127        var $i = jQuery(this),
     128            query = $i.val(),
     129            html = "",
     130            counter = 0,
     131            $sos = jQuery('#optionsearchstatus',$imp);
     132           
     133        if(event.which == 13 || event.keyCode == 13 && jQuery.trim(query) !== ''){
     134
     135            $sos.css('display','inline');
     136           
     137            var request = jQuery.ajax({
     138                url: cp_donate.ajax_url,
     139                type: "POST",
     140                data: {action: 'cp_donate_search', q: query}
     141            });
     142           
     143            request.done(function(msg) {
     144                jQuery(msg).each(function(i,user){
     145                    var currval = user.id,
     146                        tval = null,
     147                        currtxt = user.ul;
     148                    html += '<tr class="row'+ (counter++ % 2) + (currval == tval? ' checked':'')+'">'+
     149                            '<td class="td-radio"><input type="radio" name="selectedUser" id="selectedUser_'+ counter +'" value="'+ currval +'"'+ (currval == tval? ' checked':'') +'></td>'+
     150                            '<td class="td-label"><label for="selectedUser_'+ counter +'">'+ currtxt +'</label></td>'+
     151                        '</tr>';
     152                });
     153                $so.find('tbody').html(html);
     154                $so.find('tr:eq(0)').addClass('checked').find('input').attr('checked',true);
     155                if(counter == 0){
     156                    jQuery('#searchnoresult',$imp).show();
     157                    jQuery('#searchoptions',$imp).hide();
     158                }
     159                else{
     160                    jQuery('#searchnoresult',$imp).hide();
     161                    jQuery('#searchoptions',$imp).show();
     162                }
     163                jQuery('#searchoptionswrapper',$imp).slideDown('slow', function(){
     164                    $sos.hide();
     165                });
     166            });
     167
     168            request.fail(function(jqXHR, textStatus) {
     169                jQuery.prompt.getStateContent('state3').find('#cp_donateFeedback').text(cp_donate.somethingWentWrongText);
     170                jQuery.prompt.goToState('state3');
     171            });
     172
     173            return false;
     174        }// end if enter key
     175
     176    });
     177
     178    if(s){
     179        jQuery.prompt.getStateContent('state0').find('#cp_searchquery').val(s);
     180        var e = jQuery.Event("keydown");
     181        e.which = 13;
     182        jQuery("#cp_searchquery").trigger(e);
     183    }
     184   
     185    return false;
    20186}
    21 function cp_module_donate(){
    22     confirmation = cp_donate.confirmation;
    23     thebox = new Boxy('<form name="cp_donate" id="cp_donate" method="post" onsubmit="Boxy.confirm(confirmation,function(){cp_module_donate_do();});return false;"><label for="cp_recipient">'+cp_donate.recipient+':</label><br /><input type="text" id="cp_recipient" name="cp_recipient" style="width:300px;" /><br /><br /><label for="cp_points">'+cp_donate.amount+':</label><br /><input type="text" id="cp_points" name="cp_points" style="width:300px;" /><br /><br /><label for="cp_message">'+cp_donate.message+':</label><br /><textarea id="cp_message" name="cp_message" style="width:300px;height:50px;"></textarea><br /><br /><input type="submit" value="'+cp_donate.donate_points+'" style="width:300px;" /></form>', {title: cp_donate.donate, modal: true});
    24 }
  • cubepoints/trunk/modules/donate/donate.php

    r445086 r626094  
    33/** Donate Module */
    44
    5 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);
     5cp_module_register(__('Donate', 'cp') , 'donate' , '1.2', 'CubePoints', 'http://cubepoints.com', 'http://cubepoints.com' , __('This module allows your users to donate points to each other.', 'cp'), 1);
    66
    77if(cp_module_activated('donate')){
    88
     9    add_action( 'wp_ajax_cp_donate_search', 'cp_module_donate_ajax_search' );
     10    function cp_module_donate_ajax_search() {
     11
     12        header( "Content-Type: application/json" );
     13       
     14        if( $_REQUEST['q']=='' ){
     15            $response = json_encode( array() );
     16            echo $response;
     17            exit;
     18        }
     19       
     20        global $wpdb;
     21        $users = $wpdb->get_results('SELECT ID, user_login, first_name, last_name, md5(user_email) as email_hash FROM `' . $wpdb->prefix . 'users`
     22                                        LEFT JOIN (
     23                                            SELECT
     24                                                user_id,
     25                                                meta_value as first_name
     26                                            FROM `' . $wpdb->prefix . 'usermeta`
     27                                            WHERE ( meta_key =  \'first_name\' )
     28                                        ) AS A
     29                                        ON id = A.user_id
     30                                        LEFT JOIN (
     31                                            SELECT
     32                                                user_id,
     33                                                meta_value as last_name
     34                                            FROM `' . $wpdb->prefix . 'usermeta`
     35                                            WHERE ( meta_key =  \'last_name\' )
     36                                        ) AS B
     37                                        ON id = B.user_id
     38                                        WHERE
     39                                            user_login  LIKE \''. $wpdb->escape($_REQUEST['q']) .'%\'
     40                                            OR CONCAT_WS(\' \', first_name, last_name) LIKE \''. $wpdb->escape($_REQUEST['q']) .'%\'
     41                                            OR CONCAT_WS(\' \', last_name, first_name) LIKE \''. $wpdb->escape($_REQUEST['q']) .'%\'
     42                                            OR CONCAT_WS(\' \', first_name, last_name) LIKE \'% '. $wpdb->escape($_REQUEST['q']) .'%\'
     43                                            OR CONCAT_WS(\' \', last_name, last_name) LIKE \'% '. $wpdb->escape($_REQUEST['q']) .'%\'
     44                                        ORDER BY CASE
     45                                            WHEN user_login  LIKE \''. $wpdb->escape($_REQUEST['q']) .'%\' THEN 1 ELSE 2 END
     46                                        LIMIT 30');
     47        $response = array();
     48       
     49        foreach($users as $u){
     50            $response[] = array(
     51                            'id' => $u->ID,
     52                            'ul' => $u->user_login,
     53                            'fn' => $u->first_name,
     54                            'ln' => $u->last_name,
     55                            'eh' => $u->email_hash
     56                            );
     57        }
     58        $response = json_encode($response);
     59        echo $response;
     60        exit;
     61       
     62    }
     63
    964    function cp_module_donate_scripts(){
    1065   
    11         wp_register_script('boxy',
    12            CP_PATH . 'assets/boxy/javascripts/jquery.boxy.js',
     66        wp_register_script('impromptu',
     67           CP_PATH . 'modules/donate/jquery-impromptu.4.0.min.js',
    1368           array('jquery'),
    14            '0.1.4' );
     69           '4.0' );
    1570
    16         wp_register_style('boxy', CP_PATH . 'assets/boxy/stylesheets/boxy.css');
     71        wp_register_style('cp_donate', CP_PATH . 'modules/donate/donate.css');
    1772
    18         wp_enqueue_script('boxy');
    19         wp_enqueue_style('boxy');
     73        wp_enqueue_script('impromptu');
     74        wp_enqueue_style('cp_donate');
    2075       
    2176    }
     
    2782        $points = $_POST['points'];
    2883        $message = htmlentities(stripslashes($_POST['message']), ENT_QUOTES, 'UTF-8');
    29         $user =  get_userdatabylogin($recipient);
     84        $user =  get_user_by('id', $recipient);
    3085
    3186        if(!is_user_logged_in()){
     
    92147   
    93148    // Handle JS
    94    
    95     wp_register_script('cp_donate_script', WP_PLUGIN_URL.'/'.str_replace(basename( __FILE__),"",plugin_basename(__FILE__)). 'donate.js', array('jquery'));
    96 
    97     function cp_module_donate_script(){
     149    function cp_module_donate_script(){
     150        wp_register_script('cp_donate_script', WP_PLUGIN_URL.'/'.str_replace(basename( __FILE__),"",plugin_basename(__FILE__)). 'donate.js', array('jquery'));
    98151        wp_enqueue_script('cp_donate_script');
     152        wp_localize_script( 'cp_donate_script', 'cp_donate', array(
     153            'logged_in' =>  is_user_logged_in() ? '1' : '0',
     154            'ajax_url' =>  admin_url( 'admin-ajax.php' ),
     155            'title' => __('Points Transfer', 'cp'),
     156            'searchText' => __('Type a username and press Enter to search...', 'cp'),
     157            'searchingText' => __('Searching, please wait...', 'cp'),
     158            'searchPlaceholder' => __('Search...', 'cp'),
     159            'nothingFound' => __('Nothing Found', 'cp'),
     160            'amountToDonate' => __('Enter amount of points to transfer...', 'cp'),
     161            'donateAmountPlaceholder' => __('Amount to transfer...', 'cp'),
     162            'donateComment' => __('Leave feedback (to be displayed on recipient\'s profile)', 'cp'),
     163            'donateCommentPlaceholder' => __('Enter a message...', 'cp'),
     164            'notLoggedInText' => __('You must be logged in to make a transfer!', 'cp'),
     165            'somethingWentWrongText' => _('Oops, something went wrong! Please try again later.', 'cp')
     166        ) );
    99167    }
    100168
    101169    add_action('init', 'cp_module_donate_script');
    102    
    103     wp_localize_script( 'cp_donate_script', 'cp_donate', array(
    104         ajax_url=>get_bloginfo('url').'/wp-admin/admin-ajax.php',
    105         confirmation=>__('Are you sure you want to donate points?', 'cp'),
    106         recipient=>__('Recipient', 'cp'),
    107         message=>__('Message', 'cp'),
    108         amount=>__('Amount', 'cp'),
    109         donate_points=>__('Donate Points', 'cp'),
    110         donate=>__('Donate Points', 'cp')
    111     ) );
    112170   
    113171    function cp_module_donate_widget(){
     
    134192        }
    135193        if($data['message']!=''){
    136             echo ' <a href="javascript:void(0);" onclick="Boxy.alert(\''.htmlspecialchars($data['message']).'\')">[' . __('Message', 'cp') . ']</a>';
     194            echo ' <a href="javascript:void(0);" onclick="jQuery.prompt(\'MESSAGE: '.htmlspecialchars($data['message']).'\')">[' . __('Message', 'cp') . ']</a>';
    137195        }
    138196    }
  • cubepoints/trunk/modules/my_points.php

    r375874 r626094  
    44
    55cp_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);
    6 
    7 function cp_module_mypoints_install(){
    8     //add_option('cp_module_mypoints_points', 5);
    9 }
    10 add_action('cp_module_mypoints_activate','cp_module_mypoints_install');
    116
    127if(cp_module_activated('mypoints')){
     
    1611
    1712    function cp_module_mypoints_add_admin_page(){
    18         add_submenu_page('cp_admin_manage', 'CubePoints - ' .__('My Points','cp'), __('My Points','cp'), 0, 'cp_modules_mypoints_admin', 'cp_modules_mypoints_admin');
     13        add_submenu_page('cp_admin_manage', 'CubePoints - ' .__('My Points','cp'), __('My Points','cp'), 'read', 'cp_modules_mypoints_admin', 'cp_modules_mypoints_admin');
    1914    }
    2015    add_action('cp_admin_pages','cp_module_mypoints_add_admin_page');
  • cubepoints/trunk/modules/paid_content.php

    r445086 r626094  
    206206    add_action('init', 'cp_module_pcontent_buy');
    207207    function cp_module_pcontent_buy(){
    208         if($_POST['cp_module_pcontent_pay']=='') return;
     208        if(!isset($_POST['cp_module_pcontent_pay'])) return;
    209209        $pcontent_enabled = (bool) get_post_meta($_POST['cp_module_pcontent_pay'],'cp_pcontent_points_enable', 1);
    210210        if(!$pcontent_enabled) return;
  • cubepoints/trunk/modules/paypal/paypal.php

    r571698 r626094  
    33/** PayPal Top-up Module */
    44
    5 cp_module_register(__('PayPal Top-up', 'cp') , 'paypal' , '1.0', 'CubePoints', 'http://cubepoints.com', 'http://cubepoints.com' , __('Allow users to buy points using PayPal.', 'cp'), 1);
     5cp_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);
    66
    77function cp_module_paypal_install(){
     
    5858
    5959function cp_module_paypal_add_admin_page(){
    60     add_submenu_page('cp_admin_manage', 'CubePoints - ' .__('PayPal Top-up','cp'), __('PayPal Top-up','cp'), 8, 'cp_modules_paypal_admin', 'cp_modules_paypal_admin');
     60    add_submenu_page('cp_admin_manage', 'CubePoints - ' .__('PayPal Top-up','cp'), __('PayPal Top-up','cp'), 'manage_options', 'cp_modules_paypal_admin', 'cp_modules_paypal_admin');
    6161}
    6262add_action('cp_admin_pages','cp_module_paypal_add_admin_page');
     
    6767if ($_POST['cp_module_paypal_form_submit'] == 'Y') {
    6868
    69     update_option('cp_module_paypal_account', $_POST['cp_module_paypal_account']);
     69    update_option('cp_module_paypal_account', trim($_POST['cp_module_paypal_account']));
    7070    update_option('cp_module_paypal_sandbox', (bool)$_POST['cp_module_paypal_sandbox']);
    7171    update_option('cp_module_paypal_currency', $_POST['cp_module_paypal_currency']);
    72     update_option('cp_module_paypal_item', $_POST['cp_module_paypal_item']);
     72    update_option('cp_module_paypal_item', trim($_POST['cp_module_paypal_item']));
    7373        if(trim($_POST['cp_module_paypal_cancel'])==''){ $_POST['cp_module_paypal_cancel'] = get_bloginfo('url').'/?cp_module_paypal_return=0'; }
    74     update_option('cp_module_paypal_cancel', $_POST['cp_module_paypal_cancel']);
     74    update_option('cp_module_paypal_cancel', trim($_POST['cp_module_paypal_cancel']));
    7575        if(trim($_POST['cp_module_paypal_thankyou'])==''){ $_POST['cp_module_paypal_thankyou'] = get_bloginfo('url').'/?cp_module_paypal_return=1'; }
    7676    update_option('cp_module_paypal_thankyou', trim($_POST['cp_module_paypal_thankyou']));   
    7777    update_option('cp_module_paypal_price', ((float)$_POST['cp_module_paypal_price']<=0)?1:(float)$_POST['cp_module_paypal_price']);
    7878    update_option('cp_module_paypal_min', ((int)$_POST['cp_module_paypal_min']<=0)?1:(int)$_POST['cp_module_paypal_min']);
    79     update_option('cp_module_paypal_form', stripslashes($_POST['cp_module_paypal_form']));
     79    update_option('cp_module_paypal_form', trim(stripslashes($_POST['cp_module_paypal_form'])));
    8080   
    8181
     
    197197
    198198function cp_module_paypal_pay(){
    199     if($_REQUEST['cp_module_paypal_pay']!=''){
     199    if(isset($_REQUEST['cp_module_paypal_pay']) && $_REQUEST['cp_module_paypal_pay']!=''){
    200200    header("Cache-Control: no-cache, must-revalidate");
    201201    header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
     
    259259   
    260260function cp_module_paypal_message(){
    261         if($_REQUEST['cp_module_paypal_return']!=''){
     261        if(isset($_REQUEST['cp_module_paypal_return']) && $_REQUEST['cp_module_paypal_return']!=''){
    262262        if($_REQUEST['cp_module_paypal_return']=='1'){
    263263            cp_module_paypal_showMessage(__('Thank you for your purchase!', 'cp'));
     
    294294
    295295function cp_module_paypal_ipn(){
    296     if($_GET['cp_module_paypal_ipn']!=''){
    297     // read the post from PayPal system and add 'cmd'
    298     $req = 'cmd=_notify-validate';
    299 
    300     foreach ($_POST as $key => $value) {
    301     $value = urlencode(stripslashes($value));
    302     $req .= "&$key=$value";
    303     }
    304 
    305     if(get_option('cp_module_paypal_sandbox')){
    306         $loc = 'ssl://www.sandbox.paypal.com';
    307     }
    308     else{
    309         $loc = 'ssl://www.paypal.com';
    310     }
    311    
    312     // post back to PayPal system to validate
    313     $header .= "POST /cgi-bin/webscr HTTP/1.0\r\n";
    314     $header .= "Content-Type: application/x-www-form-urlencoded\r\n";
    315     $header .= "Content-Length: " . strlen($req) . "\r\n\r\n";
    316     $fp = fsockopen ($loc, 443, $errno, $errstr, 30);
    317 
    318     // assign posted variables to local variables
    319     $item_name = $_POST['item_name'];
    320     $item_number = $_POST['item_number'];
    321     $payment_status = $_POST['payment_status'];
    322     $payment_amount = $_POST['mc_gross'];
    323     $payment_currency = $_POST['mc_currency'];
    324     $txn_id = $_POST['txn_id'];
    325     $receiver_email = $_POST['receiver_email'];
    326     $payer_email = $_POST['payer_email'];
    327     $custom = $_POST['custom'];
    328     list($points,$uid)=explode('|',$custom);
    329 
    330     if (!$fp) {
    331     // HTTP ERROR
    332     } else {
    333     fputs ($fp, $header . $req);
    334     while (!feof($fp)) {
    335     $res = fgets ($fp, 1024);
    336     if (strcmp ($res, "VERIFIED") == 0) {
    337     // check the payment_status is Completed
    338         if($payment_status!='Completed'){ die(); }
    339     // check that txn_id has not been previously processed
    340         global $wpdb;
    341         $results = $wpdb->get_results('SELECT * FROM `'.CP_DB.'` WHERE `type`=\'paypal\'');
    342 
    343         foreach($results as $result){
    344             $data = $result->data;
    345             if($data['txn_id']==$txn_id){ die(); }
    346         }
    347     // check that receiver_email is your Primary PayPal email
    348         if($receiver_email!=get_option('cp_module_paypal_account')){ die(); }
    349     // check that payment_amount/payment_currency are correct
    350         if($payment_currency!=get_option('cp_module_paypal_currency')){ die(); }
    351         if((float)$payment_amount!=(float)cp_module_paypal_round_up(get_option('cp_module_paypal_price') * (int)$points, 2)){ die(); }
    352     // process payment
    353         cp_points('paypal', $uid, (int)$points, serialize(array('txn_id'=>$txn_id,'payer_email'=>$payer_email,'amt'=>$payment_amount)));
    354     }
    355     else if (strcmp ($res, "INVALID") == 0) {
    356     // invalid paypal return
    357         die();
    358     }
    359     }
    360     fclose ($fp);
    361     }
    362     exit();
     296    if(isset($_GET['cp_module_paypal_ipn']) && $_GET['cp_module_paypal_ipn']!=''){
     297
     298        if(get_option('cp_module_paypal_sandbox')){
     299            $host = 'www.sandbox.paypal.com';
     300        }
     301        else{
     302            $host = 'www.paypal.com';
     303        }
     304
     305        // read the post from PayPal system and add 'cmd'
     306        $req = 'cmd=' . urlencode('_notify-validate');
     307         
     308        foreach ($_POST as $key => $value) {
     309            $value = urlencode(stripslashes($value));
     310            $req .= "&$key=$value";
     311        }
     312       
     313        $ch = curl_init();
     314        curl_setopt($ch, CURLOPT_URL, 'https://' . $host . '/cgi-bin/webscr');
     315        curl_setopt($ch, CURLOPT_HEADER, 0);
     316        curl_setopt($ch, CURLOPT_POST, 1);
     317        curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
     318        curl_setopt($ch, CURLOPT_POSTFIELDS, $req);
     319        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
     320        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
     321        curl_setopt($ch, CURLOPT_HTTPHEADER, array('Host: ' . $host));
     322        $res = curl_exec($ch);
     323        curl_close($ch);
     324
     325        // assign posted variables to local variables
     326        $item_name = $_POST['item_name'];
     327        $item_number = $_POST['item_number'];
     328        $payment_status = $_POST['payment_status'];
     329        $payment_amount = $_POST['mc_gross'];
     330        $payment_currency = $_POST['mc_currency'];
     331        $txn_id = $_POST['txn_id'];
     332        $receiver_email = $_POST['receiver_email'];
     333        $payer_email = $_POST['payer_email'];
     334        $custom = $_POST['custom'];
     335        list($points,$uid)=explode('|',$custom);
     336       
     337        if (strcmp ($res, "VERIFIED") == 0) {
     338            // check the payment_status is Completed
     339            if($payment_status!='Completed'){
     340                die();
     341            }
     342            // check that txn_id has not been previously processed
     343            global $wpdb;
     344            $results = $wpdb->get_results('SELECT * FROM `'.CP_DB.'` WHERE `type`=\'paypal\'');
     345            foreach($results as $result){
     346                $data = unserialize($result->data);
     347                if($data['txn_id']==$txn_id){
     348                    die();
     349                }
     350            }
     351            // check that receiver_email is your Primary PayPal email
     352            if($receiver_email!=trim(get_option('cp_module_paypal_account'))){
     353                die();
     354            }
     355            // check that payment_amount/payment_currency are correct
     356            if($payment_currency!=get_option('cp_module_paypal_currency')){
     357                die();
     358            }
     359            if((float)$payment_amount!=(float)cp_module_paypal_round_up(get_option('cp_module_paypal_price') * (int)$points, 2)){
     360                die();
     361            }
     362            // process payment
     363            cp_points('paypal', $uid, (int)$points, serialize(array('txn_id'=>$txn_id,'payer_email'=>$payer_email,'amt'=>$payment_amount)));
     364        }
     365        else if (strcmp ($res, "INVALID") == 0) {
     366            // invalid IPN
     367            die();
     368        }
     369        exit();
     370
    363371    }
    364372}
  • cubepoints/trunk/modules/ranks.php

    r373729 r626094  
    1313
    1414    function cp_module_ranks_data_add_admin_page(){
    15         add_submenu_page('cp_admin_manage', 'CubePoints - ' .__('Ranks','cp'), __('Ranks','cp'), 8, 'cp_modules_ranks_admin', 'cp_modules_ranks_admin');
     15        add_submenu_page('cp_admin_manage', 'CubePoints - ' .__('Ranks','cp'), __('Ranks','cp'), 'manage_options', 'cp_modules_ranks_admin', 'cp_modules_ranks_admin');
    1616    }
    1717    add_action('cp_admin_pages','cp_module_ranks_data_add_admin_page');
  • cubepoints/trunk/modules/reset.php

    r445086 r626094  
    88
    99function cp_module_resetdata_add_admin_page(){
    10     add_submenu_page('cp_admin_manage', 'CubePoints - ' .__('Reset Data','cp'), __('Reset Data','cp'), 8, 'cp_modules_resetdata_admin', 'cp_modules_resetdata_admin');
     10    add_submenu_page('cp_admin_manage', 'CubePoints - ' .__('Reset Data','cp'), __('Reset Data','cp'), 'manage_options', 'cp_modules_resetdata_admin', 'cp_modules_resetdata_admin');
    1111}
    1212add_action('cp_admin_pages','cp_module_resetdata_add_admin_page');
  • cubepoints/trunk/modules/youtube/youtube.php

    r384401 r626094  
    9494    add_shortcode('cp_youtube','cp_module_youtube_shortcode');
    9595   
    96     // enqueue swfobject
    97     wp_enqueue_script("swfobject");
    98 
    99     wp_register_script('cp_youtube_common', WP_PLUGIN_URL.'/'.str_replace(basename( __FILE__),"",plugin_basename(__FILE__)). 'cp_youtube.js', array('jquery'));
    100    
    101     function cp_youtube_scripts(){
     96    function cp_module_youtube_scripts(){
     97        wp_enqueue_script("swfobject");
     98        wp_register_script('cp_youtube_common', WP_PLUGIN_URL.'/'.str_replace(basename( __FILE__),"",plugin_basename(__FILE__)). 'cp_youtube.js', array('jquery'));
    10299        wp_enqueue_script('cp_youtube_common');
     100        wp_localize_script( 'cp_youtube_common', 'cp_youtube', array(
     101            'ajax_url' =>  (!empty($_SERVER['HTTPS'])) ? "https://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'] : "http://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']
     102        ) );
    103103    }
    104    
    105     add_action('init', 'cp_youtube_scripts');
    106 
    107     // ajax handling
    108 
    109     wp_localize_script( 'cp_youtube_common', 'cp_youtube', array(
    110     'ajax_url' =>  (!empty($_SERVER['HTTPS'])) ? "https://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'] : "http://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']
    111     ) );
     104    add_action('init', 'cp_module_youtube_scripts');
    112105
    113106    /** YouTube Log Hook */
  • cubepoints/trunk/readme.txt

    r571698 r626094  
    22Contributors: lauweijie7715, petester
    33Donate link: http://cubepoints.com/donate/
    4 Tags: points, comments, post, admin, widget
     4Tags: points, comments, post, admin, widget, sidebar, paypal, gamification, rewards
    55Requires at least: 2.2
    6 Tested up to: 3.4.1
    7 Stable tag: 3.1.1
     6Tested up to: 3.4.2
     7Stable tag: 3.2
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
    1010
    11 CubePoints is a point management system designed for WordPress blogs.
     11CubePoints is a point management system for WordPress.
    1212
    1313== Description ==
    1414
    15 CubePoints is a point management system designed for WordPress blogs. Users can earn points by posting comments creating posts, or even by logging in on your site.
    16 
    17 Encourage your users to comment on your posts by offering them points which could be used to purchase items / upgrades / etc. Users will be awarded a certain number of points for each comment they make.
    18 
    19 A lot of API is available for other plugins/systems to work with CubePoints. For more information, consult the documentation.
     15CubePoints is a point management system for sites running on WordPress. Users can earn virtual credits on your site by posting comments, creating posts, or even by logging in each day! Install CubePoints and watch your visitor interaction soar by offering them points which could be used to view certain posts, exchange for downloads or even real items!
     16
     17CubePoints is modular! And this means that it can be easily extended to offer more ways for your users to earn and spend points. APIs are also available for other plugins to work with CubePoints.
     18
     19> #### CubePoints Support Forum
     20> Please visit the [CubePoints Support Forum](http://cubepoints.com/forums) for additional help with using this plugin. You may also post feature requests, ideas and bug reports there.
    2021
    2122== Installation ==
     
    4950== Upgrade Notice ==
    5051
     52= 3.2 =
     53New "Limit Comment Points" module added. "Donate" module updated. Several bugfixes to the "PayPal Top-up" module, "Custom Points" module and CubePoints core.
     54
    5155= 3.1.1 =
    5256Translations for 11 locales added. Problems with RTL support, "PayPal Top-up" module & "Comment Spam Control" module fixed.
     
    8387
    8488== Changelog ==
     89
     90**Version 3.2** *(November 16th, 2012)*
     91
     92+ [Feature] New "Limit Comment Points" module added
     93+ [Change] Donate module updated with a new frontend interface
     94+ [Bugfix] Fixed a bug in the "Custom Points" module which prevented it from working
     95+ [Bugfix] Several bugfixes and and optimisations to the "PayPal Top-up" module
     96+ [Bugfix] Code that produce E_NOTICE errors fixed
     97+ [Bugfix] Fixes the issue where ajax requests in the admin back-end (e.g. updating points) fails to run if the administration over SSL is forced
    8598
    8699**Version 3.1.1** *(July 13th, 2012)*
Note: See TracChangeset for help on using the changeset viewer.