コード例 #1
0
ファイル: mod_form.php プロジェクト: uofr/moodle-mod_zoom
 /**
  * Defines forms elements
  */
 public function definition()
 {
     global $USER;
     $service = new mod_zoom_webservice();
     if (!$service->user_getbyemail($USER->email)) {
         zoom_print_error('user/getbyemail', $service->lasterror);
     }
     $zoomuser = $service->lastresponse;
     $mform = $this->_form;
     // Adding the "general" fieldset, where all the common settings are showed.
     $mform->addElement('header', 'general', get_string('general', 'form'));
     // Add topic (stored in database as 'name').
     $mform->addElement('text', 'name', get_string('topic', 'zoom'), array('size' => '64'));
     $mform->setType('name', PARAM_TEXT);
     $mform->addRule('name', null, 'required', null, 'client');
     $mform->addRule('name', get_string('maximumchars', '', 300), 'maxlength', 300, 'client');
     // Add description ('intro' and 'introformat').
     $this->standard_intro_elements();
     // Add date/time. Validation in validation().
     $mform->addElement('date_time_selector', 'start_time', get_string('start_time', 'zoom'));
     // Disable for recurring meetings.
     $mform->disabledIf('start_time', 'recurring', 'checked');
     // Add duration.
     $mform->addElement('duration', 'duration', get_string('duration', 'zoom'), array('optional' => false));
     // Validation in validation(). Default to one hour.
     $mform->setDefault('duration', array('number' => 1, 'timeunit' => 3600));
     // Disable for recurring meetings.
     $mform->disabledIf('duration', 'recurring', 'checked');
     // Add recurring.
     $mform->addElement('advcheckbox', 'recurring', get_string('recurringmeeting', 'zoom'));
     $mform->setDefault('recurring', 0);
     $mform->addHelpButton('recurring', 'recurringmeeting', 'zoom');
     // Add webinar, disabled if the user cannot create webinars.
     $webinarattr = null;
     if (!$zoomuser->enable_webinar) {
         $webinarattr = array('disabled' => true, 'group' => null);
     }
     $mform->addElement('advcheckbox', 'webinar', get_string('webinar', 'zoom'), '', $webinarattr);
     $mform->setDefault('webinar', 0);
     $mform->addHelpButton('webinar', 'webinar', 'zoom');
     // Add password.
     $mform->addElement('passwordunmask', 'password', get_string('password', 'zoom'), array('maxlength' => '10'));
     // Check password uses valid characters.
     $regex = '/^[a-zA-Z0-9@_*-]{1,10}$/';
     $mform->addRule('password', get_string('err_password', 'mod_zoom'), 'regex', $regex, 'client');
     $mform->disabledIf('password', 'webinar', 'checked');
     // Add host/participants video (checked by default).
     $mform->addGroup(array($mform->createElement('radio', 'option_host_video', '', get_string('on', 'zoom'), true), $mform->createElement('radio', 'option_host_video', '', get_string('off', 'zoom'), false)), null, get_string('option_host_video', 'zoom'));
     $mform->setDefault('option_host_video', true);
     $mform->disabledIf('option_host_video', 'webinar', 'checked');
     $mform->addGroup(array($mform->createElement('radio', 'option_participants_video', '', get_string('on', 'zoom'), true), $mform->createElement('radio', 'option_participants_video', '', get_string('off', 'zoom'), false)), null, get_string('option_participants_video', 'zoom'));
     $mform->setDefault('option_participants_video', true);
     $mform->disabledIf('option_participants_video', 'webinar', 'checked');
     // Add audio options.
     $mform->addGroup(array($mform->createElement('radio', 'option_audio', '', get_string('audio_telephony', 'zoom'), ZOOM_AUDIO_TELEPHONY), $mform->createElement('radio', 'option_audio', '', get_string('audio_voip', 'zoom'), ZOOM_AUDIO_VOIP), $mform->createElement('radio', 'option_audio', '', get_string('audio_both', 'zoom'), ZOOM_AUDIO_BOTH)), null, get_string('option_audio', 'zoom'));
     $mform->setDefault('option_audio', ZOOM_AUDIO_BOTH);
     // Add meeting options. Make sure we pass $appendName as false
     // so the options aren't nested in a 'meetingoptions' array.
     $mform->addGroup(array($mform->createElement('advcheckbox', 'option_jbh', '', get_string('option_jbh', 'zoom'))), 'meetingoptions', get_string('meetingoptions', 'zoom'), null, false);
     $mform->addHelpButton('meetingoptions', 'meetingoptions', 'zoom');
     $mform->disabledIf('meetingoptions', 'webinar', 'checked');
     // Add meeting id.
     $mform->addElement('hidden', 'meeting_id', -1);
     $mform->setType('meeting_id', PARAM_ALPHANUMEXT);
     // Add host id (will error if user does not have an account on Zoom).
     $mform->addElement('hidden', 'host_id', zoom_get_user_id());
     $mform->setType('host_id', PARAM_ALPHANUMEXT);
     // Add standard grading elements.
     $this->standard_grading_coursemodule_elements();
     $mform->setDefault('grade', false);
     // Add standard elements, common to all modules.
     $this->standard_coursemodule_elements();
     // Add standard buttons, common to all modules.
     $this->add_action_buttons();
 }
コード例 #2
0
ファイル: view.php プロジェクト: uofr/moodle-mod_zoom
// Print the page header.
$PAGE->set_url('/mod/zoom/view.php', array('id' => $cm->id));
$PAGE->set_title(format_string($zoom->name));
$PAGE->set_heading(format_string($course->fullname));
/*
 * Other things you may want to set - remove if not needed.
 * $PAGE->set_cacheable(false);
 * $PAGE->set_focuscontrol('some-html-id');
 * $PAGE->add_body_class('zoom-'.$somevar);
 */
$cache = cache::make('mod_zoom', 'zoomid');
if (!($zoomuserid = $cache->get($USER->id))) {
    $zoomuserid = false;
    $service = new mod_zoom_webservice();
    // Not an error if this fails, since people don't need a Zoom account to view/join meetings.
    if ($service->user_getbyemail($USER->email)) {
        $zoomuserid = $service->lastresponse->id;
    }
    $cache->set($USER->id, $zoomuserid);
}
$userishost = $zoomuserid == $zoom->host_id;
$stryes = get_string('yes');
$strno = get_string('no');
$strstart = get_string('start_meeting', 'mod_zoom');
$strjoin = get_string('join_meeting', 'mod_zoom');
$strunavailable = get_string('unavailable', 'mod_zoom');
$strtime = get_string('meeting_time', 'mod_zoom');
$strduration = get_string('duration', 'mod_zoom');
$strpassprotect = get_string('passwordprotected', 'mod_zoom');
$strpassword = get_string('password', 'mod_zoom');
$strjoinlink = get_string('join_link', 'mod_zoom');
コード例 #3
0
ファイル: locallib.php プロジェクト: uofr/moodle-mod_zoom
/**
 * Get the Zoom id of the currently logged-in user.
 *
 * @return string
 */
function zoom_get_user_id()
{
    global $USER;
    $service = new mod_zoom_webservice();
    if (!$service->user_getbyemail($USER->email)) {
        zoom_print_error('user/getbyemail', $service->lasterror);
    }
    return $service->lastresponse->id;
}