@@ -196,35 +196,52 @@ discard block |
||
196 | 196 | { |
197 | 197 | $schedMmodes=array("daily","weekly","monthly","annually"); |
198 | 198 | |
199 | - if (in_array($scheduleMode, $schedMmodes)) return TRUE; else return FALSE; |
|
199 | + if (in_array($scheduleMode, $schedMmodes)) { |
|
200 | + return TRUE; |
|
201 | + } else { |
|
202 | + return FALSE; |
|
203 | + } |
|
200 | 204 | } |
201 | 205 | |
202 | 206 | public static function validateScheduleEnable($scheduleEnabled) |
203 | 207 | { |
204 | 208 | $schedEnambles=array(TRUE,FALSE); |
205 | 209 | |
206 | - if (in_array($scheduleEnabled, $schedEnambles)) return TRUE; else return FALSE; |
|
210 | + if (in_array($scheduleEnabled, $schedEnambles)) { |
|
211 | + return TRUE; |
|
212 | + } else { |
|
213 | + return FALSE; |
|
214 | + } |
|
207 | 215 | } |
208 | 216 | |
209 | 217 | public static function validateScheduleEvery($scheduleEvery) |
210 | 218 | { |
211 | - if (is_numeric($scheduleEvery)) return TRUE; else return FALSE; |
|
219 | + if (is_numeric($scheduleEvery)) { |
|
220 | + return TRUE; |
|
221 | + } else { |
|
222 | + return FALSE; |
|
223 | + } |
|
212 | 224 | } |
213 | 225 | |
214 | 226 | public static function validateScheduleWeekDays($scheduleWeekDays) |
215 | 227 | { |
216 | 228 | $weekdays = explode(',', $scheduleWeekDays); |
217 | 229 | |
218 | - if (sizeof($weekdays)<1) return FALSE; |
|
230 | + if (sizeof($weekdays)<1) { |
|
231 | + return FALSE; |
|
232 | + } |
|
219 | 233 | |
220 | 234 | $isValid=TRUE; |
221 | 235 | |
222 | 236 | for ($i=0; $i < sizeof($weekdays); $i++) { |
223 | 237 | if (is_numeric($weekdays[$i])) { |
224 | 238 | $wday=intval($weekdays[$i]); |
225 | - if ($wday<1 || $wday>7) $isValid=FALSE; |
|
239 | + if ($wday<1 || $wday>7) { |
|
240 | + $isValid=FALSE; |
|
241 | + } |
|
242 | + } else { |
|
243 | + $isValid=FALSE; |
|
226 | 244 | } |
227 | - else $isValid=FALSE; |
|
228 | 245 | } |
229 | 246 | //echo $scheduleWeekDays.' --- '. $isValid."<br>"; |
230 | 247 | return $isValid; |
@@ -234,23 +251,32 @@ discard block |
||
234 | 251 | { |
235 | 252 | $schedMonthlyMmodes=array("dates","nth"); |
236 | 253 | |
237 | - if (in_array($scheduleMonthlyMode, $schedMonthlyMmodes)) return TRUE; else return FALSE; |
|
254 | + if (in_array($scheduleMonthlyMode, $schedMonthlyMmodes)) { |
|
255 | + return TRUE; |
|
256 | + } else { |
|
257 | + return FALSE; |
|
258 | + } |
|
238 | 259 | } |
239 | 260 | |
240 | 261 | public static function validateScheduleMonthlyDates($scheduleMonthlyDates) |
241 | 262 | { |
242 | 263 | $monthlyDates = explode(',', $scheduleMonthlyDates); |
243 | 264 | |
244 | - if (sizeof($monthlyDates)<1) return FALSE; |
|
265 | + if (sizeof($monthlyDates)<1) { |
|
266 | + return FALSE; |
|
267 | + } |
|
245 | 268 | |
246 | 269 | $isValid=TRUE; |
247 | 270 | |
248 | 271 | for ($i=0; $i < sizeof($monthlyDates); $i++) { |
249 | 272 | if (is_numeric($monthlyDates[$i])) { |
250 | 273 | $mday=intval($monthlyDates[$i]); |
251 | - if ($mday<1 || $mday>31) $isValid=FALSE; |
|
274 | + if ($mday<1 || $mday>31) { |
|
275 | + $isValid=FALSE; |
|
276 | + } |
|
277 | + } else { |
|
278 | + $isValid=FALSE; |
|
252 | 279 | } |
253 | - else $isValid=FALSE; |
|
254 | 280 | } |
255 | 281 | |
256 | 282 | return $isValid; |
@@ -258,18 +284,30 @@ discard block |
||
258 | 284 | |
259 | 285 | public static function validateScheduleNthN($scheduleNthN) |
260 | 286 | { |
261 | - if (!is_numeric($scheduleNthN)) return FALSE; |
|
287 | + if (!is_numeric($scheduleNthN)) { |
|
288 | + return FALSE; |
|
289 | + } |
|
262 | 290 | |
263 | 291 | $schedNthNs=array(1,2,3,4,5,-1); |
264 | - if (in_array($scheduleNthN, $schedNthNs)) return TRUE; else return FALSE; |
|
292 | + if (in_array($scheduleNthN, $schedNthNs)) { |
|
293 | + return TRUE; |
|
294 | + } else { |
|
295 | + return FALSE; |
|
296 | + } |
|
265 | 297 | } |
266 | 298 | |
267 | 299 | public static function validateScheduleNthWhat($scheduleNthWhat) |
268 | 300 | { |
269 | - if (!is_numeric($scheduleNthWhat)) return FALSE; |
|
301 | + if (!is_numeric($scheduleNthWhat)) { |
|
302 | + return FALSE; |
|
303 | + } |
|
270 | 304 | |
271 | 305 | $schedNthWhats=array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); |
272 | - if (in_array($scheduleNthWhat, $schedNthWhats)) return TRUE; else return FALSE; |
|
306 | + if (in_array($scheduleNthWhat, $schedNthWhats)) { |
|
307 | + return TRUE; |
|
308 | + } else { |
|
309 | + return FALSE; |
|
310 | + } |
|
273 | 311 | } |
274 | 312 | |
275 | 313 | /* Function adds the locations (with/without schedule) from the CSV file. |
@@ -302,16 +340,13 @@ discard block |
||
302 | 340 | if ($this->validateScheduleMode($rows[$locationsFieldsMapping['schedule_mode']])) { |
303 | 341 | $curSchedule='"mode":"'.$rows[$locationsFieldsMapping['schedule_mode']].'",'; |
304 | 342 | $mode=$rows[$locationsFieldsMapping['schedule_mode']]; |
305 | - } |
|
306 | - else {array_push($results['fail'],"$iRow --> Wrong schedule mode parameter"); $curSchedule="";} |
|
307 | - } |
|
308 | - else {array_push($results['fail'],"$iRow --> The schedule mode parameter is not set"); $curSchedule="";} |
|
343 | + } else {array_push($results['fail'],"$iRow --> Wrong schedule mode parameter"); $curSchedule="";} |
|
344 | + } else {array_push($results['fail'],"$iRow --> The schedule mode parameter is not set"); $curSchedule="";} |
|
309 | 345 | |
310 | 346 | if (isset($rows[$locationsFieldsMapping['schedule_enabled']])) { |
311 | 347 | if ($this->validateScheduleEnable($rows[$locationsFieldsMapping['schedule_enabled']])) { |
312 | 348 | $curSchedule.='"enabled":'.$rows[$locationsFieldsMapping['schedule_enabled']].','; |
313 | - } |
|
314 | - else {array_push($results['fail'],"$iRow --> The schedule enabled parameter is not set "); $curSchedule="";} |
|
349 | + } else {array_push($results['fail'],"$iRow --> The schedule enabled parameter is not set "); $curSchedule="";} |
|
315 | 350 | } |
316 | 351 | |
317 | 352 | if (isset($rows[$locationsFieldsMapping['schedule_every']])) { |
@@ -321,8 +356,7 @@ discard block |
||
321 | 356 | $curSchedule=trim($curSchedule,','); |
322 | 357 | $curSchedule.='}'; |
323 | 358 | } |
324 | - } |
|
325 | - else {array_push($results['fail'],"$iRow --> The parameter sched_every is not set"); $curSchedule=""; } |
|
359 | + } else {array_push($results['fail'],"$iRow --> The parameter sched_every is not set"); $curSchedule=""; } |
|
326 | 360 | } |
327 | 361 | |
328 | 362 | if ($mode!='daily') { |
@@ -331,10 +365,8 @@ discard block |
||
331 | 365 | if (isset($rows[$locationsFieldsMapping['schedule_weekdays']])) { |
332 | 366 | if ($this->validateScheduleWeekDays($rows[$locationsFieldsMapping['schedule_weekdays']])) { |
333 | 367 | $curSchedule.='"weekdays":['.$rows[$locationsFieldsMapping['schedule_weekdays']].']}'; |
334 | - } |
|
335 | - else {array_push($results['fail'],"$iRow --> Wrong weekdays"); $curSchedule="";} |
|
336 | - } |
|
337 | - else {array_push($results['fail'],"$iRow --> The parameters sched_weekdays is not set"); $curSchedule="";} |
|
368 | + } else {array_push($results['fail'],"$iRow --> Wrong weekdays"); $curSchedule="";} |
|
369 | + } else {array_push($results['fail'],"$iRow --> The parameters sched_weekdays is not set"); $curSchedule="";} |
|
338 | 370 | break; |
339 | 371 | case 'monthly': |
340 | 372 | $monthlyMode=""; |
@@ -342,10 +374,8 @@ discard block |
||
342 | 374 | if ($this->validateScheduleMonthlyMode($rows[$locationsFieldsMapping['monthly_mode']])) { |
343 | 375 | $monthlyMode=$rows[$locationsFieldsMapping['monthly_mode']]; |
344 | 376 | $curSchedule.='"mode": "'.$rows[$locationsFieldsMapping['monthly_mode']].'",'; |
345 | - } |
|
346 | - else {array_push($results['fail'],"$iRow --> Wrong monthly mode"); $curSchedule="";} |
|
347 | - } |
|
348 | - else {array_push($results['fail'],"$iRow --> The parameter sched_monthly_mode is not set"); $curSchedule="";} |
|
377 | + } else {array_push($results['fail'],"$iRow --> Wrong monthly mode"); $curSchedule="";} |
|
378 | + } else {array_push($results['fail'],"$iRow --> The parameter sched_monthly_mode is not set"); $curSchedule="";} |
|
349 | 379 | |
350 | 380 | if ($monthlyMode!="") { |
351 | 381 | switch ($monthlyMode) { |
@@ -353,27 +383,22 @@ discard block |
||
353 | 383 | if (isset($rows[$locationsFieldsMapping['monthly_dates']])) { |
354 | 384 | if ($this->validateScheduleMonthlyDates($rows[$locationsFieldsMapping['monthly_dates']])) { |
355 | 385 | $curSchedule.='"dates":['.$rows[$locationsFieldsMapping['monthly_dates']].']}'; |
356 | - } |
|
357 | - else {array_push($results['fail'],"$iRow --> Wrong monthly dates"); $curSchedule="";} |
|
386 | + } else {array_push($results['fail'],"$iRow --> Wrong monthly dates"); $curSchedule="";} |
|
358 | 387 | } |
359 | 388 | break; |
360 | 389 | case 'nth': |
361 | 390 | if (isset($rows[$locationsFieldsMapping['monthly_nth_n']])) { |
362 | 391 | if ($this->validateScheduleNthN($rows[$locationsFieldsMapping['monthly_nth_n']])) { |
363 | 392 | $curSchedule.='"nth":{"n":'.$rows[$locationsFieldsMapping['monthly_nth_n']].','; |
364 | - } |
|
365 | - else {array_push($results['fail'],"$iRow --> Wrong parameter sched_nth_n"); $curSchedule="";} |
|
366 | - } |
|
367 | - else {array_push($results['fail'],"$iRow --> The parameter sched_nth_n is not set"); $curSchedule="";} |
|
393 | + } else {array_push($results['fail'],"$iRow --> Wrong parameter sched_nth_n"); $curSchedule="";} |
|
394 | + } else {array_push($results['fail'],"$iRow --> The parameter sched_nth_n is not set"); $curSchedule="";} |
|
368 | 395 | |
369 | 396 | if ($curSchedule!="") { |
370 | 397 | if (isset($rows[$locationsFieldsMapping['monthly_nth_wwhat']])) { |
371 | 398 | if ($this->validateScheduleNthWhat($rows[$locationsFieldsMapping['monthly_nth_wwhat']])) { |
372 | 399 | $curSchedule.='"what":'.$rows[$locationsFieldsMapping['monthly_nth_wwhat']].'}}'; |
373 | - } |
|
374 | - else {array_push($results['fail'],"$iRow --> Wrong parameter sched_nth_what"); $curSchedule="";} |
|
375 | - } |
|
376 | - else {array_push($results['fail'],"$iRow --> The parameter sched_nth_what is not set"); $curSchedule="";} |
|
400 | + } else {array_push($results['fail'],"$iRow --> Wrong parameter sched_nth_what"); $curSchedule="";} |
|
401 | + } else {array_push($results['fail'],"$iRow --> The parameter sched_nth_what is not set"); $curSchedule="";} |
|
377 | 402 | } |
378 | 403 | |
379 | 404 | break; |