function getResourceEntries($resource_id = FALSE, $start_date = FALSE, $end_date = FALSE, $consumer_filter = FALSE) { $res = array(); $qtxt = "SELECT * FROM " . $this->getTimeTableTable() . " WHERE "; $qtxt .= "resource='" . $this->getResourceCode() . "'"; $qtxt .= $resource_id !== FALSE ? " AND resource_id='" . $resource_id . "'" : ""; if ($consumer_filter !== FALSE && is_array($consumer_filter) && count($consumer_filter) > 0) { $consumer_filter = addSurroundingQuotes($consumer_filter); $qtxt .= " AND consumer IN (" . implode(",", $consumer_filter) . ")"; } $where_start_date = " AND (start_date >= '" . $start_date . "' OR start_date IS NULL)"; $qtxt .= $start_date !== FALSE ? $where_start_date : ""; $where_end_date = " AND (end_date <= '" . $end_date . "' OR end_date IS NULL)"; $qtxt .= $end_date !== FALSE ? $where_end_date : ""; $q = $this->_query($qtxt); //echo $qtxt; if ($q && mysql_num_rows($q) > 0) { while ($row = mysql_fetch_assoc($q)) { $res[] = $row; // TODO: cache result in global variable } } return $res; }
function getForm() { require_once $GLOBALS["where_lms"] . "/lib/lib.classroom.php"; $cm = new ClassroomManager(); $class_arr = $cm->getClassroomArray(); $class_list = "[" . implode(",", addSurroundingQuotes($class_arr, '"')) . "]"; $class_keys = "[" . implode(",", addSurroundingQuotes(array_keys($class_arr), '"')) . "]"; $form_obj = '{ "form":[ {"type":"structure","value":"row"}, {"type":"structure","value":"cell","field_class":"label"}, {"type":"label","value":"_START"}, {"type":"structure","value":"/cell"}, {"type":"structure","value":"cell","field_class":"field"}, {"type":"day","id":"start_day"}, {"type":"string","value":"/"}, {"type":"month","id":"start_month"}, {"type":"string","value":"/"}, {"type":"year","id":"start_year"}, {"type":"string","value":" "}, {"type":"hour","id":"start_hour"}, {"type":"string","value":":"}, {"type":"min","id":"start_min"}, {"type":"string","value":":"}, {"type":"sec","id":"start_sec"}, {"type":"structure","value":"/cell"}, {"type":"structure","value":"/row"}, {"type":"structure","value":"row"}, {"type":"structure","value":"cell","field_class":"label"}, {"type":"label","value":"_END"}, {"type":"structure","value":"/cell"}, {"type":"structure","value":"cell","field_class":"field"}, {"type":"day","id":"end_day"}, {"type":"string","value":"/"}, {"type":"month","id":"end_month"}, {"type":"string","value":"/"}, {"type":"year","id":"end_year"}, {"type":"string","value":" "}, {"type":"hour","id":"end_hour"}, {"type":"string","value":":"}, {"type":"min","id":"end_min"}, {"type":"string","value":":"}, {"type":"sec","id":"end_sec"}, {"type":"structure","value":"/cell"}, {"type":"structure","value":"/row"}, {"type":"structure","value":"row"}, {"type":"structure","value":"cell","field_class":"label"}, {"type":"label","value":"_SUBJECT"}, {"type":"structure","value":"/cell"}, {"type":"structure","value":"cell","field_class":"field"}, {"type":"text","id":"title","style":"width:300px"}, {"type":"structure","value":"/cell"}, {"type":"structure","value":"/row"}, {"type":"structure","value":"row"}, {"type":"structure","value":"cell","field_class":"label"}, {"type":"label","value":"' . Lang::t("_CLASSROOM", "admin_classroom", "lms") . '","translatevalue":"0"}, {"type":"structure","value":"/cell"}, {"type":"structure","value":"cell","field_class":"field"}, {"type":"select","id":"classroom","value":' . $class_list . ',"key":' . $class_keys . ',"translatevalue":"0"}, {"type":"structure","value":"/cell"}, {"type":"structure","value":"/row"}, {"type":"structure","value":"row"}, {"type":"structure","value":"cell","field_class":"label"}, {"type":"label","value":"_DESCR"}, {"type":"structure","value":"/cell"}, {"type":"structure","value":"cell","field_class":"field"}, {"type":"textarea","id":"description"}, {"type":"structure","value":"/cell"}, {"type":"structure","value":"/row"} ] }'; return $form_obj; }