Skip to content

Commit

Permalink
ext_dl_source
Browse files Browse the repository at this point in the history
  • Loading branch information
ferishili committed Oct 11, 2023
1 parent 113628c commit 2684abd
Show file tree
Hide file tree
Showing 14 changed files with 140 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class xoctPublicationSubUsageFormGUI extends ilPropertyFormGUI
public const F_ALLOW_MULTIPLE = 'allow_multiple';
public const F_MEDIATYPE = 'mediatype';
public const F_IGNORE_OBJECT_SETTINGS = 'ignore_object_settings';
public const F_EXT_DL_SOURCE = 'ext_dl_source';

/**
* @var PublicationUsage
Expand Down Expand Up @@ -147,14 +148,23 @@ protected function initForm()
self::F_IGNORE_OBJECT_SETTINGS
);
$ignore_object_setting->setInfo($this->parent_gui->txt(self::F_IGNORE_OBJECT_SETTINGS . '_info'));
//F_EXT_DL_SOURCE
$ext_dl_source = new ilCheckboxInputGUI(
$this->parent_gui->txt(self::F_EXT_DL_SOURCE),
self::F_EXT_DL_SOURCE
);
$ext_dl_source->setInfo($this->parent_gui->txt(self::F_EXT_DL_SOURCE . '_info'));
} else {
$allow_multiple = new ilHiddenInputGUI(self::F_ALLOW_MULTIPLE);
$allow_multiple->setValue(0);
$ignore_object_setting = new ilHiddenInputGUI(self::F_IGNORE_OBJECT_SETTINGS);
$ignore_object_setting->setValue(0);
$ext_dl_source = new ilHiddenInputGUI(self::F_EXT_DL_SOURCE);
$ext_dl_source->setValue(0);
}
$this->addItem($allow_multiple);
$this->addItem($ignore_object_setting);
$this->addItem($ext_dl_source);
}


Expand All @@ -177,6 +187,7 @@ public function fillForm()
self::F_ALLOW_MULTIPLE => $this->object->isAllowMultiple(),
self::F_MEDIATYPE => $this->object->getMediaType(),
self::F_IGNORE_OBJECT_SETTINGS => $this->object->ignoreObjectSettings(),
self::F_EXT_DL_SOURCE => $this->object->isExternalDownloadSource(),
];

$this->setValuesByArray($array);
Expand Down Expand Up @@ -207,6 +218,7 @@ public function fillObject(): bool
$this->object->setAllowMultiple((bool)$this->getInput(self::F_ALLOW_MULTIPLE));
$this->object->setMediaType($this->getInput(self::F_MEDIATYPE));
$this->object->setIgnoreObjectSettings((bool)$this->getInput(self::F_IGNORE_OBJECT_SETTINGS));
$this->object->setExternalDownloadSource((bool)$this->getInput(self::F_EXT_DL_SOURCE));

return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class xoctPublicationUsageFormGUI extends ilPropertyFormGUI
public const F_ALLOW_MULTIPLE = 'allow_multiple';
public const F_MEDIATYPE = 'mediatype';
public const F_IGNORE_OBJECT_SETTINGS = 'ignore_object_settings';
public const F_EXT_DL_SOURCE = 'ext_dl_source';

/**
* @var PublicationUsage
Expand Down Expand Up @@ -145,14 +146,23 @@ protected function initForm()
self::F_IGNORE_OBJECT_SETTINGS
);
$ignore_object_setting->setInfo($this->parent_gui->txt(self::F_IGNORE_OBJECT_SETTINGS . '_info'));
//F_EXT_DL_SOURCE
$ext_dl_source = new ilCheckboxInputGUI(
$this->parent_gui->txt(self::F_EXT_DL_SOURCE),
self::F_EXT_DL_SOURCE
);
$ext_dl_source->setInfo($this->parent_gui->txt(self::F_EXT_DL_SOURCE . '_info'));
} else {
$allow_multiple = new ilHiddenInputGUI(self::F_ALLOW_MULTIPLE);
$allow_multiple->setValue(0);
$ignore_object_setting = new ilHiddenInputGUI(self::F_IGNORE_OBJECT_SETTINGS);
$ignore_object_setting->setValue(0);
$ext_dl_source = new ilHiddenInputGUI(self::F_EXT_DL_SOURCE);
$ext_dl_source->setValue(0);
}
$this->addItem($allow_multiple);
$this->addItem($ignore_object_setting);
$this->addItem($ext_dl_source);
}

/**
Expand All @@ -174,6 +184,7 @@ public function fillForm(): void
self::F_ALLOW_MULTIPLE => $this->object->isAllowMultiple(),
self::F_MEDIATYPE => $this->object->getMediaType(),
self::F_IGNORE_OBJECT_SETTINGS => $this->object->ignoreObjectSettings(),
self::F_EXT_DL_SOURCE => $this->object->isExternalDownloadSource(),
];

$this->setValuesByArray($array);
Expand Down Expand Up @@ -201,6 +212,7 @@ public function fillObject(): bool
$this->object->setAllowMultiple((bool) $this->getInput(self::F_ALLOW_MULTIPLE));
$this->object->setMediaType($this->getInput(self::F_MEDIATYPE));
$this->object->setIgnoreObjectSettings((bool) $this->getInput(self::F_IGNORE_OBJECT_SETTINGS));
$this->object->setExternalDownloadSource((bool)$this->getInput(self::F_EXT_DL_SOURCE));

return true;
}
Expand Down
7 changes: 0 additions & 7 deletions classes/Conf/class.xoctConfFormGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -232,13 +232,6 @@ protected function initEventsSection()
$cb->setInfo($this->parent_gui->txt(PluginConfig::F_CREATE_SCHEDULED_ALLOWED . '_info'));
$this->addItem($cb);

$cb = new ilCheckboxInputGUI(
$this->parent_gui->txt(PluginConfig::F_EXT_DL_SOURCE),
PluginConfig::F_EXT_DL_SOURCE
);
$cb->setInfo($this->parent_gui->txt(PluginConfig::F_EXT_DL_SOURCE . '_info'));
$this->addItem($cb);

$cb = new ilCheckboxInputGUI(
$this->parent_gui->txt(PluginConfig::F_STUDIO_ALLOWED),
PluginConfig::F_STUDIO_ALLOWED
Expand Down
3 changes: 2 additions & 1 deletion classes/Event/class.xoctEventGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -929,7 +929,8 @@ function ($publication) use ($usage_type, $usage_id): bool {
$extension = pathinfo($url)['extension'];
$url = PluginConfig::getConfig(PluginConfig::F_SIGN_DOWNLOAD_LINKS) ? xoctSecureLink::signDownload($url) : $url;

if (PluginConfig::getConfig(PluginConfig::F_EXT_DL_SOURCE)) {
// if (PluginConfig::getConfig(PluginConfig::F_EXT_DL_SOURCE)) {
if (property_exists($publication, 'ext_dl_source') && $publication->ext_dl_source == true) {
// Open external source page
header('Location: ' . $url);
} else {
Expand Down
4 changes: 0 additions & 4 deletions configuration/default_config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -262,10 +262,6 @@
<name>workflow_unpublish</name>
<value><![CDATA[]]></value>
</xoct_conf>
<xoct_conf>
<name>external_download_source</name>
<value><![CDATA[]]></value>
</xoct_conf>
<xoct_conf>
<name>presenter-mandatory</name>
<value><![CDATA[1]]></value>
Expand Down
4 changes: 2 additions & 2 deletions lang/ilias_de.lang
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ config_editor_link#:#Link zum Opencast-Video-Editor
config_editor_link_info#:#Link, welcher für die Aktion "Schneiden" verwendet wird. Als Platzhalter kann &#123event_id} verwendet werden. Default: https://[ihre-opencast-url.de]/admin-ng/index.html#!/events/events/&#123event_id}/tools/editor
config_eula#:#Nutzungsvereinbarung
config_events#:#Aufzeichnungen
config_external_download_source#:#Externe Downloadquelle
config_external_download_source_info#:#Aktivieren Sie diese Option im Falle einer externen Webseite, um die Downloads anzuzeigen
config_series#:#Serien
config_licenses#:#Lizenzen
config_licenses_info#:#Neue Einträge auf neuer Zeile in der Form URL#Name hinzufügen
Expand Down Expand Up @@ -331,6 +329,8 @@ publication_usage_search_key_info#:#Die Medien/Attachments werden nach dem hier
publication_usage_tag#:#Tag
publication_usage_allow_multiple#:#Mehrere Möglichkeiten zulassen
publication_usage_allow_multiple_info#:#Wenn aktiviert und es werden mehrere Medien/Attachments mit dem oben angegebenen Flavor/Tag gefunden, werden diese alle zum Download in einer Dropdown-Liste angeboten. In diesem Fall wäre die Publikationsgruppe <b>NICHT</b> wirksam.
publication_usage_ext_dl_source#:#Externe Downloadquelle
publication_usage_ext_dl_source_info#:#Aktivieren Sie diese Option im Falle einer externen Webseite, um die Downloads anzuzeigen
series_accept_eula#:#Ich akzeptiere die Nutzungsvereinbarungen
series_alert_eula#:#Die Nutzungsvereinbarung muss akzeptiert werden
series_cancel#:#Abbrechen
Expand Down
4 changes: 2 additions & 2 deletions lang/ilias_en.lang
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ config_schedule_channel#:#Input value for scheduling
config_schedule_channel_info#:#Input value sent to the capture agents when scheduling events via plugin. Warning: Scheduling events requires API v1.1.0.
config_common_idp#:#Common IdP
config_common_idp_info#:#Check if ILIAS and Opencast are using the same identity provider (e.g. Shibboleth or LDAP). This allows for more precise permission checks ("as-user" instead of "with-user-role").
config_external_download_source#:#External download source
config_external_download_source_info#:#Enable this option in case of an external web page to show the downloads
config_oc_studio_allowed#:#Enable Opencast Studio
config_oc_studio_allowed_info#:#Allow users to access to Opencast Studio from Ilias (Requires Opencast > 8.3)
config_oc_studio_url#:#Opencast Studio URL
Expand Down Expand Up @@ -334,6 +332,8 @@ publication_usage_search_key_info#:#The media/attachments will be search for the
publication_usage_tag#:#Tag
publication_usage_allow_multiple#:#Allow multiple
publication_usage_allow_multiple_info#:#If active and multiple media/attachments can be found for the given flavor/tag, all of them in a form of dropdown list will be offered to download. In this case the Publication Group <b>would NOT</b> be effective.
publication_usage_ext_dl_source#:#External download source
publication_usage_ext_dl_source_info#:#Enable this option in case of an external web page to show the downloads
series_accept_eula#:#I accept the agreement
series_alert_eula#:#The EULA has to be accepted
series_cancel#:#Cancel
Expand Down
27 changes: 26 additions & 1 deletion sql/dbupdate.php
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,31 @@
\srag\Plugins\Opencast\Model\Publication\Config\PublicationUsageGroup::updateDB();
// Introducing PublicationSubUsage as for sub usages.
\srag\Plugins\Opencast\Model\Publication\Config\PublicationSubUsage::updateDB();
// Add display name and groupd id to PublicationUsage.
// Add new columns to PublicationUsage.
\srag\Plugins\Opencast\Model\Publication\Config\PublicationUsage::updateDB();

foreach (\srag\Plugins\Opencast\Model\Publication\Config\PublicationUsage::get() as $publication_usage) {
if ($publication_usage->getUsageId() == \srag\Plugins\Opencast\Model\Publication\Config\PublicationUsage::USAGE_DOWNLOAD || $publication_usage->getUsageId() == \srag\Plugins\Opencast\Model\Publication\Config\PublicationUsage::USAGE_DOWNLOAD_FALLBACK) {
$ext_dl_source = false;
$config = \srag\Plugins\Opencast\Model\Config\PluginConfig::getConfig('external_download_source');
if ((bool) $config) {
$ext_dl_source = true;
}
$publication_usage->setExternalDownloadSource($ext_dl_source);
$publication_usage->update();
}
}

foreach (\srag\Plugins\Opencast\Model\Publication\Config\PublicationSubUsage::get() as $publication_subusage) {
if ($publication_subusage->getParentUsageId() == \srag\Plugins\Opencast\Model\Publication\Config\PublicationUsage::USAGE_DOWNLOAD || $publication_subusage->getParentUsageId() == \srag\Plugins\Opencast\Model\Publication\Config\PublicationUsage::USAGE_DOWNLOAD_FALLBACK) {
$ext_dl_source = false;
$config = \srag\Plugins\Opencast\Model\Config\PluginConfig::getConfig('external_download_source');
if ((bool) $config) {
$ext_dl_source = true;
}
$publication_subusage->setExternalDownloadSource($ext_dl_source);
$publication_subusage->update();
}
}

?>
11 changes: 10 additions & 1 deletion src/Model/Config/PluginConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ class PluginConfig extends ActiveRecord
public const F_CREATE_SCHEDULED_ALLOWED = 'create_scheduled_allowed';
public const F_STUDIO_ALLOWED = 'oc_studio_allowed';
public const F_STUDIO_URL = 'oc_studio_url';
public const F_EXT_DL_SOURCE = 'external_download_source';
public const F_VIDEO_PORTAL_LINK = 'video_portal_link';
public const F_VIDEO_PORTAL_TITLE = 'video_portal_title';
public const F_ENABLE_LIVE_STREAMS = 'enable_live_streams';
Expand Down Expand Up @@ -238,6 +237,8 @@ public static function importFromXML(string $xml_file_path): void
$xoctPublicationUsage->setMediaType($mediatype ?? '');
$ignore_object_setting = (bool) $node->getElementsByTagName('ignore_object_setting')->item(0)->nodeValue;
$xoctPublicationUsage->setIgnoreObjectSettings($ignore_object_setting);
$ext_dl_source = (bool) $node->getElementsByTagName('ext_dl_source')->item(0)->nodeValue;
$xoctPublicationUsage->setExternalDownloadSource($ext_dl_source);

if (!PublicationUsage::where(['usage_id' => $xoctPublicationUsage->getUsageId()])->hasSets()) {
$xoctPublicationUsage->create();
Expand Down Expand Up @@ -274,6 +275,8 @@ public static function importFromXML(string $xml_file_path): void
$xoctPublicationSubUsage->setMediaType($mediatype ?? '');
$ignore_object_setting = (bool) $node->getElementsByTagName('ignore_object_setting')->item(0)->nodeValue;
$xoctPublicationSubUsage->setIgnoreObjectSettings($ignore_object_setting);
$ext_dl_source = (bool) $node->getElementsByTagName('ext_dl_source')->item(0)->nodeValue;
$xoctPublicationSubUsage->setExternalDownloadSource($ext_dl_source);
$xoctPublicationSubUsage->create();
}

Expand Down Expand Up @@ -404,6 +407,9 @@ public static function getXMLExport(): string
$xml_xoctPU->appendChild(new DOMElement('ignore_object_setting'))->appendChild(
new DOMCdataSection($xoctPublicationUsage->ignoreObjectSettings())
);
$xml_xoctPU->appendChild(new DOMElement('ext_dl_source'))->appendChild(
new DOMCdataSection($xoctPublicationUsage->isExternalDownloadSource())
);
}

// xoctPublicationSubUsage
Expand Down Expand Up @@ -449,6 +455,9 @@ public static function getXMLExport(): string
$xml_xoctPSU->appendChild(new DOMElement('ignore_object_setting'))->appendChild(
new DOMCdataSection($xoctPublicationSubUsage->ignoreObjectSettings())
);
$xml_xoctPSU->appendChild(new DOMElement('ext_dl_source'))->appendChild(
new DOMCdataSection($xoctPublicationSubUsage->isExternalDownloadSource())
);
}

// xoctPublicationUsageGroups
Expand Down
25 changes: 24 additions & 1 deletion src/Model/Publication/Config/PublicationSubUsage.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,14 @@ public function getConnectorContainerName()
* @con_length 1
*/
protected $ignore_object_setting = false;

/**
* @var bool
*
* @con_has_field true
* @con_fieldtype integer
* @con_length 1
*/
protected $ext_dl_source = false;

/**
* @return int
Expand Down Expand Up @@ -433,6 +440,22 @@ public function setIgnoreObjectSettings(bool $ignore_object_setting)
$this->ignore_object_setting = $ignore_object_setting;
}

/**
* @return bool
*/
public function isExternalDownloadSource(): bool
{
return (bool) $this->ext_dl_source;
}

/**
* @param bool $ext_dl_source
*/
public function setExternalDownloadSource(bool $ext_dl_source)
{
$this->ext_dl_source = $ext_dl_source;
}

/**
* Create the object, but we check if it is allowed!
* @throws xoctException
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ public function convertSingleSubToUsage($sub_id): ?PublicationUsage
$usage->setAllowMultiple($sub->isAllowMultiple());
$usage->setMediaType($sub->getMediaType());
$usage->setIgnoreObjectSettings($sub->ignoreObjectSettings());
$usage->setExternalDownloadSource($sub->isExternalDownloadSource());
// Add extra tracking information.
$usage->is_sub = true;
$usage->sub_id = $sub->getId();
Expand Down
24 changes: 24 additions & 0 deletions src/Model/Publication/Config/PublicationUsage.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,14 @@ public function getConnectorContainerName()
* @con_length 1
*/
protected $ignore_object_setting = false;
/**
* @var bool
*
* @con_has_field true
* @con_fieldtype integer
* @con_length 1
*/
protected $ext_dl_source = false;

public function getUsageId(): string
{
Expand Down Expand Up @@ -400,4 +408,20 @@ public function setIgnoreObjectSettings(bool $ignore_object_setting)
{
$this->ignore_object_setting = $ignore_object_setting;
}

/**
* @return bool
*/
public function isExternalDownloadSource(): bool
{
return (bool) $this->ext_dl_source;
}

/**
* @param bool $ext_dl_source
*/
public function setExternalDownloadSource(bool $ext_dl_source)
{
$this->ext_dl_source = $ext_dl_source;
}
}
4 changes: 3 additions & 1 deletion src/Model/Publication/Config/PublicationUsageRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ public function store(
string $tag = '',
bool $allow_multiple = false,
string $mediatype = '',
bool $ignore_object_settings = false
bool $ignore_object_settings = false,
bool $ext_dl_source = false
): void {
/** @var PublicationUsage $usage */
$usage = PublicationUsage::findOrGetInstance($usage);
Expand All @@ -92,6 +93,7 @@ public function store(
$usage->setAllowMultiple($allow_multiple);
$usage->setMediaType($mediatype);
$usage->setIgnoreObjectSettings($ignore_object_settings);
$usage->setExternalDownloadSource($ext_dl_source);
$usage->store();
}

Expand Down
26 changes: 22 additions & 4 deletions src/Model/Publication/PublicationSelector.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,11 +173,29 @@ public function getDownloadPublications(): array
}
}
if (empty($pubs)) {
$pubs = $this->getPublicationMetadataForUsage(
$this->publication_usage_repository->getUsage(PublicationUsage::USAGE_DOWNLOAD_FALLBACK)
);
$download_fallback_usage = $this->publication_usage_repository->getUsage(PublicationUsage::USAGE_DOWNLOAD_FALLBACK);
$download_usages = array_merge([$download_fallback_usage], $download_usages);
$pubs = $this->getPublicationMetadataForUsage($download_fallback_usage);
}
$this->download_publications = $pubs;
// adding external download source option to the publications.
$pubs_mapped = array_map(function ($pub) use ($download_usages) {
$ext_dl_source = false;
$usage_id = $pub->usage_id;
$usage_type = $pub->usage_type;
$usage_filtered = array_filter($download_usages, function ($usage) use ($usage_id, $usage_type) {
if ($usage_type == 'sub') {
return property_exists($usage, 'is_sub') && $usage->is_sub == true && $usage->sub_id == $usage_id;
} else {
return !property_exists($usage, 'is_sub') && $usage->getUsageId() == $usage_id;
}
});
if (!empty($usage_filtered)) {
$ext_dl_source = reset($usage_filtered)->isExternalDownloadSource();
}
$pub->ext_dl_source = $ext_dl_source;
return $pub;
}, $pubs);
$this->download_publications = $pubs_mapped;
}

return $this->download_publications;
Expand Down

0 comments on commit 2684abd

Please sign in to comment.