function calendar_display_user_appointment_settings_page

6.x calendar.module calendar_display_user_appointment_settings_page()

This page is where the user can configure their various appointment settings (like when they offer them)

1 string reference to 'calendar_display_user_appointment_settings_page'
calendar_menu in modules/calendar/calendar.module
implements hook_menu

File

modules/calendar/calendar.module, line 814

Code

function calendar_display_user_appointment_settings_page() {
  global $user;

  $rtn = "";

  fp_add_css(fp_get_module_path('calendar') . '/css/style.css');

  $day_names = array('Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat');

  $base_url = $GLOBALS ['fp_system_settings']['base_url'];
  $url = $base_url . '/' . fp_url("schedule-appointment/$user->id", '', false);

  fp_set_title($user->f_name . " " . $user->l_name . " (" . $user->cwid . ")");


  $rtn .= "<p>FlightPath allows you to offer appointment scheduling to students at this URL: <a href='$url' target='_blank'>$url</a> </p>
              <p>To begin, create a new Appointment Type you wish to offer
              (for example: Office Meeting, Video Call, etc), then specify what your availability is.</p>";

  $url = fp_url("content/add/schedule_event_type", "faculty_id=" . $user->cwid . "&window_mode=popup");
  $dtitle = t("Create New Appointment Type");

  $rtn .= "<a href='javascript:fpOpenLargeIframeDialog(\"$url\",\"$dtitle\");' class='button'><i class='fa fa-plus'></i> $dtitle</a>";

  $rtn .= "
        <table class='schedule-event-types'>
          <tr>
            <th class='actions'>Actions</th>
            <th>Enabled?</th>
            <th>Appointment Type Title</th>
            <th>Duration</th>
            <th>Buffer</th>            
            <th>Video Meeting?</th>            
          </tr>";

  // Display all of the event types for this faculty member.

  $event_types = content_get_content_for_faculty_id('schedule_event_type', $user->cwid);
  foreach ($event_types as $cid => $content) {

    $dtitle = t("Edit Event Type");
    $url = fp_url("content/$cid/edit", "window_mode=popup&content_tabs=false");
    $edit_link = "<a href='javascript:fpOpenLargeIframeDialog(\"$url\",\"$dtitle\");'><i class='fa fa-pencil'></i></a>";

    $video = "-";
    if ($content->field__video_meeting ['value'] == 'zoom' && module_enabled('zoomapi')) {
      $video = "Zoom";
    }


    $rtn .= "<tr>
                <td class='actions'>$edit_link</td>
                <td>{$content->field__enabled ['display_value']}</td>
                <td>$content->title</td>
                <td>{$content->field__event_duration_minutes ['display_value']}</td>
                <td>{$content->field__event_buffer_minutes ['display_value']}</td>
                <td>$video</td>
             </tr>";

  } // foreach


  $rtn .= "</table>";

  // Connect Zoom?
  if (module_enabled("zoomapi") && isset($GLOBALS ['zoom_client_id'])) {

    $msg = t("To enable automatic Zoom meeting creation for video chats, you must first link your Zoom account with your FlightPath account by pressing
                            the button below:");
    $button_text = t("Link Zoom Account");
    $link_class = "button";
    // is the user already set up with Zoom?  If so, display a message, and change the install link to something like "Re-install Zoom", etc.
    $zoomapi_data = zoomapi_get_zoomapi_data_for_user($user->id);

    if ($zoomapi_data) {
      $msg = t("You have already linked your FlightPath account with Zoom!  If you need to re-link your account, click the following:");
      $button_text = "Re-Link Zoom Account";
      $link_class = "";
    }
    $rtn .= "<p>" . t("<strong>Zoom:</strong> @msg", array("@msg" => $msg)) . "</p>";
    $url = zoomapi_get_zoom_install_url();
    $rtn .= "<div class='zoom-install-btn'>&nbsp; &nbsp; <a href='$url' class='$link_class' title='" . t($button_text) . "'><i class='fa fa-external-link'></i> " . t($button_text) . "</a> &nbsp;";
    if ($zoomapi_data) {
      $rtn .= t("To unlink/de-authorize Zoom from FlightPath, view the instructions here: ") . "<a href='https://flightpathacademics.com/help/61' target='_blank'>Uninstalling Zoom from FlightPath</a>";
    }
    $rtn .= "</div>";

  } // we have zoom client id set up.




  $rtn .= "<hr><h3>Unavailabile Times</h3>
            <p>Use the options below to define when you will be <em>unavailable</em> for appointments.  For example, you should set that you are unavailable on
                weekends, mornings, and evenings outside of your work hours.  You may create as many of these <em>Unavailable Time</em> records as you wish.</p>
            
            <p>To create specific one-off dates and times, you may enter appointments into your calendar.</p>
            <p>You may also provide a URL to an outside calendar (in ICS format) to mark your unavailable times.</p>";

  $url = fp_url("content/add/schedule_unavailable_time", "faculty_id=" . $user->cwid . "&window_mode=popup");
  $dtitle = t("Create New Unavailable Time");

  $rtn .= "<a href='javascript:fpOpenLargeIframeDialog(\"$url\",\"$dtitle\");' class='button'><i class='fa fa-plus'></i> Create New Unavailable Time</a>";


  // Display all of the schedule_unavailable_time nodes.
  $rtn .= "
        <table class='schedule-event-types schedule-unavailable-time'>
          <tr>
            <th class='actions'>Actions</th>
            <th>Short Name</th>
            <th>Days</th>
            <th>Unavailable Desc</th>
            <th>Start Time</th>            
            <th>End Time</th>            
            <th>External calendar?</th>            
          </tr>";

  // Display all of the event types for this faculty member.
  $unavail_time = content_get_content_for_faculty_id('schedule_unavailable_time', $user->cwid);
  foreach ($unavail_time as $cid => $content) {

    $tz = $content->field__timezone ['value'];
    $ftz = friendly_timezone($tz);

    $start_time = date('g:ia', convert_time(strtotime("2020-01-01 " . $content->field__start_time ['value']), 'UTC', $tz));
    $end_time = date('g:ia', convert_time(strtotime("2020-01-01 " . $content->field__end_time ['value']), 'UTC', $tz));
    $days = "";
    if (is_array($content->field__days ['value'])) {
      foreach ($content->field__days ['value'] as $k => $v) {
        $days .= $day_names [$v] . ", ";
      }
    }
    $days = rtrim(trim($days), ","); // remove trailing comma

    $ics = '';
    if (trim($content->field__ics_url ['value'])) {
      $ics = 'Y';
      $start_time = $end_time = "";
    }

    $time_selector_disp = $content->field__time_selector ['display_value'];
    $time_selector = $content->field__time_selector ['value'];

    if ($time_selector == "none") {
      $time_selector_disp = t("None on these days");
      $start_time = "";
      $end_time = "";
    }

    if ($time_selector == "" || $time_selector == "default") {
      $time_selector_disp = t("No appointments...");
      $start_time = "before " . $content->field__day_start_hour ['display_value'];
      $end_time = "after " . $content->field__day_stop_hour ['display_value'];
    }

    if ($time_selector == "manual") {
      $time_selector_disp = t("No appointments during...");
    }



    if ($ics) {
      $time_selector_disp = "Using external cal";
      $start_time = "";
      $end_time = "";
    }


    $dtitle = t("Edit Unavailability Time");
    $url = fp_url("content/$cid/edit", "window_mode=popup&content_tabs=false");
    $edit_link = "<a href='javascript:fpOpenLargeIframeDialog(\"$url\",\"$dtitle\");'><i class='fa fa-pencil'></i></a>";

    $rtn .= "<tr>
                <td class='actions'>$edit_link</td>
                <td>$content->title</td>
                <td>$days</td>
                <td>$time_selector_disp</td>
                <td>$start_time</td>
                <td>$end_time</td>
                <td>$ics</td>
             </tr>";

  } // foreach


  $rtn .= "</table>";







  return $rtn;
}