Changeset 291

Show
Ignore:
Timestamp:
02/29/08 13:57:50 (10 months ago)
Author:
aarkerio
Message:

Fixed poll and admin routes

Location:
trunk/app
Files:
5 modified

Legend:

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

    r246 r291  
    1212 public $helpers       = array('Ajax', 'Fck', 'Gags'); 
    1313  
    14   //public $components    = array('Edublog', 'Portal', 'Search', 'Mypagination'); 
    15   public function isAuthorized()  
    16   { 
    17     if ($this->action == 'admin_listing')  
     14 public $components    = array('Edublog', 'Portal'); 
     15 
     16 public function isAuthorized()  
     17 {       
     18    if (isset( $this->params[Configure::read('Routing.admin')] ))  
    1819    { 
    1920    if ($this->Auth->user('group_id') == 1)  
     
    2122        return true; 
    2223        }  
    23     else  
    24         { 
    25         return false; 
    26         } 
    27     } 
    28   
    29     return true; 
     24    }  
     25    return false;  // go away !! 
    3026 } 
    3127 
  • trunk/app/controllers/pollrows_controller.php

    r285 r291  
    4141           $this->Session->write('poll',  $this->data['Pollrow']['poll_id']); //set session, only one vote per session 
    4242                     
    43            $conditions = array("Pollrow.poll_id" => $this->data['Pollrow']['poll_id']); 
     43           $conditions = array("Poll.id" => $this->data['Pollrow']['poll_id']); 
    4444 
    45            $fields     = array("Pollrow.answer", "Pollrow.color", "Pollrow.vote", "Pollrow.poll_id", "Poll.id", "Poll.question"); 
    46                      
    47            $this->set('poll', $this->Pollrow->find($conditions, $fields)); 
     45           $this->set('poll', $this->Pollrow->Poll->find($conditions)); 
    4846                     
    4947           $this->render('results', 'ajax'); 
  • trunk/app/models/pollrow.php

    r285 r291  
    1111  public $name      = 'Pollrow'; 
    1212   
    13   /* public $belongsTo = array('Poll' => 
     13 public $belongsTo = array('Poll' => 
    1414                array( 
    1515                                  'className'  => 'Poll',  
    1616                                  'foreignKey' => 'poll_id' 
    1717                           ) 
    18                      ); */ 
     18                     ); 
    1919} 
    2020?> 
  • trunk/app/views/elements/poll.ctp

    r274 r291  
    77<div id="add_pollrow"> 
    88 
    9   <?php 
     9 <?php 
    1010  $poll = $session->read('poll'); 
    1111   
    12   if ( $poll != null &&  $Element["Poll"]['Poll']['id'] == $poll) // the user has not voted 
     12  if ( $poll != null &&  $Element["Poll"]['Poll']['id'] == $poll) // the user has already voted, show poll results 
    1313  { 
    14          
    1514    $total_votes = 0; 
    1615     
     
    4039    echo '<p class="negrita">Total votes:' . $total_votes . '</p>';  
    4140  } 
    42   else // the user has voted, just print the poll result 
     41  else // the user has no voted, print the form 
    4342  { 
    4443    echo $ajax->form(); 
     
    4847    echo "<p><b>" . $Element["Poll"]['Poll']['question'] ."</b></p>"; 
    4948     
    50     echo $form->hidden('Pollrow.poll_id', $Element["Poll"]['Poll']['id']);  // Poll_id 
     49    echo $form->hidden('Pollrow.poll_id', array("value"=>$Element["Poll"]['Poll']['id']));  // Poll_id 
    5150     
    5251    foreach ($Element["Poll"]['Pollrow'] as $key=>$val) 
  • trunk/app/views/pollrows/results.ctp

    r256 r291  
    11<?php 
    2   //exit(print_r( $poll )); 
     2/**  GPLV3 Chipotle Software  2002-2008 **/ 
     3//exit(print_r( $poll ));   
    34  $total_votes = 0; 
    45   
    5   foreach ($poll as $val)  
     6  foreach ( $poll['Pollrow'] as $val )  
    67  { 
    7        $total_votes += $val["Pollrow"]["vote"];  // the total votes 
     8       $total_votes += $val["vote"];  // the total votes 
    89  } 
    910   
    10   echo "<p><b>" . $poll[0]['Poll']['question'] ."</b></p>"; 
     11  echo "<p><b>" . $poll['Poll']['question'] ."</b></p>"; 
    1112   
    12   foreach ($poll as $val)  
     13  foreach ($poll['Pollrow'] as $val)  
    1314  {           
    14              if ($val["Pollrow"]["vote"] > 0 ) 
     15             if ($val["vote"] > 0 ) 
    1516             { 
    16                    $percent = ($val["Pollrow"]["vote"] * 100) / $total_votes;  // % = votes * 100 / total 
     17                   $percent = ($val["vote"] * 100) / $total_votes;  // % = votes * 100 / total 
    1718             } 
    1819             else 
     
    2324             $width   = number_format($percent, 0); 
    2425              
    25              echo '<p><b>' . $val["Pollrow"]["answer"] . '</b> '.number_format($percent, 2).'% <br />' . "\n";  
    26              echo $html->image('static/poll/'.$val["Pollrow"]["color"].'.png',  
    27              array("height"=>"10", "width"=>$width,"alt"=>$val["Pollrow"]["answer"], "title"=>$val["Pollrow"]["answer"])) . "\n"; 
    28              echo "  ". $val["Pollrow"]['vote'] . "\n"; 
     26             echo '<p><b>' . $val["answer"] . '</b> '.number_format($percent, 2).'% <br />' . "\n";  
     27             echo $html->image('static/poll/'.$val["color"].'.png',  
     28             array("height"=>"10", "width"=>$width,"alt"=>$val["answer"], "title"=>$val["answer"])) . "\n"; 
     29             echo "  ". $val['vote'] . "\n"; 
    2930  } 
    3031