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 ElggQuestion extends ElggObject { |
||
4 | |||
5 | const SUBTYPE = 'question'; |
||
6 | |||
7 | /** |
||
8 | * (non-PHPdoc) |
||
9 | * @see ElggObject::initializeAttributes() |
||
10 | */ |
||
11 | protected function initializeAttributes() { |
||
12 | parent::initializeAttributes(); |
||
13 | |||
14 | $this->attributes['subtype'] = self::SUBTYPE; |
||
15 | } |
||
16 | |||
17 | /** |
||
18 | * (non-PHPdoc) |
||
19 | * @see ElggEntity::getURL() |
||
20 | */ |
||
21 | public function getURL() { |
||
22 | $url = "questions/view/{$this->getGUID()}/" . elgg_get_friendly_title($this->title); |
||
23 | |||
24 | return elgg_normalize_url($url); |
||
25 | } |
||
26 | |||
27 | /** |
||
28 | * (non-PHPdoc) |
||
29 | * @see ElggObject::canComment() |
||
30 | */ |
||
31 | public function canComment($user_guid = 0) { |
||
32 | |||
33 | if ($this->comments_enabled === 'off') { |
||
0 ignored issues
–
show
|
|||
34 | return false; |
||
35 | } |
||
36 | |||
37 | return parent::canComment($user_guid); |
||
38 | } |
||
39 | |||
40 | /** |
||
41 | * Get the answers on this question |
||
42 | * |
||
43 | * @param array $options accepts all elgg_get_entities options |
||
44 | * |
||
45 | * @return false|int|ElggAnswer[] |
||
46 | */ |
||
47 | public function getAnswers(array $options = array()) { |
||
48 | $defaults = [ |
||
49 | 'order_by' => 'time_created asc', |
||
50 | ]; |
||
51 | |||
52 | $overrides = [ |
||
53 | 'type' => 'object', |
||
54 | 'subtype' => 'answer', |
||
55 | 'container_guid' => $this->getGUID(), |
||
56 | ]; |
||
57 | |||
58 | $options = array_merge($defaults, $options, $overrides); |
||
59 | |||
60 | return elgg_get_entities($options); |
||
61 | } |
||
62 | |||
63 | /** |
||
64 | * List the answers on this question |
||
65 | * |
||
66 | * @param array $options accepts all elgg_list_entities options |
||
67 | * |
||
68 | * @return string |
||
69 | */ |
||
70 | public function listAnswers(array $options = []) { |
||
71 | return elgg_list_entities($options, [$this, 'getAnswers']); |
||
72 | } |
||
73 | |||
74 | /** |
||
75 | * Get the answer that was marked as the correct answer. |
||
76 | * |
||
77 | * @return fasle|ElggAnswer |
||
78 | */ |
||
79 | public function getMarkedAnswer() { |
||
80 | $result = false; |
||
81 | |||
82 | $options = [ |
||
83 | 'type' => 'object', |
||
84 | 'subtype' => ElggAnswer::SUBTYPE, |
||
85 | 'limit' => 1, |
||
86 | 'container_guid' => $this->getGUID(), |
||
87 | 'metadata_name_value_pairs' => array( |
||
88 | 'name' => 'correct_answer', |
||
89 | 'value' => true |
||
90 | ) |
||
91 | ]; |
||
92 | |||
93 | $answers = elgg_get_entities_from_metadata($options); |
||
94 | if (!empty($answers)) { |
||
95 | $result = $answers[0]; |
||
96 | } |
||
97 | |||
98 | return $result; |
||
99 | } |
||
100 | |||
101 | /** |
||
102 | * Helper function to close a question from further answers. |
||
103 | * |
||
104 | * @return void |
||
105 | */ |
||
106 | public function close() { |
||
107 | $this->status = 'closed'; |
||
108 | } |
||
109 | |||
110 | /** |
||
111 | * Reopen the question for more answers. |
||
112 | * |
||
113 | * @return void |
||
114 | */ |
||
115 | public function reopen() { |
||
116 | $this->status = 'open'; |
||
117 | } |
||
118 | |||
119 | /** |
||
120 | * Get the current status of the question. |
||
121 | * |
||
122 | * This can be |
||
123 | * - 'open' |
||
124 | * - 'closed' |
||
125 | * |
||
126 | * @return string the current status |
||
127 | */ |
||
128 | public function getStatus() { |
||
129 | $result = 'open'; |
||
130 | |||
131 | // do we even support status |
||
132 | if (questions_close_on_marked_answer()) { |
||
133 | // make sure the status is correct |
||
134 | switch ($this->status) { |
||
135 | case 'open': |
||
136 | // is it still open, so no marked answer |
||
137 | if ($this->getMarkedAnswer()) { |
||
138 | $result = 'closed'; |
||
139 | } |
||
140 | break; |
||
141 | case 'closed': |
||
142 | $result = 'closed'; |
||
143 | // is it still open, so no marked answer |
||
144 | if (!$this->getMarkedAnswer()) { |
||
145 | $result = 'open'; |
||
146 | } |
||
147 | break; |
||
148 | default: |
||
149 | // no setting yet |
||
150 | if ($this->getMarkedAnswer()) { |
||
151 | $result = 'closed'; |
||
152 | } |
||
153 | break; |
||
154 | } |
||
155 | } |
||
156 | |||
157 | return $result; |
||
158 | } |
||
159 | } |
||
160 |
An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.
If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.