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 | * Comment model. |
||
18 | */ |
||
19 | class CommentModel extends Model |
||
20 | { |
||
21 | /** |
||
22 | * SQL table name. |
||
23 | * |
||
24 | * @var string |
||
25 | */ |
||
26 | const TABLE = 'comments'; |
||
27 | |||
28 | /** |
||
29 | * Events. |
||
30 | * |
||
31 | * @var string |
||
32 | */ |
||
33 | const EVENT_UPDATE = 'comment.update'; |
||
34 | const EVENT_CREATE = 'comment.create'; |
||
35 | const EVENT_DELETE = 'comment.delete'; |
||
36 | const EVENT_USER_MENTION = 'comment.user.mention'; |
||
37 | |||
38 | /** |
||
39 | * Get projectId from commentId. |
||
40 | * |
||
41 | * @param int $comment_id |
||
42 | * |
||
43 | * @return int |
||
44 | */ |
||
45 | public function getProjectId($comment_id) |
||
46 | { |
||
47 | return $this->db |
||
0 ignored issues
–
show
|
|||
48 | ->table(self::TABLE) |
||
49 | ->eq(self::TABLE.'.id', $comment_id) |
||
50 | ->join(TaskModel::TABLE, 'id', 'task_id') |
||
51 | ->findOneColumn(TaskModel::TABLE.'.project_id') ?: 0; |
||
52 | } |
||
53 | |||
54 | /** |
||
55 | * Get all comments for a given task. |
||
56 | * |
||
57 | * @param int $task_id Task id |
||
58 | * @param string $sorting ASC/DESC |
||
59 | * |
||
60 | * @return array |
||
61 | */ |
||
62 | public function getAll($task_id, $sorting = 'ASC') |
||
63 | { |
||
64 | return $this->db |
||
0 ignored issues
–
show
The property
db does not exist on object<Jitamin\Model\CommentModel> . 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. ![]() |
|||
65 | ->table(self::TABLE) |
||
66 | ->columns( |
||
67 | self::TABLE.'.id', |
||
68 | self::TABLE.'.date_creation', |
||
69 | self::TABLE.'.task_id', |
||
70 | self::TABLE.'.user_id', |
||
71 | self::TABLE.'.comment', |
||
72 | UserModel::TABLE.'.username', |
||
73 | UserModel::TABLE.'.name', |
||
74 | UserModel::TABLE.'.email', |
||
75 | UserModel::TABLE.'.avatar_path' |
||
76 | ) |
||
77 | ->join(UserModel::TABLE, 'id', 'user_id') |
||
78 | ->orderBy(self::TABLE.'.date_creation', $sorting) |
||
79 | ->eq(self::TABLE.'.task_id', $task_id) |
||
80 | ->findAll(); |
||
81 | } |
||
82 | |||
83 | /** |
||
84 | * Get a comment. |
||
85 | * |
||
86 | * @param int $comment_id Comment id |
||
87 | * |
||
88 | * @return array |
||
89 | */ |
||
90 | public function getById($comment_id) |
||
91 | { |
||
92 | return $this->db |
||
0 ignored issues
–
show
The property
db does not exist on object<Jitamin\Model\CommentModel> . 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. ![]() |
|||
93 | ->table(self::TABLE) |
||
94 | ->columns( |
||
95 | self::TABLE.'.id', |
||
96 | self::TABLE.'.task_id', |
||
97 | self::TABLE.'.user_id', |
||
98 | self::TABLE.'.date_creation', |
||
99 | self::TABLE.'.comment', |
||
100 | self::TABLE.'.reference', |
||
101 | UserModel::TABLE.'.username', |
||
102 | UserModel::TABLE.'.name', |
||
103 | UserModel::TABLE.'.email', |
||
104 | UserModel::TABLE.'.avatar_path' |
||
105 | ) |
||
106 | ->join(UserModel::TABLE, 'id', 'user_id') |
||
107 | ->eq(self::TABLE.'.id', $comment_id) |
||
108 | ->findOne(); |
||
109 | } |
||
110 | |||
111 | /** |
||
112 | * Get the number of comments for a given task. |
||
113 | * |
||
114 | * @param int $task_id Task id |
||
115 | * |
||
116 | * @return int |
||
117 | */ |
||
118 | public function count($task_id) |
||
119 | { |
||
120 | return $this->db |
||
0 ignored issues
–
show
The property
db does not exist on object<Jitamin\Model\CommentModel> . 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. ![]() |
|||
121 | ->table(self::TABLE) |
||
122 | ->eq(self::TABLE.'.task_id', $task_id) |
||
123 | ->count(); |
||
124 | } |
||
125 | |||
126 | /** |
||
127 | * Create a new comment. |
||
128 | * |
||
129 | * @param array $values Form values |
||
130 | * |
||
131 | * @return bool|int |
||
132 | */ |
||
133 | public function create(array $values) |
||
134 | { |
||
135 | $values['date_creation'] = time(); |
||
136 | $comment_id = $this->db->table(self::TABLE)->persist($values); |
||
0 ignored issues
–
show
The property
db does not exist on object<Jitamin\Model\CommentModel> . 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. ![]() |
|||
137 | |||
138 | if ($comment_id !== false) { |
||
139 | $this->queueManager->push($this->commentEventJob->withParams($comment_id, self::EVENT_CREATE)); |
||
0 ignored issues
–
show
The property
queueManager does not exist on object<Jitamin\Model\CommentModel> . 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. ![]() The property
commentEventJob does not exist on object<Jitamin\Model\CommentModel> . 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. ![]() |
|||
140 | } |
||
141 | |||
142 | return $comment_id; |
||
143 | } |
||
144 | |||
145 | /** |
||
146 | * Update a comment in the database. |
||
147 | * |
||
148 | * @param array $values Form values |
||
149 | * |
||
150 | * @return bool |
||
151 | */ |
||
152 | public function update(array $values) |
||
153 | { |
||
154 | $result = $this->db |
||
0 ignored issues
–
show
The property
db does not exist on object<Jitamin\Model\CommentModel> . 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. ![]() |
|||
155 | ->table(self::TABLE) |
||
156 | ->eq('id', $values['id']) |
||
157 | ->update(['comment' => $values['comment']]); |
||
158 | |||
159 | if ($result) { |
||
160 | $this->queueManager->push($this->commentEventJob->withParams($values['id'], self::EVENT_UPDATE)); |
||
0 ignored issues
–
show
The property
queueManager does not exist on object<Jitamin\Model\CommentModel> . 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. ![]() The property
commentEventJob does not exist on object<Jitamin\Model\CommentModel> . 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. ![]() |
|||
161 | } |
||
162 | |||
163 | return $result; |
||
164 | } |
||
165 | |||
166 | /** |
||
167 | * Remove a comment. |
||
168 | * |
||
169 | * @param int $comment_id Comment id |
||
170 | * |
||
171 | * @return bool |
||
172 | */ |
||
173 | public function remove($comment_id) |
||
174 | { |
||
175 | $this->commentEventJob->execute($comment_id, self::EVENT_DELETE); |
||
0 ignored issues
–
show
The property
commentEventJob does not exist on object<Jitamin\Model\CommentModel> . 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. ![]() |
|||
176 | |||
177 | return $this->db->table(self::TABLE)->eq('id', $comment_id)->remove(); |
||
0 ignored issues
–
show
The property
db does not exist on object<Jitamin\Model\CommentModel> . 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. ![]() |
|||
178 | } |
||
179 | } |
||
180 |
Since your code implements the magic getter
_get
, this function will be called for any read access on an undefined variable. You can add the@property
annotation to your class or interface to document the existence of this variable.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.