MDL-78468 admin: Removed devicedetectregex theme setting

This commit is contained in:
Meirza
2023-08-22 09:47:36 +07:00
parent 352e427520
commit 4cfa361e0a
9 changed files with 64 additions and 57 deletions
+9 -22
View File
@@ -86,12 +86,6 @@ class core_useragent {
*/
protected $devicetype = null;
/**
* Custom device types entered into the admin interface.
* @var array
*/
protected $devicetypecustoms = array();
/**
* True if the user agent supports the display of svg images. False if not.
* @var bool|null Null until initialised, then true or false.
@@ -118,15 +112,6 @@ class core_useragent {
* @param string|null $forceuseragent Optional a user agent to force.
*/
protected function __construct($forceuseragent = null) {
global $CFG;
if (!empty($CFG->devicedetectregex)) {
$this->devicetypecustoms = json_decode($CFG->devicedetectregex, true);
}
if ($this->devicetypecustoms === null) {
// This shouldn't happen unless you're hardcoding the config value.
debugging('Config devicedetectregex is not valid JSON object');
$this->devicetypecustoms = array();
}
if ($forceuseragent !== null) {
$this->useragent = $forceuseragent;
} else if (!empty($_SERVER['HTTP_USER_AGENT'])) {
@@ -176,12 +161,6 @@ class core_useragent {
* @return string
*/
protected function guess_device_type() {
foreach ($this->devicetypecustoms as $value => $regex) {
if (preg_match($regex, $this->useragent)) {
$this->devicetype = $value;
return $this->devicetype;
}
}
if ($this->is_useragent_mobile()) {
$this->devicetype = self::DEVICETYPE_MOBILE;
} else if ($this->is_useragent_tablet()) {
@@ -230,10 +209,18 @@ class core_useragent {
/**
* Gets a list of known device types.
*
* @deprecated Moodle 4.3 MDL-78468 - No longer used. Please use core_useragent::devicetypes instead.
* @todo Final deprecation on Moodle 4.7 MDL-79052
* @param bool $includecustomtypes If set to true we'll include types that have been added by the admin.
* @return array
*/
public static function get_device_type_list($includecustomtypes = true) {
debugging(
__FUNCTION__ . '() is deprecated.' .
'All functions associated with devicedetectregex theme setting are being removed.
Please use core_useragent::devicetypes instead',
DEBUG_DEVELOPER
);
$types = self::$devicetypes;
if ($includecustomtypes) {
$instance = self::instance();
@@ -313,7 +300,7 @@ class core_useragent {
unset_user_preference('switchdevice'.$devicetype);
return true;
} else {
$devicetypes = self::get_device_type_list();
$devicetypes = self::$devicetypes;
if (in_array($newdevice, $devicetypes)) {
set_user_preference('switchdevice'.$devicetype, $newdevice);
return true;