function calendar_content_alter
Search API
7.x calendar.module | calendar_content_alter(&$render, $render_id) |
6.x calendar.module | calendar_content_alter(&$render, $render_id) |
Implements hook_content_alter. We want to alter the way that our calendar appointments are displayed.
File
- modules/
calendar/ calendar.module, line 3901
Code
function calendar_content_alter(&$render, $render_id) {
global $user;
if (strstr($render_id, "content_")) {
if (@$render ['#content-type'] == 'appointment') {
$cid = str_replace("content_", "", $render_id);
$content = content_load($cid);
$student_name = @fp_get_student_name($content->field__student_id ['value'], TRUE);
$faculty_name = @fp_get_faculty_name($content->field__faculty_id ['value']);
// Replace our rendered values with actual names, instead of ONLY cwids.
$render ['field__faculty_id']['value'] = "<div class='field-value'>$faculty_name</div>";
$render ['field__student_id']['value'] = "<div class='field-value'>$student_name</div>";
// Make a nice title for this appointment.
$apt_title = t("Meeting between @ft and @st on @dt", array("@ft" => $faculty_name, "@st" => $student_name, "@dt" => $content->field__appointment_datetime ['display_value']));
$render ['content_title']['value'] = "<div class='content-title'>$apt_title</div>";
fp_set_title($apt_title); // set the page title in case we are viewing not in a dialog
// If the user has permission to cancel appointments involving them, then show link!
if (user_has_permission("can_cancel_own_appointments")) {
if ($user->cwid == $content->field__student_id ['value'] || $user->cwid == $content->field__faculty_id ['value'] || $user->id == 1) {
// if we are in an iframe, include that in query
$query = "";
if (isset($_REQUEST ['window_mode'])) {
$query .= "window_mode=" . $_REQUEST ['window_mode'];
}
$cancel_link = fp_url("calendar/confirm-cancel-appointment/$content->cid", $query);
$render ['cancel_link'] = array(
'value' => "<a href='$cancel_link' title='Cancel appointment' class='button cancel-button'>" . t("Cancel Appointment?") . "</a>",
'weight' => 99999,
);
} // if user is involved in this, or they are admin.
} // user has permission
// If we have valid video data, we should display relevant links to join the meeting and such.
unset($render ['field__video_data']);
if ($render ['#content_object'] && $render ['#content_object']->field__video_data['value'] != "") {
// Meaning, we have video meeting data to display!
// create new markup field which renders out the video links and such.
$decoded = json_decode($render ['#content_object']->field__video_data['value']);
$meeting_id = $decoded->id;
$join_url = $decoded->join_url;
$dial_in = $decoded->settings->global_dial_in_numbers [0]->number;
if (function_exists("engagements_convert_to_pretty_phone_number")) {
$dial_in = engagements_convert_to_pretty_phone_number($dial_in, TRUE);
}
$video_info .= "<p><b>" . t("Zoom Meeting:") . "</b> <a href='$join_url'>" . $join_url . "</a> \n<br> " . t("Be sure to download the Zoom app on your phone, tablet, or computer.") . " \n<br> " . t("To dial in instead of using video chat, you may dial:<br>\n @dial (ID: @id)", array("@dial" => $dial_in, "@id" => $meeting_id)) . ".</p>\n";
$render ['video_information'] = array(
'type' => 'markup',
'value' => "<div class='video-information'>" . $video_info . "</div>",
'weight' => 65,
);
} // video_data != ""
} // this is type appointment
} // this probably is a content node view
}