Skip to content

Commit d55c176

Browse files
authored
Merge pull request #10831 from snipe/merges/master_down_to_develop_march_16
v6.0.0-RC-5 - Merges master down to develop
2 parents 93ff952 + c0451fe commit d55c176

14 files changed

+200
-86
lines changed
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<?php
2+
3+
namespace App\Console\Commands;
4+
5+
use Illuminate\Console\Command;
6+
7+
class KillAllSessions extends Command
8+
{
9+
/**
10+
* The name and signature of the console command.
11+
*
12+
* @var string
13+
*/
14+
protected $signature = 'snipeit:global-logout {--force : Skip the danger prompt; assuming you enter "y"} ';
15+
16+
/**
17+
* The console command description.
18+
*
19+
* @var string
20+
*/
21+
protected $description = 'This command will destroy all web sessions on disk and will force a re-login for all users.';
22+
23+
/**
24+
* Create a new command instance.
25+
*
26+
* @return void
27+
*/
28+
public function __construct()
29+
{
30+
parent::__construct();
31+
}
32+
33+
/**
34+
* Execute the console command.
35+
*
36+
* @return mixed
37+
*/
38+
public function handle()
39+
{
40+
41+
if (!$this->option('force') && !$this->confirm("****************************************************\nTHIS WILL FORCE A LOGIN FOR ALL LOGGED IN USERS.\n\nAre you SURE you wish to continue? ")) {
42+
return $this->error("Session loss not confirmed");
43+
}
44+
45+
$session_files = glob(storage_path("framework/sessions/*"));
46+
47+
$count = 0;
48+
foreach ($session_files as $file) {
49+
50+
if (is_file($file))
51+
unlink($file);
52+
$count++;
53+
}
54+
\DB::table('users')->update(['remember_token' => null]);
55+
56+
$this->info($count. ' sessions cleared!');
57+
58+
}
59+
}

app/Console/Commands/RestoreFromBackup.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ public function handle()
8282
return $this->error('Could not access file: '.$filename.' - '.array_key_exists($errcode, $errors) ? $errors[$errcode] : " Unknown reason: $errcode");
8383
}
8484

85+
8586
$private_dirs = [
8687
'storage/private_uploads/assets', // these are asset _files_, not the pictures.
8788
'storage/private_uploads/audits',
@@ -245,19 +246,21 @@ public function handle()
245246
return false;
246247
}
247248
$bytes_read = 0;
249+
248250
while (($buffer = fgets($sql_contents, self::$buffer_size)) !== false) {
249251
$bytes_read += strlen($buffer);
250252
// \Log::debug("Buffer is: '$buffer'");
251253
$bytes_written = fwrite($pipes[0], $buffer);
254+
252255
if ($bytes_written === false) {
253256
$stdout = fgets($pipes[1]);
254257
$this->info($stdout);
255258
$stderr = fgets($pipes[2]);
256259
$this->info($stderr);
257-
258260
return false;
259261
}
260262
}
263+
261264
if (!feof($sql_contents) || $bytes_read == 0) {
262265
return $this->error("Not at end of file for sql file, or zero bytes read. aborting!");
263266
}

app/Http/Controllers/Assets/AssetsController.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,7 @@ public function edit($assetId = null)
235235
->with('statuslabel_types', Helper::statusTypeList());
236236
}
237237

238+
238239
/**
239240
* Returns a view that presents information about an asset for detail view.
240241
*
@@ -309,6 +310,7 @@ public function update(ImageUploadRequest $request, $assetId = null)
309310
$asset->location_id = $request->input('rtd_location_id', null);
310311
}
311312

313+
312314
if ($request->filled('image_delete')) {
313315
try {
314316
unlink(public_path().'/uploads/assets/'.$asset->image);
@@ -401,6 +403,24 @@ public function destroy($assetId)
401403
return redirect()->route('hardware.index')->with('success', trans('admin/hardware/message.delete.success'));
402404
}
403405

406+
/**
407+
* Searches the assets table by serial, and redirects if it finds one
408+
*
409+
* @author [A. Gianotto] [<[email protected]>]
410+
* @since [v3.0]
411+
* @return Redirect
412+
*/
413+
public function getAssetBySerial(Request $request)
414+
{
415+
$topsearch = ($request->get('topsearch')=="true");
416+
417+
if (!$asset = Asset::where('serial', '=', $request->get('serial'))->first()) {
418+
return redirect()->route('hardware.index')->with('error', trans('admin/hardware/message.does_not_exist'));
419+
}
420+
$this->authorize('view', $asset);
421+
return redirect()->route('hardware.show', $asset->id)->with('topsearch', $topsearch);
422+
}
423+
404424
/**
405425
* Searches the assets table by asset tag, and redirects if it finds one
406426
*
@@ -420,6 +440,7 @@ public function getAssetByTag(Request $request)
420440
return redirect()->route('hardware.show', $asset->id)->with('topsearch', $topsearch);
421441
}
422442

443+
423444
/**
424445
* Return a QR code for the asset
425446
*
@@ -792,6 +813,7 @@ public function overdueForAudit()
792813
return view('hardware/audit-overdue');
793814
}
794815

816+
795817
public function auditStore(Request $request, $id)
796818
{
797819
$this->authorize('audit', Asset::class);
@@ -822,6 +844,7 @@ public function auditStore(Request $request, $id)
822844
$asset->location_id = $request->input('location_id');
823845
}
824846

847+
825848
if ($asset->save()) {
826849
$file_name = '';
827850
// Upload an image, if attached

app/Http/Transformers/AssetsTransformer.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use App\Helpers\Helper;
66
use App\Models\Asset;
7+
use App\Models\Setting;
78
use Gate;
89
use Illuminate\Database\Eloquent\Collection;
910

@@ -21,6 +22,9 @@ public function transformAssets(Collection $assets, $total)
2122

2223
public function transformAsset(Asset $asset)
2324
{
25+
// This uses the getSettings() method so we're pulling from the cache versus querying the settings on single asset
26+
$setting = Setting::getSettings();
27+
2428
$array = [
2529
'id' => (int) $asset->id,
2630
'name' => e($asset->name),
@@ -65,6 +69,8 @@ public function transformAsset(Asset $asset)
6569
'name'=> e($asset->defaultLoc->name),
6670
] : null,
6771
'image' => ($asset->getImageUrl()) ? $asset->getImageUrl() : null,
72+
'qr' => ($setting->qr_code=='1') ? config('app.url').'/uploads/barcodes/qr-'.str_slug($asset->asset_tag).'-'.str_slug($asset->id).'.png' : null,
73+
'alt_barcode' => ($setting->alt_barcode_enabled=='1') ? config('app.url').'/uploads/barcodes/'.str_slug($setting->alt_barcode).'-'.str_slug($asset->asset_tag).'.png' : null,
6874
'assigned_to' => $this->transformAssignedTo($asset),
6975
'warranty_months' => ($asset->warranty_months > 0) ? e($asset->warranty_months.' '.trans('admin/hardware/form.months')) : null,
7076
'warranty_expires' => ($asset->warranty_months > 0) ? Helper::getFormattedDateObject($asset->warranty_expires, 'date') : null,

app/Importer/LicenseImporter.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@ public function createLicenseIfNotExists(array $row)
4848
}
4949
$asset_tag = $this->item['asset_tag'] = $this->findCsvMatch($row, 'asset_tag'); // used for checkout out to an asset.
5050

51-
$this->item['expiration_date'] = null;
52-
if ($this->findCsvMatch($row, 'expiration_date') != '') {
53-
$this->item['expiration_date'] = date('Y-m-d 00:00:01', strtotime($this->findCsvMatch($row, 'expiration_date')));
51+
$this->item["expiration_date"] = null;
52+
if ($this->findCsvMatch($row, "expiration_date")!='') {
53+
$this->item["expiration_date"] = date("Y-m-d 00:00:01", strtotime($this->findCsvMatch($row, "expiration_date")));
5454
}
5555
$this->item['license_email'] = $this->findCsvMatch($row, 'license_email');
5656
$this->item['license_name'] = $this->findCsvMatch($row, 'license_name');
@@ -59,9 +59,9 @@ public function createLicenseIfNotExists(array $row)
5959
$this->item['reassignable'] = $this->findCsvMatch($row, 'reassignable');
6060
$this->item['seats'] = $this->findCsvMatch($row, 'seats');
6161

62-
$this->item['termination_date'] = null;
63-
if ($this->findCsvMatch($row, 'termination_date') != '') {
64-
$this->item['termination_date'] = date('Y-m-d 00:00:01', strtotime($this->findCsvMatch($row, 'termination_date')));
62+
$this->item["termination_date"] = null;
63+
if ($this->findCsvMatch($row, "termination_date")!='') {
64+
$this->item["termination_date"] = date("Y-m-d 00:00:01", strtotime($this->findCsvMatch($row, "termination_date")));
6565
}
6666

6767
if ($editingLicense) {

config/version.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<?php
22
return array (
3-
'app_version' => 'v6.0.0-RC-4',
4-
'full_app_version' => 'v6.0.0-RC-4 - build 6754-gafd83311a',
5-
'build_version' => '6754',
3+
'app_version' => 'v6.0.0-RC-5',
4+
'full_app_version' => 'v6.0.0-RC-5 - build 6772-g7cbcd2d95',
5+
'build_version' => '6772',
66
'prerelease_version' => '',
7-
'hash_version' => 'gafd83311a',
8-
'full_hash' => 'v6.0.0-RC-4-1-gafd83311a',
9-
'branch' => 'develop',
7+
'hash_version' => 'g7cbcd2d95',
8+
'full_hash' => 'v6.0.0-RC-5-19-g7cbcd2d95',
9+
'branch' => 'merges/master_down_to_develop_march_16',
1010
);

database/migrations/2018_07_28_023826_create_checkout_acceptances_table.php

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,22 @@ class CreateCheckoutAcceptancesTable extends Migration
1313
*/
1414
public function up()
1515
{
16-
Schema::create('checkout_acceptances', function (Blueprint $table) {
17-
$table->increments('id');
16+
if (!Schema::hasTable('checkout_acceptances')) {
17+
Schema::create('checkout_acceptances', function (Blueprint $table) {
18+
$table->increments('id');
1819

19-
$table->morphs('checkoutable');
20-
$table->integer('assigned_to_id')->nullable();
20+
$table->morphs('checkoutable');
21+
$table->integer('assigned_to_id')->nullable();
2122

22-
$table->string('signature_filename')->nullable();
23+
$table->string('signature_filename')->nullable();
2324

24-
$table->timestamp('accepted_at')->nullable();
25-
$table->timestamp('declined_at')->nullable();
25+
$table->timestamp('accepted_at')->nullable();
26+
$table->timestamp('declined_at')->nullable();
2627

27-
$table->timestamps();
28-
$table->softDeletes();
29-
});
28+
$table->timestamps();
29+
$table->softDeletes();
30+
});
31+
}
3032
}
3133

3234
/**
@@ -36,6 +38,8 @@ public function up()
3638
*/
3739
public function down()
3840
{
39-
Schema::dropIfExists('checkout_acceptances');
41+
if (Schema::hasTable('checkout_acceptances')) {
42+
Schema::dropIfExists('checkout_acceptances');
43+
}
4044
}
4145
}
Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
<?php
22

3-
use Illuminate\Database\Migrations\Migration;
43
use Illuminate\Database\Schema\Blueprint;
4+
use Illuminate\Database\Migrations\Migration;
5+
use Illuminate\Support\Facades\Schema;
6+
57

68
class AddKitsLicensesTable extends Migration
79
{
@@ -12,15 +14,16 @@ class AddKitsLicensesTable extends Migration
1214
*/
1315
public function up()
1416
{
15-
//
16-
Schema::create('kits_licenses', function ($table) {
17-
$table->increments('id');
18-
$table->integer('kit_id')->nullable()->default(null);
19-
$table->integer('license_id')->nullable()->default(null);
20-
$table->integer('quantity')->default(1);
21-
$table->timestamps();
22-
});
23-
}
17+
if (!Schema::hasTable('kits_licenses')) {
18+
Schema::create('kits_licenses', function ($table) {
19+
$table->increments('id');
20+
$table->integer('kit_id')->nullable()->default(null);
21+
$table->integer('license_id')->nullable()->default(null);
22+
$table->integer('quantity')->default(1);
23+
$table->timestamps();
24+
});
25+
}
26+
}
2427

2528
/**
2629
* Reverse the migrations.
@@ -29,7 +32,9 @@ public function up()
2932
*/
3033
public function down()
3134
{
32-
//
33-
Schema::drop('kits_licenses');
34-
}
35+
if (Schema::hasTable('kits_licenses')) {
36+
Schema::drop('kits_licenses');
37+
}
38+
}
39+
3540
}
Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
<?php
22

3-
use Illuminate\Database\Migrations\Migration;
43
use Illuminate\Database\Schema\Blueprint;
4+
use Illuminate\Database\Migrations\Migration;
5+
use Illuminate\Support\Facades\Schema;
56

67
class AddKitsTable extends Migration
78
{
@@ -12,14 +13,16 @@ class AddKitsTable extends Migration
1213
*/
1314
public function up()
1415
{
15-
//
16-
Schema::create('kits', function ($table) {
17-
$table->increments('id');
18-
$table->string('name')->nullable()->default(null);
19-
$table->timestamps();
20-
$table->engine = 'InnoDB';
21-
});
22-
}
16+
if (!Schema::hasTable('kits')) {
17+
Schema::create('kits', function ($table) {
18+
$table->increments('id');
19+
$table->string('name')->nullable()->default(null);
20+
$table->timestamps();
21+
$table->engine = 'InnoDB';
22+
});
23+
}
24+
25+
}
2326

2427
/**
2528
* Reverse the migrations.
@@ -28,7 +31,9 @@ public function up()
2831
*/
2932
public function down()
3033
{
31-
//
32-
Schema::drop('kits');
33-
}
34+
if (Schema::hasTable('kits')) {
35+
Schema::drop('kits');
36+
}
37+
}
38+
3439
}

0 commit comments

Comments
 (0)