Merge remote-tracking branch 'origin/develop'

This commit is contained in:
snipe
2025-06-25 13:11:39 +01:00
6 changed files with 44 additions and 21 deletions

View File

@@ -10,15 +10,16 @@ class LocationScopeCheck extends Component
{
public $mismatched = [];
public $setting;
public $is_tested = false;
public function check_locations()
{
$this->mismatched = Helper::test_locations_fmcs(false);
$this->is_tested = true;
}
public function mount() {
$this->setting = Setting::getSettings();
$this->mismatched = Helper::test_locations_fmcs(false);
}
public function render()

View File

@@ -18,6 +18,7 @@ use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Foundation\Auth\Access\Authorizable;
use Illuminate\Notifications\Notifiable;
use Illuminate\Support\Facades\Gate;
use Illuminate\Support\Str;
use Laravel\Passport\HasApiTokens;
use Watson\Validating\ValidatingTrait;
use Illuminate\Database\Eloquent\Casts\Attribute;
@@ -168,6 +169,15 @@ class User extends SnipeModel implements AuthenticatableContract, AuthorizableCo
}
public function isAvatarExternal() {
// Check if it's a google avatar or some external avatar
if (Str::startsWith($this->avatar, ['http://', 'https://'])) {
return true;
}
return false;
}
/**
* Internally check the user permission for the given section
*

View File

@@ -453,6 +453,8 @@ class UserPresenter extends Presenter
return $this->fullName();
}
/**
* Returns the user Gravatar image url.
*
@@ -465,7 +467,7 @@ class UserPresenter extends Presenter
if ($this->avatar) {
// Check if it's a google avatar or some external avatar
if (Str::startsWith($this->avatar, ['http://', 'https://'])) {
if ($this->isAvatarExternal()) {
return $this->avatar;
}

View File

@@ -157,6 +157,7 @@ return [
'scope_locations_fmcs_support_text' => 'Scope Locations with Full Multiple Companies Support',
'scope_locations_fmcs_support_help_text' => 'Restrict locations to their selected company.',
'scope_locations_fmcs_check_button' => 'Check Compatibility',
'scope_locations_fmcs_test_needed' => 'Please Check Compatibility to enable this',
'scope_locations_fmcs_support_disabled_text' => 'This option is disabled because you have conflicting locations set for :count or more items.',
'show_in_model_list' => 'Show in Model Dropdowns',
'optional' => 'optional',

View File

@@ -107,39 +107,44 @@
</div>
</div>
<!-- Gravatar Email -->
<div class="form-group {{ $errors->has('gravatar') ? ' has-error' : '' }}">
<label for="gravatar" class="col-md-3 control-label">{{ trans('general.gravatar_email') }}
<small>(Private)</small>
</label>
<div class="col-md-8">
<input class="form-control" type="text" name="gravatar" id="gravatar" value="{{ old('gravatar', $user->gravatar) }}" />
{!! $errors->first('gravatar', '<span class="alert-msg" aria-hidden="true"><i class="fas fa-times" aria-hidden="true"></i> :message</span>') !!}
<p style="padding-top: 3px;">
<img src="//secure.gravatar.com/avatar/{{ md5(strtolower(trim($user->gravatar))) }}" width="30" height="30" alt="{{ $user->present()->fullName() }} avatar image">
{!! trans('general.gravatar_url') !!}
</p>
</div>
</div>
<!-- Avatar -->
@if (($user->avatar) && ($user->avatar!=''))
<div class="form-group{{ $errors->has('image_delete') ? ' has-error' : '' }}">
<div class="col-md-9 col-md-offset-3">
@if (!$user->isAvatarExternal())
<label for="image_delete" class="form-control">
<input type="checkbox" name="image_delete" id="image_delete" value="1" @checked(old('image_delete')) aria-label="image_delete">
{{ trans('general.image_delete') }}
</label>
{!! $errors->first('image_delete', '<span class="alert-msg">:message</span>') !!}
@endif
</div>
</div>
<div class="form-group">
<div class="col-md-9 col-md-offset-3">
<img src="{{ Storage::disk('public')->url(app('users_upload_path').e($user->avatar)) }}" class="img-responsive">
<img src="{{ (($user->isAvatarExternal()) ? $user->avatar : Storage::disk('public')->url(app('users_upload_path').e($user->avatar))) }}" class="img-responsive">
{!! $errors->first('image_delete', '<span class="alert-msg">:message</span>') !!}
</div>
</div>
@else
<!-- Gravatar Email -->
<div class="form-group {{ $errors->has('gravatar') ? ' has-error' : '' }}">
<label for="gravatar" class="col-md-3 control-label">{{ trans('general.gravatar_email') }}
<small>(Private)</small>
</label>
<div class="col-md-8">
<input class="form-control" type="text" name="gravatar" id="gravatar" value="{{ old('gravatar', $user->gravatar) }}" />
{!! $errors->first('gravatar', '<span class="alert-msg" aria-hidden="true"><i class="fas fa-times" aria-hidden="true"></i> :message</span>') !!}
<p style="padding-top: 3px;">
<img src="//secure.gravatar.com/avatar/{{ md5(strtolower(trim($user->gravatar))) }}" width="30" height="30" alt="{{ $user->present()->fullName() }} avatar image">
{!! trans('general.gravatar_url') !!}
</p>
</div>
</div>
@endif

View File

@@ -1,11 +1,15 @@
<div>
<label class="form-control{{ (count($mismatched) > 0) ? ' form-control--disabled' : '' }}">
<input type="checkbox" name="scope_locations_fmcs" value="1" @checked(old('scope_locations_fmcs', $setting->scope_locations_fmcs)) aria-label="scope_locations_fmcs" {{ (count($mismatched) > 0) ? ' disabled' : '' }}/>
<label class="form-control{{ (!$is_tested || count($mismatched) > 0 ) ? ' form-control--disabled' : '' }}">
<input type="checkbox" name="scope_locations_fmcs" value="1"
@checked(old('scope_locations_fmcs', $setting->scope_locations_fmcs)) aria-label="scope_locations_fmcs" {{ (!$is_tested || count($mismatched) > 0) ? ' disabled' : '' }}/>
{{ trans('admin/settings/general.scope_locations_fmcs_support_text') }}
</label>
<p class="help-block">
{{ trans('admin/settings/general.scope_locations_fmcs_support_help_text') }}
<strong>{{ (count($mismatched) > 0) ? trans('admin/settings/general.scope_locations_fmcs_support_disabled_text', ['count' => count($mismatched)]) : '' }}</strong>
<strong>{{ ($is_tested && count($mismatched) > 0) ? trans('admin/settings/general.scope_locations_fmcs_support_disabled_text', ['count' => count($mismatched)]) : '' }}</strong>
@if(!$is_tested)
<strong>{{ trans('admin/settings/general.scope_locations_fmcs_test_needed') }}</strong>
@endif
</p>
<button class="btn btn-sm btn-default" wire:click.prevent="check_locations">{{ trans('admin/settings/general.scope_locations_fmcs_check_button') }}</button>
</div>