Plugin Directory

Changeset 176019


Ignore:
Timestamp:
11/22/2009 04:50:00 PM (16 years ago)
Author:
zhykos
Message:

version 1.36 : see readme.txt

Location:
comment-contest/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • comment-contest/trunk/comment-contest.php

    r164608 r176019  
    55Description: If you create a contest on your website, you can draw all comments in a specific post
    66Author: Thomas "Zhykos" Cicognani
    7 Version: 1.35
     7Version: 1.36
    88Author URI: http://www.nozzhy.com
    99*/
     
    3333class CommentContest {
    3434    /*private*/var $domain = '';
    35     /*private*/var $version = '1.35'; // Current version
     35    /*private*/var $version = '1.36'; // Current version
    3636    /*private*/var $option_ns = '';
    3737    /*private*/var $options = array ();
     
    335335    /*private */function step3_chooseComments($idPost, $ranks, $numWinners, $numParticipation, $email, $type, $prizes, $errorMessage = null, $previousComments = null) {
    336336        global $wpdb;
    337 
    338337        $chooseComments = __("Choose comments to include in the contest", $this->localizationName);
    339338        $ok = __("Ok!", $this->localizationName);
     
    351350                $queryTemp = "select user_login from $wpdb->usermeta, $wpdb->users where meta_key='wp_user_level' and  meta_value=$rank and user_id=ID";
    352351                $resultQueryTemp = $wpdb->get_results ( $queryTemp );
     352
    353353                foreach ( $resultQueryTemp as $resultTemp ) {
    354354                    // 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)
     
    356356                }
    357357            } 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) . ")";
    359368                $resultQueryTemp = $wpdb->get_results ( $queryTemp );
     369
    360370                foreach ( $resultQueryTemp as $resultTemp ) {
    361371                    // 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)
     
    363373                }
    364374            } 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) . ")";
    366385                $resultQueryTemp = $wpdb->get_results ( $queryTemp );
     386
    367387                foreach ( $resultQueryTemp as $resultTemp ) {
    368388                    // 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)
     
    378398            $filter = " and (" . implode ( " OR ", $filter ) . ")";
    379399        }
    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";
    384408        $comments = $wpdb->get_results ( $query );
    385        
     409
    386410        if ($comments) {
    387411            echo "<form action='plugins.php?page=comment-contest.php' method='post'>";
  • comment-contest/trunk/readme.txt

    r164608 r176019  
    44Tags: comments contest nozzhy nozgarde zhykos concours commentaire
    55Requires at least: 2.8.4
    6 Tested up to: 2.8.4
     6Tested up to: 2.8.6
    77Stable tag: trunk
    88
     
    7575* Change error message format in certain cases
    7676* 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.