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 | * Action Parameter Model. |
||
| 18 | */ |
||
| 19 | class ActionParameterModel extends Model |
||
| 20 | { |
||
| 21 | /** |
||
| 22 | * SQL table name. |
||
| 23 | * |
||
| 24 | * @var string |
||
| 25 | */ |
||
| 26 | const TABLE = 'action_has_params'; |
||
| 27 | |||
| 28 | /** |
||
| 29 | * Get all action params. |
||
| 30 | * |
||
| 31 | * @return array |
||
| 32 | */ |
||
| 33 | public function getAll() |
||
| 34 | { |
||
| 35 | $params = $this->db->table(self::TABLE)->findAll(); |
||
|
0 ignored issues
–
show
|
|||
| 36 | |||
| 37 | return $this->toDictionary($params); |
||
| 38 | } |
||
| 39 | |||
| 40 | /** |
||
| 41 | * Get all params for a list of actions. |
||
| 42 | * |
||
| 43 | * @param array $action_ids |
||
| 44 | * |
||
| 45 | * @return array |
||
| 46 | */ |
||
| 47 | public function getAllByActions(array $action_ids) |
||
| 48 | { |
||
| 49 | $params = $this->db->table(self::TABLE)->in('action_id', $action_ids)->findAll(); |
||
|
0 ignored issues
–
show
The property
db does not exist on object<Jitamin\Model\ActionParameterModel>. 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...
|
|||
| 50 | |||
| 51 | return $this->toDictionary($params); |
||
| 52 | } |
||
| 53 | |||
| 54 | /** |
||
| 55 | * Build params dictionary. |
||
| 56 | * |
||
| 57 | * @param array $params |
||
| 58 | * |
||
| 59 | * @return array |
||
| 60 | */ |
||
| 61 | private function toDictionary(array $params) |
||
| 62 | { |
||
| 63 | $result = []; |
||
| 64 | |||
| 65 | foreach ($params as $param) { |
||
| 66 | $result[$param['action_id']][$param['name']] = $param['value']; |
||
| 67 | } |
||
| 68 | |||
| 69 | return $result; |
||
| 70 | } |
||
| 71 | |||
| 72 | /** |
||
| 73 | * Get all action params for a given action. |
||
| 74 | * |
||
| 75 | * @param int $action_id |
||
| 76 | * |
||
| 77 | * @return array |
||
| 78 | */ |
||
| 79 | public function getAllByAction($action_id) |
||
| 80 | { |
||
| 81 | return $this->db->hashtable(self::TABLE)->eq('action_id', $action_id)->getAll('name', 'value'); |
||
|
0 ignored issues
–
show
The property
db does not exist on object<Jitamin\Model\ActionParameterModel>. 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...
|
|||
| 82 | } |
||
| 83 | |||
| 84 | /** |
||
| 85 | * Insert new parameters for an action. |
||
| 86 | * |
||
| 87 | * @param int $action_id |
||
| 88 | * @param array $values |
||
| 89 | * |
||
| 90 | * @return bool |
||
| 91 | */ |
||
| 92 | public function create($action_id, array $values) |
||
| 93 | { |
||
| 94 | foreach ($values['params'] as $name => $value) { |
||
| 95 | $param = [ |
||
| 96 | 'action_id' => $action_id, |
||
| 97 | 'name' => $name, |
||
| 98 | 'value' => $value, |
||
| 99 | ]; |
||
| 100 | |||
| 101 | if (!$this->db->table(self::TABLE)->save($param)) { |
||
|
0 ignored issues
–
show
The property
db does not exist on object<Jitamin\Model\ActionParameterModel>. 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...
|
|||
| 102 | return false; |
||
| 103 | } |
||
| 104 | } |
||
| 105 | |||
| 106 | return true; |
||
| 107 | } |
||
| 108 | |||
| 109 | /** |
||
| 110 | * Duplicate action parameters. |
||
| 111 | * |
||
| 112 | * @param int $project_id |
||
| 113 | * @param int $action_id |
||
| 114 | * @param array $params |
||
| 115 | * |
||
| 116 | * @return bool |
||
| 117 | */ |
||
| 118 | public function duplicateParameters($project_id, $action_id, array $params) |
||
| 119 | { |
||
| 120 | foreach ($params as $name => $value) { |
||
| 121 | $value = $this->resolveParameter($project_id, $name, $value); |
||
| 122 | |||
| 123 | if ($value === false) { |
||
| 124 | $this->logger->error('ActionParameter::duplicateParameters => unable to resolve '.$name.'='.$value); |
||
|
0 ignored issues
–
show
The property
logger does not exist on object<Jitamin\Model\ActionParameterModel>. 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...
|
|||
| 125 | |||
| 126 | return false; |
||
| 127 | } |
||
| 128 | |||
| 129 | $values = [ |
||
| 130 | 'action_id' => $action_id, |
||
| 131 | 'name' => $name, |
||
| 132 | 'value' => $value, |
||
| 133 | ]; |
||
| 134 | |||
| 135 | if (!$this->db->table(self::TABLE)->insert($values)) { |
||
|
0 ignored issues
–
show
The property
db does not exist on object<Jitamin\Model\ActionParameterModel>. 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...
|
|||
| 136 | return false; |
||
| 137 | } |
||
| 138 | } |
||
| 139 | |||
| 140 | return true; |
||
| 141 | } |
||
| 142 | |||
| 143 | /** |
||
| 144 | * Resolve action parameter values according to another project. |
||
| 145 | * |
||
| 146 | * @param int $project_id |
||
| 147 | * @param string $name |
||
| 148 | * @param string $value |
||
| 149 | * |
||
| 150 | * @return mixed |
||
| 151 | */ |
||
| 152 | private function resolveParameter($project_id, $name, $value) |
||
| 153 | { |
||
| 154 | switch ($name) { |
||
| 155 | case 'project_id': |
||
| 156 | return $value != $project_id ? $value : false; |
||
| 157 | case 'category_id': |
||
| 158 | return $this->categoryModel->getIdByName($project_id, $this->categoryModel->getNameById($value)) ?: false; |
||
|
0 ignored issues
–
show
The property
categoryModel does not exist on object<Jitamin\Model\ActionParameterModel>. 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...
|
|||
| 159 | case 'src_column_id': |
||
| 160 | case 'dest_column_id': |
||
| 161 | case 'dst_column_id': |
||
| 162 | case 'column_id': |
||
| 163 | $column = $this->columnModel->getById($value); |
||
|
0 ignored issues
–
show
The property
columnModel does not exist on object<Jitamin\Model\ActionParameterModel>. 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...
|
|||
| 164 | |||
| 165 | return empty($column) ? false : $this->columnModel->getColumnIdByTitle($project_id, $column['title']) ?: false; |
||
|
0 ignored issues
–
show
The property
columnModel does not exist on object<Jitamin\Model\ActionParameterModel>. 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...
|
|||
| 166 | case 'user_id': |
||
| 167 | case 'owner_id': |
||
| 168 | return $this->projectPermissionModel->isAssignable($project_id, $value) ? $value : false; |
||
|
0 ignored issues
–
show
The property
projectPermissionModel does not exist on object<Jitamin\Model\ActionParameterModel>. 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...
|
|||
| 169 | case 'swimlane_id': |
||
| 170 | $column = $this->swimlaneModel->getById($value); |
||
|
0 ignored issues
–
show
The property
swimlaneModel does not exist on object<Jitamin\Model\ActionParameterModel>. 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...
|
|||
| 171 | |||
| 172 | return empty($column) ? false : $this->swimlaneModel->getIdByName($project_id, $column['name']) ?: false; |
||
|
0 ignored issues
–
show
The property
swimlaneModel does not exist on object<Jitamin\Model\ActionParameterModel>. 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...
|
|||
| 173 | default: |
||
| 174 | return $value; |
||
| 175 | } |
||
| 176 | } |
||
| 177 | } |
||
| 178 |
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.