Changeset 723381
- Timestamp:
- 06/06/2013 06:18:16 AM (13 years ago)
- Location:
- nextgen-gallery-voting
- Files:
-
- 53 added
- 4 edited
-
tags/2.5 (added)
-
tags/2.5/css (added)
-
tags/2.5/css/jquery-ui (added)
-
tags/2.5/css/jquery-ui/images (added)
-
tags/2.5/css/jquery-ui/images/animated-overlay.gif (added)
-
tags/2.5/css/jquery-ui/images/ui-bg_flat_0_aaaaaa_40x100.png (added)
-
tags/2.5/css/jquery-ui/images/ui-bg_flat_75_ffffff_40x100.png (added)
-
tags/2.5/css/jquery-ui/images/ui-bg_glass_55_fbf9ee_1x400.png (added)
-
tags/2.5/css/jquery-ui/images/ui-bg_glass_65_ffffff_1x400.png (added)
-
tags/2.5/css/jquery-ui/images/ui-bg_glass_75_dadada_1x400.png (added)
-
tags/2.5/css/jquery-ui/images/ui-bg_glass_75_e6e6e6_1x400.png (added)
-
tags/2.5/css/jquery-ui/images/ui-bg_glass_95_fef1ec_1x400.png (added)
-
tags/2.5/css/jquery-ui/images/ui-bg_highlight-soft_75_cccccc_1x100.png (added)
-
tags/2.5/css/jquery-ui/images/ui-icons_222222_256x240.png (added)
-
tags/2.5/css/jquery-ui/images/ui-icons_2e83ff_256x240.png (added)
-
tags/2.5/css/jquery-ui/images/ui-icons_454545_256x240.png (added)
-
tags/2.5/css/jquery-ui/images/ui-icons_888888_256x240.png (added)
-
tags/2.5/css/jquery-ui/images/ui-icons_cd0a0a_256x240.png (added)
-
tags/2.5/css/jquery-ui/jquery-ui-1.10.3.custom.css (added)
-
tags/2.5/css/jquery-ui/jquery-ui-1.10.3.custom.min.css (added)
-
tags/2.5/css/star_rating.css (added)
-
tags/2.5/images (added)
-
tags/2.5/images/loading.gif (added)
-
tags/2.5/images/star.gif (added)
-
tags/2.5/images/thumbs_down.png (added)
-
tags/2.5/images/thumbs_up.png (added)
-
tags/2.5/js (added)
-
tags/2.5/js/admin_gallery.js (added)
-
tags/2.5/js/ajaxify-likes.js (added)
-
tags/2.5/js/ajaxify-stars.js (added)
-
tags/2.5/js/top-voted.js (added)
-
tags/2.5/ngg-voting.php (added)
-
tags/2.5/readme.txt (added)
-
tags/2.5/voting-types.php (added)
-
trunk/css/jquery-ui (added)
-
trunk/css/jquery-ui/images (added)
-
trunk/css/jquery-ui/images/animated-overlay.gif (added)
-
trunk/css/jquery-ui/images/ui-bg_flat_0_aaaaaa_40x100.png (added)
-
trunk/css/jquery-ui/images/ui-bg_flat_75_ffffff_40x100.png (added)
-
trunk/css/jquery-ui/images/ui-bg_glass_55_fbf9ee_1x400.png (added)
-
trunk/css/jquery-ui/images/ui-bg_glass_65_ffffff_1x400.png (added)
-
trunk/css/jquery-ui/images/ui-bg_glass_75_dadada_1x400.png (added)
-
trunk/css/jquery-ui/images/ui-bg_glass_75_e6e6e6_1x400.png (added)
-
trunk/css/jquery-ui/images/ui-bg_glass_95_fef1ec_1x400.png (added)
-
trunk/css/jquery-ui/images/ui-bg_highlight-soft_75_cccccc_1x100.png (added)
-
trunk/css/jquery-ui/images/ui-icons_222222_256x240.png (added)
-
trunk/css/jquery-ui/images/ui-icons_2e83ff_256x240.png (added)
-
trunk/css/jquery-ui/images/ui-icons_454545_256x240.png (added)
-
trunk/css/jquery-ui/images/ui-icons_888888_256x240.png (added)
-
trunk/css/jquery-ui/images/ui-icons_cd0a0a_256x240.png (added)
-
trunk/css/jquery-ui/jquery-ui-1.10.3.custom.css (added)
-
trunk/css/jquery-ui/jquery-ui-1.10.3.custom.min.css (added)
-
trunk/js/admin_gallery.js (modified) (1 diff)
-
trunk/js/top-voted.js (added)
-
trunk/ngg-voting.php (modified) (30 diffs)
-
trunk/readme.txt (modified) (4 diffs)
-
trunk/voting-types.php (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
nextgen-gallery-voting/trunk/js/admin_gallery.js
r681442 r723381 64 64 $container.find('.nggv-enforce-cookies input').prop('disabled', false); 65 65 console.log($container.find('.nggv-enforce-cookies input')); 66 67 $container.find('.nggv-force-once-time select').prop('disabled', false); 66 68 }else{ 67 69 $container.find('.nggv-enforce-cookies input').attr('checked', false); 68 70 $container.find('.nggv-enforce-cookies input').prop('disabled', true); 71 72 $container.find('.nggv-force-once-time select').prop('disabled', true); 69 73 } 70 74 }); -
nextgen-gallery-voting/trunk/ngg-voting.php
r688990 r723381 4 4 Plugin URI: http://shauno.co.za/wordpress/nextgen-gallery-voting/ 5 5 Description: This plugin allows you to add user voting and rating to NextGEN Galleries and Images 6 Version: 2. 4.26 Version: 2.5 7 7 Author: Shaun Alberts 8 8 Author URI: http://shauno.co.za … … 35 35 36 36 class nggVoting { 37 private $dbVersion = 2. 4;37 private $dbVersion = 2.5; 38 38 private $slug; 39 39 public $types = array( … … 138 138 force_once TINYINT NOT NULL DEFAULT 0, 139 139 enforce_with_cookie TINYINT NOT NULL DEFAULT 0, 140 force_once_time TINYINT NOT NULL DEFAULT 0, 140 141 user_results TINYINT NOT NULL DEFAULT 0, 141 142 voting_type INT NOT NULL DEFAULT 1, … … 188 189 * @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) 189 190 */ 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='') { 191 192 if(is_numeric($pid)) { //old style arg where just 'pid' was needed 192 193 $criteriaId = 0; //default for old calls and add ons … … 207 208 } 208 209 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"); 210 215 $results['list'] = $list; 211 216 } … … 354 359 if($options->force_once == 1) { 355 360 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 } 358 371 } 359 372 }else{ //no forced login, so just check the IP for a vote 360 373 $canVote = apply_filters('nggv_image_can_vote', $pid, $criteriaId, $options, null); 361 374 362 if($canVote === true) { 375 if($canVote === true) { //cookie allows it! 363 376 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 } 369 390 } 370 391 } … … 372 393 }else if($options->force_once == 2) { 373 394 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 } 376 406 } 377 407 }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 /* 378 431 $canVote = apply_filters('nggv_image_can_vote', $pid, $criteriaId, $options, null); 379 432 … … 387 440 } 388 441 } 442 */ 389 443 } 390 444 } … … 431 485 } 432 486 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")) { 434 488 return $votes; 435 489 }else{ … … 464 518 465 519 $picturelist = nggdb::get_gallery($image->gid); 520 $inPid = array(); 466 521 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 } 474 530 } 475 531 … … 487 543 global $wpdb; 488 544 545 if(!$ip) { 546 $tmp = $this->getUserIp(); 547 $ip = $tmp["ip"]; 548 } 549 489 550 if(is_numeric($pid)) { //old style arg where just 'pid' was needed 490 551 $criteriaId = 0; //default for old calls and add ons … … 500 561 501 562 $picturelist = nggdb::get_gallery($image->gid); 563 $inPid = array(); 502 564 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 } 509 573 } 510 574 … … 556 620 } 557 621 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")) { 559 623 return $votes; 560 624 }else{ … … 742 806 wp_enqueue_script('thickbox'); 743 807 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'); 744 812 } 745 813 … … 976 1044 977 1045 <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> 979 1047 <td style="text-align:center;"><input type="checkbox" name="nggv[gallery][force_once]" <?php echo (get_option('nggv_gallery_force_once') ? 'checked="checked"' : ''); ?> /></td> 980 1048 <td style="text-align:center;"> … … 1047 1115 $_GET['nggv']['limit'] = isset($_GET['nggv']['limit']) && is_numeric($_GET['nggv']['limit']) ? $_GET['nggv']['limit'] : 25; 1048 1116 $_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 = ''; 1049 1121 1050 1122 $qry = 'SELECT '; … … 1057 1129 $qry .= ' AND p.galleryid = '.$wpdb->escape($_GET['nggv']['gallery']); 1058 1130 } 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 1059 1142 $qry .= ' GROUP BY v.pid, v.criteria_id'; 1060 1143 $qry .= ' ORDER BY avg '.$_GET['nggv']['order'].', num '.$_GET['nggv']['order']; … … 1064 1147 1065 1148 $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 } 1066 1153 $list = apply_filters('nggv_top_voted_results', $list); 1067 1154 … … 1069 1156 1070 1157 ?> 1158 1071 1159 <div class="wrap"> 1072 1160 <h2>Top Rated Images</h2> … … 1092 1180 </select> 1093 1181 </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> 1094 1189 </tr> 1095 1190 … … 1124 1219 <?php if($list && !class_exists('nggVotingPremium')) { ?> 1125 1220 <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 awesome rand 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>? 1128 1223 </div> 1129 1224 <?php } ?> … … 1173 1268 <td><?php echo round($val->max / 10, 2) ?></td> 1174 1269 <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> 1176 1271 <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> 1177 1296 </tr> 1178 1297 <?php $cnt++; ?> … … 1285 1404 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>'; 1286 1405 1287 //todo, move to premium1288 1406 echo apply_filters('nggv_manage_gallery_image_number_votes', '', $opts); 1289 1407 … … 1541 1659 wp_enqueue_style('nggv-stars-css', $this->pluginUrl.'css/star_rating.css'); 1542 1660 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']) { 1544 1662 if(isset($_GET['nggv_pid'])) { 1545 1663 if(!isset($_GET['nggv_criteria_id'])) { … … 1560 1678 'pid'=>$options->pid, 1561 1679 'criteria_id'=>$options->criteria_id, 1562 'result'=>$votedOrErr 1680 'result'=>$votedOrErr, 1681 'dateadded'=>date('Y-m-d H:i:s', time()) 1563 1682 ); 1564 1683 1565 1684 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; 1567 1732 } 1568 1733 … … 1586 1751 } 1587 1752 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']; 1592 1761 1593 1762 //moved voting catch into 'init' hook, so I can set cookies. 1594 1763 //$votedOrErr = @call_user_func_array(array($voteFuncs['class'], $voteFuncs['catch']), array($this, $options)); 1764 1765 /* 1595 1766 $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 /* 1601 1770 if(isset($_GET['ajaxify']) && $_GET['ajaxify'] && isset($_GET['nggv_pid']) && $_GET['nggv_pid'] == $pid && $_GET['nggv_criteria_id'] == $criteriaId) { 1602 1771 $out .= '<!-- NGGV START AJAX RESPONSE -->'; … … 1607 1776 $out .= 'nggv_js.msg = "'.addslashes($votedOrErr).'";'; 1608 1777 } 1778 */ 1609 1779 1610 1780 //$form = nggvGalleryVote::showVoteForm($this, $options, $votedOrErr); 1611 1781 1782 /* 1612 1783 if((($canVote = $this->canVoteImage($pid, $criteriaId)) === true) && !$votedOrErr) { //they can vote, show the form 1613 1784 //$return = apply_filters('nggv_gallery_vote_form', $nggv, $options); … … 1617 1788 if($canVote === 'NOT LOGGED IN') { //the api wants them to login to vote 1618 1789 $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) 1620 1795 if($options->user_results) { //yes! show it 1621 1796 $form = @call_user_func_array(array($voteFuncs['class'], $voteFuncs['results']), array($this, $options)); … … 1626 1801 } 1627 1802 } 1628 1803 */ 1804 1805 $form = $this->getImageVoteMarkup($options); 1806 1807 /* 1629 1808 if(isset($_GET['ajaxify']) && $_GET['ajaxify']) { 1630 1809 $out .= 'nggv_js.voting_form = "'.addslashes($form['form']).'";'; 1631 1810 }else{ 1811 */ 1632 1812 $out .= '<div class="nggv_container">'; 1633 1813 $out .= (isset($form['scripts']) ? $form['scripts'] : ''); … … 1642 1822 $out .= '</div>'; 1643 1823 $out .= '</div>'; 1644 } 1645 1824 /* 1825 } 1826 */ 1827 1828 /* 1646 1829 if(isset($_GET['ajaxify']) && $_GET['ajaxify'] && isset($_GET['nggv_pid']) && $_GET['nggv_pid'] == $pid && $_GET['nggv_criteria_id'] == $criteriaId) { 1647 1830 $out .= '<script><!-- NGGV END AJAX RESPONSE -->'; 1648 1831 } 1832 */ 1649 1833 } 1650 1834 -
nextgen-gallery-voting/trunk/readme.txt
r687360 r723381 5 5 Requires at least: 2.9.1 6 6 Tested 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. 7 Stable tag: 2.5 8 9 Adds the ability for users to vote and rate your NextGEN Galleries and Images. Simple to understand options give you the ability to 10 limit who can vote on what. 10 11 11 12 == Description == … … 15 16 NGG Voting was inspired by a request from Troy Schlegel of Schlegel Photography. Please read the FAQ for more info on how it works. 16 17 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! 18 19 19 20 == Frequently Asked Questions == 20 21 21 22 = 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. 23 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 24 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 25 current results. 23 26 24 27 = 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. 28 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. 29 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. 26 30 27 31 = How do I make the voting form appear for images? = … … 45 49 46 50 == 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. 47 58 48 59 = 2.4.1 = … … 159 170 == Upgrade Notice == 160 171 161 = 2.4 = 172 = 2.5 = 173 This 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 = 162 176 This update fixes a bug that stopped the drop down voting type working for images 163 177 -
nextgen-gallery-voting/trunk/voting-types.php
r681442 r723381 20 20 21 21 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; 22 38 } 23 39 … … 151 167 $return['scripts'] .= $nggv->includeJs($nggv->pluginUrl.'js/ajaxify-likes.js'); //ajaxify voting, from v1.7 152 168 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(); 155 170 156 171 $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>'; … … 210 225 $return['scripts'] .= $nggv->includeJs($nggv->pluginUrl.'js/ajaxify-likes.js'); //ajaxify voting, from v1.7 211 226 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(); 214 228 215 229 $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>'; … … 279 293 } 280 294 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(); 283 296 284 297 $return['form'] .= '<li><a href="'.$url.'nggv_gid='.$options->gid.'&r=20" title="1 star out of 5" class="one-star">1</a></li>'; … … 345 358 } 346 359 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(); 349 361 350 362 $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>'; … … 401 413 } 402 414 ?> 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.