From 00635bf01dd985d050e41fcd68da066058d9b827 Mon Sep 17 00:00:00 2001 From: Ryan Cramer Date: Fri, 15 Nov 2019 14:35:15 -0500 Subject: [PATCH] Minor updates, phpdoc tweaks and such --- wire/core/AdminTheme.php | 12 +++++++----- wire/core/User.php | 2 +- wire/core/Wire.php | 2 +- wire/core/WireMail.php | 5 +++++ 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/wire/core/AdminTheme.php b/wire/core/AdminTheme.php index 771c67d0..aac20306 100644 --- a/wire/core/AdminTheme.php +++ b/wire/core/AdminTheme.php @@ -130,8 +130,10 @@ abstract class AdminTheme extends WireData implements Module { $config = $this->wire('config'); /** @var Session $session */ $session = $this->wire('session'); + /** @var User $user */ + $user = $this->wire('user'); /** @var string $adminTheme */ - $adminTheme = $this->wire('user')->admin_theme; + $adminTheme = $user->admin_theme; if($adminTheme) { // there is user specified admin theme @@ -146,14 +148,14 @@ abstract class AdminTheme extends WireData implements Module { // adjust $config adminThumbOptions[scale] for auto detect when requested $o = $config->adminThumbOptions; if($o && isset($o['scale']) && $o['scale'] === 1) { - $o['scale'] = $session->hidpi ? 0.5 : 1.0; + $o['scale'] = $session->get('hidpi') ? 0.5 : 1.0; $config->adminThumbOptions = $o; } $config->js('modals', $config->modals); - - if($session->hidpi) $this->addBodyClass('hidpi-device'); - if($session->touch) $this->addBodyClass('touch-device'); + + if($session->get('hidpi')) $this->addBodyClass('hidpi-device'); + if($session->get('touch')) $this->addBodyClass('touch-device'); $this->addBodyClass($this->className()); } diff --git a/wire/core/User.php b/wire/core/User.php index 22997ff0..1bd25a47 100644 --- a/wire/core/User.php +++ b/wire/core/User.php @@ -291,7 +291,7 @@ class User extends Page { * * #pw-hooker * - * @param string $name Permission name + * @param string|Permission $name Permission name * @param Template|int|string $template Template object, name or ID * @return bool * @throws WireException diff --git a/wire/core/Wire.php b/wire/core/Wire.php index 6469a6cb..ed2d4605 100644 --- a/wire/core/Wire.php +++ b/wire/core/Wire.php @@ -1442,7 +1442,7 @@ abstract class Wire implements WireTranslatable, WireFuelable, WireTrackable { * @param string|array $options One or more of array elements or space separated string of: * - `first` - only first item will be returned * - `last` - only last item will be returned - * - `all` - include all errors, including those beyond the scope of this object + * - `all` - include all messages, including those beyond the scope of this object * - `clear` - clear out all items that are returned from this method * - `array` - return an array of strings rather than series of Notice objects. * - `string` - return a newline separated string rather than array/Notice objects. diff --git a/wire/core/WireMail.php b/wire/core/WireMail.php index 8bdd526f..9350c50a 100644 --- a/wire/core/WireMail.php +++ b/wire/core/WireMail.php @@ -150,6 +150,11 @@ class WireMail extends WireData implements WireMailInterface { protected function sanitizeEmail($email) { if(!strlen($email)) return ''; $email = strtolower(trim($email)); + if(strpos($email, ':') && preg_match('/^(.+):\d+$/', $email, $matches)) { + // sending email in particular might sometimes be auto-generated from hostname + // so remove trailing port, i.e. ':8888', if present since it will not validate + $email = $matches[1]; + } $clean = $this->wire('sanitizer')->email($email); if($email !== $clean) { throw new WireException("Invalid email address: " . $this->wire('sanitizer')->entities($email));