function calendar_content_register_content_type

6.x calendar.module calendar_content_register_content_type()

For use with the content module. We will register our custom content type(s) for use with this module.

File

modules/calendar/calendar.module, line 2670

Code

function calendar_content_register_content_type() {
  global $user;

  $arr = array();

  $arr ['appointment'] = array(
    'title' => 'Appointment',
    'description' => 'This is a content type meant to track an appointment between a student and an advisor in the system.',
    'settings' => array(
      'title' => array(
        'auto' => TRUE,
      ),
      'css' => fp_get_module_path("calendar") . "/css/style.css",
    ),
  );


  $arr ['schedule_event_type'] = array(
    'title' => 'Schedule Appointment Type',
    'description' => 'This is a content type is the type of appointment which a student can schedule. Ex: Phone Call, Meeting, etc.',
    'settings' => array(
      'title' => array(
        'label' => t("Appointment Type Title"),
        'description' => t("This is what the student will select for the type of appointment they whish to schedule with you.
                             <br>Ex: In-Person Meeting, Phone Call, Video Call"),
      ),
      'css' => fp_get_module_path("calendar") . "/css/style.css",
    ),
  );


  $arr ['schedule_unavailable_time'] = array(
    'title' => 'Schedule Unavailable Time',
    'description' => 'This content type allows the user to mark when they will be unavailable for appointments.',
    'settings' => array(
      'title' => array(
        'label' => t("Title or Short Description"),
      ),
      'js' => fp_get_module_path("calendar") . "/js/calendar.js",
      'css' => fp_get_module_path("calendar") . "/css/style.css",
    ),
  );




  // If we are in a popup (dialog)...
  if (@$_GET ['window_mode'] == 'popup') {
    // We want to make sure we redirect to our handler URL, which will close the dialog.
    $arr ['appointment']['settings']['#redirect'] = array(
      'path' => 'content-dialog-handle-after-save',
      'query' => '',
    );
    $arr ['schedule_event_type']['settings']['#redirect'] = array(
      'path' => 'content-dialog-handle-after-save',
      'query' => '',
    );
    $arr ['schedule_unavailable_time']['settings']['#redirect'] = array(
      'path' => 'content-dialog-handle-after-save',
      'query' => '',
    );


  }




  $fields = array();

  $fields ['appointment_datetime'] = array(
    'type' => 'datetime-local',
    'label' => 'Date/Time',
    'value' => date('Y-m-d\TH:i', time()), // today's date/time by default
    'format_date' => 'short',
    'weight' => 0,
    'required' => TRUE,
  );


  $options = array();
  for ($t = 5; $t <= 120; $t = $t + 5) {
    $options [$t] = "$t minutes";
  }

  $fields ['appointment_duration_minutes'] = array(
    'type' => 'select',
    'label' => 'Duration',
    'options' => $options,
    'hide_please_select' => TRUE,
    'weight' => 10,
    'required' => TRUE,
  );



  $fields ['faculty_id'] = array(
    'type' => 'textfield',
    'label' => 'Faculty/Staff',
    'weight' => 20,
  );

  $fields ['student_id'] = array(
    'type' => 'textfield',
    'label' => 'Student',
    'autocomplete_path' => 'student-search/autocomplete-student/default', // Convenient endpoint in the student_search module
    'weight' => 30,
  );


  $fields ['appointment_type'] = array(
    'type' => 'select',
    'options' => array(
      'advising' => t('Advising'),
      'other' => t('Other'),
    ),
    'label' => 'Type',
    'required' => TRUE,
    'hide_please_select' => TRUE,
    'weight' => 40,
  );


  $fields ['appointment_msg'] = array(
    'type' => 'textarea',
    'label' => '(Optional) Message / Comments',
    'filter' => 'basic',
    'weight' => 50,
  );



  // This is essentially a hidden field, but we need it to be a textarea, so it can hold linebreaks and such.
  // It's where we will save extra data regarding Zoom meetings, and possibly other video meeting services
  // in the future.
  $fields ['video_data'] = array(
    'type' => 'textarea',
    'label' => '',
    'weight' => 999999,
    'attributes' => array('readonly' => 'readonly', "style" => "display: none"),
  );



  $arr ['appointment']['fields'] = $fields;


  ///////////////////////////////////
  ///  Schedule Event Type
  ///////////////////////////////////
  $fields = array();


  $fields ['faculty_id'] = array(
    'type' => 'textfield',
    'label' => 'Faculty/Staff',
    'weight' => -10,
  );


  $fields ['enabled'] = array(
    'type' => 'select',
    'label' => t('Enabled?'),
    'description' => t("Set to Enabled in order to allow students to schedule this appointment type.  If you disable all of your event types,
                        then no student will be able to make appointments with you.  If you are unsure what to do, leave this set to 'Enabled'."),
    'options' => array('enabled' => 'Enabled', 'disabled' => 'Disabled'),
    'hide_please_select' => TRUE,
    'required' => TRUE,
    'weight' => 30,
  );


  $zoomapi_data = "";
  if (module_enabled("zoomapi")) {
    $zoomapi_data = zoomapi_get_zoomapi_data_for_user($user->id);
    if (!$zoomapi_data) {
      $attr = array("style" => "display: none; "); // hide this field if the user doesn't have anything set up for Zoom.
    }

    $fields ['video_meeting'] = array(
      'type' => 'select',
      'label' => t('Automatically generate Zoom meeting?'),
      'options' => array('no' => t('No (default)'), 'zoom' => t('Yes - Automatically generate a Zoom meeting and attach URL')),
      'hide_please_select' => TRUE,
      'description' => t("If set to Yes, this event will be treated like a video chat, and a Zoom meeting will automatically be
                          created for the appointment.  The URL for the new Zoom meeting will be included at the end of the notification
                          and reminder messages sent to the student & faculty/staff members."),
      'attributes' => $attr,
      'weight' => 40,
    );


  }





  $fields ['description'] = array(
    'type' => 'textarea',
    'label' => t('Brief Description'),
    'description' => t('Optional.  This description will appear along side the title of this event.  Provide a brief description to explain what this event type
                        is.  For example, if this is for a Video Call, you might enter: <em>Select this option if you wish to meet via your phone or laptop camera, without appearing in-person.</em>'),
    'weight' => 50,
  );


  $fields ['event_duration_minutes'] = array(
    'type' => 'select',
    'label' => 'Duration',
    'options' => array('15' => '15 min', '30' => '30 min', '45' => '45 min', '60' => '60 min', '75' => '1 hr, 15 min', '90' => '1 hr, 30 min', '105' => '1 hr, 45 min', '120' => '2 hours'),
    'hide_please_select' => TRUE,
    'weight' => 110,
    'required' => TRUE,
    'description' => t('How many minutes will this event last?'),
  );

  $fields ['event_buffer_minutes'] = array(
    'type' => 'select',
    'label' => 'Buffer between scheduled appointments',
    'options' => array('5' => '5 min', '10' => '10 min', '15' => '15 min', '30' => '30 min', '45' => '45 min', '60' => '60 min', '75' => '1 hr, 15 min', '90' => '1 hr, 30 min', '105' => '1 hr, 45 min', '120' => '2 hours'),
    'hide_please_select' => TRUE,
    'weight' => 120,
    'required' => TRUE,
    'description' => t('How many minutes should there be from the end of one appointment or event, and the start of the next?'),
  );

  $options = array();
  for ($t = 1; $t <= 24; $t++) {
    $s = "s";
    if ($t == 1) {
      $s = "";
    }
    $options [$t] = "$t " . t("hour$s");
  }

  $fields ['prevent_less_than_hours'] = array(
    'type' => 'select',
    'label' => 'Prevent events less than ___ hours away',
    'options' => $options,
    'hide_please_select' => TRUE,
    'weight' => 130,
    'required' => TRUE,
    'description' => t('This setting stops students from scheduling events too soon, which you might not notice because you are otherwise occupied.
                       For example, if you set this to 1 hour, and the current time is 2pm, then a student would not be able to schedule
                       this event before 3pm today.'),
  );


  $fields ['additional_email_msg'] = array(
    'type' => 'textarea',
    'label' => t('Additional Email Message'),
    'description' => t('When a student schedules this event, they will see a generic email message which confirms their appointment date and time.
                        If you wish, you can add an additional message here.                        
                        <br>For example:
                        <br>&nbsp; &nbsp; <i>Thank you for scheduling this in-person meeting.  My office is in Walker Hall, 3rd floor.  Check in at the reception.</i>'),
    'weight' => 140,
  );




  $arr ['schedule_event_type']['fields'] = $fields;


  ///////////////////////////////////////
  // schedule_unavailable_time
  ///////////////////////////////////////
  $fields = array();

  $fields ['faculty_id'] = array(
    'type' => 'textfield',
    'label' => 'Faculty/Staff',
    'weight' => -10,
  );

  $fields ['days'] = array(
    'type' => 'checkboxes',
    'label' => 'Days affected',
    'options' => array(0 => 'Sun', 1 => 'Mon', 2 => 'Tue', 3 => 'Wed', 4 => 'Thu', 5 => 'Fri', 6 => 'Sat'),
    'description' => t("Select the days which this unavailable time entry refers to."),
    'weight' => 20,
  );

  $hour_options = array();
  for ($t = 0; $t <= 23; $t++) {
    $twelve_version = $t . "am";
    if ($t == 0) {
      $twelve_version = "12am (midnight)";
    }

    if ($t > 12) {
      $twelve_version = ($t - 12) . "pm";
    }
    $hour_options [$t] = $twelve_version;
  }



  $fields ['time_selector'] = array(
    'type' => 'radios',
    'label' => t('How would you like to describe when you are unavailable to take appointments on the selected days?'),
    'options' => array('' => 'Default', 'manual' => 'Manual Entry', 'none' => 'None (no appointments on these days)'),
    'weight' => 23,
  );

  $fields ['day_start_hour'] = array(
    'type' => 'select',
    'label' => t('What time do you <u>begin</u> accepting appointments on the selected days?'),
    'options' => $hour_options,
    'required' => TRUE,
    'hide_please_select' => TRUE,
    'weight' => 25,
  );

  $fields ['day_stop_hour'] = array(
    'type' => 'select',
    'label' => t('What time do you <u>stop</u> accepting appointments on the selected days?'),
    'options' => $hour_options,
    'required' => TRUE,
    'hide_please_select' => TRUE,
    'weight' => 25,
  );



  $fields ['start_time'] = array(
    'type' => 'time',
    'label' => 'Start Time',
    'description' => t("Select the Start time for this unavailable window."),
    'weight' => 30,
  );

  $fields ['end_time'] = array(
    'type' => 'time',
    'label' => 'End Time',
    'description' => t("Select the End time for this unavailable window."),
    'weight' => 40,
  );


  $fields ['advanced_fs'] = array(
    'type' => 'cfieldset',
    'label' => 'Advanced Settings - click to view',
    'start_closed' => TRUE,
    'weight' => 50,
  );

  $fields ['advanced_fs']['elements'][0]['ics_url'] = array(
    'type' => 'textarea',
    'rows' => 2,
    'label' => '(Advanced) URL to external calendar feed',
    'description' => t("If a URL is entered here, all other fields will be ignored.  This optional field lets you specify the URL to an external
                        calendar feed (ex: Google Calendar, Outlook, Zoho, etc) in .ics format.  Any event times listed on that calendar
                        will be marked off as unavailable for scheduling in FlightPath.  This is a convenient way to prevent students
                        from scheduling appointments when you might otherwise be occupied, by entering a link to your work calendar.  
                        <br>If you are unsure what to enter here, leave
                        this field blank."),
    'weight' => 60,
  );



  $arr ['schedule_unavailable_time']['fields'] = $fields;





  return $arr;

}