84 lines
1.8 KiB
PHP
Executable File
84 lines
1.8 KiB
PHP
Executable File
<?php
|
|
|
|
/**
|
|
* Class DefaultController
|
|
*/
|
|
class DefaultController
|
|
{
|
|
/**
|
|
* The default index test controller
|
|
*
|
|
* @return string HTML Code
|
|
* @throws Exception
|
|
*/
|
|
public function indexAction()
|
|
{
|
|
$view = new Template( 'start' );
|
|
|
|
// Return the HTML Code to the index.php
|
|
return $view->getHtml();
|
|
|
|
} # function indexAction()
|
|
|
|
/**
|
|
* @return string
|
|
* @throws Exception
|
|
*/
|
|
public function joinFAQAction()
|
|
{
|
|
$view = new Template( 'start' );
|
|
$DefaultModel = new DefaultModel();
|
|
|
|
$Request = new Request();
|
|
|
|
$room_code = $Request->getVar( 'code', null, 'GET' );
|
|
|
|
if( empty( $room_code ) && !isset( $room_code ) )
|
|
{
|
|
$view->set_placeholder( 'error', 'Room-Code is invalid!' );
|
|
return $view->getHtml();
|
|
}
|
|
|
|
if( ( $room_id = $DefaultModel->checkCode( $room_code ) ) === false )
|
|
{
|
|
$view->set_placeholder( 'error', 'Room-Code is invalid!' );
|
|
return $view->getHtml();
|
|
}
|
|
|
|
if( !$DefaultModel->joinRoom( $room_id ) )
|
|
{
|
|
$view->set_placeholder( 'error', 'An error occured, please try again later!' );
|
|
return $view->getHtml();
|
|
}
|
|
|
|
|
|
|
|
|
|
return $view->getHtml();
|
|
|
|
}
|
|
|
|
/**
|
|
* @return string
|
|
* @throws Exception
|
|
*/
|
|
public function createFAQAction()
|
|
{
|
|
$view = new Template( 'start' );
|
|
$DefaultModel = new DefaultModel();
|
|
|
|
$Request = new Request();
|
|
$room_name = $Request->getVar( 'room-name' );
|
|
|
|
if( !$DefaultModel->createRoom( $room_name ) )
|
|
{
|
|
$view->set_placeholder( 'error', 'An error occured, please try again later!' );
|
|
return $view->getHtml();
|
|
}
|
|
|
|
return $view->getHtml();
|
|
}
|
|
|
|
|
|
} # class
|