/**
  * Process the given restore path element data
  *
  * @param array $data parsed element data
  */
 protected function process_zoom($data)
 {
     global $DB;
     $data = (object) $data;
     $oldid = $data->id;
     $data->course = $this->get_courseid();
     if (empty($data->timemodified)) {
         $data->timemodified = time();
     }
     if ($data->grade < 0) {
         // Scale found, get mapping.
         $data->grade = -$this->get_mappingid('scale', abs($data->grade));
     }
     $service = new mod_zoom_webservice();
     // Either get updated info, create a new meeting, or set meeting as expired, whichever comes first.
     if ($service->get_meeting_info($data) || $service->meeting_create($data)) {
         $data = $service->lastresponse;
     } else {
         $data->status = ZOOM_MEETING_EXPIRED;
     }
     // Create the zoom instance.
     $newitemid = $DB->insert_record('zoom', $data);
     $this->apply_activity_instance($newitemid);
 }
Пример #2
0
/**
 * Updates an instance of the zoom in the database
 *
 * Given an object containing all the necessary data,
 * (defined by the form in mod_form.php) this function
 * will update an existing instance with new data.
 *
 * @param stdClass $zoom An object from the form in mod_form.php
 * @param mod_zoom_mod_form $mform The form instance itself (if needed)
 * @return boolean Success/Fail
 */
function zoom_update_instance(stdClass $zoom, mod_zoom_mod_form $mform = null)
{
    global $CFG, $DB;
    require_once $CFG->dirroot . '/mod/zoom/classes/webservice.php';
    $old = $DB->get_record('zoom', array('id' => $zoom->instance));
    // Update meeting on Zoom.
    $service = new mod_zoom_webservice();
    // If the webinar setting changed, we have to delete and recreate.
    if ($old->webinar != $zoom->webinar) {
        if (!$service->meeting_delete($old)) {
            zoom_print_error('meeting/delete', $service->lasterror);
        }
        if (!$service->meeting_create($zoom)) {
            zoom_print_error('meeting/create', $service->lasterror);
        }
    } else {
        if (!$service->meeting_update($zoom)) {
            if (zoom_is_meeting_gone_error($service->lasterror)) {
                if (!$service->meeting_create($zoom)) {
                    zoom_print_error('meeting/create', $service->lasterror);
                }
            } else {
                zoom_print_error('meeting/update', $service->lasterror);
            }
        }
    }
    $zoom = $service->lastresponse;
    // Update meeting in database.
    $zoom->timemodified = time();
    $result = $DB->update_record('zoom', $zoom);
    zoom_calendar_item_update($zoom);
    zoom_grade_item_update($zoom);
    return $result;
}