From: Sven Schöling Date: Wed, 20 Jan 2021 10:04:59 +0000 (+0100) Subject: Request: is_mobile X-Git-Tag: kivitendo-mebil_0.1-0~9^2~119 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=90d4d3fd206ac296bea8e228a058c7fcecb58af3;p=kivitendo-erp.git Request: is_mobile --- diff --git a/SL/Request.pm b/SL/Request.pm index c33b6b3e5..7c4fa7198 100644 --- a/SL/Request.pm +++ b/SL/Request.pm @@ -20,7 +20,7 @@ our @EXPORT_OK = qw(flatten unflatten); use Rose::Object::MakeMethods::Generic ( scalar => [ qw(applying_database_upgrades post_data) ], - 'scalar --get_set_init' => [ qw(cgi layout presenter is_ajax type) ], + 'scalar --get_set_init' => [ qw(cgi layout presenter is_ajax is_mobile type) ], ); sub init_cgi { @@ -39,6 +39,12 @@ sub init_is_ajax { return ($ENV{HTTP_X_REQUESTED_WITH} || '') eq 'XMLHttpRequest' ? 1 : 0; } +sub init_is_mobile { + # mobile clients will change their user agent when the user requests + # desktop version so user agent is the most reliable way to identify + return ($ENV{HTTP_USER_AGENT} || '') =~ /Mobi/ ? 1 : 0; +} + sub init_type { return 'html'; }