Changeset 285

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

tuesday 26 update

Location:
trunk/app
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • trunk/app/app_controller.php

    r284 r285  
    88class AppController extends Controller { 
    99 
    10  public $components = array('Auth', 'Cookie'); 
     10 public $components = array('Auth', 'Cookie', 'Security'); 
    1111 
    1212 public $helpers = array('Html', 'Form', 'Session'); 
     
    2020     $this->Auth->loginError = 'Invalid e-mail / password combination. Please try again'; 
    2121     $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') ); 
    2323 
    2424     $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  
    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 
  • trunk/app/models/pollrow.php

    r282 r285  
    1111  public $name      = 'Pollrow'; 
    1212   
    13   public $belongsTo = array('Poll' => 
    14                            array('className'  => 'Poll' 
     13  /* public $belongsTo = array('Poll' => 
     14                array( 
     15                                  'className'  => 'Poll',  
     16                                  'foreignKey' => 'poll_id' 
    1517                           ) 
    16                      ); 
     18                     ); */ 
    1719} 
    1820?>