@@ -40,6 +40,9 @@ public function __construct($term_id) {
40
40
$ this ->descr = $ result ['descr ' ] . date (" Y " , strtotime ($ this ->start_date ));
41
41
$ this ->num_weeks = (int ) $ result ['weeks ' ];
42
42
$ this ->week_names = json_decode ($ result ['week_names ' ]);
43
+ if ($ this ->week_names == null ) {
44
+ $ this ->week_names = [];
45
+ }
43
46
44
47
}
45
48
@@ -80,9 +83,13 @@ public static function addTerm($start, $descr, $num_weeks)
80
83
*/
81
84
public static function getAllTerms ($ currentOnly = false )
82
85
{
83
- $ query = 'SELECT termid, EXTRACT(EPOCH FROM start) AS start FROM terms WHERE ' ;
84
- $ query .= $ currentOnly ? 'start <= now() AND ' : '' ;
85
- $ query .= 'finish > now() ORDER BY start ASC ' ;
86
+ if ($ currentOnly == "false " ) {
87
+ $ currentOnly = false ;
88
+ }
89
+
90
+ $ query = 'SELECT termid, EXTRACT(EPOCH FROM start) AS start FROM terms ' ;
91
+ $ query .= $ currentOnly ? 'WHERE start <= now() AND finish > now() ' : '' ;
92
+ $ query .= 'ORDER BY start ASC ' ;
86
93
$ result = self ::$ db ->fetchAll ($ query );
87
94
88
95
$ terms = [];
@@ -202,10 +209,10 @@ public static function getTermForm()
202
209
public function toDataSource ($ mixins = []) {
203
210
return [
204
211
"term_id " => $ this ->getID (),
205
- "descr " => $ this ->getTermDescr (),
212
+ "start " => $ this ->getTermStartDate (),
213
+ "descr " => $ this ->getTermDescr (),
206
214
"num_weeks " => $ this ->getTermWeeks (),
207
- "week_names " => $ this ->getTermWeekNames (),
208
- "start " => $ this ->getTermStartDate ()
215
+ "week_names " => $ this ->getTermWeekNames ()
209
216
];
210
217
}
211
218
}
0 commit comments