From 4eda93497b0496e54477e225dfbfc5dbccb22cce Mon Sep 17 00:00:00 2001 From: Peter Brenner Date: Sat, 9 Mar 2013 21:21:42 -0500 Subject: [PATCH] issue #72 Corrected ban user function. Now removes votes and candidates --- app/Controller/CandidatesController.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/Controller/CandidatesController.php b/app/Controller/CandidatesController.php index 026fa9b..1c2e04e 100644 --- a/app/Controller/CandidatesController.php +++ b/app/Controller/CandidatesController.php @@ -163,6 +163,8 @@ public function listByElection($id, $filter = 0, $sorting = 0) { if (empty($blockedUsers)) : $blockedUsers[] = 0; + else : + $conditions[] = array('Candidate.user_id NOT' => $blockedUsers); endif; $moderators = array(); @@ -185,12 +187,10 @@ public function listByElection($id, $filter = 0, $sorting = 0) { $order = array('User.name'); endif; - // If the sort flag is set to 5, then have the model sort randomly. - if ($sorting == '5'): - - $order = array('rand()'); - - endif; + // If the sort flag is set to 5, then have the model sort randomly. + if ($sorting == '5'): + $order = array('rand()'); + endif; foreach ($this->Candidate->find('all', array('conditions' => $conditions, 'order' => $order)) as $candidate) { $votes = array('Votes' => array(