From b537c64af4b7e6d6d8b9c04644f1587d00e96a9a Mon Sep 17 00:00:00 2001
From: Tim Steiner <tsteiner2@unl.edu>
Date: Thu, 17 Dec 2009 17:48:51 +0000
Subject: [PATCH] When counting requests that need approval for/by a user,
 pre-votes are no longer counted.

---
 library/App/RequestNotification.php | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/library/App/RequestNotification.php b/library/App/RequestNotification.php
index 33c5843d..f3fdb4bd 100644
--- a/library/App/RequestNotification.php
+++ b/library/App/RequestNotification.php
@@ -43,7 +43,21 @@ class App_RequestNotification
             $myVotes = Requests_ApproverVoteModel::findUsersVotesForRequests($user, $myRequests);
             $myRequestCount = count($myRequests);
             $myVotedRequests = array();
+            
+            if (count($myRequests) > 0) {
+                $myRequestStacks = Requests_StackModel::findForRequests($myRequests);
+            }
+            
             foreach ($myVotes as $myVote) {
+            	if ($myVote->getApprovalAction() != $myRequestStacks[$myVote->getRequest()]->getAction()) {
+            		continue;
+            	}
+            	
+            	// THIS IS A HACK TO EXCLUDE PRE-VOTES FROM PREVIOUSLY TABLED VOTES OF THE SAME ACTION.
+            	// IF ANY [VOTING PERIOD/TIME BETWEEN VOTING PERIODS] IS EVER [LONGER/SHORTER] THAN 14 DAYS IT WILL NO LONGER WORK!
+            	if ($myVote->getTime()->getTimestamp() < time() - 60*60*24*14) {
+            		continue;
+            	}
                 $myVotedRequests[] = $myVote->getRequest();
             }
             
-- 
GitLab