Changeset 445086
- Timestamp:
- 09/29/2011 06:38:02 AM (14 years ago)
- Location:
- cubepoints/trunk
- Files:
-
- 8 added
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
cubepoints/trunk/cp_admin.php
r384401 r445086 8 8 add_menu_page('CubePoints', 'CubePoints', 'manage_options', 'cp_admin_manage', 'cp_admin_manage'); 9 9 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'); 10 11 add_submenu_page('cp_admin_manage', 'CubePoints - ' .__('Configure','cp'), __('Configure','cp'), 'manage_options', 'cp_admin_config', 'cp_admin_config'); 11 12 add_submenu_page('cp_admin_manage', 'CubePoints - ' .__('Logs','cp'), __('Logs','cp'), 'manage_options', 'cp_admin_logs', 'cp_admin_logs'); … … 16 17 /** Include admin pages */ 17 18 require_once('cp_admin_manage.php'); 19 require_once('cp_admin_add_points.php'); 18 20 require_once('cp_admin_config.php'); 19 21 require_once('cp_admin_logs.php'); … … 45 47 add_action('admin_print_styles-cubepoints_page_cp_admin_modules', 'cp_datatables_style'); 46 48 49 /** Register autocomplete script and stylesheet for admin pages */ 50 wp_register_script('autocomplete', 51 CP_PATH . 'assets/autocomplete/jquery.autocomplete.js', 52 array('jquery'), 53 '3.2.2' ); 54 wp_register_style('autocomplete', CP_PATH . 'assets/autocomplete/jquery.autocomplete.css'); 55 56 /** Enqueue autocomplete */ 57 function cp_autocomplete_script(){ 58 wp_enqueue_script('autocomplete'); 59 } 60 function cp_autocomplete_style(){ 61 wp_enqueue_style('autocomplete'); 62 } 63 add_action('admin_print_scripts-cubepoints_page_cp_admin_add_points', 'cp_autocomplete_script'); 64 add_action('admin_print_styles-cubepoints_page_cp_admin_add_points', 'cp_autocomplete_style'); 65 47 66 ?> -
cubepoints/trunk/cp_common.php
r373336 r445086 4 4 */ 5 5 6 function cp_donate_html(){ 6 7 /** Prints HTML for donate link */ 8 function cp_donate_html(){ 7 9 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 */ 13 function 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 */ 32 class CURL { 33 var $callback = false; 34 35 function setCallback($func_name) { 36 $this->callback = $func_name; 37 } 38 39 function 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 67 function get($url) { 68 return $this->doRequest('GET', $url, 'NULL'); 69 } 70 71 function post($url, $vars) { 72 return $this->doRequest('POST', $url, $vars); 73 } 74 } 9 75 10 76 ?> -
cubepoints/trunk/cp_core.php
r373336 r445086 73 73 global $wpdb; 74 74 if($amt>0){ $limit = ' LIMIT ' . $start.','.$amt; } 75 $extraquery = ''; 75 76 if (count($filter_users)>0){ 76 77 $extraquery = ' WHERE '.$wpdb->base_prefix.'users.user_login != \''; … … 116 117 cp_updatePoints($uid, $points); 117 118 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 past126 $ending = __('ago','cp');127 } else { // this was in the future128 $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;137 119 } 138 120 … … 202 184 } 203 185 186 /** Function to cache module versions and run activation hook on module update */ 187 function 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 204 205 205 206 ?> -
cubepoints/trunk/cp_hooks.php
r384401 r445086 10 10 echo $data; 11 11 } 12 13 /** Add Points logs hook */ 14 add_action('cp_logs_description','cp_admin_logs_desc_addpoints', 10, 4); 15 function cp_admin_logs_desc_addpoints($type,$uid,$points,$data){ 16 if($type!='addpoints') { return; } 17 echo $data; 18 } 12 19 13 20 /** Comments hook */ 14 21 add_action('comment_post', 'cp_newComment', 10 ,2); 15 22 function 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){28 23 $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 */ 31 add_action('comment_unapproved_to_approved', 'cp_commentApprove', 10, 1); 32 add_action('comment_trash_to_approved', 'cp_commentApprove', 10, 1); 33 add_action('comment_spam_to_approved', 'cp_commentApprove', 10, 1); 34 function 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 */ 40 add_action('comment_approved_to_unapproved', 'cp_commentUnapprove', 10, 1); 41 add_action('comment_approved_to_trash', 'cp_commentUnapprove', 10, 1); 42 add_action('comment_approved_to_spam', 'cp_commentUnapprove', 10, 1); 43 function 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); 36 46 } 37 47 … … 50 60 } 51 61 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 63 62 /** Comments removal logs hook */ 64 63 add_action('cp_logs_description','cp_admin_logs_desc_comment_remove', 10, 4); … … 260 259 } 261 260 261 /** Hook for add-points autocomplete user suggestion */ 262 add_action( 'wp_ajax_cp_add_points_user_suggest', 'cp_add_points_user_suggest' ); 263 function 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 */ 288 add_action( 'wp_ajax_cp_add_points_user_query', 'cp_add_points_user_query' ); 289 function 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 */ 320 add_action( 'wp_ajax_cp_add_points_user_update', 'cp_add_points_user_update' ); 321 function 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 } 262 340 263 341 ?> -
cubepoints/trunk/cp_widgets.php
r373336 r445086 65 65 $field_id = $this->get_field_id($field); 66 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="'. 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>'; 68 68 69 69 $field = 'text'; 70 70 $field_id = $this->get_field_id($field); 71 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="'. 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>'; 73 73 74 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 />'; … … 77 77 $field_id = $this->get_field_id($field); 78 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="'. 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>'; 80 80 81 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 />'; … … 84 84 $field_id = $this->get_field_id($field); 85 85 $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>'; 87 88 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>'; … … 143 144 $field_id = $this->get_field_id($field); 144 145 $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>'; 146 147 147 148 $field = 'num'; 148 149 $field_id = $this->get_field_id($field); 149 150 $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>'; 151 152 152 153 $field = 'text'; 153 154 $field_id = $this->get_field_id($field); 154 155 $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>'; 156 157 157 158 echo "\r\n".'<small><strong>'.__('Shortcodes', 'cp') . ':</strong><br />'; … … 168 169 $field_id = $this->get_field_id($field); 169 170 $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>'; 171 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 />'; 172 173 } -
cubepoints/trunk/cubepoints.php
r384405 r445086 4 4 Plugin URI: http://cubepoints.com 5 5 Description: 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><?php cp_displayPoints(); ?></code> in your template or activate the sidebar widget. 6 Version: 3. 0.36 Version: 3.1 7 7 Author: Jonathan Lau & Peter Zhang 8 8 Author URI: http://cubepoints.com … … 12 12 13 13 /** Define constants */ 14 define('CP_VER', '3. 0.1');14 define('CP_VER', '3.1'); 15 15 define('CP_DB', $wpdb->base_prefix . 'cp'); 16 16 define('CP_PATH', WP_PLUGIN_URL.'/'.str_replace(basename( __FILE__),"",plugin_basename(__FILE__))); … … 58 58 add_action('plugins_loaded','cp_modules_include',2); 59 59 60 /** Checks if modules have been updated and run activation hook */ 61 add_action('init', 'cp_modules_updateCheck'); 62 60 63 ?> -
cubepoints/trunk/modules/comment_spam_control.php
r373336 r445086 7 7 if(cp_module_activated('cp_csc')){ 8 8 add_action('cp_newComment', 'cp_module_csc_newComment'); 9 add_action('cp_approvedComment', 'cp_module_csc_newComment'); 9 10 function cp_module_csc_newComment($cid) { 10 11 if (is_user_logged_in()) { -
cubepoints/trunk/modules/donate/donate.php
r384401 r445086 3 3 /** Donate Module */ 4 4 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);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); 6 6 7 7 if(cp_module_activated('donate')){ … … 26 26 $recipient = $_POST['recipient']; 27 27 $points = $_POST['points']; 28 $message = str_replace("'",''',htmlentities(stripslashes($_POST['message'])));28 $message = htmlentities(stripslashes($_POST['message']), ENT_QUOTES, 'UTF-8'); 29 29 $user = get_userdatabylogin($recipient); 30 30 … … 75 75 76 76 else{ 77 $message = mb_convert_encoding($message, 'HTML-ENTITIES', 'UTF-8'); 77 78 $r['success'] = true; 78 79 $r['message'] = __('Your donation is successful!', 'cp'); -
cubepoints/trunk/modules/notice/jquery.notice.css
r373336 r445086 1 1 .notice-wrap { 2 2 position: fixed; 3 top: 20px; 4 right: 20px; 5 width: 250px; 3 top: 50px; 4 right: 50px; 6 5 z-index: 9999; 7 6 opacity: 0.8; … … 12 11 position: absolute; 13 12 } 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; 16 26 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; 19 34 } 20 35 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); 35 42 } 36 43 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; 45 46 } 46 .notice-item-close:hover{47 color: #fff;48 } -
cubepoints/trunk/modules/notice/jquery.notice.js
r373336 r445086 64 64 options.stayTime); 65 65 } 66 66 67 }, 67 68 -
cubepoints/trunk/modules/notice/notice.php
r373336 r445086 3 3 /** Notify Module */ 4 4 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);5 cp_module_register(__('Notify', 'cp') , 'notify' , '1.1', 'CubePoints', 'http://cubepoints.com', 'http://cubepoints.com' , __('After activating this module, a growl-like pop up will appear to your users each time they earn points.', 'cp'), 1); 6 6 7 7 function cp_module_notify_install(){ … … 17 17 dbDelta($sql); 18 18 add_option("cp_module_notify_db_version'", "1.0"); 19 add_option("cp_module_notify_header", "CubePoints Notice");20 19 } 21 20 } … … 55 54 /************************ 56 55 * 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 ************************/ 85 57 86 58 add_action('wp_footer', 'cp_module_notify_display_hook', 10, 1); 87 59 function cp_module_notify_display($text = ''){ 88 60 if($text==''){ return; } 89 $header = get_option('cp_module_notify_header');90 61 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>'; 96 70 } 97 71 function cp_module_notify_hook(){ … … 143 117 function cp_module_notify_logsHook($type, $uid, $points, $data){ 144 118 if($points>0){ 145 $m= __('You have just earned %points%...', 'cp');119 $m= '+%npoints%'; 146 120 } else { 147 $m= __('You have just lost %points%...', 'cp');121 $m='-%npoints%'; 148 122 } 149 123 $m = apply_filters('cp_module_notify_msg',array($m, $type, $uid, $points, $data)); … … 152 126 } 153 127 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 169 128 } 170 129 ?> -
cubepoints/trunk/modules/paid_content.php
r373336 r445086 3 3 /** Paid Content Module */ 4 4 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); 5 cp_module_register(__('Paid Content', 'cp') , 'pcontent' , '1.1', 'CubePoints', 'http://cubepoints.com', 'http://cubepoints.com' , __('This module lets you deduct point from users to view a page or post.', 'cp'), 1); 6 7 function 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 } 16 add_action('cp_module_pcontent_activate','cp_module_pcontent_install'); 6 17 7 18 if(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'); 8 91 9 92 /* Define the custom box */ … … 26 109 // Use nonce for verification 27 110 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 } 29 119 // 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.' /> '; 31 121 echo '<label for="cp_module_pcontent_enable">' . __("Enable paid content" , 'cp') . '</label> '; 32 122 echo '<br /><br />'; 33 123 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 />'; 35 125 } 36 126 … … 101 191 return $content; 102 192 } 103 $c = __('You need to pay %points% to view this page!', 'cp');193 $c = '<p>' . get_option('cp_module_pcontent_text_pay') . '</p>'; 104 194 $c .= apply_filters('cp_module_pcontent_post_content_'.$post->ID, ''); 105 $c .= '< br /><br /><form method="post">';195 $c .= '<form method="post">'; 106 196 $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>'; 108 198 $c .= '</form>'; 199 if(!is_user_logged_in()){ 200 $c = get_option('cp_module_pcontent_text_logout'); 201 } 109 202 $c = str_replace('%points%',cp_formatPoints(get_post_meta($post->ID,'cp_pcontent_points', 1)),$c); 110 203 return $c; … … 123 216 } 124 217 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>";')); 126 219 return; 127 220 } 128 221 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>";')); 130 223 return; 131 224 } 132 225 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 } 133 230 } 134 231 … … 138 235 if($type!='pcontent') { return; } 139 236 $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>"'; 141 248 } 142 249 -
cubepoints/trunk/readme.txt
r384401 r445086 4 4 Tags: points, comments, post, admin, widget 5 5 Requires at least: 2.2 6 Tested up to: 3. 1.27 Stable tag: 3. 0.36 Tested up to: 3.2.1 7 Stable tag: 3.1 8 8 9 9 CubePoints is a point management system designed for WordPress blogs. … … 48 48 49 49 = 3.0.3 = 50 New features and modules added. Several bugs fixed as well. 51 52 = 3.0.3 = 50 53 New module (YouTube Video) added. Minor bugfixes made and improved code for XHTML validation. 51 54 … … 75 78 76 79 == 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 77 90 78 91 **Version 3.0.3** *(May 13th, 2011)*
Note: See TracChangeset
for help on using the changeset viewer.