1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Uccello\Core\Http\Controllers\User; |
4
|
|
|
|
5
|
|
|
use App\User; |
|
|
|
|
6
|
|
|
use Illuminate\Http\Request; |
7
|
|
|
use Uccello\Core\Http\Controllers\Core\ListController as CoreListController; |
8
|
|
|
use Uccello\Core\Models\Domain; |
9
|
|
|
use Uccello\Core\Models\Module; |
10
|
|
|
use Uccello\Core\Support\Traits\WithPrivileges; |
11
|
|
|
use Uccello\Core\Support\Traits\WithRoles; |
12
|
|
|
|
13
|
|
|
class ListController extends CoreListController |
14
|
|
|
{ |
15
|
|
|
use WithRoles; |
|
|
|
|
16
|
|
|
use WithPrivileges; |
|
|
|
|
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* {@inheritdoc} |
20
|
|
|
*/ |
21
|
|
|
public function process(?Domain $domain, Module $module, Request $request) |
22
|
|
|
{ |
23
|
|
|
// Get default view |
24
|
|
|
$view = parent::process($domain, $module, $request); |
25
|
|
|
|
26
|
|
|
// Useful if multi domains is not used |
27
|
|
|
$domain = $this->domain; |
28
|
|
|
|
29
|
|
|
// Add data to the view |
30
|
|
|
$view->roles = $this->getAllRolesOnDomain($domain); |
31
|
|
|
|
32
|
|
|
return $view; |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* Import user from another domain |
37
|
|
|
* |
38
|
|
|
* @param \Uccello\Core\Models\Domain|null $domain |
39
|
|
|
* @param \Uccello\Core\Models\Module $module |
40
|
|
|
* @param \Illuminate\Http\Request $request |
41
|
|
|
* @return void |
42
|
|
|
*/ |
43
|
|
|
public function import(?Domain $domain, Module $module, Request $request) |
44
|
|
|
{ |
45
|
|
|
$this->preProcess($domain, $module, $request); |
46
|
|
|
|
47
|
|
|
// Useful if multi domains is not used |
48
|
|
|
$domain = $this->domain; |
49
|
|
|
|
50
|
|
|
$roleIds = (array)$request->roles; |
51
|
|
|
|
52
|
|
|
$user = User::find($request->user_id); |
53
|
|
|
if ($user) { |
54
|
|
|
$this->createPrivilegesForUser($domain, $user, $roleIds); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
$route = ucroute('uccello.list', $domain, $module); |
58
|
|
|
|
59
|
|
|
return redirect($route); |
|
|
|
|
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* Build query for retrieving content |
64
|
|
|
* |
65
|
|
|
* @return \Illuminate\Database\Eloquent\Builder; |
66
|
|
|
*/ |
67
|
|
|
protected function buildContentQuery() |
68
|
|
|
{ |
69
|
|
|
$filter = [ |
70
|
|
|
'order' => $this->request->get('order'), |
71
|
|
|
'columns' => $this->request->get('columns'), |
72
|
|
|
]; |
73
|
|
|
|
74
|
|
|
// Get model model class |
75
|
|
|
$modelClass = $this->module->model_class; |
|
|
|
|
76
|
|
|
|
77
|
|
|
// Check if the class exists |
78
|
|
|
if (!class_exists($modelClass) || !method_exists($modelClass, 'scopeInDomain')) { |
79
|
|
|
return false; |
|
|
|
|
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
// Filter on domain if column exists |
83
|
|
|
$query = $modelClass::withRoleInDomain($this->domain, $this->request->session()->get('descendants')) |
84
|
|
|
->filterBy($filter); |
85
|
|
|
|
86
|
|
|
// Display trash if filter is selected |
87
|
|
|
if ($this->isDisplayingTrash()) { |
88
|
|
|
$query = $query->onlyTrashed(); |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
return $query; |
92
|
|
|
} |
93
|
|
|
} |
94
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths