Changeset 291
- Timestamp:
- 02/29/08 13:57:50 (10 months ago)
- Location:
- trunk/app
- Files:
-
- 5 modified
-
controllers/entries_controller.php (modified) (2 diffs)
-
controllers/pollrows_controller.php (modified) (1 diff)
-
models/pollrow.php (modified) (1 diff)
-
views/elements/poll.ctp (modified) (3 diffs)
-
views/pollrows/results.ctp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/app/controllers/entries_controller.php
r246 r291 12 12 public $helpers = array('Ajax', 'Fck', 'Gags'); 13 13 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')] )) 18 19 { 19 20 if ($this->Auth->user('group_id') == 1) … … 21 22 return true; 22 23 } 23 else 24 { 25 return false; 26 } 27 } 28 29 return true; 24 } 25 return false; // go away !! 30 26 } 31 27 -
trunk/app/controllers/pollrows_controller.php
r285 r291 41 41 $this->Session->write('poll', $this->data['Pollrow']['poll_id']); //set session, only one vote per session 42 42 43 $conditions = array("Poll row.poll_id" => $this->data['Pollrow']['poll_id']);43 $conditions = array("Poll.id" => $this->data['Pollrow']['poll_id']); 44 44 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)); 48 46 49 47 $this->render('results', 'ajax'); -
trunk/app/models/pollrow.php
r285 r291 11 11 public $name = 'Pollrow'; 12 12 13 /*public $belongsTo = array('Poll' =>13 public $belongsTo = array('Poll' => 14 14 array( 15 15 'className' => 'Poll', 16 16 'foreignKey' => 'poll_id' 17 17 ) 18 ); */18 ); 19 19 } 20 20 ?> -
trunk/app/views/elements/poll.ctp
r274 r291 7 7 <div id="add_pollrow"> 8 8 9 <?php9 <?php 10 10 $poll = $session->read('poll'); 11 11 12 if ( $poll != null && $Element["Poll"]['Poll']['id'] == $poll) // the user has not voted12 if ( $poll != null && $Element["Poll"]['Poll']['id'] == $poll) // the user has already voted, show poll results 13 13 { 14 15 14 $total_votes = 0; 16 15 … … 40 39 echo '<p class="negrita">Total votes:' . $total_votes . '</p>'; 41 40 } 42 else // the user has voted, just print the poll result41 else // the user has no voted, print the form 43 42 { 44 43 echo $ajax->form(); … … 48 47 echo "<p><b>" . $Element["Poll"]['Poll']['question'] ."</b></p>"; 49 48 50 echo $form->hidden('Pollrow.poll_id', $Element["Poll"]['Poll']['id']); // Poll_id49 echo $form->hidden('Pollrow.poll_id', array("value"=>$Element["Poll"]['Poll']['id'])); // Poll_id 51 50 52 51 foreach ($Element["Poll"]['Pollrow'] as $key=>$val) -
trunk/app/views/pollrows/results.ctp
r256 r291 1 1 <?php 2 //exit(print_r( $poll )); 2 /** GPLV3 Chipotle Software 2002-2008 **/ 3 //exit(print_r( $poll )); 3 4 $total_votes = 0; 4 5 5 foreach ( $poll as $val)6 foreach ( $poll['Pollrow'] as $val ) 6 7 { 7 $total_votes += $val[" Pollrow"]["vote"]; // the total votes8 $total_votes += $val["vote"]; // the total votes 8 9 } 9 10 10 echo "<p><b>" . $poll[ 0]['Poll']['question'] ."</b></p>";11 echo "<p><b>" . $poll['Poll']['question'] ."</b></p>"; 11 12 12 foreach ($poll as $val)13 foreach ($poll['Pollrow'] as $val) 13 14 { 14 if ($val[" Pollrow"]["vote"] > 0 )15 if ($val["vote"] > 0 ) 15 16 { 16 $percent = ($val[" Pollrow"]["vote"] * 100) / $total_votes; // % = votes * 100 / total17 $percent = ($val["vote"] * 100) / $total_votes; // % = votes * 100 / total 17 18 } 18 19 else … … 23 24 $width = number_format($percent, 0); 24 25 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"; 29 30 } 30 31
