Changeset 176019
- Timestamp:
- 11/22/2009 04:50:00 PM (16 years ago)
- Location:
- comment-contest/trunk
- Files:
-
- 2 edited
-
comment-contest.php (modified) (7 diffs)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
comment-contest/trunk/comment-contest.php
r164608 r176019 5 5 Description: If you create a contest on your website, you can draw all comments in a specific post 6 6 Author: Thomas "Zhykos" Cicognani 7 Version: 1.3 57 Version: 1.36 8 8 Author URI: http://www.nozzhy.com 9 9 */ … … 33 33 class CommentContest { 34 34 /*private*/var $domain = ''; 35 /*private*/var $version = '1.3 5'; // Current version35 /*private*/var $version = '1.36'; // Current version 36 36 /*private*/var $option_ns = ''; 37 37 /*private*/var $options = array (); … … 335 335 /*private */function step3_chooseComments($idPost, $ranks, $numWinners, $numParticipation, $email, $type, $prizes, $errorMessage = null, $previousComments = null) { 336 336 global $wpdb; 337 338 337 $chooseComments = __("Choose comments to include in the contest", $this->localizationName); 339 338 $ok = __("Ok!", $this->localizationName); … … 351 350 $queryTemp = "select user_login from $wpdb->usermeta, $wpdb->users where meta_key='wp_user_level' and meta_value=$rank and user_id=ID"; 352 351 $resultQueryTemp = $wpdb->get_results ( $queryTemp ); 352 353 353 foreach ( $resultQueryTemp as $resultTemp ) { 354 354 // V1.35 - BUG FIX : Simple and double quotes protected because if a pseudo contains quotes, the query bugs (thanks to Kamel from www.yoocom.fr) … … 356 356 } 357 357 } elseif ($rank == 0) { // Subscriber 358 $queryTemp = "select meta_value from $wpdb->usermeta where meta_key='nickname' and user_id not in(select distinct user_id from $wpdb->usermeta where meta_key='wp_user_level')"; 358 // V1.36 - Remove sub-query & add a new temporary query 359 $subQueryTemp = "select distinct user_id from $wpdb->usermeta where meta_key='wp_user_level'"; 360 $resultSubQueryTemp = $wpdb->get_results ( $subQueryTemp ); 361 $resultTempString = null; 362 foreach($resultSubQueryTemp as $r) { 363 $resultTempString[] = $r->user_id; 364 } 365 366 //$queryTemp = "select meta_value from $wpdb->usermeta where meta_key='nickname' and user_id not in(select distinct user_id from $wpdb->usermeta where meta_key='wp_user_level')"; 367 $queryTemp = "select meta_value from $wpdb->usermeta where meta_key='nickname' and user_id not in(" . implode(",", $resultTempString) . ")"; 359 368 $resultQueryTemp = $wpdb->get_results ( $queryTemp ); 369 360 370 foreach ( $resultQueryTemp as $resultTemp ) { 361 371 // V1.35 - BUG FIX : Simple and double quotes protected because if a pseudo contains quotes, the query bugs (thanks to Kamel from www.yoocom.fr) … … 363 373 } 364 374 } else { // User ($rank == -1) 365 $queryTemp = "SELECT comment_author FROM $wpdb->comments WHERE comment_approved = \"1\" and comment_post_id='$idPost' and comment_author not in (select meta_value from $wpdb->usermeta where meta_key='nickname')"; 375 // V1.36 - Remove sub-query & add a new temporary query 376 $subQueryTemp = "select meta_value from $wpdb->usermeta where meta_key='nickname'"; 377 $resultSubQueryTemp = $wpdb->get_results ( $subQueryTemp ); 378 $resultTempString = null; 379 foreach($resultSubQueryTemp as $r) { 380 $resultTempString[] = "\"" . addslashes($r->meta_value) . "\""; 381 } 382 383 //$queryTemp = "SELECT comment_author FROM $wpdb->comments WHERE comment_approved = \"1\" and comment_post_id='$idPost' and comment_author not in (select meta_value from $wpdb->usermeta where meta_key='nickname')"; 384 $queryTemp = "SELECT comment_author FROM $wpdb->comments WHERE comment_approved = \"1\" and comment_post_id='$idPost' and comment_author not in (" . implode(",", $resultTempString) . ")"; 366 385 $resultQueryTemp = $wpdb->get_results ( $queryTemp ); 386 367 387 foreach ( $resultQueryTemp as $resultTemp ) { 368 388 // V1.35 - BUG FIX : Simple and double quotes protected because if a pseudo contains quotes, the query bugs (thanks to Kamel from www.yoocom.fr) … … 378 398 $filter = " and (" . implode ( " OR ", $filter ) . ")"; 379 399 } 380 381 $query = "SELECT * FROM $wpdb->comments WHERE comment_approved = \"1\" and comment_post_id='$idPost' and comment_author != ( 382 select user_login from $wpdb->users u, $wpdb->posts p where u.ID = post_author and p.ID = '$idPost' 383 )$filter ORDER BY comment_author"; 400 401 // V1.36 - Remove sub-query & add a new temporary query 402 $query = "select user_login from $wpdb->users u, $wpdb->posts p where u.ID = post_author and p.ID = '$idPost'"; 403 $postAuthor = $wpdb->get_results ( $query ); 404 $postAuthor = addslashes($postAuthor[0] -> user_login); 405 406 //$query = "SELECT * FROM $wpdb->comments WHERE comment_approved = '1' and comment_post_id='$idPost' and comment_author != (select user_login from $wpdb->users u, $wpdb->posts p where u.ID = post_author and p.ID = '$idPost') $filter ORDER BY comment_author"; 407 $query = "SELECT * FROM $wpdb->comments WHERE comment_approved = '1' and comment_post_id='$idPost' and comment_author != '$postAuthor' $filter ORDER BY comment_author"; 384 408 $comments = $wpdb->get_results ( $query ); 385 409 386 410 if ($comments) { 387 411 echo "<form action='plugins.php?page=comment-contest.php' method='post'>"; -
comment-contest/trunk/readme.txt
r164608 r176019 4 4 Tags: comments contest nozzhy nozgarde zhykos concours commentaire 5 5 Requires at least: 2.8.4 6 Tested up to: 2.8. 46 Tested up to: 2.8.6 7 7 Stable tag: trunk 8 8 … … 75 75 * Change error message format in certain cases 76 76 * Change localization message in French 77 78 = 1.36 = 79 * If you use MySQL version 4.0, the plugin doesn't work because sub-querys are not compatible with MySQL 4.0. You have to use MySQL 4.1.xxx at least but some website provider don't allow us to choose our version. Sub-querys are now removed.
Note: See TracChangeset
for help on using the changeset viewer.