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 | * This file is part of Jitamin. |
||
5 | * |
||
6 | * Copyright (C) Jitamin Team |
||
7 | * |
||
8 | * For the full copyright and license information, please view the LICENSE |
||
9 | * file that was distributed with this source code. |
||
10 | */ |
||
11 | |||
12 | namespace Jitamin\Model; |
||
13 | |||
14 | use Jitamin\Foundation\Database\Model; |
||
15 | |||
16 | /** |
||
17 | * Class ProjectRoleRestrictionModel. |
||
18 | */ |
||
19 | class ProjectRoleRestrictionModel extends Model |
||
20 | { |
||
21 | /** |
||
22 | * SQL table name. |
||
23 | * |
||
24 | * @var string |
||
25 | */ |
||
26 | const TABLE = 'project_role_has_restrictions'; |
||
27 | |||
28 | const RULE_TASK_CREATION = 'task_creation'; |
||
29 | const RULE_TASK_OPEN_CLOSE = 'task_open_close'; |
||
30 | const RULE_TASK_MOVE = 'task_move'; |
||
31 | |||
32 | /** |
||
33 | * Get rules. |
||
34 | * |
||
35 | * @return array |
||
36 | */ |
||
37 | View Code Duplication | public function getRules() |
|
0 ignored issues
–
show
|
|||
38 | { |
||
39 | return [ |
||
40 | self::RULE_TASK_CREATION => t('Task creation is not permitted'), |
||
41 | self::RULE_TASK_OPEN_CLOSE => t('Closing or opening a task is not permitted'), |
||
42 | self::RULE_TASK_MOVE => t('Moving a task is not permitted'), |
||
43 | ]; |
||
44 | } |
||
45 | |||
46 | /** |
||
47 | * Get a single restriction. |
||
48 | * |
||
49 | * @param int $project_id |
||
50 | * @param int $restriction_id |
||
51 | * |
||
52 | * @return array|null |
||
53 | */ |
||
54 | public function getById($project_id, $restriction_id) |
||
55 | { |
||
56 | return $this->db |
||
0 ignored issues
–
show
The property
db does not exist on object<Jitamin\Model\ProjectRoleRestrictionModel> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
If the property has read access only, you can use the @property-read annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property. ![]() |
|||
57 | ->table(self::TABLE) |
||
58 | ->eq('project_id', $project_id) |
||
59 | ->eq('restriction_id', $restriction_id) |
||
60 | ->findOne(); |
||
61 | } |
||
62 | |||
63 | /** |
||
64 | * Get restrictions. |
||
65 | * |
||
66 | * @param int $project_id |
||
67 | * |
||
68 | * @return array |
||
69 | */ |
||
70 | public function getAll($project_id) |
||
71 | { |
||
72 | $rules = $this->getRules(); |
||
73 | $restrictions = $this->db |
||
0 ignored issues
–
show
The property
db does not exist on object<Jitamin\Model\ProjectRoleRestrictionModel> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
If the property has read access only, you can use the @property-read annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property. ![]() |
|||
74 | ->table(self::TABLE) |
||
75 | ->columns( |
||
76 | self::TABLE.'.restriction_id', |
||
77 | self::TABLE.'.project_id', |
||
78 | self::TABLE.'.role_id', |
||
79 | self::TABLE.'.rule' |
||
80 | ) |
||
81 | ->eq(self::TABLE.'.project_id', $project_id) |
||
82 | ->findAll(); |
||
83 | |||
84 | foreach ($restrictions as &$restriction) { |
||
85 | $restriction['title'] = $rules[$restriction['rule']]; |
||
86 | } |
||
87 | |||
88 | return $restrictions; |
||
89 | } |
||
90 | |||
91 | /** |
||
92 | * Get restrictions. |
||
93 | * |
||
94 | * @param int $project_id |
||
95 | * @param string $role |
||
96 | * |
||
97 | * @return array |
||
98 | */ |
||
99 | View Code Duplication | public function getAllByRole($project_id, $role) |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
100 | { |
||
101 | return $this->db |
||
0 ignored issues
–
show
The property
db does not exist on object<Jitamin\Model\ProjectRoleRestrictionModel> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
If the property has read access only, you can use the @property-read annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property. ![]() |
|||
102 | ->table(self::TABLE) |
||
103 | ->columns( |
||
104 | self::TABLE.'.restriction_id', |
||
105 | self::TABLE.'.project_id', |
||
106 | self::TABLE.'.role_id', |
||
107 | self::TABLE.'.rule', |
||
108 | 'pr.role' |
||
109 | ) |
||
110 | ->eq(self::TABLE.'.project_id', $project_id) |
||
111 | ->eq('role', $role) |
||
112 | ->left(ProjectRoleModel::TABLE, 'pr', 'role_id', self::TABLE, 'role_id') |
||
113 | ->findAll(); |
||
114 | } |
||
115 | |||
116 | /** |
||
117 | * Create a new restriction. |
||
118 | * |
||
119 | * @param int $project_id |
||
120 | * @param int $role_id |
||
121 | * @param string $rule |
||
122 | * |
||
123 | * @return bool|int |
||
124 | */ |
||
125 | View Code Duplication | public function create($project_id, $role_id, $rule) |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
126 | { |
||
127 | return $this->db->table(self::TABLE) |
||
0 ignored issues
–
show
The property
db does not exist on object<Jitamin\Model\ProjectRoleRestrictionModel> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
If the property has read access only, you can use the @property-read annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property. ![]() |
|||
128 | ->persist([ |
||
129 | 'project_id' => $project_id, |
||
130 | 'role_id' => $role_id, |
||
131 | 'rule' => $rule, |
||
132 | ]); |
||
133 | } |
||
134 | |||
135 | /** |
||
136 | * Remove a restriction. |
||
137 | * |
||
138 | * @param int $restriction_id |
||
139 | * |
||
140 | * @return bool |
||
141 | */ |
||
142 | public function remove($restriction_id) |
||
143 | { |
||
144 | return $this->db->table(self::TABLE)->eq('restriction_id', $restriction_id)->remove(); |
||
0 ignored issues
–
show
The property
db does not exist on object<Jitamin\Model\ProjectRoleRestrictionModel> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
If the property has read access only, you can use the @property-read annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property. ![]() |
|||
145 | } |
||
146 | } |
||
147 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.