Add ThemeNotFoundException

This commit is contained in:
Li Chen 2013-11-28 22:25:54 +01:00
parent a6ad7597c8
commit 7bd2e3eecf
2 changed files with 48 additions and 28 deletions

View File

@ -136,36 +136,46 @@ else if ($n && $p[0] == SALT_USER)
{
$tmp = explode("-", $p[2]);
$id = intval($tmp[0]);
$THEME = new Theme($id);
unset($tmp, $id);
$template->assign("cur_theme", $THEME);
if ($n == 4 || ($n >= 5 && $p[4] == "submission"))
$id_exo = $p[3];
else if ($n == 3)
{
foreach($THEME->get_exercices_ordered() as $exo)
{
if (! $exo->has_solved($TEAM))
break;
}
$id_exo = $exo->id;
}
if ($id == 0)
$page = "404";
else
{
try
{
$THEME = new Theme($id);
unset($tmp, $id);
$template->assign("cur_theme", $THEME);
try
{
$EXERCICE = new Exercice($id_exo, $THEME);
$template->assign("cur_exercice", $EXERCICE);
$page = require("team/exercice.php");
}
catch(ExerciceNotFoundException $e)
{
$page = "404";
}
catch(InvalidThemeException $e)
{
$page = "404";
}
if ($n == 4 || ($n >= 5 && $p[4] == "submission"))
$id_exo = $p[3];
else if ($n == 3)
{
foreach($THEME->get_exercices_ordered() as $exo)
{
if (! $exo->has_solved($TEAM))
break;
}
$id_exo = $exo->id;
}
$EXERCICE = new Exercice($id_exo, $THEME);
$template->assign("cur_exercice", $EXERCICE);
$page = require("team/exercice.php");
}
catch(ExerciceNotFoundException $e)
{
$page = "404";
}
catch(InvalidThemeException $e)
{
$page = "404";
}
catch(ThemeNotFoundException $e)
{
$page = "404";
}
}
}
}
}

View File

@ -20,6 +20,11 @@ class Theme
$this->id = $res['id'];
$this->name = $res['name'];
}
else
{
$db->deconnexion();
throw new ThemeNotFoundException();
}
$db->deconnexion();
}
}
@ -137,3 +142,8 @@ class Theme
return $array;
}
}
class ThemeNotFoundException extends Exception
{
}