Skip to content

Commit

Permalink
configurable upload info, fix wysiwyg, some minor bugfixes and changes
Browse files Browse the repository at this point in the history
  • Loading branch information
tgloeggl committed Nov 8, 2023
1 parent 68f43a0 commit 3796278
Show file tree
Hide file tree
Showing 11 changed files with 151 additions and 115 deletions.
5 changes: 3 additions & 2 deletions lib/Providers/OpencastConstants.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ public function register(\Pimple\Container $container)
'workflow'
],
'global_config_options' => [
'OPENCAST_TOS',
'OPENCAST_SHOW_TOS',
'OPENCAST_TOS',
'OPENCAST_ALLOW_ALTERNATE_SCHEDULE' ,
'OPENCAST_MEDIADOWNLOAD',
'OPENCAST_ALLOW_STUDIO',
Expand All @@ -44,7 +44,8 @@ public function register(\Pimple\Container $container)
'OPENCAST_RESOURCE_PROPERTY_ID',
'OPENCAST_SUPPORT_EMAIL',
'OPENCAST_API_TOKEN',
'OPENCAST_DEFAULT_SERVER'
'OPENCAST_DEFAULT_SERVER',
'OPENCAST_UPLOAD_INFO_TEXT_BODY'
]
];
}
Expand Down
5 changes: 4 additions & 1 deletion lib/Routes/Config/SimpleConfigList.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ class SimpleConfigList extends OpencastController

public function __invoke(Request $request, Response $response, $args)
{
global $user;

$config = Config::findBySql(1);

$config_list = [];
Expand Down Expand Up @@ -52,7 +54,8 @@ public function __invoke(Request $request, Response $response, $args)
'plugin_assets_url' => \PluginEngine::getPlugin('Opencast')->getAssetsUrl(),
'auth_url' => \PluginEngine::getURL('opencast', [], 'redirect/authenticate', true),
'redirect_url' => \PluginEngine::getURL('opencast', [], 'redirect/perform', true),
'course_id' => \Context::getId() ?: null
'course_id' => \Context::getId() ?: null,
'user_language' => getUserLanguage($user->id)
], $response);
}

Expand Down
25 changes: 25 additions & 0 deletions migrations/078_upload_legal_info_update_link.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php
class UploadLegalInfoUpdateLink extends Migration
{

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

$stmt = $db->prepare("UPDATE config
SET `value` = :value, type = 'string'
WHERE field = 'OPENCAST_UPLOAD_INFO_TEXT_BODY'
");

$stmt->execute([
':value' => '{"de_DE":"<p>Laden Sie nur Medien hoch, an denen Sie das Nutzungsrecht besitzen!</p><ul><li>Nach §60 UrhG dürfen nur maximal 5-minütige Sequenzen aus urheberrechtlich geschützten Filmen oder Musikaufnahmen bereitgestellt werden, sofern diese einen geringen Umfang des Gesamtwerkes ausmachen.</li><li><a href=\"https://www.uni-bremen.de/urheberrecht/leitfragen/5-rechtssichere-kopien-fuer-andere/antwort-kopien-fuer-lehrende-und-pruefer\">§60 UrhG Zusammenfassung auf den Seiten der Universität Bremen</a></li><li>Medien, bei denen Urheberrechtsverstöße vorliegen, werden ohne vorherige Ankündigung umgehend gelöscht.</li></ul>","en_GB":"<p>Upload</p>"}'
]);

$db->exec("DELETE FROM config WHERE field = 'OPENCAST_UPLOAD_INFO_TEXT_HEADING'");
$db->exec("DELETE FROM config_values WHERE field = 'OPENCAST_UPLOAD_INFO_TEXT_HEADING'");
}

function down()
{
}
}
13 changes: 9 additions & 4 deletions vueapp/components/Config/AdminConfigs.vue
Original file line number Diff line number Diff line change
Expand Up @@ -66,26 +66,31 @@ export default {
methods: {
storeAdminConfig(event) {
event.preventDefault();
let view = this;
this.$store.dispatch('clearMessages');
let params = {};
if (this.config_list?.settings) {
params.settings = this.config_list.settings;
}
if (this.is_scheduling_enabled) {
params.resources = this.config_list.scheduling.resources;
}
this.$store.dispatch('configListUpdate', params)
.then(({ data }) => {
this.$store.dispatch('configListRead');
view.$store.dispatch('configListRead');
if (data.messages.length) {
for (let i = 0; i < data.messages.length; i++ ) {
this.$store.dispatch('addMessage', data.messages[i]);
view.$store.dispatch('addMessage', data.messages[i]);
}
}
}).catch(function (error) {
this.$store.dispatch('addMessage', {
view.$store.dispatch('addMessage', {
type: 'error',
text: this.$gettext('Einstellungen konnten nicht gespeichert werden!')
text: view.$gettext('Einstellungen konnten nicht gespeichert werden!')
});
});
}
Expand Down
34 changes: 30 additions & 4 deletions vueapp/components/Config/ConfigOption.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
</section>
</span>

<label v-if="setting.type == 'string' && !setting.options">
<label v-if="setting.type == 'string' && !setting.options && !isI18N(setting)">
<span :class="{
required: setting.required
}">
Expand All @@ -47,7 +47,7 @@
@change="setValue(setting.value)">
</label>

<label v-if="(setting.type == 'string' || setting.type == 'integer') && setting.options">
<label v-if="(setting.type == 'string' || setting.type == 'integer') && setting.options && !isI18N(setting)">
<span :class="{
required: setting.required
}">
Expand Down Expand Up @@ -100,20 +100,34 @@
</span>
</div>
</label>

<label v-if="setting.type == 'string' && isI18N(setting)">
<span :class="{
required: setting.required
}">
{{ setting.description }}
</span>

<I18NText :text="setting.value"
:languages="languages"
@updateValue="setValue"
/>
</label>
</span>
</template>

<script>
import StudipIcon from '@studip/StudipIcon.vue';
import StudipSelect from '@studip/StudipSelect';
import I18NText from "@/components/Config/I18NText";
export default {
name: "ConfigOption",
props: ['setting'],
props: ['setting', 'languages'],
components: {
StudipIcon, StudipSelect
StudipIcon, StudipSelect, I18NText
},
data() {
Expand Down Expand Up @@ -166,6 +180,18 @@ export default {
if (!this.passwordVisible && this.password.length == 0) {
this.password = '*****';
}
},
isI18N(setting)
{
if (
setting.name == 'OPENCAST_UPLOAD_INFO_TEXT_BODY'
|| setting.name == 'OPENCAST_TOS'
) {
return true;
}
return false;
}
}
}
Expand Down
59 changes: 11 additions & 48 deletions vueapp/components/Config/GlobalOptions.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,8 @@

<ConfigOption v-for="setting in global_settings"
:key="setting.name" :setting="setting"
@updateValue="updateValue"/>
</fieldset>

<fieldset v-if="showTos">
<legend v-translate>
Terms of service
</legend>

<I18NText :text="opencastTos"
:languages="config_list.languages"
@input="updateTos"
@updateValue="updateValue"
/>
</fieldset>
</div>
Expand All @@ -27,23 +18,15 @@
<script>
import { mapGetters } from "vuex";
import StudipButton from "@studip/StudipButton";
import StudipIcon from "@studip/StudipIcon";
import MessageBox from "@/components/MessageBox";
import OpencastIcon from "@/components/OpencastIcon";
import ConfigOption from "@/components/Config/ConfigOption";
import I18NText from "@/components/Config/I18NText";
export default {
name: "GlobalOptions",
components: {
StudipButton,
StudipIcon,
MessageBox,
OpencastIcon,
ConfigOption,
I18NText,
ConfigOption
},
props: ['config_list'],
Expand All @@ -69,8 +52,14 @@ export default {
setting.options = this.defaultServerOptions;
settings.push(setting);
}
else if (this.config_list.settings[id].name != 'OPENCAST_TOS') {
settings.push(this.config_list.settings[id]);
else {
if (this.config_list.settings[id].name == 'OPENCAST_TOS') {
if (this.showTos) {
settings.push(this.config_list.settings[id]);
}
} else {
settings.push(this.config_list.settings[id]);
}
}
}
Expand Down Expand Up @@ -122,24 +111,6 @@ export default {
return options;
},
opencastTos() {
for (let id in this.config_list.settings) {
if (this.config_list.settings[id].name == 'OPENCAST_TOS') {
try {
if (typeof JSON.parse(this.config_list.settings[id].value) !== 'object')
{
return {}
} else {
return JSON.parse(this.config_list.settings[id].value);
}
} catch (e) {
console.log(e);
}
return {}
}
}
}
},
methods: {
Expand All @@ -151,15 +122,7 @@ export default {
return;
}
}
},
updateTos(text) {
for (let id in this.config_list.settings) {
if (this.config_list.settings[id].name == 'OPENCAST_TOS') {
this.config_list.settings[id].value = JSON.stringify(text);
}
}
},
}
}
}
</script>
Loading

0 comments on commit 3796278

Please sign in to comment.