Skip to content

Commit

Permalink
Create a seperate V3-version of the plugin to allow V2 to coexists in…
Browse files Browse the repository at this point in the history
… the marketplace (#1062)

* changes to have a separate plugin v3

* fix cronjobs when switching to new plugin layoyt, fix migrations

* fix deinstall cleanup

* fix tool activations as well

* clear cache to prevent errors

* guess correct plugin_id, clear cache completely
  • Loading branch information
tgloeggl authored Nov 11, 2024
1 parent b714c6c commit 9aa3965
Show file tree
Hide file tree
Showing 50 changed files with 231 additions and 206 deletions.
4 changes: 2 additions & 2 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ The reference entry in Opencast is neither needed nor wanted, since we are using
org.opencastproject.userdirectory.studip.org=mh_default_org
# The URL and token for the Studip REST webservice
org.opencastproject.userdirectory.studip.url=http://studip.me/studip/4.6/plugins.php/opencast/api/
org.opencastproject.userdirectory.studip.url=http://studip.me/studip/4.6/plugins.php/opencastv3/api/
org.opencastproject.userdirectory.studip.token=mytoken1234abcdef
# The maximum number of users to cache
Expand Down Expand Up @@ -123,4 +123,4 @@ https://hilfe.studip.de/help/4.0/de/Basis/OpencastV3Administration

## Caveats

Stud.IP root users currently get `ROLE_ADMIN` and are therefore factual Opencast admins!
Stud.IP root users currently get `ROLE_ADMIN` and are therefore factual Opencast admins!
9 changes: 5 additions & 4 deletions OpenCast.class.php → OpencastV3.class.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<?php

/**
* OpenCast.class.php - A course plugin for Stud.IP which includes an opencast player
* OpencastV3.class.php - A course plugin for Stud.IP which includes an opencast player
*/

require_once __DIR__ . '/bootstrap.php';

use Opencast\Models\Helpers;
Expand All @@ -17,7 +18,7 @@

use Courseware\CoursewarePlugin;

class OpenCast extends StudipPlugin implements SystemPlugin, StandardPlugin, CoursewarePlugin, PortalPlugin
class OpencastV3 extends StudipPlugin implements SystemPlugin, StandardPlugin, CoursewarePlugin, PortalPlugin
{
const GETTEXT_DOMAIN = 'opencast';

Expand Down Expand Up @@ -349,7 +350,7 @@ public function getAssetsUrl()
*/
public function registerBlockTypes(array $otherBlockTypes): array
{
$otherBlockTypes[] = OpencastBlock::class;
$otherBlockTypes[] = OpencastBlockV3::class;

return $otherBlockTypes;
}
Expand Down Expand Up @@ -396,7 +397,7 @@ public static function onEnable($plugin_id)
}
}

RolePersistence::expirePluginCache($plugin_id);
RolePersistence::expirePluginCache();
}

/**
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function index_action()
Navigation::activateItem('/admin/config/oc-config');
PageLayout::setBodyElementId('opencast-plugin');

$plugin_id = PluginManager::getInstance()->getPluginInfo('OpenCast')['id'];
$plugin_id = PluginManager::getInstance()->getPluginInfo('OpencastV3')['id'];
$plugin_roles = RolePersistence::getAssignedPluginRoles($plugin_id);
$has_role = false;
foreach ($plugin_roles as $plugin_role) {
Expand Down
2 changes: 1 addition & 1 deletion bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

/* Courseware Block */
if (\StudipVersion::newerThan('4.6')) {
require_once 'lib/BlockTypes/OpencastBlock.php';
require_once 'lib/BlockTypes/OpencastBlockV3.php';
} else {
if (!interface_exists('Courseware\CoursewarePlugin')) {
require_once 'lib/FakeCoursewareInterface.php';
Expand Down
17 changes: 17 additions & 0 deletions bootstrap_migrations.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php
/* Stud.IP dependencies*/
require_once 'lib/models/Institute.class.php';
require_once 'lib/raumzeit/raumzeit_functions.inc.php';
require_once 'vendor/trails/trails.php';

/* cronjobs */
require_once 'lib/classes/CronJob.class.php';

StudipAutoloader::addAutoloadPath(__DIR__, 'ElanEv');
StudipAutoloader::addAutoloadPath(__DIR__ . '/lib', 'Opencast');

// adding observer
NotificationCenter::addObserver('Opencast\Models\Videos', 'parseEvent', 'OpencastVideoSync');
NotificationCenter::addObserver('Opencast\Models\Videos', 'checkEventACL', 'OpencastVideoSync');
NotificationCenter::addObserver('Opencast\Models\Videos', 'addToCoursePlaylist', 'OpencastVideoSync');
NotificationCenter::addObserver('Opencast\Models\VideosUserPerms', 'setPermissions', 'OpencastVideoSync');
4 changes: 2 additions & 2 deletions courseware/vueapp/courseware-plugin-opencast-video.vue
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ export default {
params.append('filters', JSON.stringify(filters));
}
axios
.get(STUDIP.ABSOLUTE_URI_STUDIP + 'plugins.php/opencast/api/videos', { params })
.get(STUDIP.ABSOLUTE_URI_STUDIP + 'plugins.php/opencastv3/api/videos', { params })
.then(({ data }) => {
view.paging.items = parseInt(data.count);
view.paging.lastPage = parseInt(view.paging.items / view.limit);
Expand Down Expand Up @@ -267,7 +267,7 @@ export default {
let view = this;
axios.get(STUDIP.ABSOLUTE_URI_STUDIP + 'plugins.php/opencast/api/config/simple')
axios.get(STUDIP.ABSOLUTE_URI_STUDIP + 'plugins.php/opencastv3/api/config/simple')
.then(({data}) => {
view.simple_config_list = data;
Expand Down
4 changes: 4 additions & 0 deletions install/install.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-- Migrate from plugin version 2, if any
UPDATE plugins SET enabled = 'no' WHERE pluginclassname = 'OpenCast';
REPLACE INTO schema_version (domain, branch, version) SELECT 'OpencastV3' as domain, branch, version FROM schema_version WHERE domain = 'OpenCast';

File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* @author Ron Lucke <[email protected]>
* @license GPL2 or any later version
*/
class OpencastBlock extends BlockType
class OpencastBlockV3 extends BlockType
{
public static function getType(): string
{
Expand All @@ -19,12 +19,12 @@ public static function getType(): string

public static function getTitle(): string
{
return dcgettext(Opencast::GETTEXT_DOMAIN, 'Opencast', LC_MESSAGES);
return dcgettext(OpencastV3::GETTEXT_DOMAIN, 'Opencast', LC_MESSAGES);
}

public static function getDescription(): string
{
return dcgettext(Opencast::GETTEXT_DOMAIN, 'Stellt eine Aufzeichnung aus dem Opencast-Plugin bereit', LC_MESSAGES);
return dcgettext(OpencastV3::GETTEXT_DOMAIN, 'Stellt eine Aufzeichnung aus dem Opencast-Plugin bereit', LC_MESSAGES);
}

public function initialPayload(): array
Expand All @@ -36,7 +36,7 @@ public function initialPayload(): array

public static function getJsonSchema(): Schema
{
$schemaFile = __DIR__ . '/OpencastBlock.json';
$schemaFile = __DIR__ . '/OpencastBlockV3.json';

return Schema::fromJsonString(file_get_contents($schemaFile));
}
Expand Down
2 changes: 1 addition & 1 deletion lib/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public function getStudIPVersion()
{
$studip_version = \StudipVersion::getStudipVersion(true);
if (empty($studip_version)) {
$manifest = OpenCast::getPluginManifestInfo();
$manifest = OpencastV3::getPluginManifestInfo();
$studip_version = isset($manifest["studipMinVersion"]) ? $manifest["studipMinVersion"] : 4.6;
}

Expand Down
2 changes: 1 addition & 1 deletion lib/Helpers/PlaylistMigration.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

class PlaylistMigration
{
const CRONJOBS_DIR = 'public/plugins_packages/elan-ev/OpenCast/cronjobs/';
const CRONJOBS_DIR = 'public/plugins_packages/elan-ev/OpencastV3/cronjobs/';

/**
* Convert the Stud.IP playlists to OC playlists
Expand Down
2 changes: 1 addition & 1 deletion lib/Models/Helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ static function getMyCourses($user_id)

// get id of opencast plugin to check if it is activated for selected courses
$plugin_id = \DBManager::get()->query("SELECT pluginid
FROM plugins WHERE pluginname = 'OpenCast'")->fetchColumn();
FROM plugins WHERE pluginname = 'OpencastV3'")->fetchColumn();

if (!$perm->have_perm('admin')) {
// get all courses, user is lecturer or tutor in
Expand Down
4 changes: 2 additions & 2 deletions lib/Models/ScheduleHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -1038,13 +1038,13 @@ public static function sendRecordingNotifications($course_id)
htmlReady($course->name)
);

$plugin = \PluginEngine::getPlugin('OpenCast');
$plugin = \PluginEngine::getPlugin('OpencastV3');
$assetsUrl = rtrim($plugin->getPluginURL(), '/') . '/assets';
$icon = \Icon::create($assetsUrl . '/images/opencast-black.svg');

\PersonalNotifications::add(
$users,
\PluginEngine::getURL('opencast', ['cid' => $course_id], 'course'),
\PluginEngine::getURL('opencastv3', ['cid' => $course_id], 'course'),
$notification,
$course_id,
$icon
Expand Down
2 changes: 1 addition & 1 deletion lib/Models/WidgetHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ static function getUpcomingLivestreams()
// To avoid redundancy, we also check if the upcoming array contains the date id.
if (!empty($seminar_playlist_video) && !isset($upcoming_livestreams[$date->id])) {
$url_with_playlist_token = \PluginEngine::getURL(
'opencast',
'opencastv3',
['cid' => $course->id],
'course#/course/videos?taget_pl_token=' . $seminar_playlist->playlist->token
);
Expand Down
2 changes: 1 addition & 1 deletion lib/RelationshipTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
{
private function getRelLink($slug)
{
return \PluginEngine::getLink('opencast/api/' . $slug);
return \PluginEngine::getLink('opencastv3/api/' . $slug);
}
}
6 changes: 3 additions & 3 deletions lib/Routes/Config/SimpleConfigList.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ public function __invoke(Request $request, Response $response, $args)
'settings' => $this->getGlobalConfig(),
'workflows' => $workflows->toArray(),
'workflow_configs' => $workflow_configs->toArray(),
'plugin_assets_url' => \PluginEngine::getPlugin('Opencast')->getAssetsUrl(),
'auth_url' => \PluginEngine::getURL('opencast', [], 'redirect/authenticate', true),
'redirect_url' => \PluginEngine::getURL('opencast', [], 'redirect/perform', true),
'plugin_assets_url' => \PluginEngine::getPlugin('OpencastV3')->getAssetsUrl(),
'auth_url' => \PluginEngine::getURL('opencastv3', [], 'redirect/authenticate', true),
'redirect_url' => \PluginEngine::getURL('opencastv3', [], 'redirect/perform', true),
'course_id' => \Context::getId() ?: null,
'user_language' => getUserLanguage($user->id),
'default_upload_file_types' => Workflow::DEFAULT_UPLOAD_FILE_TYPES,
Expand Down
25 changes: 12 additions & 13 deletions migrations/001_init_ocplugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,19 +70,18 @@ function up() {

}

function down() {
DBManager::get()->query("DROP TABLE IF EXISTS `oc_series`,`oc_config`,`oc_endpoints`, `oc_seminar_series`, `oc_resources`, `oc_seminar_episodes`, `oc_scheduled_recordings`;");
if (StudipVersion::newerThan('4.4'))
{
DBManager::get()->query("DELETE FROM resource_properties
WHERE property_id IN(SELECT property_id FROM resource_property_definitions WHERE name = 'Opencast Capture Agent' );");
DBManager::get()->query("DELETE FROM resource_property_definitions WHERE name = 'Opencast Capture Agent';");
}
else {
DBManager::get()->query("DELETE FROM resources_objects_properties
WHERE property_id IN(SELECT property_id FROM resources_properties WHERE name = 'Opencast Capture Agent' );");
DBManager::get()->query("DELETE FROM resources_properties WHERE name = 'Opencast Capture Agent';");
function down()
{
$db = DBManager::get();

// clean out the whole oc config
$contents = file_get_contents(__DIR__ . '/../tools/completely_remove_opencast_tables_and_settings.sql');

$statements = preg_split("/;[[:space:]]*\n/", $contents, -1, PREG_SPLIT_NO_EMPTY);


foreach ($statements as $statement) {
$db->exec($statement);
}
}

}
2 changes: 1 addition & 1 deletion migrations/002_workflow_storage.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ function up() {
}

function down() {
DBManager::get()->query("DROP TABLE IF EXISTS `oc_seminar_workflows`;");

}

}
7 changes: 3 additions & 4 deletions migrations/003_add_position_col.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@ function up() {
DBManager::get()->query("ALTER TABLE `oc_seminar_episodes` ADD COLUMN
`position` smallint(6) NOT NULL;");
}

function down() {
DBManager::get()->query("ALTER TABLE `oc_seminar_episodes`
DROP COLUMN `position`;");

}

}
3 changes: 1 addition & 2 deletions migrations/004_add_workflow_col.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ function up() {
}

function down() {
DBManager::get()->query("ALTER TABLE `oc_resources`
DROP COLUMN `workflow_id`;");

}

}
5 changes: 0 additions & 5 deletions migrations/005_cronjob_refresh_series.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

class CronjobRefreshSeries extends Migration
{
//const FILENAME = 'public/plugins_packages/elan-ev/OpenCast/cronjobs/refresh_series.php';
public function description()
{
return 'adds a cronjob for refreshing the episodes of an scheduled series in Stud.IP';
Expand Down Expand Up @@ -35,10 +34,6 @@ public function up()
}
function down()
{
DBManager::get()->query("ALTER TABLE `oc_seminar_episodes` DROP COLUMN `mkdate`;");
DBManager::get()->query("ALTER TABLE `oc_seminar_series` DROP COLUMN `mkdate`;");
DBManager::get()->query("ALTER TABLE `oc_seminar_workflows` DROP COLUMN `mkdate`;");

DBManager::get()->query("DROP TABLE IF EXISTS `oc_series_cache`;");
}
}
1 change: 0 additions & 1 deletion migrations/007_cronjob_refresh_scheduled_events.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

class CronjobRefreshScheduledEvents extends Migration
{
// const FILENAME = 'public/plugins_packages/elan-ev/OpenCast/cronjobs/refresh_scheduled_events.php';
public function description()
{
return 'adds a cronjob for refreshing scheduled events of an scheduled series in Stud.IP';
Expand Down
7 changes: 1 addition & 6 deletions migrations/008_workflow_configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,7 @@ function up() {


function down() {
DBManager::get()->query("DROP TABLE IF EXISTS `oc_seminar_workflow_configuration`;");
DBManager::get()->query("ALTER TABLE `oc_scheduled_recordings`
DROP COLUMN `workflow_id`,
DROP COLUMN `mktime`,
DROP COLUMN `chdate`,
CHANGE status status ENUM('scheduled','recorded') NOT NULL DEFAULT 'scheduled';");

}

}
7 changes: 0 additions & 7 deletions migrations/009_add_configid_column.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,7 @@ function up()

function down()
{
$db = DBManager::get();

$db->query("ALTER TABLE `oc_config` DROP COLUMN `config_id`;");
$db->query("ALTER TABLE `oc_config` DROP INDEX `service_url`, ADD PRIMARY KEY (`service_url`);");
$db->query("ALTER TABLE `oc_endpoints` DROP COLUMN `config_id`;");
$db->query("ALTER TABLE `oc_resources` DROP COLUMN `config_id`;");
$db->query("ALTER TABLE `oc_seminar_series` DROP COLUMN `config_id`;");
$db->query("ALTER TABLE `oc_seminar_workflows` DROP COLUMN `config_id`;");

}
}
6 changes: 3 additions & 3 deletions migrations/010_remove_position_col.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?php

class RemovePositionCol extends Migration {
class RemovePositionCol extends Migration
{
function down()
{
DBManager::get()->query("ALTER TABLE `oc_seminar_episodes` ADD COLUMN
`position` smallint(6) NOT NULL;");

}

function up()
Expand Down
23 changes: 0 additions & 23 deletions migrations/015_access_control.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,30 +38,7 @@ function up()

function down()
{
DBManager::get()->query("DROP TABLE `oc_access_control`");

$result = DBManager::get()->query("SELECT seminar_id, episode_id FROM `oc_seminar_episodes`
WHERE visible = 'invisible'");
$data = $result->fetchAll(PDO::FETCH_KEY_PAIR);

DBManager::get()->query("ALTER TABLE `oc_seminar_episodes`
MODIFY `visible` ENUM('true', 'false') NOT NULL DEFAULT 'true'");

DBManager::get()->exec("UPDATE `oc_seminar_episodes`
SET visible = 'true'
WHERE 1");

$stmt = DBManager::get()->prepare("UPDATE `oc_seminar_episodes`
SET visible = 'false'
WHERE seminar_id = ?
AND episode_id = ?");

foreach ($data as $course_id => $episode_id) {
$stmt->execute([$course_id, $episode_id]);
}

// Expire orm cache, so the change can take effect
SimpleORMap::expireTableScheme();
}

}
6 changes: 0 additions & 6 deletions migrations/016_fix_cronjobs.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,6 @@

class FixCronjobs extends Migration
{
/*
const FILENAMES = [
'public/plugins_packages/elan-ev/OpenCast/cronjobs/refresh_scheduled_events.php',
'public/plugins_packages/elan-ev/OpenCast/cronjobs/refresh_series.php'
];
*/

public function description()
{
Expand Down
Loading

0 comments on commit 9aa3965

Please sign in to comment.