Changeset 285 for trunk/app/controllers/pollrows_controller.php
- Timestamp:
- 02/26/08 09:51:06 (11 months ago)
- Files:
-
- 1 modified
-
trunk/app/controllers/pollrows_controller.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/app/controllers/pollrows_controller.php
r274 r285 10 10 public $helpers = array('Ajax'); 11 11 12 public function beforeFiler()13 {14 $this->Auth->allow('vote');15 parent::beforeFilter();16 }17 12 public function isAuthorized() 18 13 { … … 29 24 public function vote() 30 25 { 31 $this->layout = 'ajax';26 $this->layout = 'ajax'; 32 27 33 // adds new vote to database34 if (!empty($this->data))35 {36 //die(print_r($this->data));28 // adds new vote to database 29 if (!empty($this->data['Pollrow'])) 30 { 31 //die(print_r($this->data)); 37 32 38 $vote = $this->Pollrow->field('vote', array("Pollrow.id" => $this->data['Pollrow']['id']));33 $vote = $this->Pollrow->field('vote', array("Pollrow.id" => $this->data['Pollrow']['id'])); // 39 34 40 $vote += 1;41 //exit("votos " . $vote);42 $this->data['Pollrow']['vote'] = $vote; // add vote43 44 if ( $this->Pollrow->save( $this->data['Pollrow'] ) ) // add the Poll vote45 {46 $this->Session->write('poll', $this->data['Pollrow']['poll_id']); //set session, only one vote per session35 $vote += 1; 36 //exit("votes " . $vote); 37 $this->data['Pollrow']['vote'] = $vote; // add vote 38 39 if ( $this->Pollrow->save( $this->data['Pollrow'] ) ) // add the Poll vote 40 { 41 $this->Session->write('poll', $this->data['Pollrow']['poll_id']); //set session, only one vote per session 47 42 48 $conditions = array("Pollrow.poll_id" => $this->data['Pollrow']['poll_id']);49 $fields = array("Pollrow.answer", "Pollrow.color", "Pollrow.vote", "Pollrow.poll_id", "Poll.id", "Poll.question"); 50 $order = "Pollrow.id";43 $conditions = array("Pollrow.poll_id" => $this->data['Pollrow']['poll_id']); 44 45 $fields = array("Pollrow.answer", "Pollrow.color", "Pollrow.vote", "Pollrow.poll_id", "Poll.id", "Poll.question"); 51 46 52 $this->set('poll', $this->Pollrow->findAll($conditions, $fields, $order));47 $this->set('poll', $this->Pollrow->find($conditions, $fields)); 53 48 54 $this->render('results', 'ajax');55 }56 else57 {58 echo "Ajax error, check with the company's computer guy...";59 }60 }61 }49 $this->render('results', 'ajax'); 50 } 51 else 52 { 53 echo "Ajax error, check with the company's computer guy..."; 54 } 55 } 56 } 62 57 63 public function admin_add() { 58 public function admin_add() 59 { 64 60 // adds new pollrow to database 65 if (!empty($this->data ))61 if (!empty($this->data['Pollrow'])) 66 62 { 67 63 if ($this->Pollrow->save($this->data)) //save the Poll vote
