function calendar_get_upcoming_appointments_for_cwid
Search API
7.x calendar.module | calendar_get_upcoming_appointments_for_cwid($cwid, $start_date = "", $end_date = "") |
6.x calendar.module | calendar_get_upcoming_appointments_for_cwid($cwid, $start_date = "", $end_date = "") |
Returns an array of upcoming appointments, where the user is specified by CWID. start_date and end_date is meant to be in UTC, in the form of Y-m-d
If start or end is left blank, we will use NOW and NOW + x DAYS respectively
This function is used by the dashboard and similar situations.
2 calls to calendar_get_upcoming_appointments_for_cwid()
- calendar_display_upcoming_appointments in modules/
calendar/ calendar.module - system_display_dashboard_page in modules/
system/ system.module - This is the "dashboard" page for FlightPath, which replaces the "main" page from FP 5.
File
- modules/
calendar/ calendar.module, line 1134
Code
function calendar_get_upcoming_appointments_for_cwid($cwid, $start_date = "", $end_date = "") {
$rtn = array();
if ($start_date == "") {
$start_date = date("Y-m-d H:i:s", strtotime("NOW"));
}
else {
$start_date .= " 00:00:01";
}
if ($end_date == "") {
$end_date = date("Y-m-d H:i:s", strtotime("NOW + 5 DAYS"));
}
else {
$end_date .= " 23:59:59";
}
$res = db_query("SELECT DISTINCT(a.cid) FROM content__appointment a, content n
WHERE (field__faculty_id = ? OR field__student_id = ?)
AND (field__appointment_datetime BETWEEN ? AND ?)
AND a.vid = n.vid
AND a.cid = n.cid
AND n.delete_flag = 0
AND published = 1
ORDER BY field__appointment_datetime ASC, a.vid DESC", array($cwid, $cwid, $start_date, $end_date));
while ($cur = db_fetch_object($res)) {
$cid = $cur->cid;
$content = content_load($cid);
$ap_datetime_ts = strtotime($content->field__appointment_datetime ['value']);
$year = date('Y', $ap_datetime_ts);
$month = date('n', $ap_datetime_ts);
$day = date('j', $ap_datetime_ts);
$faculty_name = @fp_get_faculty_name($content->field__faculty_id ['value']);
$student_name = @fp_get_student_name($content->field__student_id ['value'], TRUE);
$rtn [] = array(
'utc_start_ts' => $ap_datetime_ts,
'utc_end_ts' => $ap_datetime_ts + (intval($content->field__appointment_duration_minutes ['value']) * 60),
'cid' => $cid,
'content' => $content,
'faculty_name' => $faculty_name,
'student_name' => $student_name,
);
} // while
return $rtn;
}