Adobe Connect Bridge Marketplace edition — initial release
This commit is contained in:
+97
@@ -0,0 +1,97 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// 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/>.
|
||||
|
||||
/**
|
||||
* Ajax: SSO URL to view uploaded meeting content in Adobe Connect.
|
||||
*
|
||||
* @package mod_meetletacbmarketplace
|
||||
* @copyright 2026 MeetLet <info@meetlet.net>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
namespace mod_meetletacbmarketplace\external;
|
||||
|
||||
use core_external\external_api;
|
||||
use core_external\external_function_parameters;
|
||||
use core_external\external_single_structure;
|
||||
use core_external\external_value;
|
||||
use mod_meetletacbmarketplace\api\service;
|
||||
use mod_meetletacbmarketplace\local\config;
|
||||
use mod_meetletacbmarketplace\local\content;
|
||||
use mod_meetletacbmarketplace\local\featureaccess;
|
||||
use mod_meetletacbmarketplace\local\instance;
|
||||
use mod_meetletacbmarketplace\local\roles;
|
||||
use mod_meetletacbmarketplace\local\sso;
|
||||
use mod_meetletacbmarketplace\local\usererror;
|
||||
use moodle_exception;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* Prepare Adobe Connect content view URL with session for current user.
|
||||
*/
|
||||
class get_content_launch_url extends external_api {
|
||||
public static function execute_parameters(): external_function_parameters {
|
||||
return new external_function_parameters([
|
||||
'cmid' => new external_value(PARAM_INT, 'Course module id'),
|
||||
'contentscoid' => new external_value(PARAM_INT, 'Content sco id'),
|
||||
'groupid' => new external_value(PARAM_INT, 'Group id', VALUE_DEFAULT, 0),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function execute(int $cmid, int $contentscoid, int $groupid = 0): array {
|
||||
global $USER;
|
||||
|
||||
$params = self::validate_parameters(self::execute_parameters(), [
|
||||
'cmid' => $cmid,
|
||||
'contentscoid' => $contentscoid,
|
||||
'groupid' => $groupid,
|
||||
]);
|
||||
|
||||
\mod_meetletacbmarketplace\registration\manager::require_registered();
|
||||
|
||||
$inst = instance::get_from_cmid($params['cmid'], $params['groupid']);
|
||||
self::validate_context($inst->context);
|
||||
require_capability('mod/meetletacbmarketplace:view', $inst->context);
|
||||
featureaccess::require_feature(featureaccess::CONTENT, $inst->context, $inst->record);
|
||||
|
||||
$service = new service();
|
||||
$service->login_admin();
|
||||
$item = content::find_in_meeting($service, $inst->require_meeting(), (int)$params['contentscoid']);
|
||||
$service->logout();
|
||||
|
||||
if (!$item || empty($item->urlpath)) {
|
||||
throw new moodle_exception('nocontent', 'meetletacbmarketplace');
|
||||
}
|
||||
|
||||
try {
|
||||
$adoberole = roles::resolve_adobe_role($inst->record, $inst->context, $USER->id);
|
||||
$permission = $adoberole ?: service::ROLE_PARTICIPANT;
|
||||
$auth = sso::provision_and_login($USER, (int)$params['contentscoid'], $permission);
|
||||
$url = config::content_view_url((string)$item->urlpath, $auth['cookie']);
|
||||
return usererror::ws_ok($url);
|
||||
} catch (\Throwable $e) {
|
||||
if ($e instanceof moodle_exception && in_array($e->errorcode, ['nopermissions', 'requirelogin', 'invalidparameter'], true)) {
|
||||
throw $e;
|
||||
}
|
||||
return usererror::ws_fail($e, $inst->context);
|
||||
}
|
||||
}
|
||||
|
||||
public static function execute_returns(): external_single_structure {
|
||||
return new external_single_structure(usererror::ws_url_returns());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user