diff options
| author | Rasmus Fuhse <fuhse@data-quest.de> | 2021-12-13 15:46:41 +0000 |
|---|---|---|
| committer | Rasmus Fuhse <fuhse@data-quest.de> | 2021-12-13 15:46:41 +0000 |
| commit | c5419123d53da2656e6cec6d7bc3c77f936b73d8 (patch) | |
| tree | 4d37722352a4427777ea9f2fabf499bb9ed8f6a9 /lib/models/OERMaterial.php | |
| parent | 9ccf095bd2c597eef1ffb2c0557b1ca7e1d6b60c (diff) | |
Resolve "StEP00358 Schnittstelle zum OER Portal Niedersachsen"
Diffstat (limited to 'lib/models/OERMaterial.php')
| -rwxr-xr-x | lib/models/OERMaterial.php | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/lib/models/OERMaterial.php b/lib/models/OERMaterial.php index 65acaa4..d718d60 100755 --- a/lib/models/OERMaterial.php +++ b/lib/models/OERMaterial.php @@ -23,6 +23,7 @@ class OERMaterial extends SimpleORMap 'foreign_key' => 'license_identifier' ]; $config['serialized_fields']['structure'] = 'JSONArrayObject'; + $config['registered_callbacks']['before_store'][] = "cbHashURI"; $config['registered_callbacks']['before_delete'][] = "cbDeleteFile"; parent::configure($config); } @@ -181,6 +182,11 @@ class OERMaterial extends SimpleORMap @unlink($this->getFilePath()); } + public function cbHashURI() + { + $this['uri_hash'] = md5($this['uri']); + } + public function getTopics() { $statement = DBManager::get()->prepare(" @@ -235,7 +241,7 @@ class OERMaterial extends SimpleORMap $base = URLHelper::setBaseURL($GLOBALS['ABSOLUTE_URI_STUDIP']); $url = $this['host_id'] ? $this->host->url."download/".$this['foreign_material_id'] - : URLHelper::getURL("dispatch.php/oer/market/download/".$this->getId()); + : URLHelper::getURL("dispatch.php/oer/endpoints/download/".$this->getId()); URLHelper::setBaseURL($base); return $url; } @@ -373,6 +379,25 @@ class OERMaterial extends SimpleORMap } } + /** + * Uploads this material to twillo.de. This is not actually an upload but rather a link with metadata. + * @return bool|string : true on success, on failure a text-string as error-message + */ + public function uploadToTwillo() + { + return TwilloConnector::uploadMaterial($this); + } + + /** + * Removes this material from twillo.de if able. + */ + public function deleteFromTwillo() + { + TwilloConnector::deleteFromTwillo($this['published_id_on_twillo']); + $this['published_id_on_twillo'] = null; + $this->store(); + } + public function fetchData() { if ($this['host_id']) { |
