HTML and CSS Reference
In-Depth Information
/**
* Marks a given question as answered
*
* @return array Information about the updated question
*/
protected function answer_question( )
{
$room_id = $this->sanitize($_POST['room_id']);
$question_id = $this->sanitize($_POST['question_id']);
// Makes sure the person answering the question is the presenter
$cookie_id = 'presenter_room_' . $room_id;
if (isset($_COOKIE[$cookie_id]) && $_COOKIE[$cookie_id]==1) {
return $this->model->answer_question($room_id, $question_id);
}
return array('room_id'=>$room_id);
}
}
This method sanitizes the posted form values and then checks for a presenter's cookie to verify that the current
user has permission to mark a question as answered. If the cookie is valid, the model's answer_question() method
is fired, and its returned data is passed through; an invalid or missing cookie simply loops the user back to the room
without processing anything by returning the room ID.
Building the Rooms
The final piece of this app is to add the controller, model, and view for the rooms. This is very similar to the functionality
of the questions, except it actually loads the Question controller to load those views and leverage its methods.
Adding the Room Controller
The first step is to create the Room controller. In system/controllers/ , add a new file called class.room.inc.php and
start with the following code:
<?php
/**
* Processes output for the Room view
*
* @author Jason Lengstorf <jason@lengstorf.com>
* @author Phil Leggetter <phil@leggetter.co.uk>
*/
class Room extends Controller
{
public $room_id,
$is_presenter,
$is_active;
 
Search WWH ::




Custom Search