Changeset 46113
- Timestamp:
- 05/16/08 02:08:05 (2 months ago)
- Files:
-
- wp-ajax-edit-comments/trunk/2.0/wp-ajax-edit-comments/css/edit-comments.css (modified) (2 diffs)
- wp-ajax-edit-comments/trunk/2.0/wp-ajax-edit-comments/js/comment-editor.js.php (modified) (1 diff)
- wp-ajax-edit-comments/trunk/2.0/wp-ajax-edit-comments/js/wp-ajax-edit-comments.js.php (modified) (4 diffs)
- wp-ajax-edit-comments/trunk/2.0/wp-ajax-edit-comments/php/AjaxEditComments.php (modified) (1 diff)
- wp-ajax-edit-comments/trunk/2.0/wp-ajax-edit-comments/wp-ajax-edit-comments.php (modified) (14 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
wp-ajax-edit-comments/trunk/2.0/wp-ajax-edit-comments/css/edit-comments.css
r44479 r46113 8 8 padding: 2px 0px; 9 9 padding-left: 20px; 10 float: left; 11 margin-right: 10px; 12 /*todo - clear:after? */ 13 } 14 .clearfix:after { /* from http://blue-anvil.com/archives/experiments-with-floats-whats-the-best-method-of-clearance*/ 15 content: "."; 16 display: block; 17 height: 0; 18 clear: both; 19 visibility: hidden; 10 20 } 11 21 /* Begin Images */ … … 37 47 38 48 } 39 .editableAuthor, .editableComment{40 color: #000;41 background-color: #ffffd3;42 }43 .editAuthor { background-color: transparent; background-image: none; display: inline; margin: 0; padding: 0; border: 0; clear: none;}44 /* Edit me for the textarea shown when editing a comment */45 .textComment textarea { width: 90%; height: 100px; }46 /* Edit me for the div that contains the comment */47 .editComment, .editableComment, .textComment{ /*clear: both;*/ }48 /* various CSS classes you can edit if you really want to49 .ajaxSaveButtons { }50 .textAuthor { }51 .ajaxApproveLinks{}52 span.ajax-admin-edit-links {}53 */54 55 /*Edit me for the message that shows up to a user(non admin) when leaving a comment */56 .ajax-edit { font-size: 1em; font-style: italic; background-color: #333; color: #fff; padding: 5px; font-weight: bold;}57 .ajax-edit .ajax-timer { font-size: 0.8em; color: #FFCC66; }58 input.ajax-error { border: 3px solid #966; }59 textarea.ajax-error, li.ajax-error { background: #966; }wp-ajax-edit-comments/trunk/2.0/wp-ajax-edit-comments/js/comment-editor.js.php
r45538 r46113 156 156 url = this.data; 157 157 break; 158 case "gravatar": 159 $j("#gravatar").html(this.data).show(); 160 break; 158 161 } 159 162 } wp-ajax-edit-comments/trunk/2.0/wp-ajax-edit-comments/js/wp-ajax-edit-comments.js.php
r45725 r46113 51 51 $j(".edit-comment-admin-links").attr("style", "display: inherit"); 52 52 $j(".edit-comment-user-link").attr("style", "display: inherit"); 53 /* For Crappy IE */ 54 $j(".edit-comment-admin-links").show(); 55 $j(".edit-comment-user-link").show(); 53 56 $j(".ajax-admin-edit-links").each(function() { 54 57 var element = $j(this); … … 82 85 data.action = 'gettimeleft'; 83 86 data.success = function(r) { 87 if (r == "-1") { 88 minutes = 0; 89 seconds = 0; 90 } else if (r == "1") { 91 return; 92 } 84 93 var res = wpAjax.parseAjaxResponse(r, data.response,data.element); 85 94 jQuery.each( res.responses, function() { 95 //todo - check for errors 86 96 if (this.what == "minutes") { 87 97 minutes = parseInt(this.data); … … 110 120 element = timer.element; 111 121 //Check to see if the time has run out 112 if (minutes <=0 && seconds <= 0) {122 if (minutes ==0 && seconds == 0) { 113 123 $j("#edit" + timer.cid).unbind(); 114 124 element.remove(); … … 117 127 clearTimeout(timers[timer.cid]); 118 128 return; 119 } 129 } 120 130 if (seconds < 0) { minutes -= 1; seconds = 59; } 121 131 //Create timer text wp-ajax-edit-comments/trunk/2.0/wp-ajax-edit-comments/php/AjaxEditComments.php
r45725 r46113 27 27 if ($WPrapAjaxEditComments->can_edit_url($commentID, $postID)) { 28 28 $comment['comment_author_url'] = trim(strip_tags(urldecode($_POST['comment_author_url']))); 29 //Quick JS Test 30 if ($comment['comment_author_url'] == "undefined") {$comment['comment_author_url']='http://';} 29 31 } 30 32 $WPrapAjaxEditComments->save_comment($commentID, $postID, $comment); wp-ajax-edit-comments/trunk/2.0/wp-ajax-edit-comments/wp-ajax-edit-comments.php
r45728 r46113 98 98 if (!$this->is_comment_owner($comment->comment_post_ID)) { 99 99 //For anonymous users 100 $content .= "<div class='edit-comment-user-link ' id='edit-comment-user-link-$comment->comment_ID'>";100 $content .= "<div class='edit-comment-user-link clearfix' id='edit-comment-user-link-$comment->comment_ID'>"; 101 101 $content .= "<div class='edit-comment'><a title='Ajax Edit Comments' class='ajax-admin-edit-links thickbox' href='$edit_url' id='edit-$comment->comment_ID'>"; 102 102 $content .= $this->adminOptions['edit_text']; … … 104 104 //Check to see if timer is on 105 105 if ($this->adminOptions['show_timer'] == 'true') { 106 $content .= " <span class='ajax-edit-time-left' id='ajax-edit-time-left-$comment->comment_ID'></span>"; 106 //Check to see if user is logged in and admin can indefinitely edit 107 if (!$this->can_indefinitely_edit($comment->user_id)) { 108 $content .= " <span class='ajax-edit-time-left' id='ajax-edit-time-left-$comment->comment_ID'></span>"; 109 } 107 110 } 108 111 $content .= "</div></div>"; 109 112 } else { 110 $content .= '<div class="' . $this->commentClassName . '-admin-links " id="' . $this->commentClassName . '-admin-links' . $comment->comment_ID . '">';113 $content .= '<div class="' . $this->commentClassName . '-admin-links clearfix" id="' . $this->commentClassName . '-admin-links' . $comment->comment_ID . '">'; 111 114 //Spans are used here instead of LIs because of style conflicts in the admin panel 112 115 $content .= "<span class='edit-comment'><a title='Ajax Edit Comments' class='ajax-admin-edit-links thickbox' href='$edit_url' id='edit-$comment->comment_ID'>"; … … 171 174 } 172 175 //Get the current comment 173 $query = "SELECT UNIX_TIMESTAMP(comment_date) time, comment_author_email, comment_author_IP, comment_date_gmt, comment_post_ID, comment_ID FROM $wpdb->comments where comment_ID = $commentID";176 $query = "SELECT UNIX_TIMESTAMP(comment_date) time, comment_author_email, comment_author_IP, comment_date_gmt, comment_post_ID, comment_ID, user_id FROM $wpdb->comments where comment_ID = $commentID"; 174 177 $comment = $wpdb->get_row($query, ARRAY_A); 175 178 if (!$comment) { return 'get_comment_failed'; } … … 178 181 return 'comment_spam'; 179 182 } 180 //Check to see if the user is logged in 181 if ($this->is_logged_in($comment['comment_author_email'])) { 182 //User is logged in and this is the user's comment - Does admin allow indefinite editing? 183 if ($this->adminOptions['registered_users_edit'] == "true") { 184 return 1; //Logged in user can indefinitely edit 185 } 183 184 //Check to see if the user is logged in and can indefinitely edit 185 if ($this->can_indefinitely_edit($comment['user_id'])) { 186 return 1; 186 187 } 187 188 //Now check if options allow editing after an additional comment has been made … … 232 233 if ($this->is_comment_owner($postID)) { return true; } 233 234 $comment = get_comment($commentID, ARRAY_A); 234 if ($this->is_logged_in($comment[' comment_author_email'])) { //logged in235 if ($this->is_logged_in($comment['user_id'])) { //logged in 235 236 if ($this->adminOptions['registered_users_name_edit'] == "true") { return true;} 236 237 } else { //not logged in … … 245 246 if ($this->is_comment_owner($postID)) { return true; } 246 247 $comment = get_comment($commentID, ARRAY_A); 247 if ($this->is_logged_in($comment[' comment_author_email'])) { //logged in248 if ($this->is_logged_in($comment['user_id'])) { //logged in 248 249 if ($this->adminOptions['registered_users_email_edit'] == "true") { return true;} 249 250 } else { //not logged in … … 258 259 if ($this->is_comment_owner($postID)) { return true; } 259 260 $comment = get_comment($commentID, ARRAY_A); 260 if ($this->is_logged_in($comment[' comment_author_email'])) { //logged in261 if ($this->is_logged_in($comment['user_id'])) { //logged in 261 262 if ($this->adminOptions['registered_users_url_edit'] == "true") { return true;} 262 263 } else { //not logged in … … 271 272 if ($this->is_comment_owner($postID)) { return true; } 272 273 $comment = get_comment($commentID, ARRAY_A); 273 if ($this->is_logged_in($comment[' comment_author_email'])) { //logged in274 if ($this->is_logged_in($comment['user_id'])) { //logged in 274 275 if ($this->adminOptions['registered_users_url_edit'] == "true" || $this->adminOptions['registered_users_email_edit'] == "true" || $this->adminOptions['registered_users_name_edit'] == "true" ) { return true;} 275 276 } else { //not logged in 276 277 if ($this->adminOptions['allow_url_editing'] == "true" || $this->adminOptions['allow_email_editing'] == "true" || $this->adminOptions['allow_name_editing'] == "true") { return true;} 278 } 279 return false; 280 } 281 /* can_indefinitely_edit 282 Parameters - $userID 283 Returns - true if can, false if not */ 284 function can_indefinitely_edit($userID = 0) { 285 if ($this->is_logged_in($userID)) { 286 //User is logged in and this is the user's comment - Does admin allow indefinite editing? 287 if ($this->adminOptions['registered_users_edit'] == "true") { 288 return true; //Logged in user can indefinitely edit 289 } 277 290 } 278 291 return false; … … 340 353 return $commentID; 341 354 } 342 //Check to see if admin allows comment editing 355 //Don't save data if user can indefinitely edit 356 if ($this->can_indefinitely_edit($comment['user_id'])) { return $commentID; } 357 //Check to see if admin allows comment editing 343 358 if ($this->adminOptions['allow_editing'] == "false") { return $commentID;} 344 359 … … 521 536 } 522 537 /* get_time_left - Returns time remaining in seconds 523 parameters - $commentID */ 538 parameters - $commentID 539 Returns 1 if no time is necessary. -1 if time is unavailable. Time if available. 540 */ 524 541 function get_time_left($commentID = 0) { 525 542 global $wpdb; 526 543 $adminMinutes = (int)$this->adminOptions['minutes']; 527 $query = "SELECT ($adminMinutes * 60 - (UNIX_TIMESTAMP('" . current_time('mysql') . "') - UNIX_TIMESTAMP(comment_date))) time FROM $wpdb->comments where comment_ID = $commentID"; 544 $query = "SELECT ($adminMinutes * 60 - (UNIX_TIMESTAMP('" . current_time('mysql') . "') - UNIX_TIMESTAMP(comment_date))) time, comment_author_email, user_id FROM $wpdb->comments where comment_ID = $commentID"; 545 528 546 //Get the Timestamp 529 547 $comment = $wpdb->get_row($query, ARRAY_A); 530 if (!$comment) { return "0"; } 548 if (!$comment) { return "-1"; } 549 if ($this->can_indefinitely_edit($comment['user_id'])) { 550 return "1"; 551 } 531 552 //Get the time elapsed since making the comment 532 if ( $comment['time'] <= 0) { return "0"; }553 if ((int)$comment['time'] <= 0) { return "-1"; } 533 554 $timeleft = (int)$comment['time']; 534 555 $minutes = floor($timeleft/60); … … 607 628 Parameters - $email 608 629 Returns true if logged in, false if not */ 609 function is_logged_in($ email = '') {610 if ($this->get_user_ email() == $email) {630 function is_logged_in($userID = 0) { 631 if ($this->get_user_id() == $userID) { 611 632 return true; 612 633 } else { … … 693 714 //Condition the data for returning 694 715 do_action('wp_ajax_comments_remove_content_filter'); 716 //todo some char issues with quotes 695 717 $response->add( array( 696 718 'what' => 'comment_content', 697 719 'id' => $commentID, 698 'data' => apply_filters('comment_text',apply_filters('get_comment_text',$this->encode($commentarr['comment_content'])))720 'data' => stripslashes(apply_filters('comment_text',apply_filters('get_comment_text',$this->encode($commentarr['comment_content'])))) 699 721 )); 700 722 $response->add( array( 701 723 'what' => 'comment_author', 702 724 'id' => $commentID, 703 'data' => apply_filters('comment_author', apply_filters('get_comment_author', $this->encode($commentarr['comment_author'])))725 'data' => stripslashes(apply_filters('comment_author', apply_filters('get_comment_author', $this->encode($commentarr['comment_author'])))) 704 726 )); 705 //Quick JavaScript test706 727 $response->add( array( 707 728 'what' => 'comment_author_url', 708 729 'id' => $commentID, 709 'data' => apply_filters('comment_url', apply_filters('get_comment_author_url', $commentarr['comment_author_url'])) 730 'data' => stripslashes(apply_filters('comment_url', apply_filters('get_comment_author_url', $commentarr['comment_author_url']))) 731 )); 732 $response->add( array( 733 'what' => 'gravatar', 734 'id' => $commentID, 735 'data' => get_avatar($commentarr['comment_author_email'], '40') 710 736 )); 711 737 $response->send(); … … 810 836 return $user_email; 811 837 } 838 // Returns a logged-in user's ID 839 function get_user_id() { 840 global $user_ID; 841 if (!function_exists("get_currentuserinfo")) { return "-1"; } 842 if (empty($user_ID)) {get_currentuserinfo();} //try to get user info 843 if (empty($user_ID)) { return '-1'; } //Can't get user info, so return empty string 844 return $user_ID; 845 } 812 846 813 847 //Returns an array of an individual's options … … 857 891 echo '<link rel="stylesheet" href="'.get_bloginfo('wpurl').'/wp-content/plugins/wp-ajax-edit-comments/css/edit-comments.css" type="text/css" media="screen" />'; 858 892 echo '<link rel="stylesheet" href="'.get_bloginfo('wpurl').'//wp-includes/js/thickbox/thickbox.css" type="text/css" media="all" />'; 893 /* From http://blue-anvil.com/archives/experiments-with-floats-whats-the-best-method-of-clearance */ 894 ?> 895 <!-- Ajax Edit Comments --> 896 <!--[if IE]> 897 <style> 898 .clearfix {display: inline-block;} 899 /* Hides from IE-mac \*/ 900 * html .clearfix {height: 1%;} 901 .clearfix {display: block;} 902 /* End hide from IE-mac */ 903 </style> 904 <![endif]--> 905 <?php 859 906 } 860 907 }
