Conditions | 10 |
Paths | 18 |
Total Lines | 133 |
Code Lines | 62 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 1 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
174 | public function getReminders() { |
||
175 | $data = []; |
||
176 | |||
177 | $store = $GLOBALS["mapisession"]->getDefaultMessageStore(); |
||
178 | |||
179 | $restriction = [RES_AND, |
||
180 | [ |
||
181 | [RES_PROPERTY, |
||
182 | [ |
||
183 | RELOP => RELOP_LT, |
||
184 | ULPROPTAG => $this->properties["flagdueby"], |
||
185 | VALUE => [$this->properties["flagdueby"] => time()], |
||
186 | ], |
||
187 | ], |
||
188 | [RES_PROPERTY, |
||
189 | [ |
||
190 | RELOP => RELOP_EQ, |
||
191 | ULPROPTAG => $this->properties["reminder"], |
||
192 | VALUE => true, |
||
193 | ], |
||
194 | ], |
||
195 | [RES_PROPERTY, |
||
196 | [ |
||
197 | RELOP => RELOP_NE, |
||
198 | ULPROPTAG => $this->properties["message_class"], |
||
199 | VALUE => "IPM.TaskRequest", |
||
200 | ], |
||
201 | ], |
||
202 | [RES_PROPERTY, |
||
203 | [ |
||
204 | RELOP => RELOP_NE, |
||
205 | ULPROPTAG => $this->properties["message_class"], |
||
206 | VALUE => "IPM.TaskRequest.Cancel", |
||
207 | ], |
||
208 | ], |
||
209 | [RES_PROPERTY, |
||
210 | [ |
||
211 | RELOP => RELOP_NE, |
||
212 | ULPROPTAG => $this->properties["message_class"], |
||
213 | VALUE => "IPM.TaskRequest.Accept", |
||
214 | ], |
||
215 | ], |
||
216 | [RES_PROPERTY, |
||
217 | [ |
||
218 | RELOP => RELOP_NE, |
||
219 | ULPROPTAG => $this->properties["message_class"], |
||
220 | VALUE => "IPM.TaskRequest.Update", |
||
221 | ], |
||
222 | ], |
||
223 | [RES_PROPERTY, |
||
224 | [ |
||
225 | RELOP => RELOP_NE, |
||
226 | ULPROPTAG => $this->properties["message_class"], |
||
227 | VALUE => "IPM.TaskRequest.Complete", |
||
228 | ], |
||
229 | ], |
||
230 | ], |
||
231 | ]; |
||
232 | |||
233 | try { |
||
234 | $reminderfolder = mapi_msgstore_openentry($store, $this->reminderEntryId); |
||
235 | } |
||
236 | catch (MAPIException $e) { |
||
237 | // if the reminder folder does not exist, try to recreate it. |
||
238 | if ($e->getCode() == MAPI_E_NOT_FOUND) { |
||
239 | $e->setHandled(); |
||
240 | |||
241 | $this->reminderEntryId = $this->createReminderFolder($store); |
||
242 | $reminderfolder = mapi_msgstore_openentry($store, $this->reminderEntryId); |
||
243 | } |
||
244 | } |
||
245 | |||
246 | $remindertable = mapi_folder_getcontentstable($reminderfolder, MAPI_DEFERRED_ERRORS); |
||
247 | if (!$remindertable) { |
||
248 | return false; |
||
249 | } |
||
250 | |||
251 | mapi_table_restrict($remindertable, $restriction, TBL_BATCH); |
||
252 | mapi_table_sort($remindertable, [$this->properties["flagdueby"] => TABLE_SORT_DESCEND], TBL_BATCH); |
||
253 | |||
254 | // reminder store hold only 99 records as |
||
255 | // we show 99 notification on client side. |
||
256 | $rows = mapi_table_queryrows($remindertable, $this->properties, 0, MAX_NUM_REMINDERS); |
||
257 | $data["item"] = []; |
||
258 | |||
259 | foreach ($rows as $row) { |
||
260 | if (isset($row[$this->properties["appointment_recurring"]]) && $row[$this->properties["appointment_recurring"]]) { |
||
261 | $recur = new Recurrence($store, $row); |
||
262 | |||
263 | /** |
||
264 | * FlagDueBy == PidLidReminderSignalTime. |
||
265 | * FlagDueBy handles whether we should be showing the item; if now() is after FlagDueBy, then we should show a reminder |
||
266 | * for this recurrence. However, the item we will show is either the last passed occurrence (overdue), or the next occurrence, depending |
||
267 | * on whether we have reached the next occurrence yet (the reminder_time of the next item is ignored). |
||
268 | * |
||
269 | * The way we handle this is to get all occurrences between the 'flagdueby' moment and the current time. This will |
||
270 | * yield N items (may be a lot of it was not dismissed for a long time). We can then take the last item in this list, and this is the item |
||
271 | * we will show to the user. The idea here is: |
||
272 | * |
||
273 | * The item we want to show is the last item in that list (new occurrences that have started uptil now should override old ones) |
||
274 | * |
||
275 | * Add the reminder_minutes (default 15 minutes for calendar, 0 for tasks) to check over the gap between FlagDueBy and the start time of the |
||
276 | * occurrence, if "now" would be in between these values. |
||
277 | */ |
||
278 | $remindertimeinseconds = $row[$this->properties["reminder_minutes"]] * 60; |
||
279 | $occurrences = $recur->getItems($row[$this->properties["flagdueby"]], time() + $remindertimeinseconds, 0, true); |
||
280 | |||
281 | if (empty($occurrences)) { |
||
282 | continue; |
||
283 | } |
||
284 | |||
285 | // More than one occurrence, use the last one instead of the first one after flagdueby |
||
286 | $occ = $occurrences[count($occurrences) - 1]; |
||
287 | |||
288 | // Bydefault, on occurrence reminder is true but if reminder value is set to false then we don't send popup reminder for this occurrence |
||
289 | if (!(isset($occ[$this->properties['reminder']]) && $occ[$this->properties['reminder']] == 0)) { |
||
290 | $row[$this->properties["reminder_time"]] = $occ[$this->properties["appointment_startdate"]]; |
||
291 | $row[$this->properties["appointment_startdate"]] = $occ[$this->properties["appointment_startdate"]]; |
||
292 | $row[$this->properties["appointment_enddate"]] = $occ[$this->properties["appointment_startdate"]]; |
||
293 | } |
||
294 | } |
||
295 | |||
296 | // Add the non-bogus rows |
||
297 | array_push($data["item"], Conversion::mapMAPI2XML($this->properties, $row)); |
||
298 | } |
||
299 | |||
300 | $this->addActionData("list", $data); |
||
301 | $GLOBALS["bus"]->addData($this->getResponseData()); |
||
302 | |||
303 | // Trigger the newmailnotifier |
||
304 | $GLOBALS["bus"]->notify(REQUEST_ENTRYID, HIERARCHY_UPDATE, ['', '']); |
||
305 | |||
306 | return true; |
||
307 | } |
||
309 |
This check looks for function or method calls that always return null and whose return value is used.
The method
getObject()
can return nothing but null, so it makes no sense to use the return value.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.