mirror of
https://github.com/snipe/snipe-it.git
synced 2025-02-02 08:21:09 -08:00
Removed manual companyable from non-API views
Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
parent
801e58d52e
commit
3f9a80942e
|
@ -181,8 +181,7 @@ class UsersController extends Controller
|
||||||
{
|
{
|
||||||
|
|
||||||
$this->authorize('update', User::class);
|
$this->authorize('update', User::class);
|
||||||
$user = User::with('assets', 'assets.model', 'consumables', 'accessories', 'licenses', 'userloc')->withTrashed();
|
$user = User::with('assets', 'assets.model', 'consumables', 'accessories', 'licenses', 'userloc')->withTrashed()->find($id);
|
||||||
$user = Company::scopeCompanyables($user)->find($id);
|
|
||||||
|
|
||||||
if ($user) {
|
if ($user) {
|
||||||
|
|
||||||
|
@ -228,9 +227,7 @@ class UsersController extends Controller
|
||||||
$permissions = $request->input('permissions', []);
|
$permissions = $request->input('permissions', []);
|
||||||
app('request')->request->set('permissions', $permissions);
|
app('request')->request->set('permissions', $permissions);
|
||||||
|
|
||||||
|
$user = User::with('assets', 'assets.model', 'consumables', 'accessories', 'licenses', 'userloc')->find($id)->withTrashed();
|
||||||
$user = User::with('assets', 'assets.model', 'consumables', 'accessories', 'licenses', 'userloc')->withTrashed();
|
|
||||||
$user = Company::scopeCompanyables($user)->find($id);
|
|
||||||
|
|
||||||
// User is valid - continue...
|
// User is valid - continue...
|
||||||
if ($user) {
|
if ($user) {
|
||||||
|
@ -337,9 +334,8 @@ class UsersController extends Controller
|
||||||
{
|
{
|
||||||
|
|
||||||
$this->authorize('delete', User::class);
|
$this->authorize('delete', User::class);
|
||||||
$user = User::with('assets', 'assets.model', 'consumables', 'accessories', 'licenses', 'userloc')->withTrashed();
|
|
||||||
$user = Company::scopeCompanyables($user)->find($id);
|
|
||||||
|
|
||||||
|
$user = User::with('assets', 'assets.model', 'consumables', 'accessories', 'licenses', 'userloc')->withTrashed()->find($id);
|
||||||
|
|
||||||
if ($user) {
|
if ($user) {
|
||||||
// Check if we are not trying to delete ourselves
|
// Check if we are not trying to delete ourselves
|
||||||
|
@ -439,8 +435,7 @@ class UsersController extends Controller
|
||||||
// Make sure the user can view users at all
|
// Make sure the user can view users at all
|
||||||
$this->authorize('view', User::class);
|
$this->authorize('view', User::class);
|
||||||
|
|
||||||
$user = User::with('assets', 'assets.model', 'consumables', 'accessories', 'licenses', 'userloc')->withTrashed();
|
$user = User::with('assets', 'assets.model', 'consumables', 'accessories', 'licenses', 'userloc')->withTrashed()->find($userId);
|
||||||
$user = Company::scopeCompanyables($user)->find($userId);
|
|
||||||
|
|
||||||
// Make sure they can view this particular user
|
// Make sure they can view this particular user
|
||||||
$this->authorize('view', $user);
|
$this->authorize('view', $user);
|
||||||
|
@ -475,9 +470,7 @@ class UsersController extends Controller
|
||||||
app('request')->request->set('permissions', $permissions);
|
app('request')->request->set('permissions', $permissions);
|
||||||
|
|
||||||
|
|
||||||
$user_to_clone = User::with('assets', 'assets.model', 'consumables', 'accessories', 'licenses', 'userloc')->withTrashed();
|
$user_to_clone = User::with('assets', 'assets.model', 'consumables', 'accessories', 'licenses', 'userloc')->withTrashed()->find($id);
|
||||||
$user_to_clone = Company::scopeCompanyables($user_to_clone)->find($id);
|
|
||||||
|
|
||||||
// Make sure they can view this particular user
|
// Make sure they can view this particular user
|
||||||
$this->authorize('view', $user_to_clone);
|
$this->authorize('view', $user_to_clone);
|
||||||
|
|
||||||
|
@ -541,10 +534,7 @@ class UsersController extends Controller
|
||||||
'groups',
|
'groups',
|
||||||
'userloc',
|
'userloc',
|
||||||
'company'
|
'company'
|
||||||
)->orderBy('created_at', 'DESC');
|
)->orderBy('created_at', 'DESC')
|
||||||
|
|
||||||
// FMCS scoping
|
|
||||||
Company::scopeCompanyables($users)
|
|
||||||
->chunk(500, function ($users) use ($handle) {
|
->chunk(500, function ($users) use ($handle) {
|
||||||
$headers = [
|
$headers = [
|
||||||
// strtolower to prevent Excel from trying to open it as a SYLK file
|
// strtolower to prevent Excel from trying to open it as a SYLK file
|
||||||
|
@ -638,20 +628,20 @@ class UsersController extends Controller
|
||||||
public function printInventory($id)
|
public function printInventory($id)
|
||||||
{
|
{
|
||||||
$this->authorize('view', User::class);
|
$this->authorize('view', User::class);
|
||||||
$show_user = Company::scopeCompanyables(User::where('id', $id)->withTrashed()->first());
|
$user = User::where('id', $id)->withTrashed()->first();
|
||||||
|
|
||||||
// Make sure they can view this particular user
|
// Make sure they can view this particular user
|
||||||
$this->authorize('view', $show_user);
|
$this->authorize('view', $user);
|
||||||
|
|
||||||
$assets = Asset::where('assigned_to', $id)->where('assigned_type', User::class)->with('model', 'model.category')->get();
|
$assets = Asset::where('assigned_to', $id)->where('assigned_type', User::class)->with('model', 'model.category')->get();
|
||||||
$accessories = $show_user->accessories()->get();
|
$accessories = $user->accessories()->get();
|
||||||
$consumables = $show_user->consumables()->get();
|
$consumables = $user->consumables()->get();
|
||||||
|
|
||||||
return view('users/print')->with('assets', $assets)
|
return view('users/print')->with('assets', $assets)
|
||||||
->with('licenses', $show_user->licenses()->get())
|
->with('licenses', $user->licenses()->get())
|
||||||
->with('accessories', $accessories)
|
->with('accessories', $accessories)
|
||||||
->with('consumables', $consumables)
|
->with('consumables', $consumables)
|
||||||
->with('show_user', $show_user)
|
->with('show_user', $user)
|
||||||
->with('settings', Setting::getSettings());
|
->with('settings', Setting::getSettings());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -667,7 +657,7 @@ class UsersController extends Controller
|
||||||
{
|
{
|
||||||
$this->authorize('view', User::class);
|
$this->authorize('view', User::class);
|
||||||
|
|
||||||
$user = Company::scopeCompanyables(User::find($id));
|
$user = User::find($id);
|
||||||
|
|
||||||
// Make sure they can view this particular user
|
// Make sure they can view this particular user
|
||||||
$this->authorize('view', $user);
|
$this->authorize('view', $user);
|
||||||
|
@ -695,7 +685,7 @@ class UsersController extends Controller
|
||||||
*/
|
*/
|
||||||
public function sendPasswordReset($id)
|
public function sendPasswordReset($id)
|
||||||
{
|
{
|
||||||
if (($user = Company::scopeCompanyables(User::find($id))) && ($user->activated == '1') && ($user->email != '') && ($user->ldap_import == '0')) {
|
if (($user = User::find($id)) && ($user->activated == '1') && ($user->email != '') && ($user->ldap_import == '0')) {
|
||||||
$credentials = ['email' => trim($user->email)];
|
$credentials = ['email' => trim($user->email)];
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Reference in a new issue