Jitamin /
jitamin
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 | * Group Member Model. |
||
| 18 | */ |
||
| 19 | class GroupMemberModel extends Model |
||
| 20 | { |
||
| 21 | /** |
||
| 22 | * SQL table name. |
||
| 23 | * |
||
| 24 | * @var string |
||
| 25 | */ |
||
| 26 | const TABLE = 'group_has_users'; |
||
| 27 | |||
| 28 | /** |
||
| 29 | * Get query to fetch all users. |
||
| 30 | * |
||
| 31 | * @param int $group_id |
||
| 32 | * |
||
| 33 | * @return \PicoDb\Table |
||
| 34 | */ |
||
| 35 | public function getQuery($group_id) |
||
| 36 | { |
||
| 37 | return $this->db->table(self::TABLE) |
||
|
0 ignored issues
–
show
|
|||
| 38 | ->join(UserModel::TABLE, 'id', 'user_id') |
||
| 39 | ->eq('group_id', $group_id); |
||
| 40 | } |
||
| 41 | |||
| 42 | /** |
||
| 43 | * Get all users. |
||
| 44 | * |
||
| 45 | * @param int $group_id |
||
| 46 | * |
||
| 47 | * @return array |
||
| 48 | */ |
||
| 49 | public function getMembers($group_id) |
||
| 50 | { |
||
| 51 | return $this->getQuery($group_id)->findAll(); |
||
| 52 | } |
||
| 53 | |||
| 54 | /** |
||
| 55 | * Get all not members. |
||
| 56 | * |
||
| 57 | * @param int $group_id |
||
| 58 | * |
||
| 59 | * @return array |
||
| 60 | */ |
||
| 61 | public function getNotMembers($group_id) |
||
| 62 | { |
||
| 63 | $subquery = $this->db->table(self::TABLE) |
||
|
0 ignored issues
–
show
The property
db does not exist on object<Jitamin\Model\GroupMemberModel>. 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. Loading history...
|
|||
| 64 | ->columns('user_id') |
||
| 65 | ->eq('group_id', $group_id); |
||
| 66 | |||
| 67 | return $this->db->table(UserModel::TABLE) |
||
|
0 ignored issues
–
show
The property
db does not exist on object<Jitamin\Model\GroupMemberModel>. 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. Loading history...
|
|||
| 68 | ->notInSubquery('id', $subquery) |
||
| 69 | ->findAll(); |
||
| 70 | } |
||
| 71 | |||
| 72 | /** |
||
| 73 | * Add user to a group. |
||
| 74 | * |
||
| 75 | * @param int $group_id |
||
| 76 | * @param int $user_id |
||
| 77 | * |
||
| 78 | * @return bool |
||
| 79 | */ |
||
| 80 | public function addUser($group_id, $user_id) |
||
| 81 | { |
||
| 82 | return $this->db->table(self::TABLE)->insert([ |
||
|
0 ignored issues
–
show
The property
db does not exist on object<Jitamin\Model\GroupMemberModel>. 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. Loading history...
|
|||
| 83 | 'group_id' => $group_id, |
||
| 84 | 'user_id' => $user_id, |
||
| 85 | ]); |
||
| 86 | } |
||
| 87 | |||
| 88 | /** |
||
| 89 | * Remove user from a group. |
||
| 90 | * |
||
| 91 | * @param int $group_id |
||
| 92 | * @param int $user_id |
||
| 93 | * |
||
| 94 | * @return bool |
||
| 95 | */ |
||
| 96 | public function removeUser($group_id, $user_id) |
||
| 97 | { |
||
| 98 | return $this->db->table(self::TABLE) |
||
|
0 ignored issues
–
show
The property
db does not exist on object<Jitamin\Model\GroupMemberModel>. 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. Loading history...
|
|||
| 99 | ->eq('group_id', $group_id) |
||
| 100 | ->eq('user_id', $user_id) |
||
| 101 | ->remove(); |
||
| 102 | } |
||
| 103 | |||
| 104 | /** |
||
| 105 | * Check if a user is member. |
||
| 106 | * |
||
| 107 | * @param int $group_id |
||
| 108 | * @param int $user_id |
||
| 109 | * |
||
| 110 | * @return bool |
||
| 111 | */ |
||
| 112 | public function isMember($group_id, $user_id) |
||
| 113 | { |
||
| 114 | return $this->db->table(self::TABLE) |
||
|
0 ignored issues
–
show
The property
db does not exist on object<Jitamin\Model\GroupMemberModel>. 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. Loading history...
|
|||
| 115 | ->eq('group_id', $group_id) |
||
| 116 | ->eq('user_id', $user_id) |
||
| 117 | ->exists(); |
||
| 118 | } |
||
| 119 | |||
| 120 | /** |
||
| 121 | * Get all groups for a given user. |
||
| 122 | * |
||
| 123 | * @param int $user_id |
||
| 124 | * |
||
| 125 | * @return array |
||
| 126 | */ |
||
| 127 | public function getGroups($user_id) |
||
| 128 | { |
||
| 129 | return $this->db->table(self::TABLE) |
||
|
0 ignored issues
–
show
The property
db does not exist on object<Jitamin\Model\GroupMemberModel>. 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. Loading history...
|
|||
| 130 | ->columns(GroupModel::TABLE.'.id', GroupModel::TABLE.'.external_id', GroupModel::TABLE.'.name') |
||
| 131 | ->join(GroupModel::TABLE, 'id', 'group_id') |
||
| 132 | ->eq(self::TABLE.'.user_id', $user_id) |
||
| 133 | ->asc(GroupModel::TABLE.'.name') |
||
| 134 | ->findAll(); |
||
| 135 | } |
||
| 136 | } |
||
| 137 |
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@propertyannotation 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.