summaryrefslogtreecommitdiff
path: root/includes/controller/shifttypes_controller.php
diff options
context:
space:
mode:
authorBot <bot@myigel.name>2017-01-02 03:57:23 +0100
committerIgor Scheller <igor.scheller@igorshp.de>2017-01-02 03:57:23 +0100
commit7313e15ce8236e19331fb6639a3a5b97c8f06ecd (patch)
tree399e5eaa403d6dd5993ca8fb6f2162319d2ed2e1 /includes/controller/shifttypes_controller.php
parentb839e401062b294292fdcbd7e30b79bc149fab6f (diff)
PSR-2 formatting
Diffstat (limited to 'includes/controller/shifttypes_controller.php')
-rw-r--r--includes/controller/shifttypes_controller.php227
1 files changed, 116 insertions, 111 deletions
diff --git a/includes/controller/shifttypes_controller.php b/includes/controller/shifttypes_controller.php
index 456e39ae..f54111c4 100644
--- a/includes/controller/shifttypes_controller.php
+++ b/includes/controller/shifttypes_controller.php
@@ -1,169 +1,176 @@
<?php
-function shifttype_link($shifttype) {
- return page_link_to('shifttypes') . '&action=view&shifttype_id=' . $shifttype['id'];
+function shifttype_link($shifttype)
+{
+ return page_link_to('shifttypes') . '&action=view&shifttype_id=' . $shifttype['id'];
}
/**
* Delete a shifttype.
*/
-function shifttype_delete_controller() {
- if (! isset($_REQUEST['shifttype_id'])) {
- redirect(page_link_to('shifttypes'));
- }
-
- $shifttype = ShiftType($_REQUEST['shifttype_id']);
- if ($shifttype === false) {
- engelsystem_error('Unable to load shifttype.');
- }
+function shifttype_delete_controller()
+{
+ if (! isset($_REQUEST['shifttype_id'])) {
+ redirect(page_link_to('shifttypes'));
+ }
- if ($shifttype == null) {
- redirect(page_link_to('shifttypes'));
- }
+ $shifttype = ShiftType($_REQUEST['shifttype_id']);
+ if ($shifttype === false) {
+ engelsystem_error('Unable to load shifttype.');
+ }
- if (isset($_REQUEST['confirmed'])) {
- $result = ShiftType_delete($shifttype['id']);
- if ($result === false) {
- engelsystem_error('Unable to delete shifttype.');
+ if ($shifttype == null) {
+ redirect(page_link_to('shifttypes'));
}
+
+ if (isset($_REQUEST['confirmed'])) {
+ $result = ShiftType_delete($shifttype['id']);
+ if ($result === false) {
+ engelsystem_error('Unable to delete shifttype.');
+ }
- engelsystem_log('Deleted shifttype ' . $shifttype['name']);
- success(sprintf(_('Shifttype %s deleted.'), $shifttype['name']));
- redirect(page_link_to('shifttypes'));
- }
+ engelsystem_log('Deleted shifttype ' . $shifttype['name']);
+ success(sprintf(_('Shifttype %s deleted.'), $shifttype['name']));
+ redirect(page_link_to('shifttypes'));
+ }
- return [
+ return [
sprintf(_("Delete shifttype %s"), $shifttype['name']),
- ShiftType_delete_view($shifttype)
+ ShiftType_delete_view($shifttype)
];
}
/**
* Edit or create shift type.
*/
-function shifttype_edit_controller() {
- $shifttype_id = null;
- $name = "";
- $angeltype_id = null;
- $description = "";
+function shifttype_edit_controller()
+{
+ $shifttype_id = null;
+ $name = "";
+ $angeltype_id = null;
+ $description = "";
- $angeltypes = AngelTypes();
+ $angeltypes = AngelTypes();
- if (isset($_REQUEST['shifttype_id'])) {
- $shifttype = ShiftType($_REQUEST['shifttype_id']);
- if ($shifttype === false) {
- engelsystem_error('Unable to load shifttype.');
- }
- if ($shifttype == null) {
- error(_('Shifttype not found.'));
- redirect(page_link_to('shifttypes'));
+ if (isset($_REQUEST['shifttype_id'])) {
+ $shifttype = ShiftType($_REQUEST['shifttype_id']);
+ if ($shifttype === false) {
+ engelsystem_error('Unable to load shifttype.');
+ }
+ if ($shifttype == null) {
+ error(_('Shifttype not found.'));
+ redirect(page_link_to('shifttypes'));
+ }
+ $shifttype_id = $shifttype['id'];
+ $name = $shifttype['name'];
+ $angeltype_id = $shifttype['angeltype_id'];
+ $description = $shifttype['description'];
}
- $shifttype_id = $shifttype['id'];
- $name = $shifttype['name'];
- $angeltype_id = $shifttype['angeltype_id'];
- $description = $shifttype['description'];
- }
- if (isset($_REQUEST['submit'])) {
- $valid = true;
-
- if (isset($_REQUEST['name']) && $_REQUEST['name'] != '') {
- $name = strip_request_item('name');
- } else {
- $valid = false;
- error(_('Please enter a name.'));
- }
+ if (isset($_REQUEST['submit'])) {
+ $valid = true;
- if (isset($_REQUEST['angeltype_id']) && preg_match("/^[0-9]+$/", $_REQUEST['angeltype_id'])) {
- $angeltype_id = $_REQUEST['angeltype_id'];
- } else {
- $angeltype_id = null;
- }
+ if (isset($_REQUEST['name']) && $_REQUEST['name'] != '') {
+ $name = strip_request_item('name');
+ } else {
+ $valid = false;
+ error(_('Please enter a name.'));
+ }
- if (isset($_REQUEST['description'])) {
- $description = strip_request_item_nl('description');
- }
+ if (isset($_REQUEST['angeltype_id']) && preg_match("/^[0-9]+$/", $_REQUEST['angeltype_id'])) {
+ $angeltype_id = $_REQUEST['angeltype_id'];
+ } else {
+ $angeltype_id = null;
+ }
- if ($valid) {
- if ($shifttype_id) {
- $result = ShiftType_update($shifttype_id, $name, $angeltype_id, $description);
- if ($result === false) {
- engelsystem_error('Unable to update shifttype.');
+ if (isset($_REQUEST['description'])) {
+ $description = strip_request_item_nl('description');
}
- engelsystem_log('Updated shifttype ' . $name);
- success(_('Updated shifttype.'));
- } else {
- $shifttype_id = ShiftType_create($name, $angeltype_id, $description);
- if ($shifttype_id === false) {
- engelsystem_error('Unable to create shifttype.');
+
+ if ($valid) {
+ if ($shifttype_id) {
+ $result = ShiftType_update($shifttype_id, $name, $angeltype_id, $description);
+ if ($result === false) {
+ engelsystem_error('Unable to update shifttype.');
+ }
+ engelsystem_log('Updated shifttype ' . $name);
+ success(_('Updated shifttype.'));
+ } else {
+ $shifttype_id = ShiftType_create($name, $angeltype_id, $description);
+ if ($shifttype_id === false) {
+ engelsystem_error('Unable to create shifttype.');
+ }
+ engelsystem_log('Created shifttype ' . $name);
+ success(_('Created shifttype.'));
+ }
+ redirect(page_link_to('shifttypes') . '&action=view&shifttype_id=' . $shifttype_id);
}
- engelsystem_log('Created shifttype ' . $name);
- success(_('Created shifttype.'));
- }
- redirect(page_link_to('shifttypes') . '&action=view&shifttype_id=' . $shifttype_id);
}
- }
- return [
+ return [
shifttypes_title(),
- ShiftType_edit_view($name, $angeltype_id, $angeltypes, $description, $shifttype_id)
+ ShiftType_edit_view($name, $angeltype_id, $angeltypes, $description, $shifttype_id)
];
}
-function shifttype_controller() {
- if (! isset($_REQUEST['shifttype_id'])) {
- redirect(page_link_to('shifttypes'));
- }
- $shifttype = ShiftType($_REQUEST['shifttype_id']);
- if ($shifttype === false) {
- engelsystem_error('Unable to load shifttype.');
- }
- if ($shifttype == null) {
- redirect(page_link_to('shifttypes'));
- }
+function shifttype_controller()
+{
+ if (! isset($_REQUEST['shifttype_id'])) {
+ redirect(page_link_to('shifttypes'));
+ }
+ $shifttype = ShiftType($_REQUEST['shifttype_id']);
+ if ($shifttype === false) {
+ engelsystem_error('Unable to load shifttype.');
+ }
+ if ($shifttype == null) {
+ redirect(page_link_to('shifttypes'));
+ }
- $angeltype = null;
- if ($shifttype['angeltype_id'] != null) {
- $angeltype = AngelType($shifttype['angeltype_id']);
- }
+ $angeltype = null;
+ if ($shifttype['angeltype_id'] != null) {
+ $angeltype = AngelType($shifttype['angeltype_id']);
+ }
- return [
+ return [
$shifttype['name'],
- ShiftType_view($shifttype, $angeltype)
+ ShiftType_view($shifttype, $angeltype)
];
}
/**
* List all shift types.
*/
-function shifttypes_list_controller() {
- $shifttypes = ShiftTypes();
- if ($shifttypes === false) {
- engelsystem_error("Unable to load shifttypes.");
- }
+function shifttypes_list_controller()
+{
+ $shifttypes = ShiftTypes();
+ if ($shifttypes === false) {
+ engelsystem_error("Unable to load shifttypes.");
+ }
- return [
+ return [
shifttypes_title(),
- ShiftTypes_list_view($shifttypes)
+ ShiftTypes_list_view($shifttypes)
];
}
/**
* Text for shift type related links.
*/
-function shifttypes_title() {
- return _("Shifttypes");
+function shifttypes_title()
+{
+ return _("Shifttypes");
}
/**
* Route shift type actions
*/
-function shifttypes_controller() {
- if (! isset($_REQUEST['action'])) {
- $_REQUEST['action'] = 'list';
- }
+function shifttypes_controller()
+{
+ if (! isset($_REQUEST['action'])) {
+ $_REQUEST['action'] = 'list';
+ }
- switch ($_REQUEST['action']) {
+ switch ($_REQUEST['action']) {
default:
case 'list':
return shifttypes_list_controller();
@@ -175,5 +182,3 @@ function shifttypes_controller() {
return shifttype_delete_controller();
}
}
-
-?> \ No newline at end of file