Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop'
Browse files Browse the repository at this point in the history
# Conflicts:
#	config/version.php
  • Loading branch information
snipe committed Jan 4, 2021
2 parents f1d0d1b + 382fb31 commit eb423c2
Show file tree
Hide file tree
Showing 208 changed files with 264,748 additions and 1,268 deletions.
4 changes: 3 additions & 1 deletion Dockerfile.alpine
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM alpine:3.8
FROM alpine:3.12
# Apache + PHP
RUN apk add --update --no-cache \
apache2 \
Expand All @@ -23,6 +23,8 @@ RUN apk add --update --no-cache \
php7-fileinfo \
php7-simplexml \
php7-session \
php7-dom \
php7-xmlwriter \
curl \
wget \
vim \
Expand Down
2 changes: 1 addition & 1 deletion app/Exceptions/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public function render($request, Exception $e)
protected function unauthenticated($request, AuthenticationException $exception)
{
if ($request->expectsJson()) {
return response()->json(['error' => 'Unauthorized.'], 401);
return response()->json(['error' => 'Unauthorized or unauthenticated.'], 401);
}

return redirect()->guest('login');
Expand Down
2 changes: 0 additions & 2 deletions app/Http/Controllers/LocationsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ public function store(ImageUploadRequest $request)
{
$this->authorize('create', Location::class);
$location = new Location();
$location->id = null; // This is required to make Laravels different validation work, it errors if the parameter doesn't exist (maybe a bug)?
$location->name = $request->input('name');
$location->parent_id = $request->input('parent_id', null);
$location->currency = $request->input('currency', '$');
Expand Down Expand Up @@ -132,7 +131,6 @@ public function update(ImageUploadRequest $request, $locationId = null)
return redirect()->route('locations.index')->with('error', trans('admin/locations/message.does_not_exist'));
}


// Update the location data
$location->name = $request->input('name');
$location->parent_id = $request->input('parent_id', null);
Expand Down
1 change: 1 addition & 0 deletions app/Http/Controllers/SettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,7 @@ public function postLocalization(Request $request)
$setting->default_currency = $request->input('default_currency', '$');
$setting->date_display_format = $request->input('date_display_format');
$setting->time_display_format = $request->input('time_display_format');
$setting->digit_separator = $request->input('digit_separator');

if ($setting->save()) {
return redirect()->route('settings.index')
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Requests/SetupUserRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function rules()
'last_name' => 'required|string|min:1',
'username' => 'required|string|min:2|unique:users,username,NULL,deleted_at',
'email' => 'email|unique:users,email',
'password' => 'required|min:6|confirmed',
'password' => 'required|min:8|confirmed',
'email_domain' => 'required|min:4',
];
}
Expand Down
2 changes: 1 addition & 1 deletion app/Models/Location.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class Location extends SnipeModel
'address2' => 'max:80|nullable',
'zip' => 'min:3|max:10|nullable',
'manager_id' => 'exists:users,id|nullable',
'parent_id' => 'nullable|exists:locations,id|different:id',
'parent_id' => 'non_circular:locations,id'
);

protected $casts = [
Expand Down
21 changes: 11 additions & 10 deletions app/Presenters/AssetPresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ public static function dataTableLayout()
"searchable" => true,
"sortable" => true,
"title" => trans('general.purchase_cost'),
"formatter" => 'numberWithCommas',
"footerFormatter" => 'sumFormatter',
], [
"field" => "order_number",
Expand Down Expand Up @@ -360,18 +361,13 @@ public function imageSrc()
/**
* Get Displayable Name
* @return string
*
* @todo this should be factored out - it should be subsumed by fullName (below)
*
**/
public function name()
{

if (empty($this->model->name)) {
if (isset($this->model->model)) {
return $this->model->model->name.' ('.$this->model->asset_tag.')';
}
return $this->model->asset_tag;
}
return $this->model->name . ' (' . $this->model->asset_tag . ')';

return $this->fullName;
}

/**
Expand All @@ -381,13 +377,18 @@ public function name()
public function fullName()
{
$str = '';

// Asset name
if ($this->model->name) {
$str .= $this->name;
$str .= $this->model->name;
}

// Asset tag
if ($this->asset_tag) {
$str .= ' ('.$this->model->asset_tag.')';
}

// Asset Model name
if ($this->model->model) {
$str .= ' - '.$this->model->model->name;
}
Expand Down
46 changes: 46 additions & 0 deletions app/Providers/ValidationServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,52 @@ public function boot()
});


// Prevent circular references
//
// Example usage in Location model where parent_id references another Location:
//
// protected $rules = array(
// 'parent_id' => 'non_circular:locations,id,10'
// );
//
Validator::extend('non_circular', function ($attribute, $value, $parameters, $validator) {
if (count($parameters) < 2) {
throw new \Exception('Required validator parameters: <table>,<primary key>[,depth]');
}

// Parameters from the rule implementation ($pk will likely be 'id')
$table = array_get($parameters, 0);
$pk = array_get($parameters, 1);
$depth = (int) array_get($parameters, 2, 50);

// Data from the edited model
$data = $validator->getData();

// The primary key value from the edited model
$data_pk = array_get($data, $pk);
$value_pk = $value;

// If we’re editing an existing model and there is a parent value set…
while ($data_pk && $value_pk) {

// It’s not valid for any parent id to be equal to the existing model’s id
if ($data_pk == $value_pk) {
return false;
}

// Avoid accidental infinite loops
if (--$depth < 0) {
return false;
}

// Get the next parent id
$value_pk = DB::table($table)->select($attribute)->where($pk, '=', $value_pk)->value($attribute);
}

return true;
});


// Yo dawg. I heard you like validators.
// This validates the custom validator regex in custom fields.
// We're just checking that the regex won't throw an exception, not
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"ext-mbstring": "*",
"ext-pdo": "*",
"adldap2/adldap2": "^10.2",
"alek13/slack": "^1.12",
"bacon/bacon-qr-code": "^1.0",
"barryvdh/laravel-cors": "^0.11.3",
"barryvdh/laravel-debugbar": "^3.2",
Expand All @@ -42,7 +43,6 @@
"league/csv": "^9.5",
"league/flysystem-aws-s3-v3": "^1.0",
"league/flysystem-cached-adapter": "^1.0",
"maknz/slack": "^1.7",
"neitanod/forceutf8": "^2.0",
"nesbot/carbon": "^2.32",
"onelogin/php-saml": "^3.4",
Expand Down
117 changes: 67 additions & 50 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions config/version.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?php
return array (
'app_version' => 'v5.0.11',
'full_app_version' => 'v5.0.11 - build 5695-gfd4ee6027',
'build_version' => '5695',
'app_version' => 'v5.0.12',
'full_app_version' => 'v5.0.12 - build 5705-gf1d0d1bfe',
'build_version' => '5705',
'prerelease_version' => '',
'hash_version' => 'gfd4ee6027',
'full_hash' => 'v5.0.11-13-gfd4ee6027',
'hash_version' => 'gf1d0d1bfe',
'full_hash' => 'v5.0.12-8-gf1d0d1bfe',
'branch' => 'master',
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class AddDigitSeparatorToSettings extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('settings', function (Blueprint $table) {
$table->char('digit_separator')->nullable()->default('1234.56');
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('settings', function (Blueprint $table) {
$table->dropColumn('digit_separator');
});
}
}
Loading

0 comments on commit eb423c2

Please sign in to comment.