@@ -197,35 +197,52 @@ discard block |
||
197 | 197 | { |
198 | 198 | $schedMmodes=array("daily","weekly","monthly","annually"); |
199 | 199 | |
200 | - if (in_array($scheduleMode, $schedMmodes)) return TRUE; else return FALSE; |
|
200 | + if (in_array($scheduleMode, $schedMmodes)) { |
|
201 | + return TRUE; |
|
202 | + } else { |
|
203 | + return FALSE; |
|
204 | + } |
|
201 | 205 | } |
202 | 206 | |
203 | 207 | public static function validateScheduleEnable($scheduleEnabled) |
204 | 208 | { |
205 | 209 | $schedEnambles=array(TRUE,FALSE); |
206 | 210 | |
207 | - if (in_array($scheduleEnabled, $schedEnambles)) return TRUE; else return FALSE; |
|
211 | + if (in_array($scheduleEnabled, $schedEnambles)) { |
|
212 | + return TRUE; |
|
213 | + } else { |
|
214 | + return FALSE; |
|
215 | + } |
|
208 | 216 | } |
209 | 217 | |
210 | 218 | public static function validateScheduleEvery($scheduleEvery) |
211 | 219 | { |
212 | - if (is_numeric($scheduleEvery)) return TRUE; else return FALSE; |
|
220 | + if (is_numeric($scheduleEvery)) { |
|
221 | + return TRUE; |
|
222 | + } else { |
|
223 | + return FALSE; |
|
224 | + } |
|
213 | 225 | } |
214 | 226 | |
215 | 227 | public static function validateScheduleWeekDays($scheduleWeekDays) |
216 | 228 | { |
217 | 229 | $weekdays = explode(',', $scheduleWeekDays); |
218 | 230 | |
219 | - if (sizeof($weekdays)<1) return FALSE; |
|
231 | + if (sizeof($weekdays)<1) { |
|
232 | + return FALSE; |
|
233 | + } |
|
220 | 234 | |
221 | 235 | $isValid=TRUE; |
222 | 236 | |
223 | 237 | for ($i=0; $i < sizeof($weekdays); $i++) { |
224 | 238 | if (is_numeric($weekdays[$i])) { |
225 | 239 | $wday=intval($weekdays[$i]); |
226 | - if ($wday<1 || $wday>7) $isValid=FALSE; |
|
240 | + if ($wday<1 || $wday>7) { |
|
241 | + $isValid=FALSE; |
|
242 | + } |
|
243 | + } else { |
|
244 | + $isValid=FALSE; |
|
227 | 245 | } |
228 | - else $isValid=FALSE; |
|
229 | 246 | } |
230 | 247 | //echo $scheduleWeekDays.' --- '. $isValid."<br>"; |
231 | 248 | return $isValid; |
@@ -235,23 +252,32 @@ discard block |
||
235 | 252 | { |
236 | 253 | $schedMonthlyMmodes=array("dates","nth"); |
237 | 254 | |
238 | - if (in_array($scheduleMonthlyMode, $schedMonthlyMmodes)) return TRUE; else return FALSE; |
|
255 | + if (in_array($scheduleMonthlyMode, $schedMonthlyMmodes)) { |
|
256 | + return TRUE; |
|
257 | + } else { |
|
258 | + return FALSE; |
|
259 | + } |
|
239 | 260 | } |
240 | 261 | |
241 | 262 | public static function validateScheduleMonthlyDates($scheduleMonthlyDates) |
242 | 263 | { |
243 | 264 | $monthlyDates = explode(',', $scheduleMonthlyDates); |
244 | 265 | |
245 | - if (sizeof($monthlyDates)<1) return FALSE; |
|
266 | + if (sizeof($monthlyDates)<1) { |
|
267 | + return FALSE; |
|
268 | + } |
|
246 | 269 | |
247 | 270 | $isValid=TRUE; |
248 | 271 | |
249 | 272 | for ($i=0; $i < sizeof($monthlyDates); $i++) { |
250 | 273 | if (is_numeric($monthlyDates[$i])) { |
251 | 274 | $mday=intval($monthlyDates[$i]); |
252 | - if ($mday<1 || $mday>31) $isValid=FALSE; |
|
275 | + if ($mday<1 || $mday>31) { |
|
276 | + $isValid=FALSE; |
|
277 | + } |
|
278 | + } else { |
|
279 | + $isValid=FALSE; |
|
253 | 280 | } |
254 | - else $isValid=FALSE; |
|
255 | 281 | } |
256 | 282 | //echo $scheduleMonthlyDates.' --- '. $isValid."<br>"; |
257 | 283 | return $isValid; |
@@ -259,18 +285,30 @@ discard block |
||
259 | 285 | |
260 | 286 | public static function validateScheduleNthN($scheduleNthN) |
261 | 287 | { |
262 | - if (!is_numeric($scheduleNthN)) return FALSE; |
|
288 | + if (!is_numeric($scheduleNthN)) { |
|
289 | + return FALSE; |
|
290 | + } |
|
263 | 291 | |
264 | 292 | $schedNthNs=array(1,2,3,4,5,-1); |
265 | - if (in_array($scheduleNthN, $schedNthNs)) return TRUE; else return FALSE; |
|
293 | + if (in_array($scheduleNthN, $schedNthNs)) { |
|
294 | + return TRUE; |
|
295 | + } else { |
|
296 | + return FALSE; |
|
297 | + } |
|
266 | 298 | } |
267 | 299 | |
268 | 300 | public static function validateScheduleNthWhat($scheduleNthWhat) |
269 | 301 | { |
270 | - if (!is_numeric($scheduleNthWhat)) return FALSE; |
|
302 | + if (!is_numeric($scheduleNthWhat)) { |
|
303 | + return FALSE; |
|
304 | + } |
|
271 | 305 | |
272 | 306 | $schedNthWhats=array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); |
273 | - if (in_array($scheduleNthWhat, $schedNthWhats)) return TRUE; else return FALSE; |
|
307 | + if (in_array($scheduleNthWhat, $schedNthWhats)) { |
|
308 | + return TRUE; |
|
309 | + } else { |
|
310 | + return FALSE; |
|
311 | + } |
|
274 | 312 | } |
275 | 313 | } |
276 | 314 |
@@ -46,18 +46,15 @@ discard block |
||
46 | 46 | if (AddressBookLocation::validateScheduleMode($rows[8])) { |
47 | 47 | $schedule='"mode":"'.$rows[8].'",'; |
48 | 48 | $mode=$rows[8]; |
49 | - } |
|
50 | - else {echo "$iRow --> Wrong schedule mode parameter <br>"; $schedule="";} |
|
51 | - } |
|
52 | - else {echo "$iRow --> The schedule mode parameter is not set <br>"; $schedule="";} |
|
49 | + } else {echo "$iRow --> Wrong schedule mode parameter <br>"; $schedule="";} |
|
50 | + } else {echo "$iRow --> The schedule mode parameter is not set <br>"; $schedule="";} |
|
53 | 51 | |
54 | 52 | if ($schedule=="") {$iRow++; continue;} |
55 | 53 | |
56 | 54 | if (isset($rows[9])) { |
57 | 55 | if (AddressBookLocation::validateScheduleEnable($rows[9])) { |
58 | 56 | $schedule.='"enabled":'.$rows[9].','; |
59 | - } |
|
60 | - else {echo "$iRow --> The schedule enabled parameter is not set <br>"; $schedule="";} |
|
57 | + } else {echo "$iRow --> The schedule enabled parameter is not set <br>"; $schedule="";} |
|
61 | 58 | } |
62 | 59 | |
63 | 60 | if ($schedule=="") {$iRow++; continue;} |
@@ -69,8 +66,7 @@ discard block |
||
69 | 66 | $schedule=trim($schedule,','); |
70 | 67 | $schedule.='}'; |
71 | 68 | } |
72 | - } |
|
73 | - else {echo "$iRow --> The parameter sched_every is not set <br>"; $schedule=""; } |
|
69 | + } else {echo "$iRow --> The parameter sched_every is not set <br>"; $schedule=""; } |
|
74 | 70 | } |
75 | 71 | |
76 | 72 | if ($schedule=="") {$iRow++; continue;} |
@@ -81,10 +77,8 @@ discard block |
||
81 | 77 | if (isset($rows[11])) { |
82 | 78 | if (AddressBookLocation::validateScheduleWeekDays($rows[11])) { |
83 | 79 | $schedule.='"weekdays":['.$rows[11].']}'; |
84 | - } |
|
85 | - else {echo "$iRow --> Wrong weekdays <br>";$schedule="";} |
|
86 | - } |
|
87 | - else {echo "$iRow --> The parameters sched_weekdays is not set <br>"; $schedule="";} |
|
80 | + } else {echo "$iRow --> Wrong weekdays <br>";$schedule="";} |
|
81 | + } else {echo "$iRow --> The parameters sched_weekdays is not set <br>"; $schedule="";} |
|
88 | 82 | break; |
89 | 83 | case 'monthly': |
90 | 84 | $monthlyMode=""; |
@@ -92,10 +86,8 @@ discard block |
||
92 | 86 | if (AddressBookLocation::validateScheduleMonthlyMode($rows[12])) { |
93 | 87 | $monthlyMode=$rows[12]; |
94 | 88 | $schedule.='"mode": "'.$rows[12].'",'; |
95 | - } |
|
96 | - else {echo "$iRow --> Wrong monthly mode <br>"; $schedule="";} |
|
97 | - } |
|
98 | - else {echo "$iRow --> The parameter sched_monthly_mode is not set <br>"; $schedule="";} |
|
89 | + } else {echo "$iRow --> Wrong monthly mode <br>"; $schedule="";} |
|
90 | + } else {echo "$iRow --> The parameter sched_monthly_mode is not set <br>"; $schedule="";} |
|
99 | 91 | |
100 | 92 | if ($monthlyMode!="") { |
101 | 93 | switch ($monthlyMode) { |
@@ -103,27 +95,22 @@ discard block |
||
103 | 95 | if (isset($rows[13])) { |
104 | 96 | if (AddressBookLocation::validateScheduleMonthlyDates($rows[13])) { |
105 | 97 | $schedule.='"dates":['.$rows[13].']}'; |
106 | - } |
|
107 | - else {echo "$iRow --> Wrong monthly dates <br>"; $schedule="";} |
|
98 | + } else {echo "$iRow --> Wrong monthly dates <br>"; $schedule="";} |
|
108 | 99 | } |
109 | 100 | break; |
110 | 101 | case 'nth': |
111 | 102 | if (isset($rows[16])) { |
112 | 103 | if (AddressBookLocation::validateScheduleNthN($rows[16])) { |
113 | 104 | $schedule.='"nth":{"n":'.$rows[16].','; |
114 | - } |
|
115 | - else {echo "$iRow --> Wrong parameter sched_nth_n <br>"; $schedule="";} |
|
116 | - } |
|
117 | - else {echo "$iRow --> The parameter sched_nth_n is not set <br>"; $schedule="";} |
|
105 | + } else {echo "$iRow --> Wrong parameter sched_nth_n <br>"; $schedule="";} |
|
106 | + } else {echo "$iRow --> The parameter sched_nth_n is not set <br>"; $schedule="";} |
|
118 | 107 | |
119 | 108 | if ($schedule!="") { |
120 | 109 | if (isset($rows[17])) { |
121 | 110 | if (AddressBookLocation::validateScheduleNthWhat($rows[17])) { |
122 | 111 | $schedule.='"what":'.$rows[17].'}}'; |
123 | - } |
|
124 | - else {echo "$iRow --> Wrong parameter sched_nth_what <br>"; $schedule="";} |
|
125 | - } |
|
126 | - else {echo "$iRow --> The parameter sched_nth_what is not set <br>"; $schedule="";} |
|
112 | + } else {echo "$iRow --> Wrong parameter sched_nth_what <br>"; $schedule="";} |
|
113 | + } else {echo "$iRow --> The parameter sched_nth_what is not set <br>"; $schedule="";} |
|
127 | 114 | } |
128 | 115 | |
129 | 116 | break; |
@@ -165,8 +152,9 @@ discard block |
||
165 | 152 | $abcResults=$abContacts->addAdressBookLocation($AdressBookLocationParameters); //temporarry |
166 | 153 | |
167 | 154 | echo "The schedule location with address_id = ".strval($abcResults["address_id"])." added successfuly <br>"; //temporarry |
155 | + } else { |
|
156 | + echo "$iRow --> Wrong Address or latitude or longitude <br>"; |
|
168 | 157 | } |
169 | - else echo "$iRow --> Wrong Address or latitude or longitude <br>"; |
|
170 | 158 | $iRow++; |
171 | 159 | } |
172 | 160 | } |