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\records; |
||
10 | |||
11 | use Craft; |
||
12 | use flipbox\craft\ember\helpers\ModelHelper; |
||
13 | use flipbox\craft\ember\records\ActiveRecord; |
||
14 | use flipbox\craft\ember\records\SortableTrait; |
||
15 | use flipbox\organizations\Organizations; |
||
16 | use flipbox\organizations\queries\UserTypeAssociationQuery; |
||
17 | use yii\db\ActiveQueryInterface; |
||
18 | use yii\helpers\Json; |
||
19 | |||
20 | /** |
||
21 | * @author Flipbox Factory <[email protected]> |
||
22 | * @since 1.0.0 |
||
23 | * |
||
24 | * @property int $userId |
||
25 | * @property int $typeId |
||
26 | * @property int $sortOrder |
||
27 | */ |
||
28 | class UserTypeAssociation extends ActiveRecord |
||
29 | { |
||
30 | use UserTypeAttributeTrait, |
||
31 | SortableTrait; |
||
32 | |||
33 | /** |
||
34 | * The table name |
||
35 | */ |
||
36 | const TABLE_ALIAS = UserType::TABLE_ALIAS . '_associations'; |
||
37 | |||
38 | /** |
||
39 | * @inheritdoc |
||
40 | */ |
||
41 | protected $getterPriorityAttributes = ['typeId']; |
||
42 | protected $setterPriorityAttributes = ['typeId']; |
||
43 | |||
44 | /** |
||
45 | * @noinspection PhpDocMissingThrowsInspection |
||
46 | * |
||
47 | * @inheritdoc |
||
48 | * @return UserTypeAssociationQuery |
||
49 | */ |
||
50 | public static function find() |
||
51 | { |
||
52 | /** @noinspection PhpUnhandledExceptionInspection */ |
||
53 | /** @noinspection PhpIncompatibleReturnTypeInspection */ |
||
54 | return Craft::createObject(UserTypeAssociationQuery::class, [get_called_class()]); |
||
55 | } |
||
56 | |||
57 | /** |
||
58 | * @inheritdoc |
||
59 | */ |
||
60 | public function rules() |
||
61 | { |
||
62 | return array_merge( |
||
63 | parent::rules(), |
||
64 | $this->typeRules(), |
||
65 | [ |
||
66 | [ |
||
67 | [ |
||
68 | 'userId' |
||
69 | ], |
||
70 | 'unique', |
||
71 | 'targetAttribute' => [ |
||
72 | 'userId', |
||
73 | 'typeId' |
||
74 | ] |
||
75 | ], |
||
76 | [ |
||
77 | [ |
||
78 | 'userId' |
||
79 | ], |
||
80 | 'safe', |
||
81 | 'on' => [ |
||
82 | ModelHelper::SCENARIO_DEFAULT |
||
0 ignored issues
–
show
|
|||
83 | ] |
||
84 | ] |
||
85 | ] |
||
86 | ); |
||
87 | } |
||
88 | |||
89 | /** |
||
90 | * @inheritdoc |
||
91 | */ |
||
92 | public function beforeSave($insert) |
||
93 | { |
||
94 | $this->ensureSortOrder( |
||
95 | [ |
||
96 | 'userId' => $this->userId |
||
97 | ] |
||
98 | ); |
||
99 | |||
100 | return parent::beforeSave($insert); |
||
101 | } |
||
102 | |||
103 | /** |
||
104 | * @inheritdoc |
||
105 | * @throws \yii\db\Exception |
||
106 | */ |
||
107 | public function afterSave($insert, $changedAttributes) |
||
108 | { |
||
109 | try { |
||
110 | $this->autoReOrder( |
||
111 | 'typeId', |
||
112 | [ |
||
113 | 'userId' => $this->userId |
||
114 | ] |
||
115 | ); |
||
116 | } catch (\Exception $e) { |
||
117 | Organizations::error( |
||
118 | sprintf( |
||
119 | "Exception caught while trying to reorder '%s'. Exception: [%s].", |
||
120 | (string)get_class($this), |
||
121 | (string)Json::encode([ |
||
122 | 'Trace' => $e->getTraceAsString(), |
||
123 | 'File' => $e->getFile(), |
||
124 | 'Line' => $e->getLine(), |
||
125 | 'Code' => $e->getCode(), |
||
126 | 'Message' => $e->getMessage() |
||
127 | ]) |
||
128 | ), |
||
129 | __METHOD__ |
||
130 | ); |
||
131 | } |
||
132 | |||
133 | parent::afterSave($insert, $changedAttributes); |
||
134 | } |
||
135 | |||
136 | /** |
||
137 | * @inheritdoc |
||
138 | * @throws \yii\db\Exception |
||
139 | */ |
||
140 | public function afterDelete() |
||
141 | { |
||
142 | $this->sequentialOrder( |
||
143 | 'typeId', |
||
144 | [ |
||
145 | 'userId' => $this->userId |
||
146 | ] |
||
147 | ); |
||
148 | |||
149 | parent::afterDelete(); |
||
150 | } |
||
151 | |||
152 | /** |
||
153 | * Returns the user association. |
||
154 | * |
||
155 | * @return ActiveQueryInterface The relational query object. |
||
156 | */ |
||
157 | public function getUserAssociations(): ActiveQueryInterface |
||
158 | { |
||
159 | return $this->hasOne(UserAssociation::class, ['id' => 'userId']); |
||
160 | } |
||
161 | } |
||
162 |
This class constant has been deprecated. The supplier of the class has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the constant will be removed from the class and what other constant to use instead.