Show
Ignore:
Timestamp:
02/26/08 09:51:06 (11 months ago)
Author:
aarkerio
Message:

tuesday 26 update

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/app/controllers/pollrows_controller.php

    r274 r285  
    1010  public $helpers       = array('Ajax'); 
    1111 
    12   public function beforeFiler() 
    13   { 
    14     $this->Auth->allow('vote'); 
    15     parent::beforeFilter(); 
    16   }   
    1712  public function isAuthorized() 
    1813  { 
     
    2924 public function vote()  
    3025 { 
    31     $this->layout = 'ajax'; 
     26   $this->layout = 'ajax'; 
    3227     
    33     // adds new vote to database 
    34     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)); 
    3732            
    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'])); // 
    3934            
    40            $vote += 1; 
    41            //exit("votos " . $vote); 
    42            $this->data['Pollrow']['vote'] = $vote;  // add vote 
    43                
    44            if ( $this->Pollrow->save( $this->data['Pollrow'] ) )  // add the Poll vote 
    45             { 
    46                     $this->Session->write('poll',  $this->data['Pollrow']['poll_id']); //set session, only one vote per session 
     35      $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 
    4742                     
    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"); 
    5146                     
    52                     $this->set('poll', $this->Pollrow->findAll($conditions, $fields, $order)); 
     47           $this->set('poll', $this->Pollrow->find($conditions, $fields)); 
    5348                     
    54                     $this->render('results', 'ajax'); 
    55             } 
    56             else 
    57             { 
    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 } 
    6257   
    63   public function admin_add() { 
     58 public function admin_add()  
     59 { 
    6460         // adds new pollrow to database 
    65     if (!empty($this->data)) 
     61    if (!empty($this->data['Pollrow'])) 
    6662    { 
    6763        if ($this->Pollrow->save($this->data))   //save the Poll vote