sunnysideup /
silverstripe-staffprofiles
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 | *@author: nicolaas[at]sunnysideup.co.nz |
||
| 5 | *@description: individual staff profile |
||
| 6 | * |
||
| 7 | **/ |
||
| 8 | |||
| 9 | class StaffProfile extends DataObject |
||
|
0 ignored issues
–
show
|
|||
| 10 | { |
||
| 11 | private static $db = array( |
||
|
0 ignored issues
–
show
|
|||
| 12 | "Name" => "Varchar(255)", |
||
| 13 | "Position" => "Varchar(255)", |
||
| 14 | "Description" => "Text", |
||
| 15 | "Email" => "Varchar(255)", |
||
| 16 | "SubjectLine" => "Varchar(255)", |
||
| 17 | "Sort" => "Int" |
||
| 18 | ); |
||
| 19 | |||
| 20 | private static $has_one = array( |
||
|
0 ignored issues
–
show
|
|||
| 21 | "ProfilePicture" => "Image", |
||
| 22 | "Parent" => "StaffProfilesPage" |
||
| 23 | ); |
||
| 24 | |||
| 25 | //database related settings |
||
| 26 | private static $indexes = array( |
||
|
0 ignored issues
–
show
|
|||
| 27 | "Sort" => true |
||
| 28 | ); |
||
| 29 | |||
| 30 | //formatting |
||
| 31 | private static $searchable_fields = array("Name" => "PartialMatchFilter"); |
||
|
0 ignored issues
–
show
|
|||
| 32 | |||
| 33 | private static $field_labels = array( |
||
|
0 ignored issues
–
show
|
|||
| 34 | "SortNumber" => "Sort Index Number for Sorting (lower numbers first)", |
||
| 35 | "Subjectline" => "Optional Subject Line" |
||
| 36 | ); |
||
| 37 | |||
| 38 | private static $summary_fields = array("Name" => "Name", "Email" => "Email", "Title" => "Title"); |
||
|
0 ignored issues
–
show
|
|||
| 39 | |||
| 40 | private static $singular_name = "Staff Profile"; |
||
|
0 ignored issues
–
show
|
|||
| 41 | |||
| 42 | private static $plural_name = "Staff Profiles"; |
||
|
0 ignored issues
–
show
|
|||
| 43 | |||
| 44 | private static $default_sort = "Sort ASC, Name ASC"; |
||
|
0 ignored issues
–
show
|
|||
| 45 | |||
| 46 | private static $defaults = array( |
||
|
0 ignored issues
–
show
|
|||
| 47 | "Sort" => 100 |
||
| 48 | ); |
||
| 49 | |||
| 50 | /** |
||
| 51 | * replacement placeholders |
||
| 52 | * [xxx] => yyy |
||
| 53 | * where xxx is the string the CMS user types |
||
| 54 | * and yyy the replacement field / relation. |
||
| 55 | * |
||
| 56 | * @var array |
||
| 57 | */ |
||
| 58 | private static $subject_place_holders = array( |
||
|
0 ignored issues
–
show
|
|||
| 59 | "Name" => "Name", |
||
| 60 | "Email" => "Email", |
||
| 61 | "Position" => "Position", |
||
| 62 | "PageTitle" => "Parent.Title", |
||
| 63 | "PageLink" => "Parent.Link" |
||
| 64 | ); |
||
| 65 | |||
| 66 | public function populateDefaults() |
||
| 67 | { |
||
| 68 | $this->Sort = 100; |
||
|
0 ignored issues
–
show
The property
Sort does not exist on object<StaffProfile>. 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. Loading history...
|
|||
| 69 | parent::populateDefaults(); |
||
| 70 | } |
||
| 71 | |||
| 72 | public function getCMSFields() |
||
| 73 | { |
||
| 74 | $fields = parent::getCMSFields(); |
||
| 75 | $field = $fields->dataFieldByName("SubjectLine"); |
||
| 76 | $field->setRightTitle( |
||
| 77 | _t("StaffProfile.PLACEHOLDER_EXPLANATION", "you can use the following placeholders") |
||
| 78 | . ": [" |
||
| 79 | . implode("], [", array_keys($this->Config()->get("subject_place_holders"))) |
||
| 80 | . "]" |
||
| 81 | ); |
||
| 82 | if (class_exists("DataObjectSorterController") && $this->hasExtension("DataObjectSorterController")) { |
||
| 83 | $fields->addFieldToTab("Root.Sort", new LiteralField("InvitationToSort", $this->dataObjectSorterPopupLink())); |
||
|
0 ignored issues
–
show
The method
dataObjectSorterPopupLink does not exist on object<StaffProfile>? Since you implemented __call, maybe consider adding a @method annotation.
If you implement This is often the case, when class ParentClass {
private $data = array();
public function __call($method, array $args) {
if (0 === strpos($method, 'get')) {
return $this->data[strtolower(substr($method, 3))];
}
throw new \LogicException(sprintf('Unsupported method: %s', $method));
}
}
/**
* If this class knows which fields exist, you can specify the methods here:
*
* @method string getName()
*/
class SomeClass extends ParentClass { }
Loading history...
|
|||
| 84 | $fields->removeFieldFromTab("Root.Main", "Sort"); |
||
| 85 | } |
||
| 86 | return $fields; |
||
| 87 | } |
||
| 88 | |||
| 89 | public function fieldLabels($includeRelations = true) |
||
| 90 | { |
||
| 91 | $labels = parent::fieldLabels($includeRelations); |
||
| 92 | return $labels; |
||
| 93 | } |
||
| 94 | |||
| 95 | /** |
||
| 96 | * Obscure all email links in StringField. |
||
| 97 | * Matches mailto:[email protected] as well as [email protected] |
||
| 98 | * |
||
| 99 | * @return string | Null |
||
| 100 | */ |
||
| 101 | public function EncodedEmailLink() |
||
| 102 | { |
||
| 103 | if ($email = $this->getBestEmail()) { |
||
| 104 | $obj = $this->retrieveEmailObject(); |
||
| 105 | if ($obj) { |
||
| 106 | return $obj->MailTo; |
||
| 107 | } else { |
||
| 108 | return "mailto:".$email; |
||
| 109 | } |
||
| 110 | } |
||
| 111 | } |
||
| 112 | |||
| 113 | /** |
||
| 114 | * Obscure all email links in StringField. |
||
| 115 | * Matches mailto:[email protected] as well as [email protected] |
||
| 116 | * |
||
| 117 | * @return string |
||
| 118 | */ |
||
| 119 | public function EncodedEmailText() |
||
| 120 | { |
||
| 121 | if ($email = $this->getBestEmail()) { |
||
| 122 | $obj = $this->retrieveEmailObject(); |
||
| 123 | if ($obj) { |
||
| 124 | return $obj->Text; |
||
| 125 | } else { |
||
| 126 | return $email; |
||
| 127 | } |
||
| 128 | } |
||
| 129 | } |
||
| 130 | |||
| 131 | public function onBeforeWrite() |
||
| 132 | { |
||
| 133 | parent::onBeforeWrite(); |
||
| 134 | if (!$this->Sort) { |
||
|
0 ignored issues
–
show
The property
Sort does not exist on object<StaffProfile>. 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...
|
|||
| 135 | $this->Sort = 100; |
||
|
0 ignored issues
–
show
The property
Sort does not exist on object<StaffProfile>. 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. Loading history...
|
|||
| 136 | } |
||
| 137 | if (!$this->ParentID) { |
||
|
0 ignored issues
–
show
The property
ParentID does not exist on object<StaffProfile>. 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...
|
|||
| 138 | $page = StaffProfilesPage::get()->First(); |
||
| 139 | $this->ParentID = $page->ID; |
||
|
0 ignored issues
–
show
The property
ParentID does not exist on object<StaffProfile>. 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. Loading history...
|
|||
| 140 | } |
||
| 141 | } |
||
| 142 | |||
| 143 | /** |
||
| 144 | * puts together a subject line with replacements |
||
| 145 | * |
||
| 146 | * @return String |
||
| 147 | */ |
||
| 148 | protected function SubjectLineCreator() |
||
| 149 | { |
||
| 150 | if ($this->SubjectLine) { |
||
|
0 ignored issues
–
show
The property
SubjectLine does not exist on object<StaffProfile>. 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...
|
|||
| 151 | $str = $this->SubjectLine; |
||
|
0 ignored issues
–
show
The property
SubjectLine does not exist on object<StaffProfile>. 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. Loading history...
|
|||
| 152 | } else { |
||
| 153 | $str = $this->Parent()->SubjectLine; |
||
|
0 ignored issues
–
show
|
|||
| 154 | } |
||
| 155 | if (!$str) { |
||
| 156 | $str = "Enquiry from [PageLink] for [Name]"; |
||
| 157 | } |
||
| 158 | $replace = $this->Config()->get("subject_place_holders"); |
||
| 159 | foreach ($replace as $findKey => $replaceField) { |
||
| 160 | if (strpos($str, $findKey) !== null) { |
||
| 161 | if (strpos($replaceField, ".")) { |
||
| 162 | $replaceFieldParts = explode(".", $replaceField); |
||
| 163 | $method1 = $replaceFieldParts[0]; |
||
| 164 | $method2 = $replaceFieldParts[1]; |
||
| 165 | $relationalObject = $this->$method1(); |
||
| 166 | if ($relationalObject) { |
||
| 167 | if ($relationalObject->hasMethod($method2)) { |
||
| 168 | $replaceValue = $relationalObject->$method2(); |
||
| 169 | } elseif ($relationalObject->hasMethod("get".$method2)) { |
||
| 170 | $method2 = "get".$method2; |
||
| 171 | $replaceValue = $relationalObject->$method2(); |
||
| 172 | } |
||
| 173 | } |
||
| 174 | } else { |
||
| 175 | $replaceValue = $this->$replaceField; |
||
| 176 | } |
||
| 177 | $str = str_ireplace("[".$findKey."]", $replaceValue, $str); |
||
|
0 ignored issues
–
show
The variable
$replaceValue does not seem to be defined for all execution paths leading up to this point.
If you define a variable conditionally, it can happen that it is not defined for all execution paths. Let’s take a look at an example: function myFunction($a) {
switch ($a) {
case 'foo':
$x = 1;
break;
case 'bar':
$x = 2;
break;
}
// $x is potentially undefined here.
echo $x;
}
In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined. Available Fixes
Loading history...
|
|||
| 178 | } |
||
| 179 | } |
||
| 180 | return $str; |
||
| 181 | } |
||
| 182 | |||
| 183 | |||
| 184 | /** |
||
| 185 | * @var EmailObject |
||
| 186 | */ |
||
| 187 | protected $emailObject = null; |
||
| 188 | |||
| 189 | /** |
||
| 190 | * |
||
| 191 | * @return EmailObject | NULL |
||
| 192 | */ |
||
| 193 | protected function retrieveEmailObject() |
||
| 194 | { |
||
| 195 | if (!$this->emailObject) { |
||
| 196 | if (class_exists("HideMailto")) { |
||
| 197 | if ($email = $this->getBestEmail()) { |
||
| 198 | $this->emailObject = HideMailto::convert_email($email, $this->SubjectLineCreator()); |
||
|
0 ignored issues
–
show
It seems like
\HideMailto::convert_ema...->SubjectLineCreator()) of type object<ViewableData> is incompatible with the declared type object<EmailObject> of property $emailObject.
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property. Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property.. Loading history...
|
|||
| 199 | } |
||
| 200 | } else { |
||
| 201 | user_error("This module requires Sunnysideup/hidemailto, but it can function without it", E_USER_NOTICE); |
||
| 202 | } |
||
| 203 | } |
||
| 204 | return $this->emailObject; |
||
| 205 | } |
||
| 206 | |||
| 207 | /** |
||
| 208 | * finds the best email available. |
||
| 209 | * |
||
| 210 | * @return String |
||
| 211 | */ |
||
| 212 | protected function getBestEmail() |
||
| 213 | { |
||
| 214 | if ($this->Email) { |
||
|
0 ignored issues
–
show
The property
Email does not exist on object<StaffProfile>. 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...
|
|||
| 215 | $email = $this->Email; |
||
|
0 ignored issues
–
show
The property
Email does not exist on object<StaffProfile>. 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. Loading history...
|
|||
| 216 | } else { |
||
| 217 | $email = $this->Parent()->DefaultEmail; |
||
|
0 ignored issues
–
show
|
|||
| 218 | } |
||
| 219 | return $email; |
||
| 220 | } |
||
| 221 | } |
||
| 222 |
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.