From 1debe567f5f9fdeff5a2afbaa4619992da67f437 Mon Sep 17 00:00:00 2001 From: msquare Date: Fri, 30 Sep 2016 16:55:47 +0200 Subject: simplify user_angeltype_add_controller --- includes/controller/angeltypes_controller.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'includes/controller/angeltypes_controller.php') diff --git a/includes/controller/angeltypes_controller.php b/includes/controller/angeltypes_controller.php index 5607ea7c..cb2bb2fb 100644 --- a/includes/controller/angeltypes_controller.php +++ b/includes/controller/angeltypes_controller.php @@ -101,6 +101,7 @@ function angeltype_delete_controller() { function angeltype_edit_controller() { global $privileges, $user; + $angeltype = null; $name = ""; $restricted = false; $description = ""; @@ -266,4 +267,24 @@ function angeltypes_list_controller() { AngelTypes_list_view($angeltypes, in_array('admin_angel_types', $privileges)) ]; } + +/** + * Loads an angeltype from given angeltype_id request param. + */ +function load_angeltype() { + if (! isset($_REQUEST['angeltype_id'])) { + redirect(page_link_to('angeltypes')); + } + + $angeltype = AngelType($_REQUEST['angeltype_id']); + if ($angeltype === false) { + engelsystem_error("Unable to load angeltype."); + } + if ($angeltype == null) { + error(_("Angeltype doesn't exist.")); + redirect(page_link_to('angeltypes')); + } + + return $angeltype; +} ?> -- cgit v1.2.3-54-g00ecf