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 | class EcommerceDashboardPanel extends DashboardPanel |
||
0 ignored issues
–
show
|
|||
4 | { |
||
5 | |||
6 | |||
7 | /** |
||
8 | * @var bool Show the configure form after creating. Used for panels that require |
||
9 | * configuration in order to show data |
||
10 | */ |
||
11 | private static $configure_on_create = true; |
||
0 ignored issues
–
show
|
|||
12 | |||
13 | |||
14 | private static $db = array( |
||
0 ignored issues
–
show
|
|||
15 | 'DaysBack' => 'Int' |
||
16 | ); |
||
17 | |||
18 | private static $defaults = array( |
||
0 ignored issues
–
show
|
|||
19 | 'DaysBack' => 7 |
||
20 | ); |
||
21 | |||
22 | |||
23 | private static $icon = "ecommerce_dashboard/images/icons"; |
||
0 ignored issues
–
show
|
|||
24 | |||
25 | public function getLabel() |
||
26 | { |
||
27 | return $this->getLabelPrefix(); |
||
28 | } |
||
29 | |||
30 | public function getTitle() |
||
31 | { |
||
32 | $str = $this->getLabelPrefix(); |
||
33 | if ($this->DaysBack) { |
||
0 ignored issues
–
show
The property
DaysBack does not exist on object<EcommerceDashboardPanel> . 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. ![]() |
|||
34 | $str .= ' '.sprintf(_t('EcommerceDashboardPanel.IN_THE_LAST_XXX_DAYS', 'in the last %s days.'), $this->DaysBack); |
||
0 ignored issues
–
show
The property
DaysBack does not exist on object<EcommerceDashboardPanel> . 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. ![]() |
|||
35 | } |
||
36 | return $str; |
||
37 | } |
||
38 | |||
39 | public function getLabelPrefix() |
||
40 | { |
||
41 | return 'please set in '.$this->ClassName; |
||
42 | } |
||
43 | |||
44 | public function getConfiguration() |
||
45 | { |
||
46 | $fields = parent::getConfiguration(); |
||
47 | $fields->push(NumericField::create("DaysBack", "Number of days back")); |
||
48 | $fields->replaceField('Title', ReadonlyField::create('Title', '')); |
||
49 | |||
50 | return $fields; |
||
51 | } |
||
52 | |||
53 | /** |
||
54 | * |
||
55 | * |
||
56 | * @return DataList |
||
57 | */ |
||
58 | protected function openOrders($numberOfDaysBack = 7) |
||
0 ignored issues
–
show
|
|||
59 | { |
||
60 | $firstStep = DataObject::get_one('OrderStep'); |
||
61 | $orders = Order::get() |
||
62 | ->LeftJoin('OrderStatusLog', '"Order"."ID" = "OrderStatusLog"."OrderID"') |
||
63 | ->LeftJoin($submittedOrderStatusLogClassName, '"OrderStatusLog"."ID" = "'.$submittedOrderStatusLogClassName.'"."ID"') |
||
0 ignored issues
–
show
The variable
$submittedOrderStatusLogClassName does not exist. Did you forget to declare it?
This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug. ![]() |
|||
64 | ->filter(array('StatusID' => $firstStep->ID)) |
||
65 | ->exclude(array('MemberID' => $this->excludedMembers())); |
||
0 ignored issues
–
show
The method
excludedMembers() does not exist on EcommerceDashboardPanel . Did you maybe mean excludedMembersArray() ?
This check marks calls to methods that do not seem to exist on an object. This is most likely the result of a method being renamed without all references to it being renamed likewise. ![]() |
|||
66 | |||
67 | return $orders; |
||
68 | } |
||
69 | |||
70 | /** |
||
71 | * |
||
72 | * |
||
73 | * @return DataList |
||
74 | */ |
||
75 | protected function submittedOrders($numberOfDaysBack = 0) |
||
76 | { |
||
77 | $orders = Order::get_datalist_of_orders_with_submit_record(); |
||
78 | $orders = $orders |
||
79 | ->exclude(array('MemberID' => $this->excludedMembersArray())) |
||
80 | ->where($this->daysBackWhereStatement($numberOfDaysBack)); |
||
81 | |||
82 | return $orders; |
||
83 | } |
||
84 | |||
85 | /** |
||
86 | * |
||
87 | * |
||
88 | * @return DataList |
||
89 | */ |
||
90 | protected function archivedOrders($numberOfDaysBack = 0) |
||
91 | { |
||
92 | $submittedOrderStatusLogClassName = EcommerceConfig::get('OrderStatusLog', 'order_status_log_class_used_for_submitting_order'); |
||
93 | $lastStep = OrderStep::last_order_step(); |
||
94 | return Order::get() |
||
95 | ->LeftJoin('OrderStatusLog', '"Order"."ID" = "OrderStatusLog"."OrderID"') |
||
96 | ->LeftJoin($submittedOrderStatusLogClassName, '"OrderStatusLog"."ID" = "'.$submittedOrderStatusLogClassName.'"."ID"') |
||
97 | ->filter(array('StatusID' => $lastStep->ID)) |
||
98 | ->exclude(array('MemberID' => $this->excludedMembersArray())) |
||
99 | ->where($this->daysBackWhereStatement($numberOfDaysBack)); |
||
100 | return $orders; |
||
0 ignored issues
–
show
return $orders; does not seem to be reachable.
This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed. Unreachable code is most often the result of function fx() {
try {
doSomething();
return true;
}
catch (\Exception $e) {
return false;
}
return false;
}
In the above example, the last ![]() |
|||
101 | } |
||
102 | |||
103 | |||
104 | |||
105 | /** |
||
106 | * An accessor to the Dashboard controller |
||
107 | * |
||
108 | * @return Dashboard |
||
109 | */ |
||
110 | public function getDashboard() |
||
111 | { |
||
112 | return Injector::inst()->get("EcommerceDashboard"); |
||
113 | } |
||
114 | |||
115 | /** |
||
116 | * |
||
117 | * |
||
118 | * @var array |
||
119 | */ |
||
120 | private static $_excluded_members_array = array(); |
||
121 | |||
122 | /** |
||
123 | * |
||
124 | * |
||
125 | * @return array array of member IDs |
||
126 | */ |
||
127 | protected function excludedMembersArray() |
||
128 | { |
||
129 | if (! count(self::$_excluded_members_array)) { |
||
130 | self::$_excluded_members_array = array(-1 => -1); |
||
131 | $adminGroup = EcommerceRole::get_admin_group(); |
||
132 | $assitantGroup = EcommerceRole::get_assistant_group(); |
||
133 | if ($adminGroup) { |
||
134 | foreach ($adminGroup->Members() as $member) { |
||
135 | self::$_excluded_members_array[$member->ID] = $member->ID; |
||
136 | } |
||
137 | } |
||
138 | if ($assitantGroup) { |
||
139 | foreach ($assitantGroup->Members() as $member) { |
||
140 | self::$_excluded_members_array[$member->ID] = $member->ID; |
||
141 | } |
||
142 | } |
||
143 | } |
||
144 | |||
145 | return self::$_excluded_members_array; |
||
146 | } |
||
147 | |||
148 | /** |
||
149 | * |
||
150 | * |
||
151 | * @return string where statement for orders that have been submitted. |
||
152 | */ |
||
153 | protected function daysBackWhereStatement($daysBack = 0) |
||
154 | { |
||
155 | if (! $daysBack) { |
||
156 | $daysBack = $this->DaysBack ? $this->DaysBack : $this->Config()->defaults['DaysBack']; |
||
0 ignored issues
–
show
The property
DaysBack does not exist on object<EcommerceDashboardPanel> . 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. ![]() |
|||
157 | } |
||
158 | return '"OrderStatusLog"."Created" > ( NOW() - INTERVAL '.($daysBack).' DAY )'; |
||
159 | } |
||
160 | |||
161 | /** |
||
162 | * @var int The "weight" of the dashboard panel when listed in the available panels. |
||
163 | * Higher is lower in the list. |
||
164 | */ |
||
165 | //private static $priority = 100; |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
50% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. ![]() |
|||
166 | |||
167 | |||
168 | |||
169 | /** |
||
170 | * @var string The name of the template used for the contents of this panel. |
||
171 | */ |
||
172 | //protected $template; |
||
173 | |||
174 | public function maxOrdersForLoop() |
||
175 | { |
||
176 | return 500; |
||
177 | } |
||
178 | |||
179 | |||
180 | /** |
||
181 | * Allows the panel to be added |
||
182 | * |
||
183 | * @return string |
||
184 | */ |
||
185 | public function registered() |
||
186 | { |
||
187 | $enabled = Config::inst()->get($this->ClassName, 'enabled'); |
||
188 | if (is_bool($enabled)) { |
||
189 | return self::config()->enabled; |
||
190 | } |
||
191 | if (strtolower(self::config()->enabled) == 'no') { |
||
0 ignored issues
–
show
|
|||
192 | return false; |
||
193 | } |
||
194 | return true; |
||
195 | } |
||
196 | |||
197 | protected function CalculatedDaysBack() |
||
0 ignored issues
–
show
The return type could not be reliably inferred; please add a
@return annotation.
Our type inference engine in quite powerful, but sometimes the code does not
provide enough clues to go by. In these cases we request you to add a ![]() |
|||
198 | { |
||
199 | return $this->DaysBack ? : 7; |
||
0 ignored issues
–
show
The property
DaysBack does not exist on object<EcommerceDashboardPanel> . 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. ![]() |
|||
200 | } |
||
201 | } |
||
202 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.