/** * Returns general link or file embedding html. * * @param string $fullurl * @param string $clicktoopen * @param string $mimetype * @return string html */ function equella_embed_general($equella) { global $CFG, $PAGE; if ($CFG->equella_enable_lti) { $launchurl = new moodle_url('/mod/equella/ltilaunch.php', array('cmid' => $equella->cmid, 'action' => 'view')); $url = $launchurl->out(); } else { $url = equella_appendtoken($equella->url); } $link = html_writer::tag('a', $equella->name, array('href' => str_replace('&', '&', $url))); $clicktoopen = get_string('clicktoopen', 'equella', $link); $iframe = false; // IE can not embed stuff properly, that is why we use iframe instead. // Unfortunately this tag does not validate in xhtml strict mode, // but in any case it is undeprecated in HTML 5 - we will use it everywhere soon! $ie5 = false; $vendor = 'MSIE'; $version = 5; if (method_exists('core_useragent', 'check_browser_version')) { $ie5 = core_useragent::check_browser_version($vendor, $version); } else { $ie5 = check_browser_version($vendor, $version); } if ($ie5 || $CFG->equella_enable_lti) { $iframe = true; } if ($iframe) { $code = <<<EOT <div class="resourcecontent resourcegeneral"> <iframe id="resourceobject" src="{$url}"> {$clicktoopen} </iframe> </div> EOT; } else { $param = '<param name="src" value="' . $url . '" />'; $code = <<<EOT <div class="resourcecontent resourcegeneral"> <object id="resourceobject" data="{$url}" width="800" height="600"> {$param} {$clicktoopen} </object> </div> EOT; } // the size is hardcoded in the object above intentionally because it is adjusted by the following function on-the-fly $PAGE->requires->js_init_call('M.util.init_maximised_embed', array('resourceobject'), true); return $code; }
notice(get_string("activityiscurrentlyhidden")); } if (class_exists('mod_equella\\event\\course_module_viewed')) { $eventparams = array('context' => $context, 'objectid' => $equella->id); $event = \mod_equella\event\course_module_viewed::create($eventparams); $event->add_record_snapshot('course_modules', $cm); $event->add_record_snapshot('course', $course); $event->add_record_snapshot('equella', $equella); $event->trigger(); } else { add_to_log($course->id, "equella", "view equella resource", "view.php?id={$cm->id}", $equella->id, $cm->id); } // Update 'viewed' state if required by completion system $completion = new completion_info($course); $completion->set_module_viewed($cm); $PAGE->set_url('/mod/equella/view.php', array('id' => $cm->id)); $url = equella_appendtoken($equella->url); if (optional_param('inpopup', 0, PARAM_BOOL)) { redirect($url); } $PAGE->set_title($course->shortname . ': ' . $equella->name); $PAGE->set_heading($course->fullname); $PAGE->set_cm($cm); echo $OUTPUT->header(); if (trim(strip_tags($equella->intro))) { echo $OUTPUT->box_start('mod_introbox', 'equellaintro'); echo format_module_intro('equella', $equella, $cm->id); echo $OUTPUT->box_end(); } echo equella_embed_general($equella); echo $OUTPUT->footer($course);
private static function contribute_file($filename, $fp, $params = array(), $useoauth = false) { global $CFG; $endpoint = self::get_end_point() . 'api/item/quick/' . rawurlencode($filename); $quickcontributeurl = new moodle_url($endpoint, $params); $curl = new equella_curl(); if ($useoauth) { $curl->setHeader(array('X-Authorization: access_token=' . $CFG->equella_oauth_access_token)); } $result = $curl->put($quickcontributeurl->out(false), array('filehandle' => $fp, 'filesize' => $params['filesize'])); fclose($fp); if (!empty($result)) { $resultjson = json_decode($result); if (empty($resultjson) && debugging()) { throw new moodle_exception(html_to_text($result)); } if (!empty($resultjson->error_description)) { throw new equella_exception('EQUELLA: ' . $resultjson->error_description); } else { if (!empty($resultjson->error)) { throw new equella_exception('EQUELLA: ' . $resultjson->error); } else { if (debugging()) { throw new moodle_exception($resultjson); } else { throw new moodle_exception('error'); } } } } // URL is in HTTP header $resp = $curl->getResponse(); if (empty($resp['Location'])) { throw new moodle_exception('restapinolocation', 'equella'); } $itemurl = $resp['Location']; if (!$useoauth) { $itemurl = equella_appendtoken($itemurl); } $json = $curl->get($itemurl); $info = json_decode($json); if (!empty($info)) { return $info; } else { return null; } }
<?php // This file is part of the EQUELLA module - http://git.io/vUuof // // Moodle is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Moodle is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with Moodle. If not, see <http://www.gnu.org/licenses/>. require_once '../../config.php'; require_once $CFG->dirroot . '/mod/equella/common/lib.php'; require_login(); $url = equella_appendtoken(required_param('url', PARAM_URL)); header("Location: {$url}");
// $notify = array('some.user'); // /////////////////////////////////////////////////////////// if (empty($password)) { echo 'EQUELLA link checking has not been configured. Please see the source code for this page.'; exit; } $password_param = required_param('password', PARAM_RAW); if ($password_param != $password) { echo 'Password doesn\'t match.'; exit; } $http = new curl(array('cookie' => true)); echo '<style>.ok {color: green;} .bad {color: red;}</style><ul>'; foreach ($DB->get_records('equella') as $resource) { $url = equella_appendtoken($resource->url, equella_getssotoken_api()); $http->head($url); $info = $http->get_info(); $statuscode = $info['http_code']; echo '<li>Checking <a href="' . $resource->url . '">' . $resource->url . '</a><br>'; if ((int) $statuscode == 200) { echo '<span class="ok">OK</span>'; } else { echo '<span class="bad">Could not find in EQUELLA</span><br>'; // tell someone - get users with course edit perms for the course in question $recipients = $DB->get_records_list('user', 'username', $notify); if ($recipients) { $from = get_admin(); $subject = get_string('checker.subject', 'equella'); $course = $DB->get_record('course', array('id' => $resource->course)); $courseurl = new moodle_url('/course/view.php', array('id' => $course->id));
function equella_delete_instance($id) { global $DB, $CFG; if (!($equella = $DB->get_record("equella", array("id" => $id)))) { return false; } if ($equella->activation) { $url = str_replace("signon.do", "access/activationwebservice.do", $CFG->equella_url); $url = equella_appendtoken($url) . "&activationUuid=" . rawurlencode($equella->activation); $curl = curl_init($url); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); $res = curl_exec($curl); curl_close($curl); } $DB->delete_records("equella", array("id" => $equella->id)); return true; }