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 SmartChimpSignupPage extends Page |
||
0 ignored issues
–
show
|
|||
4 | { |
||
5 | public static $icon = "smartchimp/images/treeicons/SmartChimpSignupPage"; |
||
6 | |||
7 | public static $db = array( |
||
8 | // @todo: provide optional dropdown for entering username/password?? |
||
9 | 'MCApiKey' => 'Varchar(50)', // api_key |
||
10 | 'MCListKey' => 'Varchar(50)', // list_unique_id |
||
11 | 'MCSuccessContent' => 'HTMLText', |
||
12 | "DoubleOptin" => "Boolean", |
||
13 | "SendWelcomeMail" => "Boolean", |
||
14 | "SendGoodbey" => "Boolean", |
||
15 | "SendDeleteNotification" => "Boolean", |
||
16 | "IsDefaultList" => "Boolean", |
||
17 | "FirstFieldRequired" => "Boolean", |
||
18 | "LastFieldRequired" => "Boolean" |
||
19 | ); |
||
20 | |||
21 | public static $has_many = array( |
||
22 | "SmartChimpNewsletters" => "SmartChimpNewsletter" |
||
23 | ); |
||
24 | |||
25 | public static $defaults = array( |
||
26 | "DoubleOptin" => 1, |
||
27 | "SendWelcomeMail" => 0, |
||
28 | "SendGoodbey" => 0, |
||
29 | "IsDefaultList" => 1 |
||
30 | ); |
||
31 | |||
32 | public static $mc_api_version = '1.2.1'; |
||
33 | |||
34 | protected static $api = null; |
||
35 | |||
36 | public function getAPI() |
||
37 | { |
||
38 | if ($this->MCApiKey && $this->MCListKey) { |
||
39 | if (!(self::$api instanceof MCAPI)) { |
||
0 ignored issues
–
show
The class
MCAPI does not exist. Did you forget a USE statement, or did you not list all dependencies?
This error could be the result of: 1. Missing dependenciesPHP Analyzer uses your Are you sure this class is defined by one of your dependencies, or did you maybe
not list a dependency in either the 2. Missing use statementPHP does not complain about undefined classes in if ($x instanceof DoesNotExist) {
// Do something.
}
If you have not tested against this specific condition, such errors might go unnoticed. ![]() |
|||
40 | require_once(Director::baseFolder().'/smartchimp/thirdparty/mcapi/'.self::$mc_api_version.'/MCAPI.class.php'); |
||
41 | self::$api = new MCAPI("$this->MCApiKey"); |
||
42 | } |
||
43 | return self::$api; |
||
44 | } |
||
45 | } |
||
46 | |||
47 | |||
48 | public function getCMSFields() |
||
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 ![]() |
|||
49 | { |
||
50 | $fields = parent::getCMSFields(); |
||
51 | |||
52 | $fields->addFieldsToTab('Root.Content.SentNewsletters', array( |
||
53 | new LiteralField('HowToRetrieve', '<p>To retrieve sent newsletters, simply save this page or <a href="'.$this->Link("update").'?flush=1">click here</a>.</p>'), |
||
54 | $this->SmartChimpNewslettersTable() |
||
55 | )); |
||
56 | $fields->addFieldsToTab('Root.Content.MailChimpConfig', array( |
||
57 | new CheckboxField('IsDefaultList', 'This is the default newsletter'), |
||
0 ignored issues
–
show
'IsDefaultList' is of type string , but the function expects a object<The> .
It seems like the type of the argument is not accepted by the function/method which you are calling. In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug. We suggest to add an explicit type cast like in the following example: function acceptsInteger($int) { }
$x = '123'; // string "123"
// Instead of
acceptsInteger($x);
// we recommend to use
acceptsInteger((integer) $x);
![]() 'This is the default newsletter' is of type string , but the function expects a object<The>|null .
It seems like the type of the argument is not accepted by the function/method which you are calling. In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug. We suggest to add an explicit type cast like in the following example: function acceptsInteger($int) { }
$x = '123'; // string "123"
// Instead of
acceptsInteger($x);
// we recommend to use
acceptsInteger((integer) $x);
![]() |
|||
58 | new TextField('MCApiKey', _t('SmartChimp.MCAPIKEY', 'API Key')), |
||
59 | new TextField('MCListKey', _t('SmartChimp.MCLISTKEY', 'Unique ID for List')), |
||
60 | new HTMLEditorField('MCSuccessContent', _t('SmartChimp.MCSuccessContent', 'Signup Success Content')) |
||
61 | )); |
||
62 | $fields->addFieldsToTab('Root.Content.Subscribe', array( |
||
63 | new CheckboxField('DoubleOptin', "Double Opt-In Process (send email to confirm registration)"), |
||
0 ignored issues
–
show
'DoubleOptin' is of type string , but the function expects a object<The> .
It seems like the type of the argument is not accepted by the function/method which you are calling. In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug. We suggest to add an explicit type cast like in the following example: function acceptsInteger($int) { }
$x = '123'; // string "123"
// Instead of
acceptsInteger($x);
// we recommend to use
acceptsInteger((integer) $x);
![]() 'Double Opt-In Process (... confirm registration)' is of type string , but the function expects a object<The>|null .
It seems like the type of the argument is not accepted by the function/method which you are calling. In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug. We suggest to add an explicit type cast like in the following example: function acceptsInteger($int) { }
$x = '123'; // string "123"
// Instead of
acceptsInteger($x);
// we recommend to use
acceptsInteger((integer) $x);
![]() |
|||
64 | new CheckboxField('SendWelcomeMail', "Send Welcome Mail") |
||
0 ignored issues
–
show
'SendWelcomeMail' is of type string , but the function expects a object<The> .
It seems like the type of the argument is not accepted by the function/method which you are calling. In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug. We suggest to add an explicit type cast like in the following example: function acceptsInteger($int) { }
$x = '123'; // string "123"
// Instead of
acceptsInteger($x);
// we recommend to use
acceptsInteger((integer) $x);
![]() 'Send Welcome Mail' is of type string , but the function expects a object<The>|null .
It seems like the type of the argument is not accepted by the function/method which you are calling. In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug. We suggest to add an explicit type cast like in the following example: function acceptsInteger($int) { }
$x = '123'; // string "123"
// Instead of
acceptsInteger($x);
// we recommend to use
acceptsInteger((integer) $x);
![]() |
|||
65 | )); |
||
66 | $fields->addFieldsToTab('Root.Content.Unsubscribe', array( |
||
67 | new CheckboxField('SendGoodbey', "Send Goodbey Email"), |
||
0 ignored issues
–
show
'SendGoodbey' is of type string , but the function expects a object<The> .
It seems like the type of the argument is not accepted by the function/method which you are calling. In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug. We suggest to add an explicit type cast like in the following example: function acceptsInteger($int) { }
$x = '123'; // string "123"
// Instead of
acceptsInteger($x);
// we recommend to use
acceptsInteger((integer) $x);
![]() 'Send Goodbey Email' is of type string , but the function expects a object<The>|null .
It seems like the type of the argument is not accepted by the function/method which you are calling. In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug. We suggest to add an explicit type cast like in the following example: function acceptsInteger($int) { }
$x = '123'; // string "123"
// Instead of
acceptsInteger($x);
// we recommend to use
acceptsInteger((integer) $x);
![]() |
|||
68 | new CheckboxField('SendDeleteNotification', "Send notification of unsubscribe") |
||
0 ignored issues
–
show
'SendDeleteNotification' is of type string , but the function expects a object<The> .
It seems like the type of the argument is not accepted by the function/method which you are calling. In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug. We suggest to add an explicit type cast like in the following example: function acceptsInteger($int) { }
$x = '123'; // string "123"
// Instead of
acceptsInteger($x);
// we recommend to use
acceptsInteger((integer) $x);
![]() 'Send notification of unsubscribe' is of type string , but the function expects a object<The>|null .
It seems like the type of the argument is not accepted by the function/method which you are calling. In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug. We suggest to add an explicit type cast like in the following example: function acceptsInteger($int) { }
$x = '123'; // string "123"
// Instead of
acceptsInteger($x);
// we recommend to use
acceptsInteger((integer) $x);
![]() |
|||
69 | )); |
||
70 | $fields->addFieldsToTab("Root.Content.RequiredFields", array( |
||
71 | new CheckboxField('FirstRequired', "First name is required"), |
||
0 ignored issues
–
show
'FirstRequired' is of type string , but the function expects a object<The> .
It seems like the type of the argument is not accepted by the function/method which you are calling. In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug. We suggest to add an explicit type cast like in the following example: function acceptsInteger($int) { }
$x = '123'; // string "123"
// Instead of
acceptsInteger($x);
// we recommend to use
acceptsInteger((integer) $x);
![]() 'First name is required' is of type string , but the function expects a object<The>|null .
It seems like the type of the argument is not accepted by the function/method which you are calling. In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug. We suggest to add an explicit type cast like in the following example: function acceptsInteger($int) { }
$x = '123'; // string "123"
// Instead of
acceptsInteger($x);
// we recommend to use
acceptsInteger((integer) $x);
![]() |
|||
72 | new CheckboxField('LastRequired', "Last name is required") |
||
0 ignored issues
–
show
'LastRequired' is of type string , but the function expects a object<The> .
It seems like the type of the argument is not accepted by the function/method which you are calling. In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug. We suggest to add an explicit type cast like in the following example: function acceptsInteger($int) { }
$x = '123'; // string "123"
// Instead of
acceptsInteger($x);
// we recommend to use
acceptsInteger((integer) $x);
![]() 'Last name is required' is of type string , but the function expects a object<The>|null .
It seems like the type of the argument is not accepted by the function/method which you are calling. In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug. We suggest to add an explicit type cast like in the following example: function acceptsInteger($int) { }
$x = '123'; // string "123"
// Instead of
acceptsInteger($x);
// we recommend to use
acceptsInteger((integer) $x);
![]() |
|||
73 | )); |
||
74 | $this->extend('updateSmartChimpCMSFields'); |
||
75 | |||
76 | return $fields; |
||
77 | } |
||
78 | |||
79 | public function SmartChimpNewslettersTable() |
||
80 | { |
||
81 | $table = new HasManyComplexTableField( |
||
82 | $controller = $this, |
||
83 | $name = "SmartChimpNewsletters", |
||
84 | $sourceClass = "SmartChimpNewsletter", |
||
85 | $fieldList = null, |
||
86 | $detailFormFields = null, |
||
87 | $sourceFilter = "ParentID = ".$this->ID |
||
88 | ); |
||
89 | $table->setPageSize(100); |
||
90 | $table->setPermissions(array('export', 'show', 'edit', 'delete')); |
||
91 | return $table; |
||
92 | } |
||
93 | |||
94 | public function SmartChimpNewslettersShow() |
||
95 | { |
||
96 | return DataObject::get("SmartChimpNewsletter", "\"ParentID\" = ".$this->ID." AND \"Hide\" <> 1"); |
||
97 | } |
||
98 | |||
99 | public function RetrieveCampaigns() |
||
100 | { |
||
101 | $dos = new DataObjectSet(); |
||
0 ignored issues
–
show
$dos is not used, you could remove the assignment.
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently. $myVar = 'Value';
$higher = false;
if (rand(1, 6) > 3) {
$higher = true;
} else {
$higher = false;
}
Both the ![]() |
|||
102 | SmartChimpNewsletter::clean_up_characters(); |
||
103 | $api = $this->getAPI(); |
||
104 | if ($api && $this->ID) { |
||
105 | $campaignArray = $api->campaigns(array("list_id" => $this->MCListKey)); |
||
106 | if (is_array($campaignArray) && count($campaignArray)) { |
||
107 | foreach ($campaignArray as $key => $campaign) { |
||
108 | if ($campaign["status"] == "sent") { |
||
109 | $obj = DataObject::get_one("SmartChimpNewsletter", "`ParentID` = ".$this->ID." AND `CampaignID` = '".$campaign["id"]."'"); |
||
110 | if ($obj) { |
||
0 ignored issues
–
show
This
if statement is empty and can be removed.
This check looks for the bodies of These if (rand(1, 6) > 3) {
//print "Check failed";
} else {
print "Check succeeded";
}
could be turned into if (rand(1, 6) <= 3) {
print "Check succeeded";
}
This is much more concise to read. ![]() |
|||
111 | //do nothing |
||
112 | } else { |
||
113 | $content = $api->campaignContent($campaign["id"]); |
||
114 | if ($content) { |
||
115 | $obj = new SmartChimpNewsletter(); |
||
116 | $obj->ParentID = $this->ID; |
||
0 ignored issues
–
show
The property
ParentID does not exist on object<SmartChimpNewsletter> . Since you implemented __set , maybe consider adding a @property annotation.
Since your code implements the magic setter <?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.");
}
}
}
Since the property has write access only, you can use the @property-write 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. ![]() |
|||
117 | $obj->Date = $campaign["send_time"];// |
||
0 ignored issues
–
show
The property
Date does not exist on object<SmartChimpNewsletter> . Since you implemented __set , maybe consider adding a @property annotation.
Since your code implements the magic setter <?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.");
}
}
}
Since the property has write access only, you can use the @property-write 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. ![]() |
|||
118 | $obj->Title = $campaign["title"];// |
||
0 ignored issues
–
show
The property
Title does not exist on object<SmartChimpNewsletter> . Since you implemented __set , maybe consider adding a @property annotation.
Since your code implements the magic setter <?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.");
}
}
}
Since the property has write access only, you can use the @property-write 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. ![]() |
|||
119 | $obj->Subject = $campaign["subject"];// |
||
0 ignored issues
–
show
The property
Subject does not exist on object<SmartChimpNewsletter> . Since you implemented __set , maybe consider adding a @property annotation.
Since your code implements the magic setter <?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.");
}
}
}
Since the property has write access only, you can use the @property-write 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. ![]() |
|||
120 | $obj->PermaLink = $campaign["archive_url"];// |
||
0 ignored issues
–
show
The property
PermaLink does not exist on object<SmartChimpNewsletter> . Since you implemented __set , maybe consider adding a @property annotation.
Since your code implements the magic setter <?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.");
}
}
}
Since the property has write access only, you can use the @property-write 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 | $obj->CampaignID = $campaign["id"];// |
||
0 ignored issues
–
show
The property
CampaignID does not exist on object<SmartChimpNewsletter> . Since you implemented __set , maybe consider adding a @property annotation.
Since your code implements the magic setter <?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.");
}
}
}
Since the property has write access only, you can use the @property-write 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. ![]() |
|||
122 | $obj->WebID = $campaign["web_id"];// |
||
0 ignored issues
–
show
The property
WebID does not exist on object<SmartChimpNewsletter> . Since you implemented __set , maybe consider adding a @property annotation.
Since your code implements the magic setter <?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.");
}
}
}
Since the property has write access only, you can use the @property-write 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. ![]() |
|||
123 | $obj->Status = $campaign["status"];//should be sent! |
||
0 ignored issues
–
show
The property
Status does not exist on object<SmartChimpNewsletter> . Since you implemented __set , maybe consider adding a @property annotation.
Since your code implements the magic setter <?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.");
}
}
}
Since the property has write access only, you can use the @property-write 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. ![]() |
|||
124 | //$obj->TextContent = $content["text"] ;//html |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
59% 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. ![]() |
|||
125 | //$obj->HTMLContent = $content["html"];//text |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
64% 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. ![]() |
|||
126 | } else { |
||
127 | user_error(" could not retrieve content for newsletter with subject: ".$campaign["subject"]." AND ID".$campaign["id"], E_USER_NOTICE); |
||
128 | } |
||
129 | $obj->write(); |
||
130 | } |
||
131 | } |
||
132 | } |
||
133 | } |
||
134 | } |
||
135 | } |
||
136 | |||
137 | |||
138 | public function subscribe($email, $firstname, $lastname) |
||
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 ![]() |
|||
139 | { |
||
140 | $api = $this->getAPI(); |
||
141 | if ($api) { |
||
142 | $mergeVars = array( |
||
143 | 'FNAME' => $firstname, |
||
144 | 'LNAME' => $lastname |
||
145 | ); |
||
146 | //NOTE: update existing is set to false to not accidentally resubscribe someone. |
||
147 | if (true === $api->listSubscribe($id = $this->MCListKey, $email, $mergeVars, $email_type='html', $this->DoubleOptin, $update_existing=false, $replace_interests=true, $this->SendWelcomeMail)) { |
||
148 | return true; |
||
149 | } else { |
||
150 | return $api->errorMessage; |
||
151 | } |
||
152 | } |
||
153 | } |
||
154 | |||
155 | public function unsubscribe($email) |
||
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 ![]() |
|||
156 | { |
||
157 | $api = $this->getAPI(); |
||
158 | if ($api) { |
||
159 | if (true === $api->listUnsubscribe($id = $this->MCListKey, $email, $delete_member=false, $this->SendGoodbey, $this->SendDeleteNotification)) { |
||
160 | return true; |
||
161 | } else { |
||
162 | return $api->errorMessage; |
||
163 | } |
||
164 | } |
||
165 | } |
||
166 | |||
167 | public function onBeforeWrite() |
||
168 | { |
||
169 | parent::onBeforeWrite(); |
||
170 | if ($this->IsDefaultList && $this->ID) { |
||
171 | $others = DataObject::get("SmartChimpSignupPage", "`SmartChimpSignupPage`.`ID` <> ".intval($this->ID)." AND `SmartChimpSignupPage`.`IsDefaultList` = 1"); |
||
172 | if ($others) { |
||
173 | foreach ($others as $other) { |
||
174 | $other->IsDefaultList = 0; |
||
175 | $other->writeToStage('Stage'); |
||
176 | $other->publish('Stage', 'Live'); |
||
177 | } |
||
178 | } |
||
179 | } |
||
180 | } |
||
181 | |||
182 | public function onAfterWrite() |
||
183 | { |
||
184 | parent::onAfterWrite(); |
||
185 | $this->RetrieveCampaigns(); |
||
186 | } |
||
187 | |||
188 | |||
189 | |||
190 | public function requireDefaultRecords() |
||
191 | { |
||
192 | parent::requireDefaultRecords(); |
||
193 | $pages = DataObject::get("SmartChimpSignupPage"); |
||
194 | if ($pages) { |
||
195 | if ($pages->count() == 1) { |
||
196 | foreach ($pages as $page) { |
||
197 | if (!$page->IsDefaultList) { |
||
198 | $page->IsDefaultList = 1; |
||
199 | $page->writeToStage('Stage'); |
||
200 | $page->publish('Stage', 'Live'); |
||
201 | Database::alteration_message($page->ClassName.' created/updated: added IsDefaultList = true setting as there is only one SmartChimpSignupPage', 'edited'); |
||
202 | } |
||
203 | } |
||
204 | } |
||
205 | } |
||
206 | } |
||
207 | } |
||
208 | |||
209 | |||
210 | class SmartChimpSignupPage_Controller extends Page_Controller |
||
0 ignored issues
–
show
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.
You can fix this by adding a namespace to your class: namespace YourVendor;
class YourClass { }
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries. ![]() |
|||
211 | { |
||
212 | public static $allowed_actions = array("Form", "update"); |
||
213 | |||
214 | public function init() |
||
215 | { |
||
216 | parent::init(); |
||
217 | } |
||
218 | |||
219 | |||
220 | public function update() |
||
221 | { |
||
222 | $this->RetrieveCampaigns(); |
||
223 | return array(); |
||
224 | } |
||
225 | |||
226 | public function Form() |
||
227 | { |
||
228 | if (Session::get('SmartChimp.SUCCESS')) { |
||
229 | Session::clear('SmartChimp.SUCCESS'); |
||
230 | return false; |
||
231 | } |
||
232 | $requiredFields = new RequiredFields('email'); |
||
233 | if ($this->FirstFieldRequired) { |
||
234 | $requiredFields->appendRequiredFields(array('fname')); |
||
235 | } |
||
236 | if ($this->LastFieldRequired) { |
||
237 | $requiredFields->appendRequiredFields(array('lname')); |
||
238 | } |
||
239 | $form = new Form($this, 'Form', |
||
240 | new FieldSet( |
||
241 | new TextField('fname', 'First name'), |
||
242 | new TextField('lname', 'Last name'), |
||
243 | new TextField('email', 'Email address') |
||
244 | ), |
||
245 | new FieldSet( |
||
246 | new FormAction('SignupAction', 'Sign up') |
||
0 ignored issues
–
show
'SignupAction' is of type string , but the function expects a object<The> .
It seems like the type of the argument is not accepted by the function/method which you are calling. In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug. We suggest to add an explicit type cast like in the following example: function acceptsInteger($int) { }
$x = '123'; // string "123"
// Instead of
acceptsInteger($x);
// we recommend to use
acceptsInteger((integer) $x);
![]() |
|||
247 | ), |
||
248 | $requiredFields |
||
249 | ); |
||
250 | $this->extend('updateSmartChimpForm', $form); |
||
251 | return $form; |
||
252 | } |
||
253 | |||
254 | public function ShortForm() |
||
255 | { |
||
256 | if (Session::get('SmartChimp.SUCCESS')) { |
||
257 | Session::clear('SmartChimp.SUCCESS'); |
||
258 | return false; |
||
259 | } |
||
260 | $form = new Form($this, 'Form', |
||
261 | new FieldSet( |
||
262 | new TextField('email', 'Email Address') |
||
263 | ), |
||
264 | new FieldSet( |
||
265 | new FormAction('SignupAction', 'Sign up') |
||
0 ignored issues
–
show
'SignupAction' is of type string , but the function expects a object<The> .
It seems like the type of the argument is not accepted by the function/method which you are calling. In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug. We suggest to add an explicit type cast like in the following example: function acceptsInteger($int) { }
$x = '123'; // string "123"
// Instead of
acceptsInteger($x);
// we recommend to use
acceptsInteger((integer) $x);
![]() |
|||
266 | ), |
||
267 | new RequiredFields('email') |
||
268 | ); |
||
269 | |||
270 | $this->extend('updateSmartChimpForm', $form); |
||
271 | |||
272 | return $form; |
||
273 | } |
||
274 | |||
275 | public function mcsuccess() |
||
276 | { |
||
277 | if (Session::get('SmartChimp.SUCCESS')) { |
||
278 | $this->Content = $this->MCSuccessContent; |
||
279 | } |
||
280 | return array(); |
||
281 | } |
||
282 | |||
283 | public function SignupAction($raw_data, $form) |
||
284 | { |
||
285 | $data = Convert::raw2sql($raw_data); |
||
286 | $outcome = $this->subscribe($data['email'], $data['fname'], $data['lname']); |
||
287 | if (true === $outcome) { |
||
288 | Session::set('SmartChimp.SUCCESS', true); |
||
0 ignored issues
–
show
true is of type boolean , but the function expects a string .
It seems like the type of the argument is not accepted by the function/method which you are calling. In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug. We suggest to add an explicit type cast like in the following example: function acceptsInteger($int) { }
$x = '123'; // string "123"
// Instead of
acceptsInteger($x);
// we recommend to use
acceptsInteger((integer) $x);
![]() |
|||
289 | return $this->mcsuccess(); |
||
290 | } else { |
||
291 | $form->sessionMessage($outcome, 'warning'); |
||
292 | Director::redirectBack(); |
||
0 ignored issues
–
show
The method
Director::redirectBack() has been deprecated with message: 2.5 Use Controller->redirectBack()
This method has been deprecated. The supplier of the class has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead. ![]() |
|||
293 | } |
||
294 | } |
||
295 | } |
||
296 |
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.