Plugin Directory

Changeset 723381


Ignore:
Timestamp:
06/06/2013 06:18:16 AM (13 years ago)
Author:
shauno
Message:

new version 2.5.
Optimised js/ajax voting process
New date filter on top voted screen
You can now see individual votes in top voted screen
Lots of hooks and filters added from new Premium features coming soon

Location:
nextgen-gallery-voting
Files:
53 added
4 edited

Legend:

Unmodified
Added
Removed
  • nextgen-gallery-voting/trunk/js/admin_gallery.js

    r681442 r723381  
    6464                    $container.find('.nggv-enforce-cookies input').prop('disabled', false);
    6565                    console.log($container.find('.nggv-enforce-cookies input'));
     66                   
     67                    $container.find('.nggv-force-once-time select').prop('disabled', false);
    6668                }else{
    6769                    $container.find('.nggv-enforce-cookies input').attr('checked', false);
    6870                    $container.find('.nggv-enforce-cookies input').prop('disabled', true);
     71                   
     72                    $container.find('.nggv-force-once-time select').prop('disabled', true);
    6973                }
    7074        });
  • nextgen-gallery-voting/trunk/ngg-voting.php

    r688990 r723381  
    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.2
     6Version: 2.5
    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', $pid, $criteriaId, $options, $vote[0]->dateadded, null);
     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', $pid, $criteriaId, $options, $vote[0]->dateadded, null);
     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', $pid, $criteriaId, $options, $vote[0]->dateadded, null);
     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', $pid, $criteriaId, $options, $vote[0]->dateadded, null);
     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';
    10601143            $qry .= ' ORDER BY avg '.$_GET['nggv']['order'].', num '.$_GET['nggv']['order'];
     
    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
     
    15411659            wp_enqueue_style('nggv-stars-css', $this->pluginUrl.'css/star_rating.css');
    15421660           
    1543             if((isset($_GET['nggv_pid']) && $_GET['nggv_pid']) || isset($_POST['nggv']['vote_pid_id']) && $_POST['nggv']['vote_pid_id']) {             
     1661            if((isset($_GET['nggv_pid']) && $_GET['nggv_pid']) || isset($_POST['nggv']['vote_pid_id']) && $_POST['nggv']['vote_pid_id']) {
    15441662                if(isset($_GET['nggv_pid'])) {
    15451663                    if(!isset($_GET['nggv_criteria_id'])) {
     
    15601678                    'pid'=>$options->pid,
    15611679                    'criteria_id'=>$options->criteria_id,
    1562                     'result'=>$votedOrErr
     1680                    'result'=>$votedOrErr,
     1681                    'dateadded'=>date('Y-m-d H:i:s', time())
    15631682                    );
    15641683               
    15651684                do_action('nggv_catch_vote', $options->pid, $options->criteria_id, $this->initCatchVote);
    1566             }
     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;
    15671732        }
    15681733       
     
    15861751                }
    15871752               
    1588                 $url = $_SERVER['REQUEST_URI'];
    1589                 $url .= (strpos($url, '?') === false ? '?' : (substr($url, -1) == '&' ? '' : '&')); //make sure the url ends in '?' or '&' correctly
    1590                
    1591                 $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'];
    15921761               
    15931762                //moved voting catch into 'init' hook, so I can set cookies.
    15941763                //$votedOrErr = @call_user_func_array(array($voteFuncs['class'], $voteFuncs['catch']), array($this, $options));
     1764               
     1765                /*
    15951766                $votedOrErr = isset($this->initCatchVote[$pid][$criteriaId]['result']) ? $this->initCatchVote[$pid][$criteriaId]['result'] : '';
    1596                
    1597                 if(!isset($_GET['nggv_criteria_id'])) {
    1598                     $_GET['nggv_criteria_id'] = 0;
    1599                 }
    1600                
     1767                */
     1768               
     1769                /*
    16011770                if(isset($_GET['ajaxify']) && $_GET['ajaxify'] && isset($_GET['nggv_pid']) &&  $_GET['nggv_pid'] == $pid && $_GET['nggv_criteria_id'] == $criteriaId) {
    16021771                    $out .= '<!-- NGGV START AJAX RESPONSE -->';
     
    16071776                    $out .= 'nggv_js.msg = "'.addslashes($votedOrErr).'";';
    16081777                }
     1778                */
    16091779               
    16101780                //$form = nggvGalleryVote::showVoteForm($this, $options, $votedOrErr);
    16111781               
     1782                /*
    16121783                if((($canVote = $this->canVoteImage($pid, $criteriaId)) === true) && !$votedOrErr) { //they can vote, show the form
    16131784                    //$return = apply_filters('nggv_gallery_vote_form', $nggv, $options);
     
    16171788                        if($canVote === 'NOT LOGGED IN') { //the api wants them to login to vote
    16181789                            $form['form'] = nggVoting::msg('Only registered users can vote. Please login to cast your vote.');
    1619                         }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)
    16201795                            if($options->user_results) { //yes! show it
    16211796                                $form = @call_user_func_array(array($voteFuncs['class'], $voteFuncs['results']), array($this, $options));
     
    16261801                    }
    16271802                }
    1628                
     1803                */
     1804               
     1805                $form = $this->getImageVoteMarkup($options);
     1806               
     1807                /*
    16291808                if(isset($_GET['ajaxify']) && $_GET['ajaxify']) {
    16301809                    $out .= 'nggv_js.voting_form = "'.addslashes($form['form']).'";';
    16311810                }else{
     1811                */
    16321812                    $out .= '<div class="nggv_container">';
    16331813                        $out .= (isset($form['scripts']) ?  $form['scripts'] : '');
     
    16421822                        $out .= '</div>';
    16431823                    $out .= '</div>';
    1644                 }
    1645                
     1824                /*
     1825                }
     1826                */
     1827               
     1828                /*
    16461829                if(isset($_GET['ajaxify']) && $_GET['ajaxify'] && isset($_GET['nggv_pid']) && $_GET['nggv_pid'] == $pid && $_GET['nggv_criteria_id'] == $criteriaId) {
    16471830                    $out .= '<script><!-- NGGV END AJAX RESPONSE -->';
    16481831                }
     1832                */
    16491833            }
    16501834           
  • nextgen-gallery-voting/trunk/readme.txt

    r687360 r723381  
    55Requires at least: 2.9.1
    66Tested up to: 3.5.1
    7 Stable tag: 2.4.1
    8 
    9 This plugin adds the ability for users to vote and rate your NextGEN Galleries and Images. Simple to understand options give you the ability to limit who can vote on what.
     7Stable tag: 2.5
     8
     9Adds the ability for users to vote and rate your NextGEN Galleries and Images. Simple to understand options give you the ability to
     10limit who can vote on what.
    1011
    1112== Description ==
     
    1516NGG Voting was inspired by a request from Troy Schlegel of Schlegel Photography.  Please read the FAQ for more info on how it works.
    1617
    17 **Please read the FAQ**, as you are required to add a tag to templates for certain functionality to work!
     18**Please read the FAQ**, as you are required to add a tag to gallery templates for certain functionality to work!
    1819
    1920== Frequently Asked Questions ==
    2021
    2122= In a nutshell, what is this? =
    22 This plugin adds options that can allow your users to vote on (more like rate) your Galleries and Images. There are options to limit which Gallery/Image to allow voting on, if the user needs to be registered and logged in, if they can vote more that once, and if they can see the current results.
     23This plugin adds options that can allow your users to vote on (more like rate) your Galleries and Images. There are options to limit which
     24Gallery/Image to allow voting on, if the user needs to be registered and logged in, if they can vote more that once, and if they can see the
     25current results.
    2326
    2427= How do I add the voting form? =
    25 For Galleries it's easy.  You just need to enable voting on the gallery, and the voting form will automatically be appended to the gallery.  There is some basic styling, but the markup has got plenty of classes and ids that you should easily be able to hook into with your own stylesheets to make suit your site.
     28For Galleries it's easy.  You just need to enable voting on the gallery, and the voting form will automatically be appended to the gallery.
     29There is some basic styling, but the markup has got plenty of classes and ids that you should easily be able to hook into with your own stylesheets to make suit your site.
    2630
    2731= How do I make the voting form appear for images? =
     
    4549
    4650== Changelog ==
     51
     52= 2.5 =
     53* Optimized ajax voting.
     54* Optimized JavaScript inclusions to fix conflicts with other plugins.
     55* Added date range to 'Top Voted' filter.
     56* Added ability to see indvidual votes in 'Top Voted' filter.
     57* Added hooks and filters for the premium add-on to use.
    4758
    4859= 2.4.1 =
     
    159170== Upgrade Notice ==
    160171
    161 = 2.4 =
     172= 2.5 =
     173This update optimizes the voting process code, and adds filter options to the Top Voted screen. Lots of hooks and filters have been added for Premium features coming soon.
     174
     175= 2.4.1 =
    162176This update fixes a bug that stopped the drop down voting type working for images
    163177
  • nextgen-gallery-voting/trunk/voting-types.php

    r681442 r723381  
    2020       
    2121        return $out;
     22    }
     23   
     24    public static function getUrl() {
     25        $url = strtok($_SERVER['REQUEST_URI'], '?');
     26        $get = $_GET;
     27        if(isset($get['nggv_pid']) || isset($get['nggv_criteria_id'])) {
     28            unset($get['nggv_pid']);
     29            unset($get['nggv_criteria_id']);
     30            unset($get['r']);
     31        }
     32        if($get) {
     33            $url .= '?'.http_build_query($get);
     34        }
     35        $url .= (strpos($url, '?') === false ? '?' : (substr($url, -1) == '&' ? '' : '&')); //make sure the url ends in '?' or '&' correctly
     36       
     37        return $url;
    2238    }
    2339   
     
    151167            $return['scripts'] .= $nggv->includeJs($nggv->pluginUrl.'js/ajaxify-likes.js'); //ajaxify voting, from v1.7
    152168           
    153             $url = $_SERVER['REQUEST_URI'];
    154             $url .= (strpos($url, '?') === false ? '?' : (substr($url, -1) == '&' ? '' : '&')); //make sure the url ends in '?' or '&' correctly
     169            $url = self::getUrl();
    155170           
    156171            $return['form'] .= '<a href="'.$url.'nggv_gid='.$options->gid.'&r=1" class="nggv-link-like"><img src="'.$nggv->pluginUrl.'images/thumbs_up.png" alt="Like" /></a>';
     
    210225            $return['scripts'] .= $nggv->includeJs($nggv->pluginUrl.'js/ajaxify-likes.js'); //ajaxify voting, from v1.7
    211226           
    212             $url = $_SERVER['REQUEST_URI'];
    213             $url .= (strpos($url, '?') === false ? '?' : (substr($url, -1) == '&' ? '' : '&')); //make sure the url ends in '?' or '&' correctly
     227            $url = self::getUrl();
    214228           
    215229            $return['form'] .= '<a href="'.$url.'nggv_pid='.$options->pid.'&nggv_criteria_id='.$options->criteria_id.'&r=1" class="nggv-link-like"><img src="'.$nggv->pluginUrl.'images/thumbs_up.png" alt="Like" /></a>';
     
    279293            }
    280294           
    281             $url = $_SERVER['REQUEST_URI'];
    282             $url .= (strpos($url, '?') === false ? '?' : (substr($url, -1) == '&' ? '' : '&')); //make sure the url ends in '?' or '&' correctly
     295            $url = self::getUrl();
    283296
    284297            $return['form'] .= '<li><a href="'.$url.'nggv_gid='.$options->gid.'&r=20" title="1 star out of 5" class="one-star">1</a></li>';
     
    345358            }
    346359           
    347             $url = $_SERVER['REQUEST_URI'];
    348             $url .= (strpos($url, '?') === false ? '?' : (substr($url, -1) == '&' ? '' : '&')); //make sure the url ends in '?' or '&' correctly
     360            $url = self::getUrl();
    349361           
    350362            $return['form'] .= '<li><a href="'.$url.'nggv_pid='.$options->pid.'&nggv_criteria_id='.$options->criteria_id.'&r=20" title="1 star out of 5" class="one-star">1</a></li>';
     
    401413}
    402414?>
     415'<li>5</li>';
     416            $return['form'] .= '</ul>';
     417            $return['form'] .= '</span>';
     418           
     419        }
     420        return $return;
     421    }
     422}
     423?>
Note: See TracChangeset for help on using the changeset viewer.