Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

country list by competition round

  • Loading branch information...
commit b5efdd31c19cd3e3d312cac37802bfeae715859a 1 parent 293add0
@sandaru1 authored
View
2  www/apps/frontend/modules/scores/actions/actions.class.php
@@ -21,7 +21,7 @@ public function executeIndex(sfWebRequest $request)
$this->round = $request->getParameter('round');
$competition = Doctrine::getTable('Competition')->find($this->round);
- $this->form = new FilterForm(array(),array('questions' => $competition->getQuestions()));
+ $this->form = new FilterForm(array(),array('questions' => $competition->getQuestions(),'competition' => $this->round));
$this->form->bind($request->getParameter($this->form->getName()));
$size = $this->form->getValue('results');
View
7 www/lib/form/FilterForm.class.php
@@ -4,7 +4,12 @@ class FilterForm extends sfForm {
public function configure()
{
- $countries = Doctrine::getTable('User')->getCountries();
+ if (isset($this->options['competition'])) {
+ $countries = Doctrine::getTable('Competition')->getCountries($this->options['competition']);
+ } else {
+ $countries = Doctrine::getTable('User')->getCountries();
+ }
+
$this->setWidgets(array(
'handle' => new sfWidgetFormInput(array(),array('class' => 'inputtext','style' => 'width:243px')),
View
16 www/lib/model/doctrine/CompetitionTable.class.php
@@ -4,5 +4,17 @@
*/
class CompetitionTable extends Doctrine_Table
{
-
-}
+ public function getCountries($round)
+ {
+ $query = Doctrine_Query::create()
+ ->from('Rank r, r.User u')->select('r.competition_id,u.country,count(*) as c')
+ ->andWhere('r.competition_id = ?',$round);
+ $arr = $query->groupBy('u.country')->fetchArray();
+ $countries = array('' => 'Any');
+ foreach($arr as $u) {
+ $user = $u['User'];
+ $countries[$user['country']] = $user['country'].' ('.$u['c'].')';
+ }
+ return $countries;
+ }
+}
Please sign in to comment.
Something went wrong with that request. Please try again.