From bc185a28482a898533956a588e7deb68e64af14e Mon Sep 17 00:00:00 2001 From: snipe Date: Wed, 21 Dec 2022 16:46:29 -0800 Subject: [PATCH] Squashed commit of the following: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit commit 685cc86d714b1367cfa4a9e5f2a90700f4638b5b Author: snipe Date: Tue Dec 20 17:24:01 2022 -0800 Sets the `ldap_default_group` field to nullable and default null Signed-off-by: snipe commit fb10a6f21884672d275a599b4d7a0312562b17a8 Merge: 128c21a90 3a9b8a499 Author: snipe Date: Tue Dec 20 17:05:18 2022 -0800 Merge pull request #12268 from inietov/fixes/people_count Fixed: Dashboard user count scoping when full company support is enabled commit 3a9b8a49930d696a5bcb608afeb289893ec75a86 Author: Ivan Nieto Vivanco Date: Tue Dec 20 18:39:17 2022 -0600 Calculate the proper amount of people in the dashboard if Full Company Support is enabled commit 128c21a9052ab9412214b549f22c7f6677f61003 Merge: 88291cadc 75a757d6f Author: snipe Date: Tue Dec 20 15:09:30 2022 -0800 Merge pull request #12266 from uberbrady/fix-select-all-bug Fixed: There was a bug with BS tables' select-all which showed an incorrect list of elements commit 75a757d6f52ff7462d75d77be8dd698e74e7e71b Author: Brady Wetherington Date: Tue Dec 20 14:57:58 2022 -0800 There was a bug with select-all where some bits didn't quite work commit 88291cadc18fafa627c3d215252911bd3fd13e0b Merge: 399c7590c 94afe2bc6 Author: snipe Date: Mon Dec 19 12:41:32 2022 -0800 Merge pull request #12254 from akemidx/documentating_something Commenting on a scope in Models/Company.php commit 94afe2bc6ae8dbaa8471803e9914a7b1ab158842 Author: akemidx Date: Mon Dec 19 14:48:43 2022 -0500 edits & typo fixes commit 399c7590cd17b76aea264bd989e1a24c084ce01b Merge: d0c5ba70f eb67d1b06 Author: snipe Date: Thu Dec 15 14:19:41 2022 -0800 Merge pull request #12209 from snipe/fixes/error_downloading_unaccepted_assets Fixed 500 when downloading the Unaccepted Assets report [sc-19555] commit d0c5ba70f630f0d36e40260343b98773d2402722 Merge: 29c2ff56e d9a21cce0 Author: snipe Date: Thu Dec 15 12:42:29 2022 -0800 Merge pull request #12242 from inietov/features/add_purchase_cost_column Added `purchase_cost` to user's default view [sc-19680] commit 133d6ffa50cf4ee0832008f3f6050fcf7c3bf9c6 Author: akemidx Date: Thu Dec 15 15:18:24 2022 -0500 Commenting on a scope in Models/Company.php commit d9a21cce00a096271ac2316e9c532b106ce4824b Author: Ivan Nieto Vivanco Date: Thu Dec 15 14:12:05 2022 -0600 Add other items' purchase_cost columns to the same permission commit 29c2ff56ec7ffef5cfa6da93951efc749efe13f4 Merge: 3e7975b2c 1fe0bfe17 Author: snipe Date: Thu Dec 15 11:26:49 2022 -0800 Merge pull request #12188 from snipe/fixes/decrease_logging_for_saml_when_not_enabled Removed extra logging case that was very noisy commit 3e7975b2c3b991e2d475ac4d56a7a1128c4ccbc9 Merge: 227fef76e d870bc3b0 Author: snipe Date: Thu Dec 15 11:25:53 2022 -0800 Merge pull request #12250 from akemidx/grey_out_pw_reset_button Fixed: Grey out pw reset button for consistency commit d870bc3b0226cc8d9403c76e5cf219482ce01e12 Author: akemidx Date: Thu Dec 15 14:19:51 2022 -0500 nested if loop commit 227fef76ee02a73afd63d1cefe68e1df24ccba19 Merge: 418ddcfac 9d44720ff Author: snipe Date: Thu Dec 15 11:06:53 2022 -0800 Merge pull request #11736 from Godmartinz/gh6508_ldap_default_group Adds a permission group selection for directory sync commit 9d44720ffdb7cfa42239df48777a47fd5b3dbfc8 Author: Godfrey M Date: Thu Dec 15 11:02:34 2022 -0800 reverted changes to composer.lock commit 9f3f0a25ed94445e19e1d533b7bdbcd4db85dfa0 Author: Godfrey M Date: Thu Dec 15 10:53:45 2022 -0800 reverted changes to composer.lock commit 2e228ccb0bd94c295493f3aeb5a9a13f83af149e Author: Godfrey M Date: Thu Dec 15 10:45:42 2022 -0800 redid a few things. should be good now :) commit 3ee413f3791caedadea9d33c40a6959c181ea3af Author: Godfrey M Date: Thu Dec 15 09:20:30 2022 -0800 removes livewire stuff commit b142f8e012b00763af1cde329199ab71528160a2 Author: Ivan Nieto Vivanco Date: Wed Dec 14 23:00:35 2022 -0600 Add the permission to show purchase cost column to non-admin sessions commit 418ddcfac39aed2cc48a5c8c886ab2b1d6e47c30 Merge: c342668f0 1a908e361 Author: snipe Date: Wed Dec 14 17:46:53 2022 -0800 Merge pull request #9876 from Toreg87/fixes/locations-deletable Fixed #9875: Make locations deletable for non Superuser-Accounts with FullMultipleCompanySupport commit c342668f0ff1c1f1aebb772fed3ffdcf8a9612f5 Author: snipe Date: Wed Dec 14 17:25:39 2022 -0800 Update @scoo73r as a contributor commit 2f6a26ec7d1635c3108ec84e0679bfd94cb0212c Author: snipe Date: Wed Dec 14 17:25:25 2022 -0800 Add @scoo73r as a contributor commit f63527801010d8cfbe1ea79c43c15537408c6491 Merge: d13a23700 8043b8678 Author: snipe Date: Wed Dec 14 16:42:41 2022 -0800 Merge pull request #12251 from snipe/security/upgrade_font_awesome Upgraded font awesome to 6.2.1 commit 8043b86786322c0bdb1712d238eb7a544440312f Author: snipe Date: Wed Dec 14 16:41:56 2022 -0800 Upgraded font awesome to 6.2.1 Signed-off-by: snipe commit d13a2370004a26720fb8985a43e2a5c413ed7f7a Merge: fabefa61b d0d0058e7 Author: snipe Date: Wed Dec 14 12:13:18 2022 -0800 Merge pull request #12205 from Godmartinz/sc19675_add_remote_to_importer Adds remote field to the user importer commit b114ffd2c3d34c0760076e0d20d3278a7196bbcb Author: akemidx Date: Wed Dec 14 14:48:59 2022 -0500 Grey out button pw reset button for consistency When user has no email in their profile, the box is greyed out for consistency accross all buttons on the user profile commit fabefa61b08443cc28c6359e18495aec550f6e1c Merge: 389ec3a3c f3e57d7dc Author: snipe Date: Tue Dec 13 14:00:48 2022 -0800 Merge pull request #12243 from akemidx/new_grey_out_when_no_assets Created method in users.php for adding up all assigned to user and pr… commit f3e57d7dc0186bb2466a7968c5e49402a4495864 Author: akemidx Date: Tue Dec 13 16:00:59 2022 -0500 fixing PR commit 389ec3a3cb1e6879c5c65103abd18dc010f75424 Merge: c432fb9d7 6a72c344b Author: snipe Date: Tue Dec 13 12:57:50 2022 -0800 Merge pull request #12247 from Godmartinz/gh12225_serial_added_to_components adds serial to components tab of assets commit 6a72c344b74285e3f627642388e024ef28f3a59a Author: Godfrey M Date: Tue Dec 13 12:32:30 2022 -0800 removed the cuddlers commit 4442b446b994bf81c03175485d69922c0e8619cb Author: Godfrey M Date: Tue Dec 13 10:30:37 2022 -0800 adds serial to components tab of assets commit c432fb9d708cccfe1f43beab02edcddffb03c93e Merge: 9e8fff6e5 fa872b09a Author: snipe Date: Tue Dec 13 10:28:17 2022 -0800 Merge pull request #12181 from Godmartinz/gh12163_asset_age Adds asset age to asset index and asset view pages commit 07ae91b00ff8ff41125ff25a6f31cfbdf2c730a8 Author: akemi Date: Wed Dec 7 17:46:18 2022 -0500 Created method in users.php for adding up all assigned to user and providing an integer value. this then used to grey out buttons on user view if user has nothing assigned. commit 450ad3dcec585a56179ac457de5297c835bf7545 Author: Ivan Nieto Vivanco Date: Mon Dec 12 14:17:08 2022 -0600 Added the column purchase_cost to user's default view commit fa872b09a907016cda4e28993495f0dc2d23f61d Author: Godfrey M Date: Mon Dec 12 10:38:31 2022 -0800 fixes a typo, the world is great again commit eb67d1b064229528a1629d9e16b1860ff0f5345a Author: Ivan Nieto Vivanco Date: Tue Dec 6 18:00:16 2022 -0600 Filter items from the report if null returned commit d0d0058e79897809b5be14222826a44d6435746f Author: Godfrey M Date: Tue Dec 6 11:19:28 2022 -0800 removed unwanted changes commit bbd04f88764d426cebf7b058d31838abf16edb96 Author: Godfrey M Date: Tue Dec 6 11:13:24 2022 -0800 adds the rest of the fields for Remote commit 36901d271bd7fbb014ab2e0fc1ab8f8d434ff66c Author: Godfrey M Date: Mon Dec 5 16:28:19 2022 -0800 adds csvmatch for remote. Im a bit lost though lol commit 3206929ee4e28360fa4889b88bc1390fea74d5c5 Author: Godfrey M Date: Tue Nov 29 09:51:42 2022 -0800 adds AgeFormatter, not working yet commit 1fe0bfe17e384956402cadf6ca4c5500849f76b1 Author: snipe Date: Mon Nov 28 19:27:42 2022 -0800 Removed extra logging case that was very noisy Signed-off-by: snipe commit 8d861cfd82a5c6de8bdf1a1424bacdd09c2261aa Author: Godfrey M Date: Mon Nov 28 10:59:18 2022 -0800 adds age to the asset table commit 078e7281cdb990a5f2862625ab95b53fcfc1ac17 Author: Godfrey M Date: Mon Nov 28 10:45:58 2022 -0800 adds asset age to asset view commit f2d4a61e3cc69f5de66436ab30ef3e52c5e7c5b3 Author: Godfrey M Date: Tue Oct 18 15:31:37 2022 -0700 removes dead space commit 3f25a1bf6141ee114e38f80246f52936cf0f7911 Author: Godfrey M Date: Tue Oct 18 15:25:38 2022 -0700 removes dead code commit f9ac447dd1dea95e276414a7eb398d7f41fede01 Merge: 9b448227f b7bcfaccc Author: Godfrey M Date: Tue Oct 18 15:18:09 2022 -0700 adds default group to LDAP commit 9b448227f717e0af1110441c3a42c8bb6b053a14 Author: Godfrey M Date: Tue Sep 13 11:40:10 2022 -0700 tinkering to no avail commit 28bc97f29ff763c04c680e04b0425a06054acd27 Author: Godfrey M Date: Mon Sep 12 11:40:16 2022 -0700 one line away from this being over with commit 193b31e4274b110916f85a6f28272586ca0c54f7 Author: Godfrey M Date: Wed Aug 31 12:58:33 2022 -0700 select options working, testing sync then done commit 70ac8af9c4598163b43a53648ba8e2e98c9f4186 Author: Godfrey M Date: Wed Aug 31 09:53:20 2022 -0700 . commit 0c362e8b579c6b7c881ca3028f1041ef3e93c183 Author: Godfrey M Date: Mon Aug 29 12:09:56 2022 -0700 gets the groups selector to appear but options are blank commit fc6fefdb4ebfc3357844e361f37440b8a000c39c Author: Godfrey M Date: Thu Aug 25 15:19:38 2022 -0700 adds migration, variables, checkbox,working on groups commit 1a908e361e190d02844903a71d7c18118857684f Author: Tobias Regnery Date: Thu Jul 29 10:33:34 2021 +0200 Make locations deletable for non Superuser-Accounts with FullMultipleCompanySupport locations->isDeletable() checks via gate::allows if a locations is deletable. This calls SnipePermissionsPolicy->before() and checks for !Company::isCurrentUserHasAccess($item). This returns false because locations don't have a company_id. Check for this and return true if the item don't have a company_id. Signed-off-by: snipe --- app/Http/Controllers/DashboardController.php | 2 +- app/Models/Company.php | 4 +++ ...51_fix_nullable_migration_for_settings.php | 30 +++++++++++++++++++ .../views/partials/bootstrap-table.blade.php | 5 +++- 4 files changed, 39 insertions(+), 2 deletions(-) create mode 100644 database/migrations/2022_12_20_171851_fix_nullable_migration_for_settings.php diff --git a/app/Http/Controllers/DashboardController.php b/app/Http/Controllers/DashboardController.php index bd527f7643..89283a7c21 100755 --- a/app/Http/Controllers/DashboardController.php +++ b/app/Http/Controllers/DashboardController.php @@ -34,7 +34,7 @@ class DashboardController extends Controller $counts['license'] = \App\Models\License::assetcount(); $counts['consumable'] = \App\Models\Consumable::count(); $counts['component'] = \App\Models\Component::count(); - $counts['user'] = \App\Models\User::count(); + $counts['user'] = \App\Models\Company::scopeCompanyables(Auth::user())->count(); $counts['grand_total'] = $counts['asset'] + $counts['accessory'] + $counts['license'] + $counts['consumable']; if ((! file_exists(storage_path().'/oauth-private.key')) || (! file_exists(storage_path().'/oauth-public.key'))) { diff --git a/app/Models/Company.php b/app/Models/Company.php index 83b6a0670b..413011b9a7 100644 --- a/app/Models/Company.php +++ b/app/Models/Company.php @@ -73,6 +73,10 @@ final class Company extends SnipeModel } } + /** + * Scoping table queries, determining if a logged in user is part of a company, and only allows + * that user to see items associated with that company + */ private static function scopeCompanyablesDirectly($query, $column = 'company_id', $table_name = null) { if (Auth::user()) { diff --git a/database/migrations/2022_12_20_171851_fix_nullable_migration_for_settings.php b/database/migrations/2022_12_20_171851_fix_nullable_migration_for_settings.php new file mode 100644 index 0000000000..aaffd88c4e --- /dev/null +++ b/database/migrations/2022_12_20_171851_fix_nullable_migration_for_settings.php @@ -0,0 +1,30 @@ +string('ldap_default_group')->nullable()->default(null)->change(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + // nothing to do here - this is a hotfix + } +} diff --git a/resources/views/partials/bootstrap-table.blade.php b/resources/views/partials/bootstrap-table.blade.php index 6766159be5..38ffde10a0 100644 --- a/resources/views/partials/bootstrap-table.blade.php +++ b/resources/views/partials/bootstrap-table.blade.php @@ -129,7 +129,10 @@ var tableId = $(this).data('id-table'); for (var i in rowsAfter) { - $(buttonName).after(''); + // Do not select things that were already selected + if($('#'+ tableId + '_checkbox_' + rowsAfter[i].id).length == 0) { + $(buttonName).after(''); + } } });