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 | * Forum Post Object. Contains a single post by the user. A thread is generated |
||
5 | * with multiple posts. |
||
6 | * |
||
7 | * @package forum |
||
8 | */ |
||
9 | |||
10 | class Post extends DataObject |
||
11 | { |
||
12 | |||
13 | private static $db = array( |
||
0 ignored issues
–
show
Comprehensibility
introduced
by
![]() |
|||
14 | "Content" => "Text", |
||
15 | "Status" => "Enum('Awaiting, Moderated, Rejected, Archived', 'Moderated')", |
||
16 | ); |
||
17 | |||
18 | private static $casting = array( |
||
0 ignored issues
–
show
|
|||
19 | "Updated" => "SS_Datetime", |
||
20 | "RSSContent" => "HTMLText", |
||
21 | "RSSAuthor" => "Varchar", |
||
22 | "Content" => "HTMLText" |
||
23 | ); |
||
24 | |||
25 | private static $has_one = array( |
||
0 ignored issues
–
show
|
|||
26 | "Author" => "Member", |
||
27 | "Thread" => "ForumThread", |
||
28 | "Forum" => "Forum" // denormalized data but used for read speed |
||
29 | ); |
||
30 | |||
31 | private static $has_many = array( |
||
0 ignored issues
–
show
|
|||
32 | "Attachments" => "Post_Attachment" |
||
33 | ); |
||
34 | |||
35 | private static $summary_fields = array( |
||
0 ignored issues
–
show
|
|||
36 | "Content.LimitWordCount" => "Summary", |
||
37 | "Created" => "Created", |
||
38 | "Status" => "Status", |
||
39 | "Thread.Title" => "Thread", |
||
40 | "Forum.Title" => "Forum" |
||
41 | ); |
||
42 | |||
43 | /** |
||
44 | * Update all the posts to have a forum ID of their thread ID. |
||
45 | */ |
||
46 | public function requireDefaultRecords() |
||
47 | { |
||
48 | $posts = Post::get()->filter(array('ForumID' => 0, 'ThreadID:GreaterThan' => 0)); |
||
49 | |||
50 | if ($posts->exists()) { |
||
51 | foreach ($posts as $post) { |
||
52 | if ($post->ThreadID) { |
||
53 | $post->ForumID = $post->Thread()->ForumID; |
||
54 | $post->write(); |
||
55 | } |
||
56 | } |
||
57 | |||
58 | DB::alteration_message(_t('Forum.POSTSFORUMIDUPDATED', 'Forum posts forum ID added'), 'created'); |
||
59 | } |
||
60 | } |
||
61 | |||
62 | /** |
||
63 | * Before deleting a post make sure all attachments are also deleted |
||
64 | */ |
||
65 | public function onBeforeDelete() |
||
66 | { |
||
67 | parent::onBeforeDelete(); |
||
68 | |||
69 | if ($attachments = $this->Attachments()) { |
||
0 ignored issues
–
show
The method
Attachments does not exist on object<Post> ? 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 { }
![]() |
|||
70 | foreach ($attachments as $file) { |
||
71 | $file->delete(); |
||
72 | $file->destroy(); |
||
73 | } |
||
74 | } |
||
75 | } |
||
76 | |||
77 | /** |
||
78 | * Check if user can see the post |
||
79 | */ |
||
80 | public function canView($member = null) |
||
81 | { |
||
82 | if (!$member) { |
||
83 | $member = Member::currentUser(); |
||
84 | } |
||
85 | |||
86 | if ($this->Author()->ForumStatus != 'Normal') { |
||
0 ignored issues
–
show
|
|||
87 | if ($this->AuthorID != $member->ID || $member->ForumStatus != 'Ghost') { |
||
0 ignored issues
–
show
The property
AuthorID does not exist on object<Post> . 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. ![]() |
|||
88 | return false; |
||
89 | } |
||
90 | } |
||
91 | |||
92 | return $this->Thread()->canView($member); |
||
0 ignored issues
–
show
The method
Thread does not exist on object<Post> ? 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 { }
![]() |
|||
93 | } |
||
94 | |||
95 | /** |
||
96 | * Check if user can edit the post (only if it's his own, or he's an admin user) |
||
97 | */ |
||
98 | public function canEdit($member = null) |
||
99 | { |
||
100 | if (!$member) { |
||
101 | $member = Member::currentUser(); |
||
102 | } |
||
103 | |||
104 | if ($member) { |
||
105 | // Admins can always edit, regardless of thread/post ownership |
||
106 | if (Permission::checkMember($member, 'ADMIN')) { |
||
107 | return true; |
||
108 | } |
||
109 | |||
110 | // Otherwise check for thread permissions and ownership |
||
111 | if ($this->Thread()->canPost($member) && $member->ID == $this->AuthorID) { |
||
0 ignored issues
–
show
The property
AuthorID does not exist on object<Post> . 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. ![]() The method
Thread does not exist on object<Post> ? 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 { }
![]() |
|||
112 | return true; |
||
113 | } |
||
114 | } |
||
115 | |||
116 | return false; |
||
117 | } |
||
118 | |||
119 | /** |
||
120 | * Follow edit permissions for this, but additionally allow moderation even |
||
121 | * if the thread is marked as readonly. |
||
122 | */ |
||
123 | public function canDelete($member = null) |
||
124 | { |
||
125 | if (!$member) { |
||
126 | $member = Member::currentUser(); |
||
127 | } |
||
128 | if ($this->canEdit($member)) { |
||
129 | return true; |
||
130 | } else { |
||
131 | return $this->Thread()->canModerate($member); |
||
0 ignored issues
–
show
The method
Thread does not exist on object<Post> ? 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 { }
![]() |
|||
132 | } |
||
133 | } |
||
134 | |||
135 | /** |
||
136 | * Check if user can add new posts - hook up into canPost. |
||
137 | */ |
||
138 | public function canCreate($member = null) |
||
139 | { |
||
140 | if (!$member) { |
||
141 | $member = Member::currentUser(); |
||
142 | } |
||
143 | return $this->Thread()->canPost($member); |
||
0 ignored issues
–
show
The method
Thread does not exist on object<Post> ? 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 { }
![]() |
|||
144 | } |
||
145 | |||
146 | /** |
||
147 | * Returns the absolute url rather then relative. Used in Post RSS Feed |
||
148 | * |
||
149 | * @return String |
||
150 | */ |
||
151 | public function AbsoluteLink() |
||
152 | { |
||
153 | return Director::absoluteURL($this->Link()); |
||
154 | } |
||
155 | |||
156 | /** |
||
157 | * Return the title of the post. Because we don't have to have the title |
||
158 | * on individual posts check with the topic |
||
159 | * |
||
160 | * @return String |
||
161 | */ |
||
162 | public function getTitle() |
||
163 | { |
||
164 | return ($this->isFirstPost()) ? $this->Thread()->Title : sprintf(_t('Post.RESPONSE', "Re: %s", 'Post Subject Prefix'), $this->Thread()->Title); |
||
0 ignored issues
–
show
The method
Thread does not exist on object<Post> ? 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 { }
![]() |
|||
165 | } |
||
166 | |||
167 | /** |
||
168 | * Return the last edited date, if it's different from created |
||
169 | */ |
||
170 | public function getUpdated() |
||
171 | { |
||
172 | if ($this->LastEdited != $this->Created) { |
||
173 | return $this->LastEdited; |
||
174 | } |
||
175 | } |
||
176 | |||
177 | /** |
||
178 | * Is this post the first post in the thread. Check if their is a post with an ID less |
||
179 | * than the one of this post in the same thread |
||
180 | * |
||
181 | * @return bool |
||
182 | */ |
||
183 | public function isFirstPost() |
||
184 | { |
||
185 | if (empty($this->ThreadID) || empty($this->ID)) { |
||
0 ignored issues
–
show
The property
ThreadID does not exist on object<Post> . 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. ![]() |
|||
186 | return false; |
||
187 | } |
||
188 | $earlierPosts = DB::query(sprintf( |
||
189 | 'SELECT COUNT("ID") FROM "Post" WHERE "ThreadID" = \'%d\' and "ID" < \'%d\'', |
||
190 | $this->ThreadID, |
||
0 ignored issues
–
show
The property
ThreadID does not exist on object<Post> . 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. ![]() |
|||
191 | $this->ID |
||
192 | ))->value(); |
||
193 | return empty($earlierPosts); |
||
194 | } |
||
195 | |||
196 | /** |
||
197 | * Return a link to edit this post. |
||
198 | * |
||
199 | * @return String |
||
200 | */ |
||
201 | public function EditLink() |
||
202 | { |
||
203 | if ($this->canEdit()) { |
||
204 | $url = Controller::join_links($this->Link('editpost'), $this->ID); |
||
205 | return '<a href="' . $url . '" class="editPostLink">' . _t('Post.EDIT', 'Edit') . '</a>'; |
||
206 | } |
||
207 | return false; |
||
208 | } |
||
209 | |||
210 | /** |
||
211 | * Return a link to delete this post. |
||
212 | * |
||
213 | * If the member is an admin of this forum, (ADMIN permissions |
||
214 | * or a moderator) then they can delete the post. |
||
215 | * |
||
216 | * @return String |
||
217 | */ |
||
218 | public function DeleteLink() |
||
219 | { |
||
220 | if ($this->canDelete()) { |
||
221 | $url = Controller::join_links($this->Link('deletepost'), $this->ID); |
||
222 | $token = SecurityToken::inst(); |
||
223 | $url = $token->addToUrl($url); |
||
224 | |||
225 | $firstPost = ($this->isFirstPost()) ? ' firstPost' : ''; |
||
226 | |||
227 | return '<a class="deleteLink' . $firstPost . '" href="' . $url . '">' . _t('Post.DELETE', 'Delete') . '</a>'; |
||
228 | } |
||
229 | |||
230 | return false; |
||
231 | } |
||
232 | |||
233 | /** |
||
234 | * Return a link to the reply form. Permission checking is handled on the actual URL |
||
235 | * and not on this function |
||
236 | * |
||
237 | * @return String |
||
238 | */ |
||
239 | public function ReplyLink() |
||
240 | { |
||
241 | $url = $this->Link('reply'); |
||
242 | |||
243 | return '<a href="' . $url . '" class="replyLink">' . _t('Post.REPLYLINK', 'Post Reply') . '</a>'; |
||
244 | } |
||
245 | |||
246 | /** |
||
247 | * Return a link to the post view. |
||
248 | * |
||
249 | * @return String |
||
250 | */ |
||
251 | public function ShowLink() |
||
252 | { |
||
253 | $url = $this->Link('show'); |
||
254 | |||
255 | return '<a href="' . $url . '" class="showLink">' . _t('Post.SHOWLINK', 'Show Thread') . "</a>"; |
||
256 | } |
||
257 | |||
258 | /** |
||
259 | * Return a link to mark this post as spam. |
||
260 | * used for the spamprotection module |
||
261 | * |
||
262 | * @return String |
||
263 | */ |
||
264 | public function MarkAsSpamLink() |
||
265 | { |
||
266 | if ($this->Thread()->canModerate()) { |
||
0 ignored issues
–
show
The method
Thread does not exist on object<Post> ? 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 { }
![]() |
|||
267 | $member = Member::currentUser(); |
||
268 | if ($member->ID != $this->AuthorID) { |
||
0 ignored issues
–
show
The property
AuthorID does not exist on object<Post> . 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. ![]() |
|||
269 | $url = Controller::join_links($this->Forum()->Link('markasspam'), $this->ID); |
||
0 ignored issues
–
show
The method
Forum does not exist on object<Post> ? 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 { }
![]() |
|||
270 | $token = SecurityToken::inst(); |
||
271 | $url = $token->addToUrl($url); |
||
272 | |||
273 | $firstPost = ($this->isFirstPost()) ? ' firstPost' : ''; |
||
274 | |||
275 | return '<a href="' . $url .'" class="markAsSpamLink' . $firstPost . '" rel="' . $this->ID . '">'. _t('Post.MARKASSPAM', 'Mark as Spam') . '</a>'; |
||
276 | } |
||
277 | } |
||
278 | return false; |
||
279 | } |
||
280 | |||
281 | View Code Duplication | public function BanLink() |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
282 | { |
||
283 | $thread = $this->Thread(); |
||
0 ignored issues
–
show
The method
Thread does not exist on object<Post> ? 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 { }
![]() |
|||
284 | if ($thread->canModerate()) { |
||
285 | $link = $thread->Forum()->Link('ban') .'/'. $this->AuthorID; |
||
0 ignored issues
–
show
The property
AuthorID does not exist on object<Post> . 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. ![]() |
|||
286 | return "<a class='banLink' href=\"$link\" rel=\"$this->AuthorID\">". _t('Post.BANUSER', 'Ban User') ."</a>"; |
||
0 ignored issues
–
show
The property
AuthorID does not exist on object<Post> . 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. ![]() |
|||
287 | } |
||
288 | return false; |
||
289 | } |
||
290 | |||
291 | View Code Duplication | public function GhostLink() |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
292 | { |
||
293 | $thread = $this->Thread(); |
||
0 ignored issues
–
show
The method
Thread does not exist on object<Post> ? 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 { }
![]() |
|||
294 | if ($thread->canModerate()) { |
||
295 | $link = $thread->Forum()->Link('ghost') .'/'. $this->AuthorID; |
||
0 ignored issues
–
show
The property
AuthorID does not exist on object<Post> . 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. ![]() |
|||
296 | return "<a class='ghostLink' href=\"$link\" rel=\"$this->AuthorID\">". _t('Post.GHOSTUSER', 'Ghost User') ."</a>"; |
||
0 ignored issues
–
show
The property
AuthorID does not exist on object<Post> . 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. ![]() |
|||
297 | } |
||
298 | return false; |
||
299 | } |
||
300 | |||
301 | /** |
||
302 | * Return the parsed content and the information for the |
||
303 | * RSS feed |
||
304 | */ |
||
305 | public function getRSSContent() |
||
306 | { |
||
307 | return $this->renderWith('Includes/Post_rss'); |
||
308 | } |
||
309 | |||
310 | |||
311 | public function getRSSAuthor() |
||
312 | { |
||
313 | $author = $this->Author(); |
||
0 ignored issues
–
show
|
|||
314 | |||
315 | return $author->Nickname; |
||
316 | } |
||
317 | |||
318 | /** |
||
319 | * Return a link to show this post |
||
320 | * |
||
321 | * @return String |
||
322 | */ |
||
323 | public function Link($action = "show") |
||
324 | { |
||
325 | // only include the forum thread ID in the URL if we're showing the thread either |
||
326 | // by showing the posts or replying therwise we only need to pass a single ID. |
||
327 | $includeThreadID = ($action == "show" || $action == "reply") ? true : false; |
||
328 | $link = $this->Thread()->Link($action, $includeThreadID); |
||
0 ignored issues
–
show
The method
Thread does not exist on object<Post> ? 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 { }
![]() |
|||
329 | |||
330 | // calculate what page results the post is on |
||
331 | // the count is the position of the post in the thread |
||
332 | $count = DB::query(" |
||
333 | SELECT COUNT(\"ID\") |
||
334 | FROM \"Post\" |
||
335 | WHERE \"ThreadID\" = '$this->ThreadID' AND \"Status\" = 'Moderated' AND \"ID\" < $this->ID |
||
0 ignored issues
–
show
The property
ThreadID does not exist on object<Post> . 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. ![]() |
|||
336 | ")->value(); |
||
337 | |||
338 | $start = ($count >= Forum::$posts_per_page) ? floor($count / Forum::$posts_per_page) * Forum::$posts_per_page : 0; |
||
0 ignored issues
–
show
The property
posts_per_page cannot be accessed from this context as it is declared private in class Forum .
This check looks for access to properties that are not accessible from the current context. If you need to make a property accessible to another context you can either raise its visibility level or provide an accessible getter in the defining class. ![]() |
|||
339 | $pos = ($start == 0 ? '' : "?start=$start") . ($count == 0 ? '' : "#post{$this->ID}"); |
||
340 | |||
341 | return ($action == "show") ? $link . $pos : $link; |
||
342 | } |
||
343 | } |
||
344 | |||
345 | /** |
||
346 | * Attachments for posts (one post can have many attachments) |
||
347 | * |
||
348 | * @package forum |
||
349 | */ |
||
350 | class Post_Attachment extends File |
||
351 | { |
||
352 | |||
353 | private static $has_one = array( |
||
0 ignored issues
–
show
|
|||
354 | "Post" => "Post" |
||
355 | ); |
||
356 | |||
357 | private static $defaults = array( |
||
0 ignored issues
–
show
|
|||
358 | 'ShowInSearch' => 0 |
||
359 | ); |
||
360 | |||
361 | /** |
||
362 | * Can a user delete this attachment |
||
363 | * |
||
364 | * @return bool |
||
365 | */ |
||
366 | public function canDelete($member = null) |
||
367 | { |
||
368 | if (!$member) { |
||
369 | $member = Member::currentUser(); |
||
370 | } |
||
371 | return ($this->Post()) ? $this->Post()->canDelete($member) : true; |
||
0 ignored issues
–
show
The method
Post does not exist on object<Post_Attachment> ? 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 { }
![]() |
|||
372 | } |
||
373 | |||
374 | /** |
||
375 | * Can a user edit this attachement |
||
376 | * |
||
377 | * @return bool |
||
378 | */ |
||
379 | public function canEdit($member = null) |
||
380 | { |
||
381 | if (!$member) { |
||
382 | $member = Member::currentUser(); |
||
383 | } |
||
384 | return ($this->Post()) ? $this->Post()->canEdit($member) : true; |
||
0 ignored issues
–
show
The method
Post does not exist on object<Post_Attachment> ? 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 { }
![]() |
|||
385 | } |
||
386 | |||
387 | /** |
||
388 | * Allows the user to download a file without right-clicking |
||
389 | */ |
||
390 | public function download() |
||
391 | { |
||
392 | if (isset($this->urlParams['ID'])) { |
||
0 ignored issues
–
show
The property
urlParams does not exist on object<Post_Attachment> . 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. ![]() |
|||
393 | $SQL_ID = Convert::raw2sql($this->urlParams['ID']); |
||
0 ignored issues
–
show
The property
urlParams does not exist on object<Post_Attachment> . 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. ![]() |
|||
394 | |||
395 | if (is_numeric($SQL_ID)) { |
||
396 | $file = DataObject::get_by_id("Post_Attachment", $SQL_ID); |
||
397 | $response = SS_HTTPRequest::send_file(file_get_contents($file->getFullPath()), $file->Name); |
||
398 | $response->output(); |
||
399 | } |
||
400 | } |
||
401 | |||
402 | return $this->redirectBack(); |
||
0 ignored issues
–
show
The method
redirectBack does not exist on object<Post_Attachment> ? 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 { }
![]() |
|||
403 | } |
||
404 | } |
||
405 |