Plugin Directory

Changeset 724078


Ignore:
Timestamp:
06/07/2013 04:07:27 PM (13 years ago)
Author:
shauno
Message:

missed Version tag in file header. oops :)

Location:
nextgen-gallery-voting
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • nextgen-gallery-voting/tags/2.4/ngg-voting.php

    r681442 r724078  
    44Plugin URI: http://shauno.co.za/wordpress/nextgen-gallery-voting/
    55Description: This plugin allows you to add user voting and rating to NextGEN Galleries and Images
    6 Version: 2.4
     6Version: 2.5.1
    77Author: Shaun Alberts
    88Author URI: http://shauno.co.za
     
    3535
    3636class nggVoting {
    37     private $dbVersion = 2.4;
     37    private $dbVersion = 2.5;
    3838    private $slug;
    3939    public $types = array(
     
    138138                force_once TINYINT NOT NULL DEFAULT 0,
    139139                enforce_with_cookie TINYINT NOT NULL DEFAULT 0,
     140                force_once_time TINYINT NOT NULL DEFAULT 0,
    140141                user_results TINYINT NOT NULL DEFAULT 0,
    141142                voting_type INT NOT NULL DEFAULT 1,
     
    188189         * @return array("avg"=>double average for image, "list"=>array of objects of all votes of the image, "number"=>integer the number of votes for the image)
    189190         */
    190         function getImageVotingResults($pid, $type=array("avg"=>true, "list"=>true, "number"=>true, "likes"=>true, "dislikes"=>true)) {
     191        function getImageVotingResults($pid, $type=array("avg"=>true, "list"=>true, "number"=>true, "likes"=>true, "dislikes"=>true), $extraWhere='') {
    191192            if(is_numeric($pid)) { //old style arg where just 'pid' was needed
    192193                $criteriaId = 0; //default for old calls and add ons
     
    207208                }
    208209                if(isset($type["list"]) && $type["list"]) {
    209                     $list = $wpdb->get_results("SELECT * FROM ".$wpdb->prefix."nggv_votes WHERE pid = '".$wpdb->escape($pid)."' AND criteria_id = '".$wpdb->escape($criteriaId)."' ORDER BY dateadded DESC");
     210                    $where = "pid = '".$wpdb->escape($pid)."' AND criteria_id = '".$wpdb->escape($criteriaId)."'";
     211                    if($extraWhere) {
     212                        $where = '('.$where.') AND ('.$extraWhere.')';
     213                    }
     214                    $list = $wpdb->get_results("SELECT * FROM ".$wpdb->prefix."nggv_votes WHERE ".$where." ORDER BY dateadded DESC");
    210215                    $results['list'] = $list;
    211216                }
     
    354359            if($options->force_once == 1) {
    355360                if($options->force_login) { //force login, so check userid has voted already
    356                     if($this->userHasVotedImage(array('pid'=>$pid, 'criteria_id'=>$criteriaId), $current_user->ID)) {
    357                         return "USER HAS VOTED";
     361                    if($vote = $this->userHasVotedImage(array('pid'=>$pid, 'criteria_id'=>$criteriaId), $current_user->ID)) {
     362                        $canVote = apply_filters('nggv_check_vote_time', null, $pid, $criteriaId, $options, $vote[0]->dateadded);
     363                       
     364                        if($canVote === true) { //time allows it!
     365                            return true;
     366                        }else if($canVote) { //returned a string, so thats an error
     367                            return 'USER '.$canVote;
     368                        }else{ //not allowing or error message, so fall back to old default
     369                            return 'USER HAS VOTED';
     370                        }
    358371                    }
    359372                }else{ //no forced login, so just check the IP for a vote
    360373                    $canVote = apply_filters('nggv_image_can_vote', $pid, $criteriaId, $options, null);
    361374                   
    362                     if($canVote === true) {
     375                    if($canVote === true) { //cookie allows it!
    363376                        return true;
    364                     }else if($canVote === false) {
    365                         return "COOKIE HAS VOTED";
    366                     }else{
    367                         if($this->ipHasVotedImage(array('pid'=>$pid, 'criteria_id'=>$criteriaId))) {
    368                             return "IP HAS VOTED";
     377                    }else if($canVote) { //returned a string, so thats an error
     378                        return $canVote;
     379                    }else if($canVote === null) { //cookie voting not set, so use IP
     380                        if($vote = $this->ipHasVotedImage(array('pid'=>$pid, 'criteria_id'=>$criteriaId))) {
     381                            $canVote = apply_filters('nggv_check_vote_time', null, $pid, $criteriaId, $options, $vote[0]->dateadded);
     382                           
     383                            if($canVote === true) { //filter (cookie for now) allows it!
     384                                return true;
     385                            }else if($canVote) {
     386                                return 'IP '.$canVote;
     387                            }else{
     388                                return "IP HAS VOTED";
     389                            }
    369390                        }
    370391                    }
     
    372393            }else if($options->force_once == 2) {
    373394                if($options->force_login) { //force login, so check userid has voted already
    374                     if($this->userHasVotedOnGalleryImage(array('pid'=>$pid, 'criteria_id'=>$criteriaId), $current_user->ID)) {
    375                         return "USER HAS VOTED";
     395                   
     396                    if($vote = $this->userHasVotedOnGalleryImage(array('pid'=>$pid, 'criteria_id'=>$criteriaId), $current_user->ID)) {
     397                        $canVote = apply_filters('nggv_check_vote_time', null, $pid, $criteriaId, $options, $vote[0]->dateadded);
     398                       
     399                        if($canVote === true) { //time allows it!
     400                            return true;
     401                        }else if($canVote) { //returned a string, so thats an error
     402                            return 'USER '.$canVote;
     403                        }else{ //not allowing or error message, so fall back to old default
     404                            return 'USER HAS VOTED';
     405                        }
    376406                    }
    377407                }else{ //no forced login, so just check (a filter return value), then the IP for a vote
     408                    $canVote = apply_filters('nggv_image_can_vote', $pid, $criteriaId, $options, null);
     409                                                           
     410                    if($canVote === true) { //cookie allows it!
     411                        return true;
     412                    }else if($canVote) { //returned a string, so thats an error
     413                        return $canVote;
     414                    }else if($canVote === null) { //cookie voting not set, so use IP
     415                        if($vote = $this->ipHasVotedOnGalleryImage(array('pid'=>$pid, 'criteria_id'=>$criteriaId))) {
     416                            $canVote = apply_filters('nggv_check_vote_time', null, $pid, $criteriaId, $options, $vote[0]->dateadded);
     417                           
     418                            if($canVote === true) { //cookie allows it!
     419                                return true;
     420                            }else if($canVote) {
     421                                return 'IP '.$canVote;
     422                            }else{
     423                                return "IP HAS VOTED";
     424                            }
     425                        }
     426                    }
     427
     428                   
     429                   
     430                    /*
    378431                    $canVote = apply_filters('nggv_image_can_vote', $pid, $criteriaId, $options, null);
    379432                   
     
    387440                        }
    388441                    }
     442                    */
    389443                }
    390444            }
     
    431485            }
    432486           
    433             if($votes = $wpdb->get_results("SELECT * FROM ".$wpdb->prefix."nggv_votes WHERE pid = '".$wpdb->escape($pid)."' AND criteria_id = '".$wpdb->escape($criteriaId)."' AND user_id = '".$wpdb->escape($userid)."'")) {
     487            if($votes = $wpdb->get_results("SELECT * FROM ".$wpdb->prefix."nggv_votes WHERE pid = '".$wpdb->escape($pid)."' AND criteria_id = '".$wpdb->escape($criteriaId)."' AND user_id = '".$wpdb->escape($userid)."' ORDER BY dateadded DESC")) {
    434488                return $votes;
    435489            }else{
     
    464518           
    465519            $picturelist = nggdb::get_gallery($image->gid);
     520            $inPid = array();
    466521            foreach ((array)$picturelist as $key=>$val) {
    467                 if($v = $this->userHasVotedImage(array('pid'=>$val->pid, 'criteria_id'=>$criteriaId), $userid)) {
    468                     return true; //aha! there was a vote somewhere in this gallery.
    469                 }
    470             }
    471            
    472             return false; //cant find any votes, so seems safe
    473            
     522                $inPid[] = $val->pid;
     523            }
     524           
     525            if($votes = $wpdb->get_results("SELECT * FROM ".$wpdb->prefix."nggv_votes WHERE pid IN (".implode(', ', $inPid).") AND criteria_id = '".$wpdb->escape($criteriaId)."' AND user_id = '".$wpdb->escape($userid)."' ORDER BY dateadded DESC")) {
     526                return $votes;
     527            }else{
     528                return array();
     529            }
    474530        }
    475531
     
    487543            global $wpdb;
    488544           
     545            if(!$ip) {
     546                $tmp = $this->getUserIp();
     547                $ip = $tmp["ip"];
     548            }
     549           
    489550            if(is_numeric($pid)) { //old style arg where just 'pid' was needed
    490551                $criteriaId = 0; //default for old calls and add ons
     
    500561           
    501562            $picturelist = nggdb::get_gallery($image->gid);
     563            $inPid = array();
    502564            foreach ((array)$picturelist as $key=>$val) {
    503                 if($v = $this->ipHasVotedImage(array('pid'=>$val->pid, 'criteria_id'=>$criteriaId), $ip)) {
    504                     return true; //aha! there was a vote somewhere in this gallery.
    505                 }
    506             }
    507            
    508             return false; //cant find any votes, so seems safe
     565                $inPid[] = $val->pid;
     566            }
     567           
     568            if($votes = $wpdb->get_results("SELECT * FROM ".$wpdb->prefix."nggv_votes WHERE pid IN (".implode(', ', $inPid).") AND criteria_id = '".$wpdb->escape($criteriaId)."' AND ip = '".$wpdb->escape($ip)."' ORDER BY dateadded DESC")) {
     569                return $votes;
     570            }else{
     571                return array();
     572            }
    509573        }
    510574       
     
    556620            }
    557621           
    558             if($votes = $wpdb->get_results("SELECT * FROM ".$wpdb->prefix."nggv_votes WHERE pid = '".$wpdb->escape($pid)."' AND criteria_id = '".$wpdb->escape($criteriaId)."' AND ip = '".$wpdb->escape($ip)."'")) {
     622            if($votes = $wpdb->get_results("SELECT * FROM ".$wpdb->prefix."nggv_votes WHERE pid = '".$wpdb->escape($pid)."' AND criteria_id = '".$wpdb->escape($criteriaId)."' AND ip = '".$wpdb->escape($ip)."' ORDER BY dateadded DESC")) {
    559623                return $votes;
    560624            }else{
     
    742806            wp_enqueue_script('thickbox');
    743807            wp_enqueue_style('thickbox');
     808           
     809            wp_enqueue_script('jquery-ui-datepicker');
     810            wp_enqueue_script('nggv-top-voted', $this->pluginUrl.'js/top-voted.js');
     811            wp_enqueue_style('jquery-ui-nggv', $this->pluginUrl.'css/jquery-ui/jquery-ui-1.10.3.custom.min.css');
    744812        }
    745813       
     
    9761044       
    9771045                                <tr valign="top">
    978                                     <th>Number of votes allowed<br ><em>(IP or userid is used to stop multiple)</em></th>
     1046                                    <th>Limit user to 1 vote:<br ><em>(IP or userid is used to stop multiple)</em></th>
    9791047                                    <td style="text-align:center;"><input type="checkbox" name="nggv[gallery][force_once]" <?php echo (get_option('nggv_gallery_force_once') ? 'checked="checked"' : ''); ?> /></td>
    9801048                                    <td style="text-align:center;">
     
    10471115            $_GET['nggv']['limit'] = isset($_GET['nggv']['limit']) && is_numeric($_GET['nggv']['limit']) ? $_GET['nggv']['limit'] : 25;
    10481116            $_GET['nggv']['order'] = isset($_GET['nggv']['order']) && $_GET['nggv']['order'] ? $_GET['nggv']['order'] : 'DESC';
     1117            //premium feature, but add it here to keep consistency (wont affect anything if premium not installed)
     1118            $_GET['nggv']['export_type'] = isset($_GET['nggv']['export_type']) && $_GET['nggv']['export_type'] ? $_GET['nggv']['export_type'] : 'avg';
     1119           
     1120            $listWhere = '';
    10491121           
    10501122            $qry = 'SELECT ';
     
    10571129                $qry .= ' AND p.galleryid = '.$wpdb->escape($_GET['nggv']['gallery']);
    10581130            }
     1131            if(isset($_GET['nggv']['date_from']) && $_GET['nggv']['date_from']) {
     1132                $qry .= ' AND v.dateadded >= "'.$wpdb->escape($_GET['nggv']['date_from']).' 00:00:00"';
     1133                $listWhere .= $listWhere ? ' AND ' : '';
     1134                $listWhere .= 'dateadded >= "'.$wpdb->escape($_GET['nggv']['date_from']).' 00:00:00"';
     1135            }
     1136            if(isset($_GET['nggv']['date_to']) && $_GET['nggv']['date_to']) {
     1137                $qry .= ' AND v.dateadded <= "'.$wpdb->escape($_GET['nggv']['date_to']).' 23:59:59"';
     1138                $listWhere .= $listWhere ? ' AND ' : '';
     1139                $listWhere .= 'dateadded <= "'.$wpdb->escape($_GET['nggv']['date_to']).' 23:59:59"';
     1140            }
     1141                       
    10591142            $qry .= ' GROUP BY v.pid, v.criteria_id';
    1060             $qry .= ' ORDER BY avg '.$_GET['nggv']['order'];
     1143            $qry .= ' ORDER BY avg '.$_GET['nggv']['order'].', num '.$_GET['nggv']['order'];
    10611144            if($_GET['nggv']['limit']) {
    10621145                $qry .= ' LIMIT 0, '.$_GET['nggv']['limit'];
     
    10641147           
    10651148            $list = $wpdb->get_results($qry);
     1149            foreach ((array)$list as $key=>$val) {
     1150                $tmp = $this->getImageVotingResults(array('pid'=>$val->pid, 'criteria_id'=>$val->criteria_id), array('list'=>true), $listWhere);
     1151                $list[$key]->details = $tmp['list'];
     1152            }
    10661153            $list = apply_filters('nggv_top_voted_results', $list);
    10671154           
     
    10691156
    10701157            ?>
     1158                       
    10711159            <div class="wrap">
    10721160                <h2>Top Rated Images</h2>
     
    10921180                                        </select>
    10931181                                    </td>
     1182                                </tr>
     1183                               
     1184                                <tr>
     1185                                    <th>From Date</th>
     1186                                    <td><input type="text" id="nggv_date_from" name="nggv[date_from]" value="<?php echo $_GET['nggv']['date_from'] ?>" /></td>
     1187                                    <th>To Date</th>
     1188                                    <td><input type="text" id="nggv_date_to" name="nggv[date_to]" value="<?php echo $_GET['nggv']['date_to'] ?>" /></td>
    10941189                                </tr>
    10951190                               
     
    11241219                <?php if($list && !class_exists('nggVotingPremium')) { ?>
    11251220                    <div class="updated below-h2">
    1126                         Wow, check all those awesome people voing for your images! Have you returned the favour by <a target="_blank" href="http://wordpress.org/extend/plugins/nextgen-gallery-voting/">rating NGG Voting</a>?<br />
    1127                         Maybe you're even more awesomer and might consider <a target="_blank" href="http://shauno.co.za/donate/">donating</a>?
     1221                        Look at the people voing for your images! Have you returned the favour by <a target="_blank" href="http://wordpress.org/support/view/plugin-reviews/nextgen-gallery-voting">rating NGG Voting</a>?<br />
     1222                        Maybe you're even more awesome, and might consider <a target="_blank" href="http://shauno.co.za/donate/">donating</a>?
    11281223                    </div>
    11291224                <?php } ?>
     
    11731268                                        <td><?php echo round($val->max / 10, 2) ?></td>
    11741269                                        <td><?php echo round($val->min / 10, 2) ?></td>
    1175                                         <td><?php echo $val->num ?> </td>
     1270                                        <td><?php echo $val->num ?> <a href="#" class="nggv-top-vote-item">(View Votes)</a></td>
    11761271                                        <td><img src="<?php echo $image->thumbURL; ?>" /></td>
     1272                                    </tr>
     1273                                    <tr style="display:none;">
     1274                                        <td colspan="9">
     1275                                            <table cellspacing="0" class="wp-list-table widefat fixed">
     1276                                            <thead>
     1277                                                <tr>
     1278                                                    <th>Date</th>
     1279                                                    <th>Username</th>
     1280                                                    <th>IP</th>
     1281                                                    <th>Vote / 10</th>
     1282                                                </tr>
     1283                                            </thead>
     1284                                            <?php foreach ((array)$val->details as $vote) { ?>
     1285                                                <?php $user_info = $vote->user_id ? get_userdata($vote->user_id) : array(); ?>
     1286                                                    <tr>
     1287                                                        <td><?php echo $vote->dateadded ?></td>
     1288                                                        <td><?php echo (isset($user_info->data->display_name) && $user_info->data->display_name ? $user_info->data->display_name : $vote->user_id) ?></td>
     1289                                                        <td><?php echo $vote->ip ?></td>
     1290                                                        <td><?php echo $vote->vote / 10 ?></td>
     1291                                                    </tr>
     1292                                                <?php } ?>
     1293                                        </table>
     1294
     1295                                        </td>
    11771296                                    </tr>
    11781297                                    <?php $cnt++; ?>
     
    12851404                    echo '<tr class="nggv-force-once"><td width="1px"><input type="radio" name="nggv_image['.$pid.']['.$val->id.'][force_once]" value=2 '.(isset($opts->force_once) && $opts->force_once == 2 ? 'checked' : '').' /></td><td>Only allow 1 vote per person for this gallery</td></tr>';
    12861405                   
    1287                     //todo, move to premium
    12881406                    echo apply_filters('nggv_manage_gallery_image_number_votes', '', $opts);
    12891407
     
    15311649    // Front End Functions {
    15321650        function wpInit() {
    1533             if(isset($_GET['nggv_pid']) && $_GET['nggv_pid']) {
    1534                 if(!isset($_GET['nggv_criteria_id'])) {
    1535                     $_GET['nggv_criteria_id'] = 0;
    1536                 }
    1537                 $options = $this->getImageVotingOptions($_GET['nggv_pid'], $_GET['nggv_criteria_id']);
     1651            //I have added this code to the init, so the scripts are loaded correctly. The trade off is they load every page. Meh, seems better than users getting problems
     1652            //(calling this->includeJs() because I haven't removed calls in body code. this prevents them actually being included at that point)
     1653            $this->includeJs($this->pluginUrl.'js/ajaxify-stars.js');   //ajaxify voting, from v1.7
     1654            $this->includeJs($this->pluginUrl.'js/ajaxify-likes.js');
     1655            $this->includeCss($this->pluginUrl.'css/star_rating.css');
     1656           
     1657            wp_enqueue_script('nggv-stars', $this->pluginUrl.'js/ajaxify-stars.js', array('jquery'));
     1658            wp_enqueue_script('nggv-like', $this->pluginUrl.'js/ajaxify-likes.js', array('jquery'));
     1659            wp_enqueue_style('nggv-stars-css', $this->pluginUrl.'css/star_rating.css');
     1660           
     1661            if((isset($_GET['nggv_pid']) && $_GET['nggv_pid']) || isset($_POST['nggv']['vote_pid_id']) && $_POST['nggv']['vote_pid_id']) {
     1662                if(isset($_GET['nggv_pid'])) {
     1663                    if(!isset($_GET['nggv_criteria_id'])) {
     1664                        $_GET['nggv_criteria_id'] = 0;
     1665                    }
     1666                    $options = $this->getImageVotingOptions($_GET['nggv_pid'], $_GET['nggv_criteria_id']);
     1667                }else if(isset($_POST['nggv']['vote_pid_id'])) {
     1668                    if(!isset( $_POST['nggv']['vote_criteria_id'])) {
     1669                         $_POST['nggv']['vote_criteria_id'] = 0;
     1670                    }
     1671                    $options = $this->getImageVotingOptions($_POST['nggv']['vote_pid_id'], $_POST['nggv']['vote_criteria_id']);
     1672                }
    15381673                $voteFuncs = $this->types[$options->voting_type]['imageCallback'];
    15391674                $votedOrErr = @call_user_func_array(array($voteFuncs['class'], $voteFuncs['catch']), array($this, $options));
    15401675               
    15411676                //store in class var, so we have it for this page execution
    1542                 $this->initCatchVote[$_GET['nggv_pid']][$_GET['nggv_criteria_id']] = array(
    1543                     'pid'=>$_GET['nggv_pid'],
    1544                     'criteria_id'=>$_GET['nggv_criteria_id'],
    1545                     'result'=>$votedOrErr
     1677                $this->initCatchVote[$options->pid][$options->criteria_id] = array(
     1678                    'pid'=>$options->pid,
     1679                    'criteria_id'=>$options->criteria_id,
     1680                    'result'=>$votedOrErr,
     1681                    'dateadded'=>date('Y-m-d H:i:s', time())
    15461682                    );
    15471683               
    1548                 do_action('nggv_catch_vote', $_GET['nggv_pid'], $_GET['nggv_criteria_id'], $this->initCatchVote);
    1549             }
     1684                do_action('nggv_catch_vote', $options->pid, $options->criteria_id, $this->initCatchVote);
     1685               
     1686                if($_GET['ajaxify']) { //catch the ajax vote
     1687                    $form = $this->getImageVoteMarkup($options);
     1688
     1689                    echo '<!-- NGGV START AJAX RESPONSE -->';
     1690                    echo '<script>';
     1691                    echo 'var nggv_js = {};';
     1692                    echo 'nggv_js.options = {};';
     1693                    echo 'nggv_js.saved = '.($votedOrErr === true ? '1' : '0').';';
     1694                    echo 'nggv_js.msg = "'.addslashes($votedOrErr).'";';
     1695                    echo 'nggv_js.voting_form = "'.addslashes($form['form']).'";';
     1696                    echo '<script><!-- NGGV END AJAX RESPONSE -->';
     1697                    exit;
     1698                }
     1699            }
     1700        }
     1701       
     1702        function getImageVoteMarkup($options) {
     1703            $pid = $options->pid;
     1704            $criteriaId = $options->criteria_id;
     1705            $voteFuncs = $this->types[$options->voting_type]['imageCallback'];
     1706           
     1707            //is there a vote happing for this pid right now?
     1708            $votedOrErr = isset($this->initCatchVote[$pid][$criteriaId]['result']) ? $this->initCatchVote[$pid][$criteriaId]['result'] : '';
     1709           
     1710            $form = array();
     1711            if((($canVote = $this->canVoteImage($pid, $criteriaId)) === true) && !$votedOrErr) { //they can vote, show the form
     1712                //$return = apply_filters('nggv_gallery_vote_form', $nggv, $options);
     1713                $form = @call_user_func_array(array($voteFuncs['class'], $voteFuncs['form']), array($this, $options));
     1714            }else{ //ok, they cant vote.  what next?
     1715                if($options->enable) {
     1716                    if($canVote === 'NOT LOGGED IN') { //the api wants them to login to vote
     1717                        $form['form'] = nggVoting::msg('Only registered users can vote. Please login to cast your vote.');
     1718                    }else if($canVote === 'USER HAS VOTED'
     1719                        || $canVote === 'IP HAS VOTED' || $canVote == 'IP HAS VOTED TODAY' || $canVote == 'IP HAS VOTED THIS WEEK' || $canVote == 'IP HAS VOTED THIS MONTH' || $canVote == 'IP HAS VOTED THIS YEAR'
     1720                        || $canVote === 'USER HAS VOTED' || $canVote == 'USER HAS VOTED TODAY' || $canVote == 'USER HAS VOTED THIS WEEK' || $canVote == 'USER HAS VOTED THIS MONTH' || $canVote == 'USER HAS VOTED THIS YEAR'
     1721                        || $canVote === 'COOKIE HAS VOTED' || $canVote == 'COOKIE HAS VOTED TODAY' || $canVote == 'COOKIE HAS VOTED THIS WEEK' || $canVote == 'COOKIE HAS VOTED THIS MONTH' || $canVote == 'COOKIE HAS VOTED THIS YEAR'
     1722                        || $canVote === true) { //api tells us they have voted, can they see results? (canVote will be true if they have just voted successfully)
     1723                        if($options->user_results) { //yes! show it
     1724                            $form = @call_user_func_array(array($voteFuncs['class'], $voteFuncs['results']), array($this, $options));
     1725                        }else{ //nope, but thanks for trying
     1726                            $form['form'] = nggVoting::msg('Thank you for casting your vote.');
     1727                        }
     1728                    }
     1729                }
     1730            }
     1731            return $form;
    15501732        }
    15511733       
     
    15691751                }
    15701752               
    1571                 $url = $_SERVER['REQUEST_URI'];
    1572                 $url .= (strpos($url, '?') === false ? '?' : (substr($url, -1) == '&' ? '' : '&')); //make sure the url ends in '?' or '&' correctly
    1573                
    1574                 $voteFuncs = $this->types[$options->voting_type]['imageCallback'];
     1753                if(!isset($_GET['nggv_criteria_id'])) {
     1754                    $_GET['nggv_criteria_id'] = 0;
     1755                }
     1756               
     1757                //$url = $_SERVER['REQUEST_URI'];
     1758                //$url .= (strpos($url, '?') === false ? '?' : (substr($url, -1) == '&' ? '' : '&')); //make sure the url ends in '?' or '&' correctly
     1759               
     1760                //$voteFuncs = $this->types[$options->voting_type]['imageCallback'];
    15751761               
    15761762                //moved voting catch into 'init' hook, so I can set cookies.
    15771763                //$votedOrErr = @call_user_func_array(array($voteFuncs['class'], $voteFuncs['catch']), array($this, $options));
     1764               
     1765                /*
    15781766                $votedOrErr = isset($this->initCatchVote[$pid][$criteriaId]['result']) ? $this->initCatchVote[$pid][$criteriaId]['result'] : '';
    1579                
    1580                 if(!isset($_GET['nggv_criteria_id'])) {
    1581                     $_GET['nggv_criteria_id'] = 0;
    1582                 }
    1583                
     1767                */
     1768               
     1769                /*
    15841770                if(isset($_GET['ajaxify']) && $_GET['ajaxify'] && isset($_GET['nggv_pid']) &&  $_GET['nggv_pid'] == $pid && $_GET['nggv_criteria_id'] == $criteriaId) {
    15851771                    $out .= '<!-- NGGV START AJAX RESPONSE -->';
     
    15901776                    $out .= 'nggv_js.msg = "'.addslashes($votedOrErr).'";';
    15911777                }
     1778                */
    15921779               
    15931780                //$form = nggvGalleryVote::showVoteForm($this, $options, $votedOrErr);
    15941781               
     1782                /*
    15951783                if((($canVote = $this->canVoteImage($pid, $criteriaId)) === true) && !$votedOrErr) { //they can vote, show the form
    15961784                    //$return = apply_filters('nggv_gallery_vote_form', $nggv, $options);
     
    16001788                        if($canVote === 'NOT LOGGED IN') { //the api wants them to login to vote
    16011789                            $form['form'] = nggVoting::msg('Only registered users can vote. Please login to cast your vote.');
    1602                         }else if($canVote === 'USER HAS VOTED' || $canVote === 'IP HAS VOTED' || $canVote === 'COOKIE HAS VOTED' || $canVote === true) { //api tells us they have voted, can they see results? (canVote will be true if they have just voted successfully)
     1790                        }else if($canVote === 'USER HAS VOTED'
     1791                            || $canVote === 'IP HAS VOTED' || $canVote == 'IP HAS VOTED TODAY' || $canVote == 'IP HAS VOTED THIS WEEK' || $canVote == 'IP HAS VOTED THIS MONTH' || $canVote == 'IP HAS VOTED THIS YEAR'
     1792                            || $canVote === 'USER HAS VOTED' || $canVote == 'USER HAS VOTED TODAY' || $canVote == 'USER HAS VOTED THIS WEEK' || $canVote == 'USER HAS VOTED THIS MONTH' || $canVote == 'USER HAS VOTED THIS YEAR'
     1793                            || $canVote === 'COOKIE HAS VOTED' || $canVote == 'COOKIE HAS VOTED TODAY' || $canVote == 'COOKIE HAS VOTED THIS WEEK' || $canVote == 'COOKIE HAS VOTED THIS MONTH' || $canVote == 'COOKIE HAS VOTED THIS YEAR'
     1794                            || $canVote === true) { //api tells us they have voted, can they see results? (canVote will be true if they have just voted successfully)
    16031795                            if($options->user_results) { //yes! show it
    16041796                                $form = @call_user_func_array(array($voteFuncs['class'], $voteFuncs['results']), array($this, $options));
     
    16091801                    }
    16101802                }
    1611                
     1803                */
     1804               
     1805                $form = $this->getImageVoteMarkup($options);
     1806               
     1807                /*
    16121808                if(isset($_GET['ajaxify']) && $_GET['ajaxify']) {
    16131809                    $out .= 'nggv_js.voting_form = "'.addslashes($form['form']).'";';
    16141810                }else{
     1811                */
    16151812                    $out .= '<div class="nggv_container">';
    16161813                        $out .= (isset($form['scripts']) ?  $form['scripts'] : '');
     
    16251822                        $out .= '</div>';
    16261823                    $out .= '</div>';
    1627                 }
    1628                
     1824                /*
     1825                }
     1826                */
     1827               
     1828                /*
    16291829                if(isset($_GET['ajaxify']) && $_GET['ajaxify'] && isset($_GET['nggv_pid']) && $_GET['nggv_pid'] == $pid && $_GET['nggv_criteria_id'] == $criteriaId) {
    16301830                    $out .= '<script><!-- NGGV END AJAX RESPONSE -->';
    16311831                }
     1832                */
    16321833            }
    16331834           
  • nextgen-gallery-voting/trunk/ngg-voting.php

    r724069 r724078  
    44Plugin URI: http://shauno.co.za/wordpress/nextgen-gallery-voting/
    55Description: This plugin allows you to add user voting and rating to NextGEN Galleries and Images
    6 Version: 2.5
     6Version: 2.5.1
    77Author: Shaun Alberts
    88Author URI: http://shauno.co.za
Note: See TracChangeset for help on using the changeset viewer.