/** * Get url for forwarding to meeting room. * * @throws \coding_exception * @return bool|string */ protected function forward() { global $PAGE, $USER; $PAGE->set_url('/mod/collaborate/view.php', array('id' => $this->cm->id, 'action' => 'view')); $this->log_viewed_event(); $url = $this->api_update_attendee(); if (empty($url)) { $this->api->process_error('error:failedtocreateurl', logging\constants::SEV_CRITICAL); return false; } else { if (!empty($USER->id) && $this->collaborate->completionlaunch) { // Completion tracking on forward. $completion = new \completion_info($this->course); $completion->update_state($this->cm, COMPLETION_COMPLETE, $USER->id); } return $url; } }
/** * get recordings * * @param int | object $collaborate * @return array */ public static function get_recordings($collaborate) { global $DB; if (!is_object($collaborate)) { $collaborate = $DB->get_record('collaborate', array('id' => $collaborate)); } $config = get_config('collaborate'); $api = api::get_api(); $session = new HtmlSessionRecording(); $session->setSessionId($collaborate->sessionid); $result = $api->ListHtmlSessionRecording($session); if (!$result) { return []; } $respobjs = $result->getHtmlSessionRecordingResponse(); if (!is_array($respobjs) || empty($respobjs)) { return []; } return $respobjs; }
/** * Removes an instance of the collaborate from the database * * Given an ID of an instance of this module, * this function will permanently delete the instance * and any data that depends on it. * * @param int $id Id of the module instance * @return boolean Success/Failure */ function collaborate_delete_instance($id) { global $DB; if (!($collaborate = $DB->get_record('collaborate', array('id' => $id)))) { return false; } // API request deletion. $api = api::get_api(); $api->set_silent(true); $params = new RemoveHtmlSession($collaborate->sessionid); try { $result = $api->RemoveHtmlSession($params); } catch (Exception $e) { $result = false; } if ($result === null) { // TODO: Warning - this is a bodge fix! - the wsdl2phpgenerator has set up this class so that it is expecting // a Success Response object but we are actually getting back a RemoveSessionSuccessResponse element in the // xml and as a result of that we end up with a 'null' object. $xml = $api->__getLastResponse(); if (preg_match('/<success[^>]*>true<\\/success>/', $xml)) { // Manually create the response object! $result = new SuccessResponse(true); } else { $result = false; } } if (!$result || !$result->getSuccess()) { $api->process_error('error:failedtodeletesession', constants::SEV_WARNING); } // Delete main record. $DB->delete_records('collaborate', array('id' => $collaborate->id)); collaborate_grade_item_delete($collaborate); return true; }