This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | /** |
||
4 | * @copyright Copyright (c) Flipbox Digital Limited |
||
5 | * @license https://flipboxfactory.com/software/organization/license |
||
6 | * @link https://www.flipboxfactory.com/software/organization/ |
||
7 | */ |
||
8 | |||
9 | namespace flipbox\organizations\queries; |
||
10 | |||
11 | use craft\db\QueryAbortedException; |
||
12 | use craft\helpers\Db; |
||
13 | use flipbox\craft\ember\queries\CacheableActiveQuery; |
||
14 | use flipbox\craft\ember\queries\UserAttributeTrait; |
||
15 | use flipbox\organizations\records\UserAssociation; |
||
16 | use flipbox\organizations\records\UserTypeAssociation; |
||
17 | |||
18 | /** |
||
19 | * @author Flipbox Factory <[email protected]> |
||
20 | * @since 1.0.0 |
||
21 | * |
||
22 | * @method UserAssociation one($db = null) |
||
23 | * @method UserAssociation[] all($db = null) |
||
24 | * @method UserAssociation[] getCachedResult($db = null) |
||
25 | */ |
||
26 | class UserAssociationQuery extends CacheableActiveQuery |
||
27 | { |
||
28 | use UserAttributeTrait, |
||
29 | OrganizationAttributeTrait, |
||
30 | UserTypeAttributeTrait; |
||
31 | |||
32 | /** |
||
33 | * @var string|string[]|null |
||
34 | */ |
||
35 | public $state; |
||
36 | |||
37 | /** |
||
38 | * @param string|string[]|null $value |
||
39 | * @return static The query object |
||
40 | */ |
||
41 | public function setState($value) |
||
42 | { |
||
43 | $this->state = $value; |
||
44 | return $this; |
||
45 | } |
||
46 | |||
47 | /** |
||
48 | * @param string|string[]|null $value |
||
49 | * @return static The query object |
||
50 | */ |
||
51 | public function state($value) |
||
52 | { |
||
53 | return $this->setState($value); |
||
54 | } |
||
55 | |||
56 | /** |
||
57 | * @inheritdoc |
||
58 | */ |
||
59 | public function init() |
||
60 | { |
||
61 | $this->from([ |
||
62 | UserAssociation::tableName() . ' ' . UserAssociation::tableAlias() |
||
63 | ]); |
||
64 | |||
65 | parent::init(); |
||
66 | } |
||
67 | |||
68 | /** |
||
69 | * @return string |
||
70 | */ |
||
71 | protected function joinUserTypeTable(): string |
||
72 | { |
||
73 | $name = UserTypeAssociation::tableName(); |
||
74 | $alias = UserTypeAssociation::tableAlias(); |
||
75 | |||
76 | $table = "{$name} {$alias}"; |
||
77 | |||
78 | if (!is_array($this->join) || !$this->isJoined($table)) { |
||
0 ignored issues
–
show
|
|||
79 | $this->leftJoin( |
||
80 | $table, |
||
81 | '[[' . $alias . '.userId]] = [['. UserAssociation::tableAlias() .'.id]]' |
||
82 | ); |
||
83 | } |
||
84 | |||
85 | return $alias; |
||
86 | } |
||
87 | |||
88 | /** |
||
89 | * @inheritdoc |
||
90 | * @throws QueryAbortedException |
||
91 | */ |
||
92 | public function prepare($builder) |
||
93 | { |
||
94 | $attributes = ['state']; |
||
95 | |||
96 | foreach ($attributes as $attribute) { |
||
97 | if (null !== ($value = $this->{$attribute})) { |
||
98 | $this->andWhere(Db::parseParam($attribute, $value)); |
||
99 | } |
||
100 | } |
||
101 | |||
102 | $this->applyUserParam(); |
||
103 | $this->applyOrganizationParam(); |
||
104 | $this->applyUserTypeParam(); |
||
105 | |||
106 | return parent::prepare($builder); |
||
107 | } |
||
108 | |||
109 | /** |
||
110 | * @return void |
||
111 | * @throws QueryAbortedException |
||
112 | */ |
||
113 | protected function applyUserParam() |
||
114 | { |
||
115 | // Is the query already doomed? |
||
116 | if ($this->user !== null && empty($this->user)) { |
||
117 | throw new QueryAbortedException(); |
||
118 | } |
||
119 | |||
120 | if (empty($this->user)) { |
||
121 | return; |
||
122 | } |
||
123 | |||
124 | $this->andWhere( |
||
125 | Db::parseParam('userId', $this->parseUserValue($this->user)) |
||
126 | ); |
||
127 | } |
||
128 | |||
129 | /** |
||
130 | * @return void |
||
131 | * @throws QueryAbortedException |
||
132 | */ |
||
133 | protected function applyOrganizationParam() |
||
134 | { |
||
135 | // Is the query already doomed? |
||
136 | if ($this->organization !== null && empty($this->organization)) { |
||
137 | throw new QueryAbortedException(); |
||
138 | } |
||
139 | |||
140 | if (empty($this->organization)) { |
||
141 | return; |
||
142 | } |
||
143 | |||
144 | $this->andWhere( |
||
145 | Db::parseParam('organizationId', $this->parseOrganizationValue($this->organization)) |
||
146 | ); |
||
147 | } |
||
148 | |||
149 | /** |
||
150 | * @return void |
||
151 | * @throws QueryAbortedException |
||
152 | */ |
||
153 | protected function applyUserTypeParam() |
||
154 | { |
||
155 | // Is the query already doomed? |
||
156 | if ($this->userType !== null && empty($this->userType)) { |
||
157 | throw new QueryAbortedException(); |
||
158 | } |
||
159 | |||
160 | if (empty($this->userType)) { |
||
161 | return; |
||
162 | } |
||
163 | |||
164 | $alias = $this->joinUserTypeTable(); |
||
165 | |||
166 | $this->andWhere( |
||
167 | Db::parseParam($alias . '.typeId', $this->parseUserTypeValue($this->userType)) |
||
168 | ); |
||
169 | } |
||
170 | } |
||
171 |
If you implement
__call
and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.This is often the case, when
__call
is implemented by a parent class and only the child class knows which methods exist: