mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Fix public status location (#10526)
* Fix public status location Implementing __toString() seemed to be the most elegant way to fix it. Added pre-loading for locations too * Take advantage of new __toString function
This commit is contained in:
@@ -47,7 +47,7 @@ class LoginController extends Controller
|
||||
public function showLoginForm()
|
||||
{
|
||||
if (Config::get('public_status')) {
|
||||
$devices = Device::isActive()->get();
|
||||
$devices = Device::isActive()->with('location')->get();
|
||||
return view('auth.public-status')->with('devices', $devices);
|
||||
}
|
||||
return view('auth.login');
|
||||
|
||||
@@ -251,15 +251,9 @@ class DeviceController extends TableController
|
||||
*/
|
||||
private function getLocation($device)
|
||||
{
|
||||
if ($device->location) {
|
||||
if (extension_loaded('mbstring')) {
|
||||
return mb_substr($device->location->location, 0, 32, 'utf8');
|
||||
} else {
|
||||
return substr($device->location->location, 0, 32);
|
||||
}
|
||||
}
|
||||
|
||||
return '';
|
||||
return extension_loaded('mbstring')
|
||||
? mb_substr($device->location, 0, 32, 'utf8')
|
||||
: substr($device->location, 0, 32);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -155,4 +155,9 @@ class Location extends Model
|
||||
{
|
||||
return $this->hasMany('App\Models\Device', 'location_id');
|
||||
}
|
||||
|
||||
public function __toString()
|
||||
{
|
||||
return $this->location;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -149,7 +149,7 @@ if ($_POST['editing']) {
|
||||
if (!$device_model->override_sysLocation) {
|
||||
echo(' disabled="1"');
|
||||
}
|
||||
?> value="<?php echo display($device_model->location->location); ?>" />
|
||||
?> value="<?php echo display($device_model->location); ?>" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
|
||||
Reference in New Issue
Block a user