Changeset 285
- Timestamp:
- 02/26/08 09:51:06 (11 months ago)
- Location:
- trunk/app
- Files:
-
- 3 modified
-
app_controller.php (modified) (2 diffs)
-
controllers/pollrows_controller.php (modified) (2 diffs)
-
models/pollrow.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/app/app_controller.php
r284 r285 8 8 class AppController extends Controller { 9 9 10 public $components = array('Auth', 'Cookie' );10 public $components = array('Auth', 'Cookie', 'Security'); 11 11 12 12 public $helpers = array('Html', 'Form', 'Session'); … … 20 20 $this->Auth->loginError = 'Invalid e-mail / password combination. Please try again'; 21 21 $this->Auth->authorize = 'controller'; 22 $this->Auth->allow( array('view', 'display', 'subscribe', 'recover', 'register', 'insert' ) );22 $this->Auth->allow( array('view', 'display', 'subscribe', 'recover', 'register', 'insert', 'vote') ); 23 23 24 24 $this->set('cU', $this->Auth->user()); // $cU current user array to use in the views if user logged -
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 -
trunk/app/models/pollrow.php
r282 r285 11 11 public $name = 'Pollrow'; 12 12 13 public $belongsTo = array('Poll' => 14 array('className' => 'Poll' 13 /* public $belongsTo = array('Poll' => 14 array( 15 'className' => 'Poll', 16 'foreignKey' => 'poll_id' 15 17 ) 16 ); 18 ); */ 17 19 } 18 20 ?>
