summaryrefslogtreecommitdiff
path: root/includes/controller/user_driver_licenses_controller.php
diff options
context:
space:
mode:
authorBot <bot@myigel.name>2017-01-02 15:43:36 +0100
committerIgor Scheller <igor.scheller@igorshp.de>2017-01-02 15:49:53 +0100
commitd71e7bbfad2f07f82df0c515608996d250fd4182 (patch)
tree5083a17b218c08b3a699a0bf15bec926cc2dd185 /includes/controller/user_driver_licenses_controller.php
parent7313e15ce8236e19331fb6639a3a5b97c8f06ecd (diff)
Formatting
Diffstat (limited to 'includes/controller/user_driver_licenses_controller.php')
-rw-r--r--includes/controller/user_driver_licenses_controller.php72
1 files changed, 38 insertions, 34 deletions
diff --git a/includes/controller/user_driver_licenses_controller.php b/includes/controller/user_driver_licenses_controller.php
index 434d9274..a499eff7 100644
--- a/includes/controller/user_driver_licenses_controller.php
+++ b/includes/controller/user_driver_licenses_controller.php
@@ -1,26 +1,30 @@
<?php
/**
- * Generates a hint, if user joined angeltypes that require a driving license and the user has no driver license information provided.
+ * Generates a hint, if user joined angeltypes that require a driving license and the user has no driver license
+ * information provided.
*/
function user_driver_license_required_hint()
{
global $user;
-
+
$angeltypes = User_angeltypes($user);
$user_driver_license = UserDriverLicense($user['UID']);
-
- // User has already entered data, no hint needed.
- if ($user_driver_license != null) {
- return null;
- }
-
+
+ // User has already entered data, no hint needed.
+ if ($user_driver_license != null) {
+ return null;
+ }
+
foreach ($angeltypes as $angeltype) {
if ($angeltype['requires_driver_license']) {
- return sprintf(_("You joined an angeltype which requires a driving license. Please edit your driving license information here: %s."), '<a href="' . user_driver_license_edit_link() . '">' . _("driving license information") . '</a>');
+ return sprintf(
+ _("You joined an angeltype which requires a driving license. Please edit your driving license information here: %s."),
+ '<a href="' . user_driver_license_edit_link() . '">' . _("driving license information") . '</a>'
+ );
}
}
-
+
return null;
}
@@ -30,18 +34,18 @@ function user_driver_license_required_hint()
function user_driver_licenses_controller()
{
global $user;
-
- if (! isset($user)) {
+
+ if (!isset($user)) {
redirect(page_link_to(''));
}
-
+
$action = strip_request_item('action', 'edit');
-
+
switch ($action) {
- default:
- case 'edit':
- return user_driver_license_edit_controller();
- }
+ default:
+ case 'edit':
+ return user_driver_license_edit_controller();
+ }
}
/**
@@ -63,16 +67,16 @@ function user_driver_license_edit_link($user = null)
function user_driver_license_load_user()
{
global $user;
-
+
$user_source = $user;
-
+
if (isset($_REQUEST['user_id'])) {
$user_source = User($_REQUEST['user_id']);
if ($user_source == null) {
redirect(user_driver_license_edit_link());
}
}
-
+
return $user_source;
}
@@ -82,14 +86,14 @@ function user_driver_license_load_user()
function user_driver_license_edit_controller()
{
global $privileges, $user;
-
+
$user_source = user_driver_license_load_user();
-
- // only privilege admin_user can edit other users driver license information
- if ($user['UID'] != $user_source['UID'] && ! in_array('admin_user', $privileges)) {
- redirect(user_driver_license_edit_link());
- }
-
+
+ // only privilege admin_user can edit other users driver license information
+ if ($user['UID'] != $user_source['UID'] && !in_array('admin_user', $privileges)) {
+ redirect(user_driver_license_edit_link());
+ }
+
$user_driver_license = UserDriverLicense($user_source['UID']);
if ($user_driver_license == null) {
$wants_to_drive = false;
@@ -97,7 +101,7 @@ function user_driver_license_edit_controller()
} else {
$wants_to_drive = true;
}
-
+
if (isset($_REQUEST['submit'])) {
$wants_to_drive = isset($_REQUEST['wants_to_drive']);
if ($wants_to_drive) {
@@ -107,7 +111,7 @@ function user_driver_license_edit_controller()
$user_driver_license['has_license_7_5t_truck'] = isset($_REQUEST['has_license_7_5t_truck']);
$user_driver_license['has_license_12_5t_truck'] = isset($_REQUEST['has_license_12_5t_truck']);
$user_driver_license['has_license_forklift'] = isset($_REQUEST['has_license_forklift']);
-
+
if (UserDriverLicense_valid($user_driver_license)) {
if ($user_driver_license['user_id'] == null) {
$user_driver_license = UserDriverLicenses_create($user_driver_license, $user);
@@ -127,9 +131,9 @@ function user_driver_license_edit_controller()
redirect(user_link($user_source));
}
}
-
+
return [
- sprintf(_("Edit %s driving license information"), $user_source['Nick']),
- UserDriverLicense_edit_view($user_source, $wants_to_drive, $user_driver_license)
- ];
+ sprintf(_("Edit %s driving license information"), $user_source['Nick']),
+ UserDriverLicense_edit_view($user_source, $wants_to_drive, $user_driver_license)
+ ];
}