Changeset 724078
- Timestamp:
- 06/07/2013 04:07:27 PM (13 years ago)
- Location:
- nextgen-gallery-voting
- Files:
-
- 2 edited
-
tags/2.4/ngg-voting.php (modified) (29 diffs)
-
trunk/ngg-voting.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
nextgen-gallery-voting/tags/2.4/ngg-voting.php
r681442 r724078 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. 46 Version: 2.5.1 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', 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 } 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', 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 } 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', 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 } 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', 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 /* 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 $qry .= ' ORDER BY avg '.$_GET['nggv']['order'] ;1143 $qry .= ' ORDER BY avg '.$_GET['nggv']['order'].', num '.$_GET['nggv']['order']; 1061 1144 if($_GET['nggv']['limit']) { 1062 1145 $qry .= ' LIMIT 0, '.$_GET['nggv']['limit']; … … 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 … … 1531 1649 // Front End Functions { 1532 1650 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 } 1538 1673 $voteFuncs = $this->types[$options->voting_type]['imageCallback']; 1539 1674 $votedOrErr = @call_user_func_array(array($voteFuncs['class'], $voteFuncs['catch']), array($this, $options)); 1540 1675 1541 1676 //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()) 1546 1682 ); 1547 1683 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; 1550 1732 } 1551 1733 … … 1569 1751 } 1570 1752 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']; 1575 1761 1576 1762 //moved voting catch into 'init' hook, so I can set cookies. 1577 1763 //$votedOrErr = @call_user_func_array(array($voteFuncs['class'], $voteFuncs['catch']), array($this, $options)); 1764 1765 /* 1578 1766 $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 /* 1584 1770 if(isset($_GET['ajaxify']) && $_GET['ajaxify'] && isset($_GET['nggv_pid']) && $_GET['nggv_pid'] == $pid && $_GET['nggv_criteria_id'] == $criteriaId) { 1585 1771 $out .= '<!-- NGGV START AJAX RESPONSE -->'; … … 1590 1776 $out .= 'nggv_js.msg = "'.addslashes($votedOrErr).'";'; 1591 1777 } 1778 */ 1592 1779 1593 1780 //$form = nggvGalleryVote::showVoteForm($this, $options, $votedOrErr); 1594 1781 1782 /* 1595 1783 if((($canVote = $this->canVoteImage($pid, $criteriaId)) === true) && !$votedOrErr) { //they can vote, show the form 1596 1784 //$return = apply_filters('nggv_gallery_vote_form', $nggv, $options); … … 1600 1788 if($canVote === 'NOT LOGGED IN') { //the api wants them to login to vote 1601 1789 $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) 1603 1795 if($options->user_results) { //yes! show it 1604 1796 $form = @call_user_func_array(array($voteFuncs['class'], $voteFuncs['results']), array($this, $options)); … … 1609 1801 } 1610 1802 } 1611 1803 */ 1804 1805 $form = $this->getImageVoteMarkup($options); 1806 1807 /* 1612 1808 if(isset($_GET['ajaxify']) && $_GET['ajaxify']) { 1613 1809 $out .= 'nggv_js.voting_form = "'.addslashes($form['form']).'";'; 1614 1810 }else{ 1811 */ 1615 1812 $out .= '<div class="nggv_container">'; 1616 1813 $out .= (isset($form['scripts']) ? $form['scripts'] : ''); … … 1625 1822 $out .= '</div>'; 1626 1823 $out .= '</div>'; 1627 } 1628 1824 /* 1825 } 1826 */ 1827 1828 /* 1629 1829 if(isset($_GET['ajaxify']) && $_GET['ajaxify'] && isset($_GET['nggv_pid']) && $_GET['nggv_pid'] == $pid && $_GET['nggv_criteria_id'] == $criteriaId) { 1630 1830 $out .= '<script><!-- NGGV END AJAX RESPONSE -->'; 1631 1831 } 1832 */ 1632 1833 } 1633 1834 -
nextgen-gallery-voting/trunk/ngg-voting.php
r724069 r724078 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.5 6 Version: 2.5.1 7 7 Author: Shaun Alberts 8 8 Author URI: http://shauno.co.za
Note: See TracChangeset
for help on using the changeset viewer.