Plugin Directory

Changeset 445086


Ignore:
Timestamp:
09/29/2011 06:38:02 AM (14 years ago)
Author:
lauweijie7715
Message:

3.1

Location:
cubepoints/trunk
Files:
8 added
13 edited

Legend:

Unmodified
Added
Removed
  • cubepoints/trunk/cp_admin.php

    r384401 r445086  
    88    add_menu_page('CubePoints', 'CubePoints', 'manage_options', 'cp_admin_manage', 'cp_admin_manage');
    99    add_submenu_page('cp_admin_manage', 'CubePoints - ' .__('Manage','cp'), __('Manage','cp'), 'manage_options', 'cp_admin_manage', 'cp_admin_manage');
     10    add_submenu_page('cp_admin_manage', 'CubePoints - ' .__('Award Points','cp'), __('Add Points','cp'), 'manage_options', 'cp_admin_add_points', 'cp_admin_add_points');
    1011    add_submenu_page('cp_admin_manage', 'CubePoints - ' .__('Configure','cp'), __('Configure','cp'), 'manage_options', 'cp_admin_config', 'cp_admin_config');
    1112    add_submenu_page('cp_admin_manage', 'CubePoints - ' .__('Logs','cp'), __('Logs','cp'), 'manage_options', 'cp_admin_logs', 'cp_admin_logs');
     
    1617/** Include admin pages */
    1718    require_once('cp_admin_manage.php');
     19    require_once('cp_admin_add_points.php');
    1820    require_once('cp_admin_config.php');
    1921    require_once('cp_admin_logs.php');
     
    4547add_action('admin_print_styles-cubepoints_page_cp_admin_modules', 'cp_datatables_style');
    4648
     49/** Register autocomplete script and stylesheet for admin pages */
     50wp_register_script('autocomplete',
     51       CP_PATH . 'assets/autocomplete/jquery.autocomplete.js',
     52       array('jquery'),
     53       '3.2.2' );
     54wp_register_style('autocomplete', CP_PATH . 'assets/autocomplete/jquery.autocomplete.css');
     55
     56/** Enqueue autocomplete */
     57function cp_autocomplete_script(){
     58    wp_enqueue_script('autocomplete');
     59}
     60function cp_autocomplete_style(){
     61    wp_enqueue_style('autocomplete');
     62}
     63add_action('admin_print_scripts-cubepoints_page_cp_admin_add_points', 'cp_autocomplete_script');
     64add_action('admin_print_styles-cubepoints_page_cp_admin_add_points', 'cp_autocomplete_style');
     65
    4766?>
  • cubepoints/trunk/cp_common.php

    r373336 r445086  
    44 */
    55 
    6  function cp_donate_html(){
     6 
     7/** Prints HTML for donate link */
     8function cp_donate_html(){
    79    echo '<div style="text-align:center;"><a href="http://cubepoints.com/donate/" style="border:none;text-decoration:none;background:url(\''.CP_PATH.'assets/donate.png\');display:inline-block;width:94px;height:31px;line-height:30px;color:#555;">Donate</a></div><br />';
    8  }
     10}
     11
     12/** Get difference in time */
     13function cp_relativeTime($timestamp){
     14    $difference = time() - $timestamp;
     15    $periods = array(__('sec','cp'), __('min','cp'), __('hour','cp'), __('day','cp'), __('week','cp'), __('month','cp'), __('year','cp'), __('decade','cp'));
     16    $lengths = array("60","60","24","7","4.35","12","10");
     17    if ($difference >= 0) { // this was in the past
     18        $ending = __('ago','cp');
     19    } else { // this was in the future
     20        $difference = -$difference;
     21        $ending = __('to go','cp');
     22    }       
     23    for($j = 0; $difference >= $lengths[$j]; $j++)
     24        $difference /= $lengths[$j];
     25    $difference = round($difference);
     26    if($difference != 1) $periods[$j].= 's';
     27    $text = "$difference $periods[$j] $ending";
     28    return $text;
     29}
     30
     31/** Class for cURL */
     32class CURL {
     33    var $callback = false;
     34
     35function setCallback($func_name) {
     36    $this->callback = $func_name;
     37}
     38
     39function doRequest($method, $url, $vars) {
     40    $ch = curl_init();
     41    curl_setopt($ch, CURLOPT_URL, $url);
     42    curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
     43    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
     44    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     45    curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
     46    curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookie.txt');
     47    if ($method == 'POST') {
     48        curl_setopt($ch, CURLOPT_POST, 1);
     49        curl_setopt($ch, CURLOPT_POSTFIELDS, $vars);
     50    }
     51    $data = curl_exec($ch);
     52    curl_close($ch);
     53    if ($data) {
     54        if ($this->callback)
     55        {
     56            $callback = $this->callback;
     57            $this->callback = false;
     58            return call_user_func($callback, $data);
     59        } else {
     60            return $data;
     61        }
     62    } else {
     63        return false;
     64    }
     65}
     66
     67function get($url) {
     68    return $this->doRequest('GET', $url, 'NULL');
     69}
     70
     71function post($url, $vars) {
     72    return $this->doRequest('POST', $url, $vars);
     73}
     74}
    975 
    1076 ?>
  • cubepoints/trunk/cp_core.php

    r373336 r445086  
    7373    global $wpdb;
    7474    if($amt>0){ $limit = ' LIMIT ' . $start.','.$amt; }
     75  $extraquery = '';
    7576    if (count($filter_users)>0){
    7677        $extraquery = ' WHERE '.$wpdb->base_prefix.'users.user_login != \'';
     
    116117    cp_updatePoints($uid, $points);
    117118    cp_log($type, $uid, $difference, $data);
    118 }
    119 
    120 /** Get difference in time */
    121 function cp_relativeTime($timestamp){
    122     $difference = time() - $timestamp;
    123     $periods = array(__('sec','cp'), __('min','cp'), __('hour','cp'), __('day','cp'), __('week','cp'), __('month','cp'), __('year','cp'), __('decade','cp'));
    124     $lengths = array("60","60","24","7","4.35","12","10");
    125     if ($difference >= 0) { // this was in the past
    126         $ending = __('ago','cp');
    127     } else { // this was in the future
    128         $difference = -$difference;
    129         $ending = __('to go','cp');
    130     }       
    131     for($j = 0; $difference >= $lengths[$j]; $j++)
    132         $difference /= $lengths[$j];
    133     $difference = round($difference);
    134     if($difference != 1) $periods[$j].= 's';
    135     $text = "$difference $periods[$j] $ending";
    136     return $text;
    137119}
    138120
     
    202184}
    203185
     186/** Function to cache module versions and run activation hook on module update */
     187function cp_modules_updateCheck(){
     188    global $cp_module;
     189    $module_ver_cache = unserialize(get_option('cp_moduleVersions'));
     190    $module_ver = array();
     191    foreach($cp_module as $mod){
     192        $module_ver[$mod['id']] = $mod['version'];
     193        // check for change in version and run module activation hook
     194        if(cp_module_activated($mod['id'])){
     195            if($module_ver_cache[$mod['id']] != $mod['version']){
     196                if(!did_action('cp_module_'.$mod['id'].'_activate')){
     197                    do_action('cp_module_'.$mod['id'].'_activate');
     198                }
     199            }
     200        }
     201    }
     202    update_option('cp_moduleVersions', serialize($module_ver));
     203}
     204
    204205
    205206?>
  • cubepoints/trunk/cp_hooks.php

    r384401 r445086  
    1010    echo $data;
    1111}
     12
     13 /** Add Points logs hook */
     14add_action('cp_logs_description','cp_admin_logs_desc_addpoints', 10, 4);
     15function cp_admin_logs_desc_addpoints($type,$uid,$points,$data){
     16    if($type!='addpoints') { return; }
     17    echo $data;
     18}
    1219 
    1320/** Comments hook */
    1421add_action('comment_post', 'cp_newComment', 10 ,2);
    1522function cp_newComment($cid, $status) {
    16     if (is_user_logged_in()) {
    17         $cdata = get_comment($cid);
    18         if($status == 1){
    19             do_action('cp_newComment', $cid);
    20             cp_points('comment', cp_currentUser(), apply_filters('cp_comment_points',get_option('cp_comment_points')), $cid);
    21         }
    22     }
    23 }
    24 
    25 /** Comment edit status hook */
    26 add_action('wp_set_comment_status', 'cp_statusComment', 10, 2);
    27 function cp_statusComment($cid,$newstatus){
    2823    $cdata = get_comment($cid);
    29     $approved = $cdata->comment_approved;
    30     $uid = $cdata->user_id;
    31     global $wpdb;
    32     if($newstatus == 'approve' && ((int) $wpdb->get_var("SELECT COUNT(*) FROM ".CP_DB." WHERE `type`='comment' AND `data`=".$cid) == 0 )){
    33         do_action('cp_approvedComment', $cid);
    34         cp_points('comment', $uid, apply_filters('cp_comment_points',get_option('cp_comment_points')), $cid);
    35     }
     24    if($status == 1){
     25        do_action('cp_comment_add', $cid);
     26        cp_points('comment', cp_currentUser(), apply_filters('cp_comment_points',get_option('cp_comment_points')), $cid);
     27    }
     28}
     29
     30/** Comment approved hook */
     31add_action('comment_unapproved_to_approved', 'cp_commentApprove', 10, 1);
     32add_action('comment_trash_to_approved', 'cp_commentApprove', 10, 1);
     33add_action('comment_spam_to_approved', 'cp_commentApprove', 10, 1);
     34function cp_commentApprove($cdata){
     35    do_action('cp_comment_add', $cdata->comment_ID);
     36    cp_points('comment', $cdata->user_id, apply_filters('cp_comment_points',get_option('cp_comment_points')), $cdata->comment_ID);
     37}
     38
     39/** Comment unapproved hook */
     40add_action('comment_approved_to_unapproved', 'cp_commentUnapprove', 10, 1);
     41add_action('comment_approved_to_trash', 'cp_commentUnapprove', 10, 1);
     42add_action('comment_approved_to_spam', 'cp_commentUnapprove', 10, 1);
     43function cp_commentUnapprove($cdata){
     44    do_action('cp_comment_remove', $cdata->comment_ID);
     45    cp_points('comment_remove', $cdata->user_id, apply_filters('cp_del_comment_points',-get_option('cp_del_comment_points')), $cdata->comment_ID);
    3646}
    3747
     
    5060}
    5161
    52 /** Comments removal hook */
    53 add_action('delete_comment', 'cp_rmvComment');
    54 function cp_rmvComment($cid) {
    55     $comment = get_comment($cid);
    56     $uid = $comment->user_id;
    57     global $wpdb;
    58     if(((int) $wpdb->get_var("SELECT COUNT(*) FROM ".CP_DB." WHERE `type`='comment' AND `data`=".$cid) != 0 )){
    59         cp_points('comment_remove', $comment->user_id, apply_filters('cp_del_comment_points',-get_option('cp_del_comment_points')), $cid);
    60     }
    61 }
    62 
    6362/** Comments removal logs hook */
    6463add_action('cp_logs_description','cp_admin_logs_desc_comment_remove', 10, 4);
     
    260259}
    261260
     261/** Hook for add-points autocomplete user suggestion */
     262add_action( 'wp_ajax_cp_add_points_user_suggest', 'cp_add_points_user_suggest' );
     263function cp_add_points_user_suggest() {
     264
     265    header( "Content-Type: application/json" );
     266   
     267    if( ! current_user_can('manage_options') || $_REQUEST['q']=='' ){
     268        $response = json_encode( array() );
     269        echo $response;
     270        exit;
     271    }
     272   
     273    global $wpdb;
     274    $users = $wpdb->get_results('SELECT * from `' . $wpdb->prefix . 'users` WHERE `user_login` LIKE \''.$_REQUEST['q'].'%\' LIMIT 10', ARRAY_A);
     275   
     276    $response = array();
     277   
     278    foreach($users as $user){
     279        $response[] = implode("|", array($user['user_login'], $user['ID'], $user['display_name'], $user['user_email'], md5(trim(strtolower($user['user_email'])))));
     280    }
     281    $response = json_encode( implode("\n", $response) );
     282    echo $response;
     283    exit;
     284   
     285}
     286
     287/** Hook for add-points user query */
     288add_action( 'wp_ajax_cp_add_points_user_query', 'cp_add_points_user_query' );
     289function cp_add_points_user_query() {
     290
     291    header( "Content-Type: application/json" );
     292   
     293    if( ! current_user_can('manage_options') || $_REQUEST['q']=='' ){
     294        $response = json_encode( array() );
     295        echo $response;
     296        exit;
     297    }
     298   
     299    global $wpdb;
     300    $user = $wpdb->get_row('SELECT * from `' . $wpdb->prefix . 'users` WHERE `user_login` LIKE \''.$wpdb->prepare(trim($_REQUEST['q'])).'\' LIMIT 1', ARRAY_A);
     301    if($user['ID'] == null){
     302        $response = json_encode( array() );
     303        echo $response;
     304        exit;
     305    }
     306    $response = json_encode( array(
     307                            'id' => $user['ID'],
     308                            'user_login' => $user['user_login'],
     309                            'display_name' => $user['display_name'],
     310                            'email' => $user['user_email'],
     311                            'points' => cp_getPoints($user['ID']),
     312                            'hash' => md5(trim(strtolower($user['user_email'])))
     313                            ));
     314    echo $response;
     315    exit;
     316   
     317}
     318
     319/** Hook for add-points user update */
     320add_action( 'wp_ajax_cp_add_points_user_update', 'cp_add_points_user_update' );
     321function cp_add_points_user_update() {
     322
     323    header( "Content-Type: application/json" );
     324   
     325    if( ! current_user_can('manage_options') || $_POST['id']=='' || $_POST['points']=='' || $_POST['description']=='' ){
     326        $response = json_encode( array( 'status' => 'failed' ) );
     327        echo $response;
     328        exit;
     329    }
     330   
     331    cp_points('addpoints', (int)$_POST['id'], (int)$_POST['points'], htmlentities($_POST['description']));
     332    $response = json_encode( array(
     333                            'status' => 'ok',
     334                            'newpoints' => cp_getPoints((int)$_POST['id'])
     335                            ));
     336    echo $response;
     337    exit;
     338   
     339}
    262340
    263341?>
  • cubepoints/trunk/cp_widgets.php

    r373336 r445086  
    6565            $field_id = $this->get_field_id($field);
    6666            $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="'.attribute_escape( $instance[$field] ).'" /><label></p>';
     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>';
    6868           
    6969            $field = 'text';
    7070            $field_id = $this->get_field_id($field);
    7171            $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="'.attribute_escape( $instance[$field] ).'" /><label></p>';
     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>';
    7373           
    7474            echo "\r\n".'<small><strong>'.__('Note', 'cp').':</strong> '.__('%points% would be replaced with the points of the logged in user', 'cp').'</small><br /><br />';
     
    7777            $field_id = $this->get_field_id($field);
    7878            $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="'.attribute_escape( $instance[$field] ).'" /><label></p>';
     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>';
    8080           
    8181            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 />';
     
    8484            $field_id = $this->get_field_id($field);
    8585            $field_name = $this->get_field_name($field);
    86             echo "\r\n".'<p><label for="'.$field_id.'">'.__('HTML Code (advanced)', 'cp').': <textarea class="widefat" id="'.$field_id.'" name="'.$field_name.'" >'.attribute_escape( $instance[$field] ).'</textarea><label></p>';
     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>';
    8788
    8889            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>';
     
    143144            $field_id = $this->get_field_id($field);
    144145            $field_name = $this->get_field_name($field);
    145             echo "\r\n".'<p><label for="'.$field_id.'">'.__('Title', 'cp').': <input type="text" class="widefat" id="'.$field_id.'" name="'.$field_name.'" value="'.attribute_escape( $instance[$field] ).'" /><label></p>';
     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>';
    146147           
    147148            $field = 'num';
    148149            $field_id = $this->get_field_id($field);
    149150            $field_name = $this->get_field_name($field);
    150             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="'.attribute_escape( $instance[$field] ).'" /><label></p>';
     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>';
    151152           
    152153            $field = 'text';
    153154            $field_id = $this->get_field_id($field);
    154155            $field_name = $this->get_field_name($field);
    155             echo "\r\n".'<p><label for="'.$field_id.'">'.__('Text', 'cp').': <input type="text" class="widefat" id="'.$field_id.'" name="'.$field_name.'" value="'.attribute_escape( $instance[$field] ).'" /><label></p>';
     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>';
    156157
    157158            echo "\r\n".'<small><strong>'.__('Shortcodes', 'cp') . ':</strong><br />';
     
    168169            $field_id = $this->get_field_id($field);
    169170            $field_name = $this->get_field_name($field);
    170             echo "\r\n".'<p><label for="'.$field_id.'">'.__('Style', 'cp').': <input type="text" class="widefat" id="'.$field_id.'" name="'.$field_name.'" value="'.attribute_escape( $instance[$field] ).'" /><label></p>';
     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>';
    171172            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 />';
    172173        }
  • cubepoints/trunk/cubepoints.php

    r384405 r445086  
    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.0.3
     6Version: 3.1
    77Author: Jonathan Lau & Peter Zhang
    88Author URI: http://cubepoints.com
     
    1212
    1313/** Define constants */
    14 define('CP_VER', '3.0.1');
     14define('CP_VER', '3.1');
    1515define('CP_DB', $wpdb->base_prefix . 'cp');
    1616define('CP_PATH', WP_PLUGIN_URL.'/'.str_replace(basename( __FILE__),"",plugin_basename(__FILE__)));
     
    5858add_action('plugins_loaded','cp_modules_include',2);
    5959
     60/** Checks if modules have been updated and run activation hook */
     61add_action('init', 'cp_modules_updateCheck');
     62
    6063?>
  • cubepoints/trunk/modules/comment_spam_control.php

    r373336 r445086  
    77if(cp_module_activated('cp_csc')){
    88    add_action('cp_newComment', 'cp_module_csc_newComment');
     9    add_action('cp_approvedComment', 'cp_module_csc_newComment');
    910    function cp_module_csc_newComment($cid) {
    1011        if (is_user_logged_in()) {
  • cubepoints/trunk/modules/donate/donate.php

    r384401 r445086  
    33/** Donate Module */
    44
    5 cp_module_register(__('Donate', 'cp') , 'donate' , '1.0', '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.1', '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')){
     
    2626        $recipient = $_POST['recipient'];
    2727        $points = $_POST['points'];
    28         $message = str_replace("'",'&#039;',htmlentities(stripslashes($_POST['message'])));
     28        $message = htmlentities(stripslashes($_POST['message']), ENT_QUOTES, 'UTF-8');
    2929        $user =  get_userdatabylogin($recipient);
    3030
     
    7575       
    7676        else{
     77            $message = mb_convert_encoding($message, 'HTML-ENTITIES', 'UTF-8');
    7778            $r['success'] = true;
    7879            $r['message'] = __('Your donation is successful!', 'cp');
  • cubepoints/trunk/modules/notice/jquery.notice.css

    r373336 r445086  
    11.notice-wrap {
    22    position: fixed;
    3     top: 20px;
    4     right: 20px;
    5     width: 250px;
     3    top: 50px;
     4    right: 50px;
    65    z-index: 9999;
    76    opacity: 0.8;
     
    1211    position: absolute;     
    1312}
    14  
    15 .notice-header{
     13
     14.notice-item {
     15    background: #545454;
     16    background: -moz-linear-gradient(top, #545454 0%, #3d3d3d);
     17    background: -webkit-gradient(linear, left top, left bottom, from(#545454), to(#3d3d3d));
     18    border: 1px solid #3d3d3d;
     19    border-radius: 7px;
     20    -moz-border-radius: 7px;
     21    -webkit-border-radius: 7px;
     22    box-shadow: 0px 1px 2px rgba(0,0,0,.5);
     23    -moz-box-shadow: 0px 1px 2px rgba(0,0,0,.5);
     24    -webkit-box-shadow: 0px 1px 2px rgba(0,0,0,.5);
     25    color: #fff;
    1626    display: block;
    17     font-size: 13px;
    18     font-weight: bold;
     27    font-size: 54px;
     28    height: 82px;
     29    line-height: 41px;
     30    margin: 0 0 12px 0;
     31    padding: 10px 10px 0 10px;
     32    position: relative;
     33    text-align: center;
    1934}
    2035
    21 .notice-item {
    22     background: #333;
    23     -moz-border-radius: 6px;
    24     -webkit-border-radius: 6px;
    25     -moz-box-shadow: 2px 2px 10px #888;
    26     -webkit-box-shadow: 2px 2px 10px #888;
    27     color: #eee;
    28     padding: 10px 10px 0 10px;
    29     font-size: 12px;
    30     border: 1px solid #999;
    31     display: block;
    32     position: relative;
    33     margin: 0 0 12px 0;
    34     cursor:pointer;
     36.notice-item p {
     37    font-family: Helvetica;
     38    font-weight: bold;
     39    margin-top: 0;
     40    padding: 15px 20px;
     41    text-shadow: -1px -1px 0px rgba(0,0,0,.7), 1px 1px 0px rgba(0,0,0,.7);
    3542}
    3643
    37 .notice-item-close {
    38     position: absolute;
    39     font-size: 15px;
    40     font-weight: bold;
    41     right: 10px;
    42     top: 6px;
    43     cursor: pointer;
    44     font-family:arial;
     44.notice-item-close{
     45    display:none;
    4546}
    46 .notice-item-close:hover{
    47     color: #fff;
    48 }
  • cubepoints/trunk/modules/notice/jquery.notice.js

    r373336 r445086  
    6464                options.stayTime);
    6565            }
     66           
    6667        },
    6768       
  • cubepoints/trunk/modules/notice/notice.php

    r373336 r445086  
    33/** Notify Module */
    44
    5 cp_module_register(__('Notify', 'cp') , 'notify' , '1.0', '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);
     5cp_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);
    66
    77function cp_module_notify_install(){
     
    1717        dbDelta($sql);
    1818        add_option("cp_module_notify_db_version'", "1.0");
    19         add_option("cp_module_notify_header", "CubePoints Notice");
    2019    }
    2120}
     
    5554    /************************
    5655     * Enqueue End
    57      ************************/
    58      
    59     /**********************
    60      * Config
    61      ***********************/
    62     function cp_module_notify_config(){
    63     ?>
    64         <br />
    65         <h3><?php _e('Notify','cp'); ?></h3>
    66         <table class="form-table">
    67             <tr valign="top">
    68                 <th scope="row"><label for="cp_module_notify_header"><?php _e('Notify Header', 'cp'); ?>:</label></th>
    69                 <td valign="middle"><input type="text" id="cp_module_notify_header" name="cp_module_notify_header" value="<?php echo get_option('cp_module_notify_header'); ?>" size="30" /></td>
    70             </tr>
    71         </table>
    72     <?php
    73     }
    74     add_action('cp_config_form','cp_module_notify_config');
    75    
    76     function cp_module_notify_config_process(){
    77         $cp_module_notify_header = $_POST['cp_module_notify_header'];
    78         update_option('cp_module_notify_header', $cp_module_notify_header);
    79     }
    80     add_action('cp_config_process','cp_module_notify_config_process');
    81     /**********************
    82      * Config End
    83      ***********************/
    84      
     56     ************************/   
    8557
    8658    add_action('wp_footer', 'cp_module_notify_display_hook', 10, 1);   
    8759    function cp_module_notify_display($text = ''){
    8860        if($text==''){ return; }
    89         $header = get_option('cp_module_notify_header');
    9061
    91         echo '<script>jQuery.noticeAdd({';         
    92             echo ' text: "';
    93             if($header != '') echo '<span class=\'notice-header\'>'.$header.'</span>'; echo $text; echo '",';
    94             echo 'stay: false';
    95         echo '});</script>';
     62        echo '<script>';
     63            echo 'jQuery.noticeAdd({';         
     64                echo ' text: "';
     65                echo $text;
     66                echo '",';
     67                echo 'stay: false';
     68            echo '});';
     69        echo '</script>';
    9670    }
    9771    function cp_module_notify_hook(){
     
    143117    function cp_module_notify_logsHook($type, $uid, $points, $data){
    144118        if($points>0){
    145             $m= __('You have just earned %points%...', 'cp');
     119            $m= '+%npoints%';
    146120        } else {
    147             $m=__('You have just lost %points%...', 'cp');
     121            $m='-%npoints%';
    148122        }
    149123        $m = apply_filters('cp_module_notify_msg',array($m, $type, $uid, $points, $data));
     
    152126    }
    153127   
    154     /** Messages for common log items */
    155     function cp_module_notify_msg_common($d){
    156         list($m, $type, $uid, $points, $data) = $d;
    157         switch ($type) {
    158             case 'comment':
    159                 $m = __('You have earned %points% for posting a comment...', 'cp');
    160                 break;
    161             case 'post':
    162                 $m = __('You have earned %points% for making a post...', 'cp');
    163                 break;
    164         }
    165         return array($m, $type, $uid, $points, $data);
    166     }
    167     add_filter('cp_module_notify_msg','cp_module_notify_msg_common',1);
    168    
    169128}
    170129?>
  • cubepoints/trunk/modules/paid_content.php

    r373336 r445086  
    33/** Paid Content Module */
    44
    5 cp_module_register(__('Paid Content', 'cp') , 'pcontent' , '1.0', 'CubePoints', 'http://cubepoints.com', 'http://cubepoints.com' , __('This module lets you deduct point from users to view a page or post.', 'cp'), 1);
     5cp_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);
     6
     7function cp_module_pcontent_install(){
     8    add_option('cp_module_pcontent_default_points', 10);
     9    add_option('cp_module_pcontent_default', false);
     10    add_option('cp_module_pcontent_payauthor', false);
     11    add_option('cp_module_pcontent_text_pay', __('You need to pay %points% to access this page.', 'cp'));
     12    add_option('cp_module_pcontent_text_button', __('Pay %points%', 'cp'));
     13    add_option('cp_module_pcontent_text_logout', __('You must be logged in to access this page.', 'cp'));
     14    add_option('cp_module_pcontent_text_insufficient', __('You have insufficient points to purchase access for this page.', 'cp'));
     15}
     16add_action('cp_module_pcontent_activate','cp_module_pcontent_install');
    617
    718if(cp_module_activated('pcontent')){
     19
     20    /* Config for this module */
     21    function cp_module_pcontent_config(){
     22    ?>
     23        <br />
     24        <h3><?php _e('Paid Content','cp'); ?></h3>
     25        <table class="form-table">
     26
     27            <tr valign="top">
     28                <th scope="row"><label for="cp_module_pcontent_default_points"><?php _e('Default number of points', 'cp'); ?>:</label></th>
     29                <td valign="middle"><input type="text" id="cp_module_pcontent_default_points" name="cp_module_pcontent_default_points" value="<?php echo get_option('cp_module_pcontent_default_points'); ?>" size="30" /></td>
     30            </tr>
     31
     32            <tr valign="top">
     33                <th scope="row"><label for="cp_module_pcontent_default"><?php _e('Enabled by default', 'cp'); ?>:</label></th>
     34                <td valign="middle">
     35                    <input type="radio" id="cp_module_pcontent_default_y" name="cp_module_pcontent_default" value="1" <?php echo (get_option('cp_module_pcontent_default')==true)?'checked="checked"':''; ?> /> <label for="cp_module_pcontent_default_y"><?php _e('Yes', 'cp'); ?></label>
     36                    <input style="margin-left:15px;" type="radio" id="cp_module_pcontent_default_n" name="cp_module_pcontent_default" value="0" <?php echo (get_option('cp_module_pcontent_default')==false)?'checked="checked"':''; ?> /> <label for="cp_module_pcontent_default_n"><?php _e('No', 'cp'); ?></label>
     37                </td>
     38            </tr>
     39
     40            <tr valign="top">
     41                <th scope="row"><label for="cp_module_pcontent_payauthor"><?php _e('Credit post author with points paid by user', 'cp'); ?>:</label></th>
     42                <td valign="middle">
     43                    <input type="radio" id="cp_module_pcontent_payauthor_y" name="cp_module_pcontent_payauthor" value="1" <?php echo (get_option('cp_module_pcontent_payauthor')==true)?'checked="checked"':''; ?> /> <label for="cp_module_pcontent_payauthor_y"><?php _e('Yes', 'cp'); ?></label>
     44                    <input style="margin-left:15px;" type="radio" id="cp_module_pcontent_payauthor_n" name="cp_module_pcontent_payauthor" value="0" <?php echo (get_option('cp_module_pcontent_payauthor')==false)?'checked="checked"':''; ?> /> <label for="cp_module_pcontent_payauthor_n"><?php _e('No', 'cp'); ?></label>
     45                </td>
     46            </tr>
     47
     48            <tr valign="top">
     49                <th scope="row"><label for="cp_module_pcontent_text_pay"><?php _e('Text to ask users to pay for page access with points', 'cp'); ?>:</label></th>
     50                <td valign="middle"><input type="text" id="cp_module_pcontent_text_pay" name="cp_module_pcontent_text_pay" value="<?php echo get_option('cp_module_pcontent_text_pay'); ?>" size="30" /></td>
     51            </tr>
     52           
     53            <tr valign="top">
     54                <th scope="row"><label for="cp_module_pcontent_text_button"><?php _e('Text to be shown on payment button', 'cp'); ?>:</label></th>
     55                <td valign="middle"><input type="text" id="cp_module_pcontent_text_button" name="cp_module_pcontent_text_button" value="<?php echo get_option('cp_module_pcontent_text_button'); ?>" size="30" /></td>
     56            </tr>
     57
     58            <tr valign="top">
     59                <th scope="row"><label for="cp_module_pcontent_text_logout"><?php _e('Text to be shown to users who are not logged in', 'cp'); ?>:</label></th>
     60                <td valign="middle"><input type="text" id="cp_module_pcontent_text_logout" name="cp_module_pcontent_text_logout" value="<?php echo get_option('cp_module_pcontent_text_logout'); ?>" size="30" /></td>
     61            </tr>
     62
     63            <tr valign="top">
     64                <th scope="row"><label for="cp_module_pcontent_text_insufficient"><?php _e('Text to be shown when user have insufficient points', 'cp'); ?>:</label></th>
     65                <td valign="middle"><input type="text" id="cp_module_pcontent_text_insufficient" name="cp_module_pcontent_text_insufficient" value="<?php echo get_option('cp_module_pcontent_text_insufficient'); ?>" size="30" /></td>
     66            </tr>
     67
     68        </table>
     69    <?php
     70    }
     71    add_action('cp_config_form','cp_module_pcontent_config');
     72
     73    /* Process and save options */
     74    function cp_module_pcontent_config_process(){
     75        $cp_module_pcontent_default_points = (int) $_POST['cp_module_pcontent_default_points'];
     76        $cp_module_pcontent_default = (bool) $_POST['cp_module_pcontent_default'];
     77        $cp_module_pcontent_payauthor = (bool) $_POST['cp_module_pcontent_payauthor'];
     78        $cp_module_pcontent_text_pay = $_POST['cp_module_pcontent_text_pay'];
     79        $cp_module_pcontent_text_button = $_POST['cp_module_pcontent_text_button'];
     80        $cp_module_pcontent_text_logout = $_POST['cp_module_pcontent_text_logout'];
     81        $cp_module_pcontent_text_insufficient = $_POST['cp_module_pcontent_text_insufficient'];
     82        update_option('cp_module_pcontent_default_points', (($cp_module_pcontent_default_points<=0)?1:$cp_module_pcontent_default_points));
     83        update_option('cp_module_pcontent_default', $cp_module_pcontent_default);
     84        update_option('cp_module_pcontent_payauthor', $cp_module_pcontent_payauthor);
     85        update_option('cp_module_pcontent_text_pay', $cp_module_pcontent_text_pay);
     86        update_option('cp_module_pcontent_text_button', $cp_module_pcontent_text_button);
     87        update_option('cp_module_pcontent_text_logout', $cp_module_pcontent_text_logout);
     88        update_option('cp_module_pcontent_text_insufficient', $cp_module_pcontent_text_insufficient);
     89    }
     90    add_action('cp_config_process','cp_module_pcontent_config_process');
    891
    992    /* Define the custom box */
     
    26109        // Use nonce for verification
    27110        wp_nonce_field( plugin_basename(__FILE__), 'cp_module_pcontent_nonce' );
    28 
     111        if($post->post_status == 'auto-draft'){
     112            $enabled = (get_option('cp_module_pcontent_default')?'checked="yes"':'');
     113            $points = get_option('cp_module_pcontent_default_points');
     114        }
     115        else{
     116            $enabled = ((bool)(get_post_meta($post->ID , 'cp_pcontent_points_enable', 1))?'checked="yes"':'');
     117            $points = (int)get_post_meta($post->ID , 'cp_pcontent_points', 1);
     118        }
    29119        // The actual fields for data entry
    30         echo '<br /><input type="checkbox" id="cp_module_pcontent_enable" name="cp_module_pcontent_enable" value="1" size="25" '.((bool)(get_post_meta($post->ID , 'cp_pcontent_points_enable', 1))?'checked="yes"':'').' /> ';
     120        echo '<br /><input type="checkbox" id="cp_module_pcontent_enable" name="cp_module_pcontent_enable" value="1" size="25" '.$enabled.' /> ';
    31121        echo '<label for="cp_module_pcontent_enable">' . __("Enable paid content" , 'cp') . '</label> ';
    32122        echo '<br /><br />';
    33123        echo '<label for="cp_module_pcontent_points">' . __("Number of points to be deducted to view this page / post" , 'cp') . ':</label> ';
    34         echo '<input type="text" id= "cp_module_pcontent_points" name="cp_module_pcontent_points" value="'.(int)get_post_meta($post->ID , 'cp_pcontent_points', 1).'" size="25" /><br /><br />';
     124        echo '<input type="text" id= "cp_module_pcontent_points" name="cp_module_pcontent_points" value="'.$points.'" size="25" /><br /><br />';
    35125    }
    36126
     
    101191            return $content;
    102192        }
    103         $c = __('You need to pay %points% to view this page!', 'cp');
     193        $c = '<p>' . get_option('cp_module_pcontent_text_pay') . '</p>';
    104194        $c .= apply_filters('cp_module_pcontent_post_content_'.$post->ID, '');
    105         $c .= '<br /><br /><form method="post">';
     195        $c .= '<form method="post">';
    106196        $c .= '<input type="hidden" name="cp_module_pcontent_pay" value="'.$post->ID.'" />';
    107         $c .= '<input type="submit" value="'.__('View this page for %points%', 'cp').'" />';
     197        $c .= '<p><input type="submit" value="'.get_option('cp_module_pcontent_text_button').'" /></p>';
    108198        $c .= '</form>';
     199        if(!is_user_logged_in()){
     200            $c = get_option('cp_module_pcontent_text_logout');
     201        }
    109202        $c = str_replace('%points%',cp_formatPoints(get_post_meta($post->ID,'cp_pcontent_points', 1)),$c);
    110203        return $c;
     
    123216        }
    124217        if(!is_user_logged_in()){
    125             add_filter('cp_module_pcontent_post_content_'.$_POST['cp_module_pcontent_pay'], create_function('$data', 'return "<br /><br /><span style=\"color:red;\">'.__('Please log in to purchase this page!', 'cp').'</span>";'));
     218            add_filter('cp_module_pcontent_post_content_'.$_POST['cp_module_pcontent_pay'], create_function('$data', 'return "<p style=\"color:red;\">'.get_option('cp_module_pcontent_text_logout').'</p>";'));
    126219            return;
    127220        }
    128221        if(cp_getPoints(cp_currentUser())<get_post_meta($_POST['cp_module_pcontent_pay'],'cp_pcontent_points', 1)){
    129             add_filter('cp_module_pcontent_post_content_'.$_POST['cp_module_pcontent_pay'], create_function('$data', 'return "<br /><br /><span style=\"color:red;\">'.__('You do not have enough to pay for this page!', 'cp').'</span>";'));
     222            add_filter('cp_module_pcontent_post_content_'.$_POST['cp_module_pcontent_pay'], create_function('$data', 'return "<p style=\"color:red;\">'.get_option('cp_module_pcontent_text_insufficient').'</p>";'));
    130223            return;
    131224        }
    132225        cp_points('pcontent',cp_currentUser(),-get_post_meta($_POST['cp_module_pcontent_pay'],'cp_pcontent_points', 1),$_POST['cp_module_pcontent_pay']);
     226        if(get_option('cp_module_pcontent_payauthor')){
     227            $post = get_post($_POST['cp_module_pcontent_pay']);
     228            cp_points('pcontent_author',$post->post_author,get_post_meta($_POST['cp_module_pcontent_pay'],'cp_pcontent_points', 1),serialize(array($_POST['cp_module_pcontent_pay'],cp_currentUser())));
     229        }
    133230    }
    134231   
     
    138235        if($type!='pcontent') { return; }
    139236        $post = get_post($data);
    140         echo __('Purchased view of', 'cp') . ' "<a href="'.get_permalink( $post ).'">' . $post->post_title . '</a>"';
     237        echo __('Purchased access to', 'cp') . ' "<a href="'.get_permalink( $post ).'">' . $post->post_title . '</a>"';
     238    }
     239   
     240    /** Paid Content Post-author Log Hook */
     241    add_action('cp_logs_description','cp_admin_logs_desc_pcontent_author', 10, 4);
     242    function cp_admin_logs_desc_pcontent_author($type,$uid,$points,$data){
     243        if($type!='pcontent_author') { return; }
     244        $data = unserialize($data);
     245        $post = get_post($data[0]);
     246        $user = get_user_by('id', $data[1]);
     247        echo  __('User', 'cp') . ' "' . $user->user_login . '" ' . __('purchased access to', 'cp') . ' "<a href="'.get_permalink( $post ).'">' . $post->post_title . '</a>"';
    141248    }
    142249
  • cubepoints/trunk/readme.txt

    r384401 r445086  
    44Tags: points, comments, post, admin, widget
    55Requires at least: 2.2
    6 Tested up to: 3.1.2
    7 Stable tag: 3.0.3
     6Tested up to: 3.2.1
     7Stable tag: 3.1
    88
    99CubePoints is a point management system designed for WordPress blogs.
     
    4848
    4949= 3.0.3 =
     50New features and modules added. Several bugs fixed as well.
     51
     52= 3.0.3 =
    5053New module (YouTube Video) added. Minor bugfixes made and improved code for XHTML validation.
    5154
     
    7578
    7679== Changelog ==
     80
     81**Version 3.1** *(September 29th, 2011)*
     82
     83+ [Feature] Add points with custom log descriptions
     84+ [Feature] Updates to "Paid Content" module which allows page authors to earn points from users
     85+ [Feature] New "Backup and Restore" module added
     86+ [Feature] New "Reset" module added
     87+ [Change] Updates to the CubePoints modules system
     88+ [Bugfix] Fixed bug where the donate module would not work if unicode characters are entered in the message
     89
    7790
    7891**Version 3.0.3** *(May 13th, 2011)*
Note: See TracChangeset for help on using the changeset viewer.