@@ -40,9 +40,6 @@ 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
- }
46
43
47
44
}
48
45
@@ -83,13 +80,9 @@ public static function addTerm($start, $descr, $num_weeks)
83
80
*/
84
81
public static function getAllTerms ($ currentOnly = false )
85
82
{
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 ' ;
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 ' ;
93
86
$ result = self ::$ db ->fetchAll ($ query );
94
87
95
88
$ terms = [];
@@ -209,10 +202,10 @@ public static function getTermForm()
209
202
public function toDataSource ($ mixins = []) {
210
203
return [
211
204
"term_id " => $ this ->getID (),
212
- "start " => $ this ->getTermStartDate (),
213
- "descr " => $ this ->getTermDescr (),
205
+ "descr " => $ this ->getTermDescr (),
214
206
"num_weeks " => $ this ->getTermWeeks (),
215
- "week_names " => $ this ->getTermWeekNames ()
207
+ "week_names " => $ this ->getTermWeekNames (),
208
+ "start " => $ this ->getTermStartDate ()
216
209
];
217
210
}
218
211
}
0 commit comments