aboutsummaryrefslogtreecommitdiff
path: root/lib/models/ArchivedCourse.php
diff options
context:
space:
mode:
authorMarcus Eibrink-Lunzenauer <lunzenauer@elan-ev.de>2024-06-18 13:18:06 +0000
committerMarcus Eibrink-Lunzenauer <lunzenauer@elan-ev.de>2024-06-18 13:18:06 +0000
commit33fd1358507b4a5abb3dcebe78d407d0567717c1 (patch)
tree6bd8f6959da4c3fc1b8907c0bbc28eb9e10d4a5a /lib/models/ArchivedCourse.php
parent42d46671c0309bddb71a91bbfdc5f2fa2e44384e (diff)
Deprecate `StudipAutoloader` and use composer's `autoload`
Closes #4282 Merge request studip/studip!3099
Diffstat (limited to 'lib/models/ArchivedCourse.php')
-rw-r--r--lib/models/ArchivedCourse.php105
1 files changed, 105 insertions, 0 deletions
diff --git a/lib/models/ArchivedCourse.php b/lib/models/ArchivedCourse.php
new file mode 100644
index 0000000..81879af
--- /dev/null
+++ b/lib/models/ArchivedCourse.php
@@ -0,0 +1,105 @@
+<?php
+/**
+ * ArchivedCourse.class.php
+ * model class for table archiv
+ *
+ * This program 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 2 of
+ * the License, or (at your option) any later version.
+ *
+ * @author André Noack <noack@data-quest.de>
+ * @copyright 2012 Stud.IP Core-Group
+ * @license http://www.gnu.org/licenses/gpl-2.0.html GPL version 2
+ * @category Stud.IP
+ *
+ * @property string $id alias column for seminar_id
+ * @property string $seminar_id database column
+ * @property string $name database column
+ * @property string $untertitel database column
+ * @property string $beschreibung database column
+ * @property int $start_time database column
+ * @property string $semester database column
+ * @property string $heimat_inst_id database column
+ * @property string $institute database column
+ * @property string $dozenten database column
+ * @property string $fakultaet database column
+ * @property string $dump database column
+ * @property string $archiv_file_id database column
+ * @property string $archiv_protected_file_id database column
+ * @property int $mkdate database column
+ * @property string $forumdump database column
+ * @property string|null $wikidump database column
+ * @property string $studienbereiche database column
+ * @property string $veranstaltungsnummer database column
+ * @property SimpleORMapCollection|ArchivedCourseMember[] $members has_many ArchivedCourseMember
+ * @property Institute $home_institut belongs_to Institute
+ */
+
+class ArchivedCourse extends SimpleORMap implements PrivacyObject
+{
+ protected static function configure($config = [])
+ {
+ $config['db_table'] = 'archiv';
+
+ $config['has_many']['members'] = [
+ 'class_name' => ArchivedCourseMember::class,
+ 'on_delete' => 'delete',
+ 'on_store' => 'store',
+ ];
+ $config['belongs_to']['home_institut'] = [
+ 'class_name' => Institute::class,
+ 'foreign_key' => 'heimat_inst_id',
+ ];
+
+ $config['registered_callbacks']['after_delete'][] = 'deleteFiles';
+
+ parent::configure($config);
+ }
+
+ /**
+ * Export available data of a given user into a storage object
+ * (an instance of the StoredUserData class) for that user.
+ *
+ * @param StoredUserData $storage object to store data into
+ */
+ public static function exportUserData(StoredUserData $storage)
+ {
+ $sorm = self::findThru($storage->user_id, [
+ 'thru_table' => 'archiv_user',
+ 'thru_key' => 'user_id',
+ 'thru_assoc_key' => 'Seminar_id',
+ 'assoc_foreign_key' => 'Seminar_id',
+ ]);
+ if ($sorm) {
+ $limit = 'seminar_id name untertitel beschreibung start_time '
+ . 'semester heimat_inst_id institute dozenten fakultaet '
+ . 'archiv_file_id archiv_protected_file_id mkdate '
+ . 'studienbereiche VeranstaltungsNummer';
+ $field_data = [];
+ foreach ($sorm as $row) {
+ $field_data[] = $row->toRawArray($limit);
+ }
+ if ($field_data) {
+ $storage->addTabularData(_('archivierte Seminare'), 'archiv', $field_data);
+ }
+ }
+ }
+
+ /**
+ * delete data files belonging to this archived course
+ *
+ * @return int number of deleted files
+ */
+ public function deleteFiles()
+ {
+ $ok = 0;
+ if ($this->archiv_file_id) {
+ $ok += unlink($GLOBALS['ARCHIV_PATH'] . '/' . basename($this->archiv_file_id));
+ }
+ if ($this->archiv_protected_file_id) {
+ $ok += unlink($GLOBALS['ARCHIV_PATH'] . '/' . basename($this->archiv_protected_file_id));
+ }
+ return $ok;
+ }
+}