diff --git a/lib/models/Abschluss.php b/lib/models/Abschluss.php index 0c030838fe3a1430850a4e182671c665a6a98282..e222feb37653b4bd3455785ad70daa2043740a80 100644 --- a/lib/models/Abschluss.php +++ b/lib/models/Abschluss.php @@ -16,61 +16,31 @@ class Abschluss extends ModuleManagementModelTreeItem implements PrivacyObject { - /** - * Number of assigned Faecher. - * @var type int - */ - private $count_faecher; - - /** - * Number of Studiengaenge this Abschluss is assigned to. - * @var type int - */ - private $count_studiengaenge; - - /** - * The name of the assigned Kategorie. - * @var type string - */ - private $kategorie_name; - - /** - * The id of the assigned Kategorie. - * @var type - */ - private $kategorie_id; - - /** - * Alias for $count_studiengaenge - * @var type - */ - private $count_objects; - protected static function configure($config = []) { $config['db_table'] = 'abschluss'; $config['belongs_to']['category'] = [ - 'class_name' => 'AbschlussKategorie', + 'class_name' => AbschlussKategorie::class, 'assoc_func' => 'findByAbschluss', ]; $config['has_one']['category_assignment'] = [ - 'class_name' => 'AbschlussZuord', + 'class_name' => AbschlussZuord::class, 'assoc_foreign_key' => 'abschluss_id', 'on_store' => 'store', 'on_delete' => 'delete' ]; $config['has_many']['faecher'] = [ - 'class_name' => 'Fach', + 'class_name' => Fach::class, 'assoc_func' => 'findByAbschluss' ]; $config['has_many']['studiengaenge'] = [ - 'class_name' => 'Studiengang', + 'class_name' => Studiengang::class, 'assoc_foreign_key' => 'abschluss_id' ]; $config['has_and_belongs_to_many']['professions'] = [ - 'class_name' => 'Fach', + 'class_name' => Fach::class, 'thru_table' => 'user_studiengang', 'thru_key' => 'abschluss_id', 'thru_assoc_key' => 'fach_id', @@ -78,13 +48,13 @@ class Abschluss extends ModuleManagementModelTreeItem implements PrivacyObject ]; $config['additional_fields']['count_faecher']['get'] = - function($abschluss) { return $abschluss->count_faecher; }; + function($abschluss) { return $abschluss->count_faecher; }; $config['additional_fields']['kategorie_name']['get'] = - function($abschluss) { return $abschluss->kategorie_name; }; + function($abschluss) { return $abschluss->kategorie_name; }; $config['additional_fields']['kategorie_id']['get'] = - function($abschluss) { return $abschluss->category_assignment->kategorie_id; }; + function($abschluss) { return $abschluss->category_assignment->kategorie_id; }; $config['additional_fields']['count_studiengaenge']['get'] = - function($abschluss) { return $abschluss->count_studiengaenge; }; + function($abschluss) { return $abschluss->count_studiengaenge; }; $config['additional_fields']['count_objects']['get'] = function($abschluss) { return $abschluss->count_objects; }; $config['additional_fields']['count_user']['get'] = 'countUser'; @@ -96,6 +66,36 @@ class Abschluss extends ModuleManagementModelTreeItem implements PrivacyObject parent::configure($config); } + /** + * Number of assigned Faecher. + * @var type int + */ + private $count_faecher; + + /** + * Number of Studiengaenge this Abschluss is assigned to. + * @var type int + */ + private $count_studiengaenge; + + /** + * The name of the assigned Kategorie. + * @var type string + */ + private $kategorie_name; + + /** + * The id of the assigned Kategorie. + * @var type + */ + private $kategorie_id; + + /** + * Alias for $count_studiengaenge + * @var type + */ + private $count_objects; + public function __construct($id = null) { parent::__construct($id); diff --git a/lib/models/AbschlussKategorie.php b/lib/models/AbschlussKategorie.php index 302c2711c353b75d3890d8fb2f15ca032b33cfe8..0f866c47b0ae625497b83ee04d20aa3729011d21 100644 --- a/lib/models/AbschlussKategorie.php +++ b/lib/models/AbschlussKategorie.php @@ -47,26 +47,26 @@ class AbschlussKategorie extends ModuleManagementModelTreeItem $config['db_table'] = 'mvv_abschl_kategorie'; $config['has_many']['documents'] = [ - 'class_name' => 'MvvFile', + 'class_name' => MvvFile::class, 'assoc_func' => 'findbyrange_id', 'assoc_func_params_func' => function ($stg) { return $stg; } ]; $config['has_many']['document_assignments'] = [ - 'class_name' => 'MvvFile', + 'class_name' => MvvFile::class, 'assoc_foreign_key' => 'range_id', 'order_by' => 'ORDER BY position', 'on_delete' => 'delete', 'on_store' => 'store' ]; $config['has_and_belongs_to_many']['abschluesse'] = [ - 'class_name' => 'Abschluss', + 'class_name' => Abschluss::class, 'thru_table' => 'mvv_abschl_zuord', 'thru_key' => 'kategorie_id', 'thru_assoc_key' => 'abschluss_id', 'order_by' => 'ORDER BY position' ]; $config['has_many']['abschluss_assignments'] = [ - 'class_name' => 'AbschlussZuord', + 'class_name' => AbschlussZuord::class, 'assoc_foreign_key' => 'kategorie_id', 'on_delete' => 'delete' ]; diff --git a/lib/models/AbschlussZuord.php b/lib/models/AbschlussZuord.php index 8ec666764418b79412f47ac9d258c5efcc8965bb..9a83e58fc29b4cb7eb3009d95cd70db8a8c90acf 100644 --- a/lib/models/AbschlussZuord.php +++ b/lib/models/AbschlussZuord.php @@ -23,12 +23,12 @@ class AbschlussZuord extends ModuleManagementModel $config['db_table'] = 'mvv_abschl_zuord'; $config['belongs_to']['abschluss'] = [ - 'class_name' => 'Abschluss', + 'class_name' => Abschluss::class, 'foreign_key' => 'abschluss_id', 'assoc_func' => 'findCached', ]; $config['belongs_to']['kategorie'] = [ - 'class_name' => 'AbschlussKategorie', + 'class_name' => AbschlussKategorie::class, 'foreign_key' => 'kategorie_id', 'assoc_func' => 'findCached', ]; diff --git a/lib/models/AdmissionApplication.class.php b/lib/models/AdmissionApplication.class.php index d91f77b99439a0f3342fa94d07da76873bb72fb8..74c79860a3eac66fb488e003a317f21b688a2aaf 100644 --- a/lib/models/AdmissionApplication.class.php +++ b/lib/models/AdmissionApplication.class.php @@ -33,6 +33,27 @@ */ class AdmissionApplication extends SimpleORMap implements PrivacyObject { + protected static function configure($config = []) + { + $config['db_table'] = 'admission_seminar_user'; + $config['belongs_to']['user'] = [ + 'class_name' => User::class, + 'foreign_key' => 'user_id', + ]; + $config['belongs_to']['course'] = [ + 'class_name' => Course::class, + 'foreign_key' => 'seminar_id', + ]; + $config['additional_fields']['vorname'] = ['user', 'vorname']; + $config['additional_fields']['nachname'] = ['user', 'nachname']; + $config['additional_fields']['username'] = ['user', 'username']; + $config['additional_fields']['email'] = ['user', 'email']; + $config['additional_fields']['title_front'] = ['user', 'title_front']; + $config['additional_fields']['title_rear'] = ['user', 'title_rear']; + $config['additional_fields']['course_name'] = []; + parent::configure($config); + } + public static function findByCourse($course_id) { $db = DbManager::get(); @@ -57,27 +78,6 @@ class AdmissionApplication extends SimpleORMap implements PrivacyObject __CLASS__ . '::buildExisting'); } - protected static function configure($config = []) - { - $config['db_table'] = 'admission_seminar_user'; - $config['belongs_to']['user'] = [ - 'class_name' => 'User', - 'foreign_key' => 'user_id', - ]; - $config['belongs_to']['course'] = [ - 'class_name' => 'Course', - 'foreign_key' => 'seminar_id', - ]; - $config['additional_fields']['vorname'] = ['user', 'vorname']; - $config['additional_fields']['nachname'] = ['user', 'nachname']; - $config['additional_fields']['username'] = ['user', 'username']; - $config['additional_fields']['email'] = ['user', 'email']; - $config['additional_fields']['title_front'] = ['user', 'title_front']; - $config['additional_fields']['title_rear'] = ['user', 'title_rear']; - $config['additional_fields']['course_name'] = []; - parent::configure($config); - } - public function getUserFullname($format = 'full') { return User::build(array_merge(['motto' => ''], $this->toArray('vorname nachname username title_front title_rear')))->getFullname($format); diff --git a/lib/models/ArchivedCourseMember.class.php b/lib/models/ArchivedCourseMember.class.php index ecc2cec612ddc67f997b93762ae113cdbf233e4f..536c1b677eab578cde01e2194c06b4fcc7b86b8b 100644 --- a/lib/models/ArchivedCourseMember.class.php +++ b/lib/models/ArchivedCourseMember.class.php @@ -22,31 +22,30 @@ */ class ArchivedCourseMember extends SimpleORMap implements PrivacyObject { - - public static function findByCourse($course_id) - { - return self::findBySeminar_id($course_id); - } - - public static function findByUser($user_id) - { - return self::findByUser_id($user_id); - } - protected static function configure($config = []) { $config['db_table'] = 'archiv_user'; $config['belongs_to']['user'] = [ - 'class_name' => 'User', + 'class_name' => User::class, 'foreign_key' => 'user_id', ]; $config['belongs_to']['course'] = [ - 'class_name' => 'ArchivedCourse', + 'class_name' => ArchivedCourse::class, 'foreign_key' => 'seminar_id', ]; parent::configure($config); } + public static function findByCourse($course_id) + { + return self::findBySeminar_id($course_id); + } + + public static function findByUser($user_id) + { + return self::findByUser_id($user_id); + } + /** * Export available data of a given user into a storage object * (an instance of the StoredUserData class) for that user. diff --git a/lib/models/Aufbaustudiengang.php b/lib/models/Aufbaustudiengang.php index d9429d68f939046c8d4f9b70fe53d29bf91dc8f8..9fba6e76eacc9b753a17803690caffdf70b5507e 100644 --- a/lib/models/Aufbaustudiengang.php +++ b/lib/models/Aufbaustudiengang.php @@ -16,21 +16,20 @@ class Aufbaustudiengang extends ModuleManagementModel { - protected static function configure($config = []) { $config['db_table'] = 'mvv_aufbaustudiengang'; - $config['belongs_to']['grund_studiengang'] = array( - 'class_name' => 'Studiengang', + $config['belongs_to']['grund_studiengang'] = [ + 'class_name' => Studiengang::class, 'foreign_key' => 'grund_stg_id', 'assoc_func' => 'findCached', - ); - $config['has_one']['aufbau_studiengang'] = array( - 'class_name' => 'Studiengang', + ]; + $config['has_one']['aufbau_studiengang'] = [ + 'class_name' => Studiengang::class, 'foreign_key' => 'aufbau_stg_id', 'assoc_func' => 'findCached', - ); + ]; $config['i18n_fields']['kommentar'] = true; diff --git a/lib/models/AuthUserMd5.class.php b/lib/models/AuthUserMd5.class.php index 31df383f944fcb687f2b5468aa8b57af144124b0..5879cb94836635d6960a2e65d54ddc0c8b93f459 100644 --- a/lib/models/AuthUserMd5.class.php +++ b/lib/models/AuthUserMd5.class.php @@ -31,10 +31,8 @@ class AuthUserMd5 extends SimpleORMap { - /** - * - * @param string $id primary key of table + * @param array $config */ protected static function configure($config = []) { diff --git a/lib/models/AuxLockRule.php b/lib/models/AuxLockRule.php index 5581d006a2bc3a50def35abbb684eca3cf08cbc3..ca0f168ddbfa15f56c0311fdffcce50bd4190fa0 100644 --- a/lib/models/AuxLockRule.php +++ b/lib/models/AuxLockRule.php @@ -25,17 +25,11 @@ */ class AuxLockRule extends SimpleORMap { - - /** - * Cache to avoid loading datafields for a user more than once - */ - private $datafieldCache = []; - protected static function configure($config = []) { $config['db_table'] = 'aux_lock_rules'; $config['belongs_to']['course'] = [ - 'class_name' => 'Course', + 'class_name' => Course::class, 'foreign_key' => 'lock_id', 'assoc_foreign_key' => 'aux_lock_rule', ]; @@ -44,6 +38,11 @@ class AuxLockRule extends SimpleORMap parent::configure($config); } + /** + * Cache to avoid loading datafields for a user more than once + */ + private $datafieldCache = []; + /** * Returns the sorted and filtered datafields of an aux * diff --git a/lib/models/BlubberStatusgruppeThread.php b/lib/models/BlubberStatusgruppeThread.php index 57f1d29b3da7db9de6a28341646c46fe5d72d302..bd9e443351bd4080a68f419cc4f2ead2b88c4e00 100644 --- a/lib/models/BlubberStatusgruppeThread.php +++ b/lib/models/BlubberStatusgruppeThread.php @@ -5,7 +5,7 @@ class BlubberStatusgruppeThread extends BlubberThread protected static function configure($config = []) { $config['belongs_to']['statusgruppe'] = [ - 'class_name' => 'Statusgruppen', + 'class_name' => Statusgruppen::class, 'foreign_key' => function ($thread) { return $thread['metadata']['statusgruppe_id']; } diff --git a/lib/models/CalendarEvent.class.php b/lib/models/CalendarEvent.class.php index a61922c2c7db82b753686df9e58d44a922de82c1..a7edb4aaaf53610c57e2c09e6017a7d4c2e80461 100644 --- a/lib/models/CalendarEvent.class.php +++ b/lib/models/CalendarEvent.class.php @@ -33,9 +33,6 @@ class CalendarEvent extends SimpleORMap implements Event, PrivacyObject const PARTSTAT_DELEGATED = 4; const PARTSTAT_NEEDS_ACTION = 5; - private $properties = null; - private $permission_user_id = null; - protected static function configure($config = []) { $config['db_table'] = 'calendar_event'; @@ -94,6 +91,9 @@ class CalendarEvent extends SimpleORMap implements Event, PrivacyObject parent::configure($config); } + private $properties = null; + private $permission_user_id = null; + /** * Returns the owner of this event as an object of type User, Course * or Institute. diff --git a/lib/models/CalendarUser.class.php b/lib/models/CalendarUser.class.php index a016d2eec03bfc19b993e105f853b362c7dc1762..02fdfceda230066f0a323f88c5895c8d75dc477d 100644 --- a/lib/models/CalendarUser.class.php +++ b/lib/models/CalendarUser.class.php @@ -15,18 +15,17 @@ class CalendarUser extends SimpleORMap { - protected static function configure($config = []) { $config['db_table'] = 'calendar_user'; $config['has_one']['owner'] = [ - 'class_name' => 'User', + 'class_name' => User::class, 'foreign_key' => 'owner_id', 'assoc_foreign_key' => 'user_id' ]; $config['belongs_to']['user'] = [ - 'class_name' => 'User', + 'class_name' => User::class, 'foreign_key' => 'user_id' ]; @@ -38,7 +37,6 @@ class CalendarUser extends SimpleORMap }; parent::configure($config); - } public function setPerm($permission) diff --git a/lib/models/Clipboard.class.php b/lib/models/Clipboard.class.php index 0d36a9e4b600cfbb2a9194be305919fc7d317b7e..61f926c69390e15dadd4344579501aa85f9ede49 100644 --- a/lib/models/Clipboard.class.php +++ b/lib/models/Clipboard.class.php @@ -41,18 +41,18 @@ */ class Clipboard extends SimpleORMap { - public static function configure($config = []) + protected static function configure($config = []) { $config['db_table'] = 'clipboards'; $config['belongs_to']['user'] = [ - 'class_name' => 'User', + 'class_name' => User::class, 'foreign_key' => 'user_id', 'assoc_func' => 'find' ]; $config['has_many']['items'] = [ - 'class_name' => 'ClipboardItem', + 'class_name' => ClipboardItem::class, 'assoc_foreign_key' => 'clipboard_id', 'on_delete' => 'delete', 'on_store' => 'store' diff --git a/lib/models/ClipboardItem.class.php b/lib/models/ClipboardItem.class.php index b09a12dcbec10793ad5bb1f13a79b4d2a60995a6..b5199ed09f2d20cbb1409ea2d8c4c576161b37b5 100644 --- a/lib/models/ClipboardItem.class.php +++ b/lib/models/ClipboardItem.class.php @@ -33,12 +33,12 @@ */ class ClipboardItem extends SimpleORMap { - public static function configure($config = []) + protected static function configure($config = []) { $config['db_table'] = 'clipboard_items'; $config['belongs_to']['clipboard'] = [ - 'class_name' => 'Clipboard', + 'class_name' => Clipboard::class, 'foreign_key' => 'clipboard_id', 'assoc_func' => 'find' ]; diff --git a/lib/models/ColourValue.class.php b/lib/models/ColourValue.class.php index 5523f102f69a56d590e4986c05e00ead607f6d2d..9b1a899d8aa58f1b6bfee54b5db353247762d483 100644 --- a/lib/models/ColourValue.class.php +++ b/lib/models/ColourValue.class.php @@ -39,13 +39,6 @@ */ class ColourValue extends SimpleORMap { - /** - * $colours is an array with all colour values that is filled - * when a colour is requested. - */ - protected static $colours; - - protected static function configure($config = []) { $config['db_table'] = 'colour_values'; @@ -55,6 +48,11 @@ class ColourValue extends SimpleORMap parent::configure($config); } + /** + * $colours is an array with all colour values that is filled + * when a colour is requested. + */ + protected static $colours; /** * The find method is overloaded here since the table is usually very diff --git a/lib/models/Contact.class.php b/lib/models/Contact.class.php index ddc9fe73d8410b550c2e0988163b723bd9292a56..32eae2c74f647bbaad893e44713cc3c1f61d824e 100644 --- a/lib/models/Contact.class.php +++ b/lib/models/Contact.class.php @@ -17,19 +17,19 @@ */ class Contact extends SimpleORMap { - protected static function configure($config = []) { - $config['db_table'] = 'contact'; + $config['belongs_to']['owner'] = [ - 'class_name' => 'User', + 'class_name' => User::class, 'foreign_key' => 'owner_id' ]; $config['belongs_to']['friend'] = [ - 'class_name' => 'User', + 'class_name' => User::class, 'foreign_key' => 'user_id' ]; + $config['has_many']['group_assignments'] = [ 'class_name' => 'StatusgruppeUser', 'assoc_func' => 'findByContact', @@ -43,7 +43,6 @@ class Contact extends SimpleORMap 'on_delete' => 'delete' ]; - parent::configure($config); } } diff --git a/lib/models/Course.class.php b/lib/models/Course.class.php index 63e5186df347d3a0fdb902eddb622b9bd3883901..971d92f82ef68173e147e16fa70ef8799ce5f2df 100644 --- a/lib/models/Course.class.php +++ b/lib/models/Course.class.php @@ -74,68 +74,52 @@ class Course extends SimpleORMap implements Range, PrivacyObject, StudipItem, FeedbackRange { - - /** - * Returns the currently active course or false if none is active. - * - * @return Course object of currently active course, null otherwise - * @since 3.0 - */ - public static function findCurrent() - { - if (Context::isCourse()) { - return Context::get(); - } - - return null; - } - protected static function configure($config = []) { $config['db_table'] = 'seminare'; $config['has_many']['topics'] = [ - 'class_name' => 'CourseTopic', + 'class_name' => CourseTopic::class, 'on_delete' => 'delete', 'on_store' => 'store', ]; $config['has_many']['dates'] = [ - 'class_name' => 'CourseDate', + 'class_name' => CourseDate::class, 'assoc_foreign_key' => 'range_id', 'on_delete' => 'delete', 'on_store' => 'store', 'order_by' => 'ORDER BY date' ]; $config['has_many']['ex_dates'] = [ - 'class_name' => 'CourseExDate', + 'class_name' => CourseExDate::class, 'assoc_foreign_key' => 'range_id', 'on_delete' => 'delete', 'on_store' => 'store', ]; $config['has_many']['members'] = [ - 'class_name' => 'CourseMember', + 'class_name' => CourseMember::class, 'assoc_func' => 'findByCourse', 'on_delete' => 'delete', 'on_store' => 'store', ]; $config['has_many']['deputies'] = [ - 'class_name' => 'Deputy', + 'class_name' => Deputy::class, 'assoc_func' => 'findByRange_id', 'on_delete' => 'delete', 'on_store' => 'store', ]; $config['has_many']['statusgruppen'] = [ - 'class_name' => 'Statusgruppen', + 'class_name' => Statusgruppen::class, 'on_delete' => 'delete', 'on_store' => 'store', ]; $config['has_many']['admission_applicants'] = [ - 'class_name' => 'AdmissionApplication', + 'class_name' => AdmissionApplication::class, 'assoc_func' => 'findByCourse', 'on_delete' => 'delete', 'on_store' => 'store', ]; $config['has_many']['datafields'] = [ - 'class_name' => 'DatafieldEntryModel', + 'class_name' => DatafieldEntryModel::class, 'assoc_func' => 'findByModel', 'assoc_foreign_key' => function ($model, $params) { $model->setValue('range_id', $params[0]->id); @@ -147,20 +131,20 @@ class Course extends SimpleORMap implements Range, PrivacyObject, StudipItem, Fe 'on_store' => 'store', ]; $config['has_many']['cycles'] = [ - 'class_name' => 'SeminarCycleDate', + 'class_name' => SeminarCycleDate::class, 'assoc_func' => 'findBySeminar', 'on_delete' => 'delete', 'on_store' => 'store', ]; $config['has_many']['blubberthreads'] = [ - 'class_name' => 'BlubberThread', + 'class_name' => BlubberThread::class, 'assoc_func' => 'findBySeminar', 'on_delete' => 'delete', 'on_store' => 'store', ]; $config['has_and_belongs_to_many']['semesters'] = [ - 'class_name' => 'Semester', + 'class_name' => Semester::class, 'thru_table' => 'semester_courses', 'thru_key' => 'course_id', 'thru_assoc_key' => 'semester_id', @@ -170,29 +154,29 @@ class Course extends SimpleORMap implements Range, PrivacyObject, StudipItem, Fe ]; $config['belongs_to']['home_institut'] = [ - 'class_name' => 'Institute', + 'class_name' => Institute::class, 'foreign_key' => 'institut_id', 'assoc_func' => 'find', ]; $config['belongs_to']['aux'] = [ - 'class_name' => 'AuxLockRule', + 'class_name' => AuxLockRule::class, 'foreign_key' => 'aux_lock_rule', ]; $config['has_and_belongs_to_many']['study_areas'] = [ - 'class_name' => 'StudipStudyArea', + 'class_name' => StudipStudyArea::class, 'thru_table' => 'seminar_sem_tree', 'on_delete' => 'delete', 'on_store' => 'store', ]; $config['has_and_belongs_to_many']['institutes'] = [ - 'class_name' => 'Institute', + 'class_name' => Institute::class, 'thru_table' => 'seminar_inst', 'on_delete' => 'delete', 'on_store' => 'store', ]; $config['has_and_belongs_to_many']['domains'] = [ - 'class_name' => 'UserDomain', + 'class_name' => UserDomain::class, 'thru_table' => 'seminar_userdomains', 'on_delete' => 'delete', 'on_store' => 'store', @@ -200,21 +184,21 @@ class Course extends SimpleORMap implements Range, PrivacyObject, StudipItem, Fe ]; $config['has_many']['room_requests'] = [ - 'class_name' => 'RoomRequest', + 'class_name' => RoomRequest::class, 'assoc_foreign_key' => 'course_id', 'on_delete' => 'delete', ]; $config['belongs_to']['parent'] = [ - 'class_name' => 'Course', + 'class_name' => Course::class, 'foreign_key' => 'parent_course' ]; $config['has_many']['children'] = [ - 'class_name' => 'Course', + 'class_name' => Course::class, 'assoc_foreign_key' => 'parent_course', 'order_by' => 'GROUP BY seminar_id ORDER BY VeranstaltungsNummer, Name' ]; $config['has_many']['tools'] = [ - 'class_name' => 'ToolActivation', + 'class_name' => ToolActivation::class, 'assoc_foreign_key' => 'range_id', 'order_by' => 'ORDER BY position', 'on_delete' => 'delete', @@ -282,6 +266,21 @@ class Course extends SimpleORMap implements Range, PrivacyObject, StudipItem, Fe parent::configure($config); } + + /** + * Returns the currently active course or false if none is active. + * + * @return Course object of currently active course, null otherwise + * @since 3.0 + */ + public static function findCurrent() + { + if (Context::isCourse()) { + return Context::get(); + } + + return null; + } public function getEnd_Time() { return $this->duration_time == -1 ? -1 : $this->start_time + $this->duration_time; diff --git a/lib/models/CourseDate.class.php b/lib/models/CourseDate.class.php index 9930f23eee53575d5385f0d0b62ba3917cc7f44b..3780fc872adf8e9bfbb9dc0c2e21f645a1380662 100644 --- a/lib/models/CourseDate.class.php +++ b/lib/models/CourseDate.class.php @@ -50,21 +50,21 @@ class CourseDate extends SimpleORMap implements PrivacyObject { $config['db_table'] = 'termine'; $config['has_and_belongs_to_many']['topics'] = [ - 'class_name' => 'CourseTopic', + 'class_name' => CourseTopic::class, 'thru_table' => 'themen_termine', 'order_by' => 'ORDER BY priority', 'on_delete' => 'delete', 'on_store' => 'store' ]; $config['has_and_belongs_to_many']['statusgruppen'] = [ - 'class_name' => 'Statusgruppen', + 'class_name' => Statusgruppen::class, 'thru_table' => 'termin_related_groups', 'order_by' => 'ORDER BY position', 'on_delete' => 'delete', 'on_store' => 'store' ]; $config['has_and_belongs_to_many']['dozenten'] = [ - 'class_name' => 'User', + 'class_name' => User::class, 'thru_table' => 'termin_related_persons', 'foreign_key' => 'termin_id', 'thru_key' => 'range_id', @@ -73,30 +73,30 @@ class CourseDate extends SimpleORMap implements PrivacyObject 'on_store' => 'store' ]; $config['has_many']['folders'] = [ - 'class_name' => 'Folder', + 'class_name' => Folder::class, 'assoc_func' => 'findByTermin_id' ]; $config['belongs_to']['author'] = [ - 'class_name' => 'User', + 'class_name' => User::class, 'foreign_key' => 'autor_id' ]; $config['belongs_to']['course'] = [ - 'class_name' => 'Course', + 'class_name' => Course::class, 'foreign_key' => 'range_id' ]; $config['belongs_to']['cycle'] = [ - 'class_name' => 'SeminarCycleDate', + 'class_name' => SeminarCycleDate::class, 'foreign_key' => 'metadate_id' ]; $config['has_one']['room_booking'] = [ - 'class_name' => 'ResourceBooking', + 'class_name' => ResourceBooking::class, 'foreign_key' => 'termin_id', 'assoc_foreign_key' => 'range_id', 'on_delete' => 'delete', //'on_store' => 'store' ]; $config['has_many']['room_requests'] = [ - 'class_name' => 'RoomRequest', + 'class_name' => RoomRequest::class, 'assoc_foreign_key' => 'termin_id', 'on_delete' => 'delete', ]; @@ -462,4 +462,4 @@ class CourseDate extends SimpleORMap implements PrivacyObject } } } -} \ No newline at end of file +} diff --git a/lib/models/CourseEvent.class.php b/lib/models/CourseEvent.class.php index 0e6b4b7b47c2be36867f3f1328c8a994d82c653a..930c57a37e25ebba82a2dd728fcaf045ad5b2bb8 100644 --- a/lib/models/CourseEvent.class.php +++ b/lib/models/CourseEvent.class.php @@ -14,9 +14,6 @@ class CourseEvent extends CourseDate implements Event { - private $properties = null; - private $permission_user_id = null; - protected static function configure($config = []) { $config['alias_fields']['event_id'] = 'termin_id'; @@ -37,7 +34,7 @@ class CourseEvent extends CourseDate implements Event }; $config['additional_fields']['uid']['get'] = function ($date) { return 'Stud.IP-SEM-' . $date->getId() - . '@' . $_SERVER['SERVER_NAME']; + . '@' . $_SERVER['SERVER_NAME']; }; $config['additional_fields']['summary']['get'] = function ($date) { return $date->course->name; @@ -48,6 +45,9 @@ class CourseEvent extends CourseDate implements Event parent::configure($config); } + private $properties = null; + private $permission_user_id = null; + public function __construct($id = null) { $this->permission_user_id = $GLOBALS['user']->id; diff --git a/lib/models/CourseExDate.class.php b/lib/models/CourseExDate.class.php index 5cff067dad06f2cf455a203283ed71e64343ac3b..d77a8ca02d57d4823cd788bd084cbb4f9f69fb5e 100644 --- a/lib/models/CourseExDate.class.php +++ b/lib/models/CourseExDate.class.php @@ -35,32 +35,6 @@ class CourseExDate extends SimpleORMap implements PrivacyObject { - const FORMAT_DEFAULT = 'default'; - const FORMAT_VERBOSE = 'verbose'; - - /** - * Returns course dates by course id - * - * @param String $seminar_id Id of the course - * @return array with the associated dates - */ - public static function findBySeminar_id($seminar_id) - { - return self::findByRange_id($seminar_id); - } - - /** - * Return course dates by range id (which is in many cases the course id) - * - * @param String $seminar_id Id of the course - * @param String $order_by Optional order definition - * @return array with the associated dates - */ - public static function findByRange_id($seminar_id, $order_by = 'ORDER BY date') - { - return parent::findByRange_id($seminar_id, $order_by); - } - /** * Configures this model. * @@ -70,15 +44,15 @@ class CourseExDate extends SimpleORMap implements PrivacyObject { $config['db_table'] = 'ex_termine'; $config['belongs_to']['author'] = [ - 'class_name' => 'User', + 'class_name' => User::class, 'foreign_key' => 'autor_id' ]; $config['belongs_to']['course'] = [ - 'class_name' => 'Course', + 'class_name' => Course::class, 'foreign_key' => 'range_id' ]; $config['belongs_to']['cycle'] = [ - 'class_name' => 'SeminarCycleDate', + 'class_name' => SeminarCycleDate::class, 'foreign_key' => 'metadate_id' ]; @@ -93,6 +67,31 @@ class CourseExDate extends SimpleORMap implements PrivacyObject parent::configure($config); } + const FORMAT_DEFAULT = 'default'; + const FORMAT_VERBOSE = 'verbose'; + + /** + * Returns course dates by course id + * + * @param String $seminar_id Id of the course + * @return array with the associated dates + */ + public static function findBySeminar_id($seminar_id) + { + return self::findByRange_id($seminar_id); + } + + /** + * Return course dates by range id (which is in many cases the course id) + * + * @param String $seminar_id Id of the course + * @param String $order_by Optional order definition + * @return array with the associated dates + */ + public static function findByRange_id($seminar_id, $order_by = 'ORDER BY date') + { + return parent::findByRange_id($seminar_id, $order_by); + } /** * Returns the name of the assigned room for this date. * diff --git a/lib/models/CourseMarkedEvent.class.php b/lib/models/CourseMarkedEvent.class.php index a69a5b98aa17d0c2567ad8b694f0f9f49c231a72..76cc050702ceb469263f367e096f037cfe7e3e12 100644 --- a/lib/models/CourseMarkedEvent.class.php +++ b/lib/models/CourseMarkedEvent.class.php @@ -93,4 +93,4 @@ class CourseMarkedEvent extends CourseEvent return ''; } -} \ No newline at end of file +} diff --git a/lib/models/CourseMember.class.php b/lib/models/CourseMember.class.php index 738a455ba75fe6dda4a5aaf56ba8cb6c864e4fd8..6c83961fd78b729294d6d35bf83a39e5b08af6ff 100644 --- a/lib/models/CourseMember.class.php +++ b/lib/models/CourseMember.class.php @@ -42,15 +42,15 @@ class CourseMember extends SimpleORMap implements PrivacyObject { $config['db_table'] = 'seminar_user'; $config['belongs_to']['user'] = [ - 'class_name' => 'User', + 'class_name' => User::class, 'foreign_key' => 'user_id', ]; $config['belongs_to']['course'] = [ - 'class_name' => 'Course', + 'class_name' => Course::class, 'foreign_key' => 'seminar_id', ]; $config['has_many']['datafields'] = [ - 'class_name' => 'DatafieldEntryModel', + 'class_name' => DatafieldEntryModel::class, 'assoc_foreign_key' => function($model, $params) { list($sec_range_id, $range_id) = (array)$params[0]->getId(); diff --git a/lib/models/Courseware/Task.php b/lib/models/Courseware/Task.php index fe61a2e618cc71f6cfa98bbc3ecccef061ba7ed6..d8ecb80bf20d85cc17c958cc2ad3c27070f26cb0 100755 --- a/lib/models/Courseware/Task.php +++ b/lib/models/Courseware/Task.php @@ -69,11 +69,6 @@ class Task extends \SimpleORMap 'foreign_key' => 'seminar_id', ]; - $config['belongs_to']['structural_element'] = [ - 'class_name' => StructuralElement::class, - 'foreign_key' => 'structural_element_id', - ]; - $config['belongs_to']['task_feedback'] = [ 'class_name' => TaskFeedback::class, 'foreign_key' => 'feedback_id', diff --git a/lib/models/CronjobLog.class.php b/lib/models/CronjobLog.class.php index 70fc31796ecd30b9045c7d19a8c860dc8892ec72..942bf6a8ce767cc1b2e5bd3f80139d3d34439c0d 100644 --- a/lib/models/CronjobLog.class.php +++ b/lib/models/CronjobLog.class.php @@ -45,7 +45,7 @@ class CronjobLog extends SimpleORMap $config['db_table'] = 'cronjobs_logs'; $config['belongs_to']['schedule'] = [ - 'class_name' => 'CronjobSchedule', + 'class_name' => CronjobSchedule::class, 'foreign_key' => 'schedule_id', ]; diff --git a/lib/models/CronjobSchedule.class.php b/lib/models/CronjobSchedule.class.php index 238e6e5c01f3566114517c545add76f02ba2027f..cac458e7cfa5926e63e8df4c336b49d7259888bd 100644 --- a/lib/models/CronjobSchedule.class.php +++ b/lib/models/CronjobSchedule.class.php @@ -62,11 +62,11 @@ class CronjobSchedule extends SimpleORMap $config['db_table'] = 'cronjobs_schedules'; $config['belongs_to']['task'] = [ - 'class_name' => 'CronjobTask', + 'class_name' => CronjobTask::class, 'foreign_key' => 'task_id', ]; $config['has_many']['logs'] = [ - 'class_name' => 'CronjobLog', + 'class_name' => CronjobLog::class, 'on_delete' => 'delete', 'on_store' => 'store', ]; diff --git a/lib/models/CronjobTask.class.php b/lib/models/CronjobTask.class.php index a70eda35797621057b8497d8d73baacbb0def7b6..7bb2b6bf6d7ccf94ee09bf1bccb3767d0e09f3ff 100644 --- a/lib/models/CronjobTask.class.php +++ b/lib/models/CronjobTask.class.php @@ -38,8 +38,6 @@ */ class CronjobTask extends SimpleORMap { - public $valid = false; - /** * Configures the model. * @@ -49,7 +47,7 @@ class CronjobTask extends SimpleORMap { $config['db_table'] = 'cronjobs_tasks'; $config['has_many']['schedules'] = [ - 'class_name' => 'CronjobSchedule', + 'class_name' => CronjobSchedule::class, 'on_delete' => 'delete', 'on_store' => 'store' ]; @@ -59,6 +57,8 @@ class CronjobTask extends SimpleORMap parent::configure($config); } + public $valid = false; + /** * Tries to load the underlying php class. This also determines the valid * state of the task. If the class does not exists, the task is marked diff --git a/lib/models/DataField.class.php b/lib/models/DataField.class.php index 0a82add516ba75e83ecc24b47caa94e06a1f3459..d771eb28c4db8f21240367b4dd47332972cf547e 100644 --- a/lib/models/DataField.class.php +++ b/lib/models/DataField.class.php @@ -35,16 +35,6 @@ */ class DataField extends SimpleORMap implements PrivacyObject { - protected static $permission_masks = [ - 'user' => 1, - 'autor' => 2, - 'tutor' => 4, - 'dozent' => 8, - 'admin' => 16, - 'root' => 32, - 'self' => 64, - ]; - /** * Configures this model. * @@ -54,11 +44,11 @@ class DataField extends SimpleORMap implements PrivacyObject { $config['db_table'] = 'datafields'; $config['has_many']['entries'] = [ - 'class_name' => 'DatafieldEntryModel', + 'class_name' => DatafieldEntryModel::class, 'on_delete' => 'delete', ]; $config['has_many']['visibility_settings'] = [ - 'class_name' => 'User_Visibility_Settings', + 'class_name' => User_Visibility_Settings::class, 'assoc_foreign_key' => 'identifier', 'on_delete' => 'delete', ]; @@ -78,6 +68,15 @@ class DataField extends SimpleORMap implements PrivacyObject parent::configure($config); } + protected static $permission_masks = [ + 'user' => 1, + 'autor' => 2, + 'tutor' => 4, + 'dozent' => 8, + 'admin' => 16, + 'root' => 32, + 'self' => 64, + ]; /** * Returns a collection of datafields filtered by objectType, * objectClass and/or unassigned objectClasses. diff --git a/lib/models/DatafieldEntryModel.class.php b/lib/models/DatafieldEntryModel.class.php index fe9791f0784509526aeeb6e1d5527e4a5969865f..2ea16f619ca5d2af5a9ba7b0937d7860af7fae26 100644 --- a/lib/models/DatafieldEntryModel.class.php +++ b/lib/models/DatafieldEntryModel.class.php @@ -26,6 +26,17 @@ class DatafieldEntryModel extends SimpleORMap implements PrivacyObject { + protected static function configure($config = []) + { + $config['db_table'] = 'datafields_entries'; + $config['belongs_to']['datafield'] = [ + 'class_name' => DataField::class, + 'foreign_key' => 'datafield_id' + ]; + $config['additional_fields']['name'] = ['datafield', 'name']; + parent::configure($config); + } + /** * returns datafields belonging to given model * if a datafield entry not exists yet, a new DatafieldEntryModel is returned @@ -167,18 +178,6 @@ class DatafieldEntryModel extends SimpleORMap implements PrivacyObject } return $ret; } - - protected static function configure($config = []) - { - $config['db_table'] = 'datafields_entries'; - $config['belongs_to']['datafield'] = [ - 'class_name' => 'DataField', - 'foreign_key' => 'datafield_id' - ]; - $config['additional_fields']['name'] = ['datafield', 'name']; - parent::configure($config); - } - public function setContentLanguage($language) { if (!Config::get()->CONTENT_LANGUAGES[$language]) { diff --git a/lib/models/DatafieldEntryModelI18N.class.php b/lib/models/DatafieldEntryModelI18N.class.php index 9d8c7e1b5aae7d302e2f49b4f4ef219652f1b454..bea234df067bcea3a19e3a58a85c3e5094b348a1 100644 --- a/lib/models/DatafieldEntryModelI18N.class.php +++ b/lib/models/DatafieldEntryModelI18N.class.php @@ -27,11 +27,9 @@ class DatafieldEntryModelI18N extends DatafieldEntryModel { - protected static function configure($config = []) { $config['i18n_fields']['content'] = true; parent::configure($config); } - } diff --git a/lib/models/Degree.class.php b/lib/models/Degree.class.php index 502e9f73c2c1d283d4a9e051fa7db499329446c4..04c4da6bdb67bf67627e13e3e1bad9c5716dd283 100644 --- a/lib/models/Degree.class.php +++ b/lib/models/Degree.class.php @@ -25,20 +25,20 @@ class Degree extends SimpleORMap protected static function configure($config = []) { $config['db_table'] = 'abschluss'; - + $config['has_and_belongs_to_many']['professions'] = [ - 'class_name' => 'StudyCourse', + 'class_name' => StudyCourse::class, 'thru_table' => 'user_studiengang', 'thru_key' => 'abschluss_id', 'thru_assoc_key' => 'fach_id', 'order_by' => 'GROUP BY fach_id ORDER BY name' ]; - + $config['additional_fields']['count_user']['get'] = 'countUser'; - + parent::configure($config); } - + public function countUser() { $stmt = DBManager::get()->prepare('SELECT COUNT(DISTINCT user_id) ' @@ -46,7 +46,7 @@ class Degree extends SimpleORMap $stmt->execute([$this->id]); return $stmt->fetchColumn(); } - + public function countUserByStudycourse($studycourse_id) { $stmt = DBManager::get()->prepare('SELECT COUNT(DISTINCT user_id) ' @@ -55,7 +55,7 @@ class Degree extends SimpleORMap $stmt->execute([$studycourse_id, $this->id]); return $stmt->fetchColumn(); } - + public function store() { if ($this->isNew() || $this->isDirty()) { @@ -64,8 +64,8 @@ class Degree extends SimpleORMap $this->author_id = $GLOBALS['user']->id; } } - + return parent::store(); } - + } diff --git a/lib/models/Deputy.php b/lib/models/Deputy.php index e36101d9e68a266dfeda0637e608cda2ecdef045..eef56d4e1f37f11fb9d1fc5ac120b6c00552cd9d 100644 --- a/lib/models/Deputy.php +++ b/lib/models/Deputy.php @@ -29,16 +29,16 @@ class Deputy extends SimpleORMap $config['db_table'] = 'deputies'; $config['belongs_to']['deputy'] = [ - 'class_name' => 'User', + 'class_name' => User::class, 'foreign_key' => 'user_id' ]; $config['belongs_to']['course'] = [ - 'class_name' => 'Course', + 'class_name' => Course::class, 'foreign_key' => 'range_id', 'assoc_foreign_key' => 'seminar_id' ]; $config['belongs_to']['boss'] = [ - 'class_name' => 'User', + 'class_name' => User::class, 'foreign_key' => 'range_id', 'assoc_foreign_key' => 'user_id' ]; diff --git a/lib/models/EventData.class.php b/lib/models/EventData.class.php index b3c3767f3d33db2cfad5aa8bb1c8089c435d458b..e5e41401e12a4aeecac4ee639e59f72285755628 100644 --- a/lib/models/EventData.class.php +++ b/lib/models/EventData.class.php @@ -15,7 +15,6 @@ class EventData extends SimpleORMap implements PrivacyObject { - protected static function configure($config = []) { $config['db_table'] = 'event_data'; diff --git a/lib/models/Fach.php b/lib/models/Fach.php index 8fec33b342736e9e1c2a6f93eb51ae5d1c34c9c0..cc5d9145f059471197da69332b8f265dcafe2331 100644 --- a/lib/models/Fach.php +++ b/lib/models/Fach.php @@ -16,41 +16,34 @@ class Fach extends ModuleManagementModelTreeItem implements PrivacyObject { - - private $count_abschluesse; - private $count_user; - private $count_sem; - private $count_stgteile; - private $count_module; - protected static function configure($config = []) { $config['db_table'] = 'fach'; $config['has_many']['abschluesse'] = [ - 'class_name' => 'Abschluss', + 'class_name' => Abschluss::class, 'assoc_func' => 'findByFach' ]; $config['has_many']['studiengangteile'] = [ - 'class_name' => 'StudiengangTeil', + 'class_name' => StudiengangTeil::class, 'assoc_foreign_key' => 'fach_id' ]; $config['has_and_belongs_to_many']['departments'] = [ - 'class_name' => 'Fachbereich', + 'class_name' => Fachbereich::class, 'thru_table' => 'mvv_fach_inst', 'thru_key' => 'fach_id', 'thru_assoc_key' => 'institut_id', 'order_by' => 'ORDER BY position' ]; $config['has_and_belongs_to_many']['degrees'] = [ - 'class_name' => 'Abschluss', + 'class_name' => Abschluss::class, 'thru_table' => 'user_studiengang', 'thru_key' => 'fach_id', 'thru_assoc_key' => 'abschluss_id', 'order_by' => 'GROUP BY abschluss_id ORDER BY name' ]; $config['has_many']['department_assignments'] = [ - 'class_name' => 'FachFachbereich', + 'class_name' => FachFachbereich::class, 'assoc_foreign_key' => 'fach_id', 'order_by' => 'ORDER BY position', 'on_store' => 'store', @@ -79,6 +72,12 @@ class Fach extends ModuleManagementModelTreeItem implements PrivacyObject parent::configure($config); } + private $count_abschluesse; + private $count_user; + private $count_sem; + private $count_stgteile; + private $count_module; + /** * * @param string $id primary key of table diff --git a/lib/models/FachFachbereich.php b/lib/models/FachFachbereich.php index 37993ce1b6fbc6b103ff0a50fa3b501d6c5a519c..0de44547c67b61797a52c340f15a3fccb9647fc8 100644 --- a/lib/models/FachFachbereich.php +++ b/lib/models/FachFachbereich.php @@ -17,18 +17,17 @@ class FachFachbereich extends ModuleManagementModel { - protected static function configure($config = []) { $config['db_table'] = 'mvv_fach_inst'; $config['belongs_to']['fach'] = [ - 'class_name' => 'Fach', + 'class_name' => Fach::class, 'foreign_key' => 'fach_id', 'assoc_func' => 'findCached', ]; $config['belongs_to']['fachbereich'] = [ - 'class_name' => 'Fachbereich', + 'class_name' => Fachbereich::class, 'foreign_key' => 'institut_id', 'assoc_func' => 'findCached', ]; diff --git a/lib/models/Fachbereich.php b/lib/models/Fachbereich.php index eea04c704c7e37f01f83bd1d7cdbddffa007e6d4..19b88a4b9d13bdccf05f85743d1a75352559d082 100644 --- a/lib/models/Fachbereich.php +++ b/lib/models/Fachbereich.php @@ -16,10 +16,6 @@ class Fachbereich extends ModuleManagementModelTreeItem { - - private $count_objects; - private $count_module; - protected static function configure($config = []) { $config['db_table'] = 'Institute'; @@ -34,6 +30,9 @@ class Fachbereich extends ModuleManagementModelTreeItem parent::configure($config); } + private $count_objects; + private $count_module; + public function __construct($id = null) { parent::__construct($id); diff --git a/lib/models/FeedbackElement.php b/lib/models/FeedbackElement.php index bdfe29a07939adcf8a1fed06c30bf396cd6a1ade..f9f1ccb625c2a927ec13735d37f227c07ddc938e 100644 --- a/lib/models/FeedbackElement.php +++ b/lib/models/FeedbackElement.php @@ -29,8 +29,9 @@ class FeedbackElement extends SimpleORMap public static function configure($config = []) { $config['db_table'] = 'feedback'; + $config['has_many']['entries'] = [ - 'class_name' => 'FeedbackEntry', + 'class_name' => FeedbackEntry::class, 'assoc_foreign_key' => 'feedback_id', 'order_by' => 'ORDER BY mkdate DESC', 'on_delete' => 'delete' diff --git a/lib/models/FeedbackEntry.php b/lib/models/FeedbackEntry.php index 5779794bbcef61267d6b446b9b259476037d4dbc..dd2f86b2bb2343119cd1972b0b1cda8802f4e533 100644 --- a/lib/models/FeedbackEntry.php +++ b/lib/models/FeedbackEntry.php @@ -19,7 +19,7 @@ class FeedbackEntry extends SimpleORMap $config['db_table'] = 'feedback_entries'; $config['belongs_to']['feedback'] = [ - 'class_name' => 'FeedbackElement', + 'class_name' => FeedbackElement::class, 'foreign_key' => 'feedback_id', ]; $config['belongs_to']['user'] = [ @@ -29,6 +29,7 @@ class FeedbackEntry extends SimpleORMap parent::configure($config); } + public function isEditable() { $editable = false; @@ -37,6 +38,7 @@ class FeedbackEntry extends SimpleORMap } return $editable; } + public function isDeletable() { $deletable = false; @@ -54,6 +56,7 @@ class FeedbackEntry extends SimpleORMap } return $deletable; } + public function delete() { if ($this->isDeletable()) { diff --git a/lib/models/File.php b/lib/models/File.php index 7af6d9e43ed881eea3e1d9c5aa8c21b067248aad..16c81efa19566b8e212ffe68e7765badb227994d 100644 --- a/lib/models/File.php +++ b/lib/models/File.php @@ -37,11 +37,11 @@ class File extends SimpleORMap { $config['db_table'] = 'files'; $config['belongs_to']['owner'] = [ - 'class_name' => 'User', + 'class_name' => User::class, 'foreign_key' => 'user_id', ]; $config['has_many']['refs'] = [ - 'class_name' => 'FileRef', + 'class_name' => FileRef::class, 'assoc_foreign_key' => 'file_id', ]; diff --git a/lib/models/FileRef.php b/lib/models/FileRef.php index c3804f8f92e680cfb399373dbc3dd43e16a65eb8..a3f9a3a1b9f19b81d83ca262aaccaa2fb59a7fbf 100644 --- a/lib/models/FileRef.php +++ b/lib/models/FileRef.php @@ -32,29 +32,25 @@ */ class FileRef extends SimpleORMap implements PrivacyObject, FeedbackRange { - - protected $folder_type; - protected $download_url; - public $path_to_blob; - protected static function configure($config = []) { $config['db_table'] = 'file_refs'; + $config['belongs_to']['file'] = [ - 'class_name' => 'File', + 'class_name' => File::class, 'foreign_key' => 'file_id', ]; $config['belongs_to']['folder'] = [ - 'class_name' => 'Folder', + 'class_name' => Folder::class, 'foreign_key' => 'folder_id', ]; $config['belongs_to']['owner'] = [ - 'class_name' => 'User', + 'class_name' => User::class, 'foreign_key' => 'user_id', ]; $config['belongs_to']['terms_of_use'] = [ - 'class_name' => 'ContentTermsOfUse', + 'class_name' => ContentTermsOfUse::class, 'foreign_key' => 'content_terms_of_use_id', 'assoc_func' => 'findOrBuild' ]; @@ -75,6 +71,10 @@ class FileRef extends SimpleORMap implements PrivacyObject, FeedbackRange parent::configure($config); } + protected $folder_type; + protected $download_url; + public $path_to_blob; + /** * This callback is called after deleting a FileRef. * It removes the File object that is associated with the FileRef, diff --git a/lib/models/Folder.php b/lib/models/Folder.php index a6e1a7f0f31da3e4724c2ba2117c3181cbe88d86..fcf4d984988c3dd989075040e055f326bb2bbf58 100644 --- a/lib/models/Folder.php +++ b/lib/models/Folder.php @@ -33,42 +33,43 @@ class Folder extends SimpleORMap implements FeedbackRange protected static function configure($config = []) { $config['db_table'] = 'folders'; + $config['belongs_to']['owner'] = [ - 'class_name' => 'User', + 'class_name' => User::class, 'foreign_key' => 'user_id', ]; $config['has_many']['file_refs'] = [ - 'class_name' => 'FileRef', + 'class_name' => FileRef::class, 'assoc_foreign_key' => 'folder_id', 'on_delete' => 'delete', 'on_store' => 'store', 'order_by' => 'ORDER BY name ASC' ]; $config['has_many']['subfolders'] = [ - 'class_name' => 'Folder', + 'class_name' => Folder::class, 'assoc_foreign_key' => 'parent_id', 'on_delete' => 'delete', 'on_store' => 'store', 'order_by' => 'ORDER BY name ASC' ]; $config['belongs_to']['parentfolder'] = [ - 'class_name' => 'Folder', + 'class_name' => Folder::class, 'foreign_key' => 'parent_id', ]; $config['belongs_to']['course'] = [ - 'class_name' => 'Course', + 'class_name' => Course::class, 'foreign_key' => 'range_id', ]; $config['belongs_to']['institute'] = [ - 'class_name' => 'Institute', + 'class_name' => Institute::class, 'foreign_key' => 'range_id', ]; $config['belongs_to']['user'] = [ - 'class_name' => 'User', + 'class_name' => User::class, 'foreign_key' => 'range_id', ]; $config['belongs_to']['message'] = [ - 'class_name' => 'Message', + 'class_name' => Message::class, 'foreign_key' => 'range_id', ]; $config['serialized_fields']['data_content'] = 'JSONArrayObject'; diff --git a/lib/models/Grading/Definition.php b/lib/models/Grading/Definition.php index 967b3271094749b988519524c890c9e81db4c09b..ed6df556f33d9ca3178933cc9d5151424365f779 100644 --- a/lib/models/Grading/Definition.php +++ b/lib/models/Grading/Definition.php @@ -11,11 +11,11 @@ class Definition extends \SimpleORMap $config['db_table'] = 'grading_definitions'; $config['belongs_to']['course'] = [ - 'class_name' => 'Course', + 'class_name' => \Course::class, 'foreign_key' => 'course_id', ]; $config['has_many']['instances'] = [ - 'class_name' => '\\Grading\\Instance', + 'class_name' => Instance::class, 'assoc_foreign_key' => 'definition_id', 'on_delete' => 'delete', 'on_store' => 'store', diff --git a/lib/models/Grading/Instance.php b/lib/models/Grading/Instance.php index 4027a96f51aa0cb28278b5c4cb9e201a91e4bccb..901fcff39cddc05dde0ebcf5fe55d8dc180e4fe9 100644 --- a/lib/models/Grading/Instance.php +++ b/lib/models/Grading/Instance.php @@ -9,11 +9,11 @@ class Instance extends \SimpleORMap $config['db_table'] = 'grading_instances'; $config['belongs_to']['user'] = [ - 'class_name' => 'User', + 'class_name' => \User::class, 'foreign_key' => 'user_id', ]; $config['belongs_to']['definition'] = [ - 'class_name' => '\\Grading\\Definition', + 'class_name' => Definition::class, 'foreign_key' => 'definition_id', ]; diff --git a/lib/models/HelpContent.class.php b/lib/models/HelpContent.class.php index ccac2a2b94dc36cfe72e74ad25b2eeec8d54357f..a767859b14c8a7b340d45dc905720b9ad0da5159 100644 --- a/lib/models/HelpContent.class.php +++ b/lib/models/HelpContent.class.php @@ -44,11 +44,23 @@ * @property string mkdate database column * @property string chdate database column */ -class HelpContent extends SimpleORMap { - +class HelpContent extends SimpleORMap +{ + /** + * configure SORM + * + * @param array $config configuration + */ + protected static function configure($config = []) + { + $config['db_table'] = 'help_content'; + + parent::configure($config); + } + /** * fetches set of content from database for given route - * + * * @param string $route route for help content * @param string $language language * @return array set of help content @@ -74,7 +86,7 @@ class HelpContent extends SimpleORMap { /** * fetches content for given content_id - * + * * @param string $id id of help content * @return array help content object */ @@ -91,7 +103,7 @@ class HelpContent extends SimpleORMap { /** * fetches set of help content from database filtered by parameters - * + * * @param string $term search term for content * @param boolean $as_objects include HelpContent objects in result array * @return array set of help content @@ -100,7 +112,7 @@ class HelpContent extends SimpleORMap { { $params = []; $condition = ''; - if (mb_strlen(trim($term)) >= 3) { + if (mb_strlen(trim($term)) >= 3) { $condition = "WHERE content LIKE CONCAT('%', ?, '%')"; $params[] = $term; } @@ -116,7 +128,7 @@ class HelpContent extends SimpleORMap { /** * fetches help content conflicts - * + * * @return array set of help content */ public static function GetConflicts() @@ -146,7 +158,7 @@ class HelpContent extends SimpleORMap { /** * builds help content objects for given set of content data - * + * * @param array $content_result content set * @return array set of content objects */ @@ -162,16 +174,4 @@ class HelpContent extends SimpleORMap { } return $objects; } - - /** - * configure SORM - * - * @param array $config configuration - */ - protected static function configure($config = []) - { - $config['db_table'] = 'help_content'; - - parent::configure($config); - } } diff --git a/lib/models/HelpTour.class.php b/lib/models/HelpTour.class.php index 726cfa7697eafdd6437f117901ecbcb5ccd9ce3c..72e5efb0a43f3def5f53a01eb6c90887bdc8b20f 100644 --- a/lib/models/HelpTour.class.php +++ b/lib/models/HelpTour.class.php @@ -46,26 +46,23 @@ require_once 'lib/object.inc.php'; */ class HelpTour extends SimpleORMap { - /** - * - */ protected static function configure($config = []) { $config['db_table'] = 'help_tours'; $config['has_one']['settings'] = [ - 'class_name' => 'HelpTourSettings', + 'class_name' => HelpTourSettings::class, 'assoc_foreign_key' => 'tour_id', 'on_delete' => 'delete', 'on_store' => 'store', ]; $config['has_many']['steps'] = [ - 'class_name' => 'HelpTourStep', + 'class_name' => HelpTourStep::class, 'assoc_foreign_key' => 'tour_id', 'on_delete' => 'delete', 'on_store' => 'store', ]; $config['has_many']['audiences'] = [ - 'class_name' => 'HelpTourAudience', + 'class_name' => HelpTourAudience::class, 'assoc_foreign_key' => 'tour_id', 'on_delete' => 'delete', 'on_store' => 'store', diff --git a/lib/models/HelpTourStep.class.php b/lib/models/HelpTourStep.class.php index 82d85245628a1e2a17d0ba9a474408568859bfbd..c74dbb89b46daa53f0dc9b76defdd6ee00199a48 100644 --- a/lib/models/HelpTourStep.class.php +++ b/lib/models/HelpTourStep.class.php @@ -49,8 +49,9 @@ class HelpTourStep extends SimpleORMap protected static function configure($config = []) { $config['db_table'] = 'help_tour_steps'; + $config['belongs_to']['help_tour'] = [ - 'class_name' => 'HelpTour', + 'class_name' => HelpTour::class, 'foreign_key' => 'tour_id', ]; diff --git a/lib/models/InstituteMember.class.php b/lib/models/InstituteMember.class.php index 4048fdd72f869ef61725b242be627e8f5170373e..a152d84d9378d5a8b97391b6ed644531e5638b1b 100644 --- a/lib/models/InstituteMember.class.php +++ b/lib/models/InstituteMember.class.php @@ -41,15 +41,15 @@ class InstituteMember extends SimpleORMap implements PrivacyObject { $config['db_table'] = 'user_inst'; $config['belongs_to']['user'] = [ - 'class_name' => 'User', + 'class_name' => User::class, 'foreign_key' => 'user_id', ]; $config['belongs_to']['institute'] = [ - 'class_name' => 'Institute', + 'class_name' => Institute::class, 'foreign_key' => 'institut_id', ]; $config['has_many']['datafields'] = [ - 'class_name' => 'DatafieldEntryModel', + 'class_name' => DatafieldEntryModel::class, 'assoc_foreign_key' => function($model, $params) { $model->setValue('range_id', $params[0]->user_id); diff --git a/lib/models/License.php b/lib/models/License.php index 65b46d20ee9917ff0a6b38c8a58400b8f1021d83..9dac65f81884cfd0b3d62736522fd3b80540c9de 100644 --- a/lib/models/License.php +++ b/lib/models/License.php @@ -2,14 +2,14 @@ class License extends SimpleORMap { - public static function findDefault() - { - return static::findOneBySQL("`default` = '1'"); - } - protected static function configure($config = []) { $config['db_table'] = 'licenses'; parent::configure($config); } + + public static function findDefault() + { + return static::findOneBySQL("`default` = '1'"); + } } diff --git a/lib/models/LockRule.class.php b/lib/models/LockRule.class.php index 66f678720a98f1d0e2149e2ddcb9393685a30c71..3f07a10e503fbe50c0b1b434fb30fd56c8bc20d3 100644 --- a/lib/models/LockRule.class.php +++ b/lib/models/LockRule.class.php @@ -35,6 +35,14 @@ class LockRule extends SimpleORMap { + protected static function configure($config = []) + { + $config['db_table'] = 'lock_rules'; + + $config['serialized_fields']['attributes'] = 'JSONArrayObject'; + + parent::configure($config); + } /** * returns the lockrule for a course @@ -88,14 +96,6 @@ class LockRule extends SimpleORMap { return self::findByObject_type($type, " ORDER BY name"); } - - protected static function configure($config = []) - { - $config['db_table'] = 'lock_rules'; - $config['serialized_fields']['attributes'] = 'JSONArrayObject'; - parent::configure($config); - } - /** * @see SimpleORMap::delete() */ diff --git a/lib/models/LogAction.php b/lib/models/LogAction.php index 7fbf1e1716adec8e037d8877f5a18012ac50877f..2f004201f7577ea8d08e5b6eae2360f306189481 100644 --- a/lib/models/LogAction.php +++ b/lib/models/LogAction.php @@ -30,10 +30,12 @@ class LogAction extends SimpleORMap protected static function configure($config = []) { $config['db_table'] = 'log_actions'; + $config['has_many']['events'] = [ 'class_name' => LogEvent::class, 'on_delete' => 'delete', ]; + parent::configure($config); } diff --git a/lib/models/LogEvent.php b/lib/models/LogEvent.php index 1d9a52bcab55b2d06a23b0448456c66c7e315946..38fdd72dfb1a416d0c7dc65033859831b7e58ba6 100644 --- a/lib/models/LogEvent.php +++ b/lib/models/LogEvent.php @@ -29,23 +29,24 @@ class LogEvent extends SimpleORMap implements PrivacyObject { - - protected $formatted_text = ''; - protected static function configure($config = []) { $config['db_table'] = 'log_events'; + $config['belongs_to']['action'] = [ - 'class_name' => 'LogAction', + 'class_name' => LogAction::class, 'foreign_key' => 'action_id', ]; $config['belongs_to']['user'] = [ - 'class_name' => 'User', + 'class_name' => User::class, 'foreign_key' => 'user_id', ]; + parent::configure($config); } + protected $formatted_text = ''; + /** * Returns the number of log events counted by actions as an array where * the ey is the action id and the value is the number of events for diff --git a/lib/models/Lvgruppe.php b/lib/models/Lvgruppe.php index bfc6cdc887baba2596ed897dd02c68729ed42408..e3a3620765977a393d69ab067bf746622950f46c 100644 --- a/lib/models/Lvgruppe.php +++ b/lib/models/Lvgruppe.php @@ -16,30 +16,24 @@ class Lvgruppe extends ModuleManagementModelTreeItem { - - private $count_seminare; - private $count_archiv; - private $count_modulteile; - private $count_semester; - protected static function configure($config = []) { $config['db_table'] = 'mvv_lvgruppe'; $config['has_and_belongs_to_many']['modulteile'] = [ - 'class_name' => 'Modulteil', + 'class_name' => Modulteil::class, 'thru_table' => 'mvv_lvgruppe_modulteil', 'on_delete' => 'delete', 'on_store' => 'store' ]; $config['has_and_belongs_to_many']['courses'] = [ - 'class_name' => 'Course', + 'class_name' => Course::class, 'thru_table' => 'mvv_lvgruppe_seminar', 'on_delete' => 'delete', 'on_store' => 'store' ]; $config['has_and_belongs_to_many']['archived_courses'] = [ - 'class_name' => 'ArchivedCourse', + 'class_name' => ArchivedCourse::class, 'thru_table' => 'mvv_lvgruppe_seminar', 'on_delete' => 'delete', 'on_store' => 'store' @@ -63,6 +57,11 @@ class Lvgruppe extends ModuleManagementModelTreeItem parent::configure($config); } + private $count_seminare; + private $count_archiv; + private $count_modulteile; + private $count_semester; + public function __construct($id = null) { parent::__construct($id); diff --git a/lib/models/LvgruppeModulteil.php b/lib/models/LvgruppeModulteil.php index 33e7e490f24f46f3b97d2742a01ef7a84c7e4c1a..da64a4b26f93d4153ddf12784386d5e30ec89617 100644 --- a/lib/models/LvgruppeModulteil.php +++ b/lib/models/LvgruppeModulteil.php @@ -17,18 +17,17 @@ class LvgruppeModulteil extends ModuleManagementModel { - protected static function configure($config = []) { $config['db_table'] = 'mvv_lvgruppe_modulteil'; $config['belongs_to']['lvgruppe'] = [ - 'class_name' => 'Lvgruppe', + 'class_name' => Lvgruppe::class, 'foreign_key' => 'lvgruppe_id', 'assoc_func' => 'findCached', ]; $config['belongs_to']['modulteil'] = [ - 'class_name' => 'Modulteil', + 'class_name' => Modulteil::class, 'foreign_key' => 'modulteil_id', 'assoc_func' => 'findCached', ]; diff --git a/lib/models/LvgruppeSeminar.php b/lib/models/LvgruppeSeminar.php index 409fcfd71da58646c070d9e9b21b29bc0b7c5146..99d6e09a640d88e60814cfa15c4345b3a83fbe59 100644 --- a/lib/models/LvgruppeSeminar.php +++ b/lib/models/LvgruppeSeminar.php @@ -17,18 +17,17 @@ class LvgruppeSeminar extends ModuleManagementModel { - protected static function configure($config = []) { $config['db_table'] = 'mvv_lvgruppe_seminar'; $config['belongs_to']['lvgruppe'] = [ - 'class_name' => 'Lvgruppe', + 'class_name' => Lvgruppe::class, 'foreign_key' => 'lvgruppe_id', 'assoc_func' => 'findCached', ]; $config['belongs_to']['course'] = [ - 'class_name' => 'Course', + 'class_name' => Course::class, 'foreign_key' => 'seminar_id' ]; diff --git a/lib/models/MailQueueEntry.class.php b/lib/models/MailQueueEntry.class.php index 2b061cbfc6360583e96b465b31c2b7728a58eb2c..11d0a2f22841430d99fdf9f7403ce270db4fb7ef 100644 --- a/lib/models/MailQueueEntry.class.php +++ b/lib/models/MailQueueEntry.class.php @@ -29,6 +29,7 @@ class MailQueueEntry extends SimpleORMap protected static function configure($config = []) { $config['db_table'] = 'mail_queue_entries'; + $config['serialized_fields']['mail'] = 'JSONArrayObject'; parent::configure($config); diff --git a/lib/models/Message.class.php b/lib/models/Message.class.php index 95ed63788fa60626e5614bf11bba25e398567dcd..f786f938da4040068e80daaa743c09e433986be6 100644 --- a/lib/models/Message.class.php +++ b/lib/models/Message.class.php @@ -31,28 +31,30 @@ class Message extends SimpleORMap implements PrivacyObject protected static function configure($config = []) { $config['db_table'] = 'message'; + $config['belongs_to']['author'] = [ - 'class_name' => 'User', + 'class_name' => User::class, 'foreign_key' => 'autor_id' ]; $config['has_one']['originator'] = [ - 'class_name' => 'MessageUser', + 'class_name' => MessageUser::class, 'assoc_func' => 'findSentByMessageId', 'on_store' => 'store', 'on_delete' => 'delete' ]; $config['has_many']['receivers'] = [ - 'class_name' => 'MessageUser', + 'class_name' => MessageUser::class, 'assoc_func' => 'findReceivedByMessageId', 'on_store' => 'store', 'on_delete' => 'delete' ]; $config['has_one']['attachment_folder'] = [ - 'class_name' => 'Folder', + 'class_name' => Folder::class, 'assoc_foreign_key' => 'range_id', 'on_store' => 'store', 'on_delete' => 'delete' ]; + parent::configure($config); } diff --git a/lib/models/MessageUser.class.php b/lib/models/MessageUser.class.php index 46a586539c5bc346a6fb6412521430beb7bbdd78..c8a406cd85d76c866a5cc535adbb2d8d7a6475fb 100644 --- a/lib/models/MessageUser.class.php +++ b/lib/models/MessageUser.class.php @@ -29,14 +29,16 @@ class MessageUser extends SimpleORMap implements PrivacyObject protected static function configure($config = []) { $config['db_table'] = 'message_user'; + $config['belongs_to']['user'] = [ - 'class_name' => 'User', + 'class_name' => User::class, 'foreign_key' => 'user_id', ]; $config['belongs_to']['message'] = [ - 'class_name' => 'Message', + 'class_name' => Message::class, 'foreign_key' => 'message_id', ]; + $config['registered_callbacks']['after_store'][] = 'cleanUpTags'; $config['registered_callbacks']['after_delete'][] = 'cleanUpTags'; diff --git a/lib/models/Modul.php b/lib/models/Modul.php index 353391db73ece384615ddfd624c791940a07ccba..8b25c788a123437ec32f2adaf5dd5051c39096f9 100644 --- a/lib/models/Modul.php +++ b/lib/models/Modul.php @@ -16,26 +16,12 @@ class Modul extends ModuleManagementModelTreeItem { - /** - * The default language of the deskriptor (defined in config). - * - * @var string - */ - private $default_language; - - /** - * The number of modulteile. - * - * @var int - */ - private $count_modulteile; - protected static function configure($config = []) { $config['db_table'] = 'mvv_modul'; $config['has_one']['deskriptoren'] = [ - 'class_name' => 'ModulDeskriptor', + 'class_name' => ModulDeskriptor::class, 'assoc_foreign_key' => 'modul_id', 'on_delete' => 'delete', 'on_store' => 'store' @@ -49,7 +35,7 @@ class Modul extends ModuleManagementModelTreeItem 'foreign_key' => 'end', ]; $config['has_many']['modulteile'] = [ - 'class_name' => 'Modulteil', + 'class_name' => Modulteil::class, 'assoc_foreign_key' => 'modul_id', 'on_delete' => 'delete', 'on_store' => 'store', @@ -57,46 +43,46 @@ class Modul extends ModuleManagementModelTreeItem ]; // Ist Novellierung von (quelle) $config['has_one']['modul_quelle'] = [ - 'class_name' => 'Modul', + 'class_name' => Modul::class, 'foreign_key' => 'quelle', 'assoc_func' => 'findCached', ]; // Ist Variante von (variante) $config['has_one']['modul_variante'] = [ - 'class_name' => 'Modul', + 'class_name' => Modul::class, 'foreign_key' => 'variante', 'assoc_func' => 'findCached', ]; // hauptverantwortliche Einrichtung $config['has_one']['responsible_institute'] = [ - 'class_name' => 'ModulInst', + 'class_name' => ModulInst::class, 'assoc_func' => 'findPrimarilyResponsibleInstitute', 'on_delete' => 'delete', 'on_store' => 'store' ]; // beteiligte Einrichtungen $config['has_many']['assigned_institutes'] = [ - 'class_name' => 'ModulInst', + 'class_name' => ModulInst::class, 'assoc_func' => 'findOtherResponsibleInstitutes', 'on_delete' => 'delete', 'on_store' => 'store' ]; $config['has_many']['contact_assignments'] = [ - 'class_name' => 'MvvContactRange', + 'class_name' => MvvContactRange::class, 'assoc_foreign_key' => 'range_id', 'order_by' => 'ORDER BY position', 'on_delete' => 'delete', 'on_store' => 'store' ]; $config['has_many']['abschnitte_modul'] = [ - 'class_name' => 'StgteilabschnittModul', + 'class_name' => StgteilabschnittModul::class, 'assoc_foreign_key' => 'modul_id', 'order_by' => 'ORDER BY position,mkdate', 'on_delete' => 'delete', 'on_store' => 'store' ]; $config['has_and_belongs_to_many']['abschnitte'] = [ - 'class_name' => 'StgteilAbschnitt', + 'class_name' => StgteilAbschnitt::class, 'thru_table' => 'mvv_stgteilabschnitt_modul', 'thru_key' => 'modul_id', 'thru_assoc_key' => 'abschnitt_id', @@ -104,7 +90,7 @@ class Modul extends ModuleManagementModelTreeItem ]; // Assigned languages of instruction $config['has_many']['languages'] = [ - 'class_name' => 'ModulLanguage', + 'class_name' => ModulLanguage::class, 'assoc_foreign_key' => 'modul_id', 'order_by' => 'ORDER BY position,mkdate', 'on_delete' => 'delete', @@ -127,6 +113,20 @@ class Modul extends ModuleManagementModelTreeItem parent::configure($config); } + /** + * The default language of the deskriptor (defined in config). + * + * @var string + */ + private $default_language; + + /** + * The number of modulteile. + * + * @var int + */ + private $count_modulteile; + public function __construct($id = null) { parent::__construct($id); diff --git a/lib/models/ModulDeskriptor.php b/lib/models/ModulDeskriptor.php index b8ab07b911e5bfd56f8d81a3ee72c677fa4000b3..330e325d0696d62e54788ce2478cad59ee4f2ab0 100644 --- a/lib/models/ModulDeskriptor.php +++ b/lib/models/ModulDeskriptor.php @@ -16,19 +16,18 @@ class ModulDeskriptor extends ModuleManagementModel { - protected static function configure($config = []) { $config['db_table'] = 'mvv_modul_deskriptor'; $config['belongs_to']['modul'] = [ - 'class_name' => 'Modul', + 'class_name' => Modul::class, 'foreign_key' => 'modul_id', 'assoc_func' => 'findCached', ]; $config['has_many']['datafields'] = [ - 'class_name' => 'DatafieldEntryModel', + 'class_name' => DatafieldEntryModel::class, 'assoc_foreign_key' => function($model, $params) { $model->setValue('range_id', $params[0]->id); diff --git a/lib/models/ModulInst.php b/lib/models/ModulInst.php index 433edd7265e9d0427038a79d944f7b31c4336a00..7393bdf4856006673df9c9c6310a8b24bf340202 100644 --- a/lib/models/ModulInst.php +++ b/lib/models/ModulInst.php @@ -17,18 +17,17 @@ class ModulInst extends ModuleManagementModel { - protected static function configure($config = []) { $config['db_table'] = 'mvv_modul_inst'; $config['belongs_to']['institute'] = [ - 'class_name' => 'Fachbereich', + 'class_name' => Fachbereich::class, 'foreign_key' => 'institut_id', 'assoc_func' => 'findCached', ]; $config['belongs_to']['modul'] = [ - 'class_name' => 'Modul', + 'class_name' => Modul::class, 'foreign_key' => 'modul_id', 'assoc_func' => 'findCached', ]; diff --git a/lib/models/ModulLanguage.php b/lib/models/ModulLanguage.php index 256492bf1cc03891f38885ff07af48698e74fe29..160a1018bb9fa6ed0f4930be4f6c41859fc5f068 100644 --- a/lib/models/ModulLanguage.php +++ b/lib/models/ModulLanguage.php @@ -17,13 +17,12 @@ class ModulLanguage extends ModuleManagementModel { - protected static function configure($config = []) { $config['db_table'] = 'mvv_modul_language'; $config['belongs_to']['modul'] = [ - 'class_name' => 'Modul', + 'class_name' => Modul::class, 'foreign_key' => 'modul_id', 'assoc_func' => 'findCached', ]; diff --git a/lib/models/Modulteil.php b/lib/models/Modulteil.php index 3b443cbd74ab60eb79962b6de52b067937dd106c..e1ee79b9f3ec4f008b9a9541554f6e995454af2f 100644 --- a/lib/models/Modulteil.php +++ b/lib/models/Modulteil.php @@ -16,22 +16,17 @@ class Modulteil extends ModuleManagementModelTreeItem { - - private $default_language; - - private $count_lvgruppen; - protected static function configure($config = []) { $config['db_table'] = 'mvv_modulteil'; $config['belongs_to']['modul'] = [ - 'class_name' => 'Modul', + 'class_name' => Modul::class, 'foreign_key' => 'modul_id', 'assoc_func' => 'findCached', ]; $config['has_and_belongs_to_many']['abschnitte'] = [ - 'class_name' => 'StgteilAbschnitt', + 'class_name' => StgteilAbschnitt::class, 'thru_table' => 'mvv_modulteil_stgteilabschnitt', 'thru_key' => 'modulteil_id', 'thru_assoc_key' => 'abschnitt_id', @@ -39,19 +34,19 @@ class Modulteil extends ModuleManagementModelTreeItem 'on_store' => 'store' ]; $config['has_many']['abschnitt_assignments'] = [ - 'class_name' => 'ModulteilStgteilabschnitt', + 'class_name' => ModulteilStgteilabschnitt::class, 'order_by' => 'ORDER BY fachsemester,mkdate', 'on_delete' => 'delete', 'on_store' => 'store' ]; $config['has_one']['deskriptoren'] = [ - 'class_name' => 'ModulteilDeskriptor', + 'class_name' => ModulteilDeskriptor::class, 'assoc_foreign_key' => 'modulteil_id', 'on_delete' => 'delete', 'on_store' => 'store' ]; $config['has_and_belongs_to_many']['lvgruppen'] = [ - 'class_name' => 'Lvgruppe', + 'class_name' => Lvgruppe::class, 'thru_table' => 'mvv_lvgruppe_modulteil', 'thru_key' => 'modulteil_id', 'thru_assoc_key' => 'lvgruppe_id', @@ -60,13 +55,13 @@ class Modulteil extends ModuleManagementModelTreeItem 'on_store' => 'store' ]; $config['has_many']['lvgruppen_assignments'] = [ - 'class_name' => 'LvgruppeModulteil', + 'class_name' => LvgruppeModulteil::class, 'order_by' => 'ORDER BY position,mkdate', 'on_delete' => 'delete', 'on_store' => 'store' ]; $config['has_many']['languages'] = [ - 'class_name' => 'ModulteilLanguage', + 'class_name' => ModulteilLanguage::class, 'assoc_foreign_key' => 'modulteil_id', 'order_by' => 'ORDER BY position,mkdate', 'on_delete' => 'delete', @@ -81,6 +76,9 @@ class Modulteil extends ModuleManagementModelTreeItem parent::configure($config); } + private $default_language; + private $count_lvgruppen; + public function __construct($id = null) { parent::__construct($id); diff --git a/lib/models/ModulteilDeskriptor.php b/lib/models/ModulteilDeskriptor.php index 4ddbde22113b6e009b39b0c7dc5bd24c9e14088f..8b1801c0064294e08b154620e59f5c0ab3ae6f3b 100644 --- a/lib/models/ModulteilDeskriptor.php +++ b/lib/models/ModulteilDeskriptor.php @@ -16,19 +16,18 @@ class ModulteilDeskriptor extends ModuleManagementModel { - protected static function configure($config = []) { $config['db_table'] = 'mvv_modulteil_deskriptor'; $config['belongs_to']['modulteil'] = [ - 'class_name' => 'Modulteil', + 'class_name' => Modulteil::class, 'foreign_key' => 'modulteil_id', 'assoc_func' => 'findCached', ]; $config['has_many']['datafields'] = [ - 'class_name' => 'DatafieldEntryModel', + 'class_name' => DatafieldEntryModel::class, 'assoc_foreign_key' => function($model, $params) { $model->setValue('range_id', $params[0]->deskriptor_id); diff --git a/lib/models/ModulteilLanguage.php b/lib/models/ModulteilLanguage.php index 193ddf8744b596f36c12f4c6c036b0f0c81600f3..ed09bff3fe1bab453c9d0fd0d036bc08a4e80d8c 100644 --- a/lib/models/ModulteilLanguage.php +++ b/lib/models/ModulteilLanguage.php @@ -17,13 +17,12 @@ class ModulteilLanguage extends ModuleManagementModel { - protected static function configure($config = []) { $config['db_table'] = 'mvv_modulteil_language'; $config['belongs_to']['modulteil'] = [ - 'class_name' => 'Modulteil', + 'class_name' => Modulteil::class, 'foreign_key' => 'modulteil_id', 'assoc_func' => 'findCached', ]; diff --git a/lib/models/ModulteilStgteilabschnitt.php b/lib/models/ModulteilStgteilabschnitt.php index 799ae77ca9893621b55338ff7d0bc5ac0048163e..4f84c303b394b844f86ffe541fae18d2024b312a 100644 --- a/lib/models/ModulteilStgteilabschnitt.php +++ b/lib/models/ModulteilStgteilabschnitt.php @@ -17,18 +17,17 @@ class ModulteilStgteilabschnitt extends ModuleManagementModel { - protected static function configure($config = []) { $config['db_table'] = 'mvv_modulteil_stgteilabschnitt'; $config['belongs_to']['modulteil'] = [ - 'class_name' => 'Modulteil', + 'class_name' => Modulteil::class, 'foreign_key' => 'modulteil_id', 'assoc_func' => 'findCached', ]; $config['belongs_to']['abschnitt'] = [ - 'class_name' => 'StgteilAbschnitt', + 'class_name' => StgteilAbschnitt::class, 'foreign_key' => 'abschnitt_id', 'assoc_func' => 'findCached', ]; diff --git a/lib/models/MvvContact.php b/lib/models/MvvContact.php index d7910c2bbb74fb6ca99db4d91fc1d4ca25c121ca..26ff5f0e6c640bddd4995177ad8804406ce97b88 100644 --- a/lib/models/MvvContact.php +++ b/lib/models/MvvContact.php @@ -23,7 +23,7 @@ class MvvContact extends ModuleManagementModel $config['db_table'] = 'mvv_contacts'; $config['has_many']['ranges'] = [ - 'class_name' => 'MvvContactRange', + 'class_name' => MvvContactRange::class, 'foreign_key' => 'contact_id', 'on_delete' => 'delete' ]; diff --git a/lib/models/MvvContactRange.php b/lib/models/MvvContactRange.php index be988e93a65796b4dd89408a755ff82dda0c640e..5d5d501fb4116ec6a579289be1a0539d697e1419 100644 --- a/lib/models/MvvContactRange.php +++ b/lib/models/MvvContactRange.php @@ -23,7 +23,7 @@ class MvvContactRange extends ModuleManagementModel $config['db_table'] = 'mvv_contacts_ranges'; $config['belongs_to']['contact'] = array( - 'class_name' => 'MvvContact', + 'class_name' => MvvContact::class, 'foreign_key' => 'contact_id', 'assoc_func' => 'findCached', ); diff --git a/lib/models/MvvExternContact.php b/lib/models/MvvExternContact.php index 7d23ff3c1a591902f0d8a94fdd8f9764b2c4c879..855d276012c773c488b6d29a99360bc81c6ca123 100644 --- a/lib/models/MvvExternContact.php +++ b/lib/models/MvvExternContact.php @@ -15,16 +15,15 @@ class MvvExternContact extends ModuleManagementModel { - - protected static function configure($config = array()) + protected static function configure($config = []) { $config['db_table'] = 'mvv_extern_contacts'; - $config['belongs_to']['MvvContact'] = array( - 'class_name' => 'MvvContact', + $config['belongs_to']['MvvContact'] = [ + 'class_name' => MvvContact::class, 'foreign_key' => 'extern_contact_id', 'assoc_func' => 'findCached', - ); + ]; $config['i18n_fields']['name'] = true; $config['i18n_fields']['homepage'] = true; diff --git a/lib/models/MvvFileFileref.php b/lib/models/MvvFileFileref.php index 78094084f59887aaddea92215128e2f15b57add8..34e7d671cb6eb94b6600ebbf4dbb5ed80b6fd9ac 100644 --- a/lib/models/MvvFileFileref.php +++ b/lib/models/MvvFileFileref.php @@ -23,13 +23,13 @@ class MvvFileFileref extends ModuleManagementModel $config['db_table'] = 'mvv_files_filerefs'; $config['belongs_to']['mvv_file'] = array( - 'class_name' => 'MvvFile', + 'class_name' => MvvFile::class, 'foreign_key' => 'mvvfile_id', 'assoc_func' => 'findCached', ); $config['belongs_to']['file_ref'] = array( - 'class_name' => 'FileRef', + 'class_name' => FileRef::class, 'foreign_key' => 'fileref_id', ); $config['additional_fields']['filetype']['get'] = 'getFiletype'; diff --git a/lib/models/MvvFileRange.php b/lib/models/MvvFileRange.php index e49f3362324d0b090ecef615ea6989bb67e26594..35e2329751d099cd34e2192351c1826eebabb349 100644 --- a/lib/models/MvvFileRange.php +++ b/lib/models/MvvFileRange.php @@ -23,7 +23,7 @@ class MvvFileRange extends ModuleManagementModel $config['db_table'] = 'mvv_files_ranges'; $config['belongs_to']['mvv_file'] = array( - 'class_name' => 'MvvFile', + 'class_name' => MvvFile::class, 'foreign_key' => 'mvvfile_id', 'assoc_func' => 'findCached', ); diff --git a/lib/models/MvvOverlappingConflict.class.php b/lib/models/MvvOverlappingConflict.class.php index 26388c7bb9fe57f18197ded35b7ec85a49a331f8..a36f6bf8d93a76a1206a3a00a716e4c7097a9925 100644 --- a/lib/models/MvvOverlappingConflict.class.php +++ b/lib/models/MvvOverlappingConflict.class.php @@ -16,59 +16,58 @@ class MvvOverlappingConflict extends SimpleORMap { - /** * Configures the model. - * + * * @param array $config Configuration */ protected static function configure($config = array()) { $config['db_table'] = 'mvv_ovl_conflicts'; $config['belongs_to']['selection'] = [ - 'class_name' => 'MvvOverlappingSelection', + 'class_name' => MvvOverlappingSelection::class, 'foreign_key' => 'selection_id', 'assoc_foreign_key' => 'id' ]; $config['belongs_to']['base_abschnitt'] = [ - 'class_name' => 'StgteilAbschnitt', + 'class_name' => StgteilAbschnitt::class, 'foreign_key' => 'base_abschnitt_id' ]; $config['belongs_to']['base_modulteil'] = [ - 'class_name' => 'Modulteil', + 'class_name' => Modulteil::class, 'foreign_key' => 'base_modulteil_id' ]; $config['belongs_to']['base_cycle'] = [ - 'class_name' => 'SeminarCycleDate', + 'class_name' => SeminarCycleDate::class, 'foreign_key' => 'base_metadate_id' ]; $config['belongs_to']['base_course'] = [ - 'class_name' => 'Course', + 'class_name' => Course::class, 'foreign_key' => 'base_course_id' ]; $config['belongs_to']['comp_abschnitt'] = [ - 'class_name' => 'StgteilAbschnitt', + 'class_name' => StgteilAbschnitt::class, 'foreign_key' => 'comp_abschnitt_id' ]; $config['belongs_to']['comp_modulteil'] = [ - 'class_name' => 'Modulteil', + 'class_name' => Modulteil::class, 'foreign_key' => 'comp_modulteil_id' ]; $config['belongs_to']['comp_cycle'] = [ - 'class_name' => 'SeminarCycleDate', + 'class_name' => SeminarCycleDate::class, 'foreign_key' => 'comp_metadate_id' ]; $config['belongs_to']['comp_course'] = [ - 'class_name' => 'Course', + 'class_name' => Course::class, 'foreign_key' => 'comp_course_id' ]; - + parent::configure($config); } - + /** * Returns true if this conflict belongs to a excluded (hidden) course. - * + * * @return boolean True if this conflict is excluded. */ public function isExcluded() @@ -76,10 +75,10 @@ class MvvOverlappingConflict extends SimpleORMap return MvvOverlappingExclude::find([$this->selection->selection_id, $this->comp_course_id]) ? true : false; } - + /** * Deletes all conflicts by given selection id. - * + * * @param string $selection_id * @return number */ diff --git a/lib/models/MvvOverlappingExclude.php b/lib/models/MvvOverlappingExclude.php index 12b5cb0626c7847ff8f746ecbea58e4d4080cd36..a940787360a00eae7d776f53c1883b68e8bb25d6 100644 --- a/lib/models/MvvOverlappingExclude.php +++ b/lib/models/MvvOverlappingExclude.php @@ -17,26 +17,25 @@ class MvvOverlappingExclude extends SimpleORMap { - /** * Configures the model. - * + * * @param array $config Configuration */ protected static function configure($config = array()) { $config['db_table'] = 'mvv_ovl_excludes'; $config['belongs_to']['selection'] = [ - 'class_name' => 'MvvOverlappingSelection', + 'class_name' => MvvOverlappingSelection::class, 'foreign_key' => 'selection_id' ]; $config['belongs_to']['course'] = [ - 'class_name' => 'Course', + 'class_name' => Course::class, 'foreign_key' => 'course_id' ]; - + parent::configure($config); } - + } diff --git a/lib/models/MvvOverlappingSelection.class.php b/lib/models/MvvOverlappingSelection.class.php index 936a2d817180c731c2db3fe4cd2b75593e7a2be0..8dc2ef08287387a1b59b34dfdb77f352f20c892c 100644 --- a/lib/models/MvvOverlappingSelection.class.php +++ b/lib/models/MvvOverlappingSelection.class.php @@ -16,7 +16,6 @@ class MvvOverlappingSelection extends SimpleORMap { - /** * Configures the model. * @@ -26,30 +25,30 @@ class MvvOverlappingSelection extends SimpleORMap { $config['db_table'] = 'mvv_ovl_selections'; $config['belongs_to']['semester'] = [ - 'class_name' => 'Semester', + 'class_name' => Semester::class, 'foreign_key' => 'semester_id' ]; $config['belongs_to']['base_version'] = [ - 'class_name' => 'StgteilVersion', + 'class_name' => StgteilVersion::class, 'foreign_key' => 'base_version_id' ]; $config['belongs_to']['comp_version'] = [ - 'class_name' => 'StgteilVersion', + 'class_name' => StgteilVersion::class, 'foreign_key' => 'comp_version_id' ]; $config['has_many']['conflicts'] = [ - 'class_name' => 'MvvOverlappingConflict', + 'class_name' => MvvOverlappingConflict::class, 'foreign_key' => 'id', 'assoc_foreign_key' => 'selection_id', 'on_delete' => 'delete', 'on_store' => 'store' ]; $config['belongs_to']['user'] = [ - 'class_name' => 'User', + 'class_name' => User::class, 'foreign_key' => 'user_id' ]; $config['has_many']['excludes'] = [ - 'class_name' => 'MvvOverlappingExclude', + 'class_name' => MvvOverlappingExclude::class, 'foreign_key' => 'selection_id', 'assoc_foreign_key' => 'selection_id', 'on_delete' => 'delete', diff --git a/lib/models/NewsRange.class.php b/lib/models/NewsRange.class.php index 10a4f23ca4c3e349c0d70ab877e2173c5d449215..ab20cf1b7ebf8062ecdf9990a13f49b5e7fe4b3e 100644 --- a/lib/models/NewsRange.class.php +++ b/lib/models/NewsRange.class.php @@ -27,15 +27,15 @@ class NewsRange extends SimpleORMap { $config['db_table'] = 'news_range'; $config['belongs_to']['user'] = [ - 'class_name' => 'User', + 'class_name' => User::class, 'foreign_key' => 'range_id', ]; $config['belongs_to']['course'] = [ - 'class_name' => 'Course', + 'class_name' => Course::class, 'foreign_key' => 'range_id', ]; $config['belongs_to']['institute'] = [ - 'class_name' => 'Institute', + 'class_name' => Institute::class, 'foreign_key' => 'range_id', ]; $config['additional_fields']['type'] = true; diff --git a/lib/models/OERMaterialUser.php b/lib/models/OERMaterialUser.php index 06d6abc871d9b66624fd1793ae4f3c6b1708180d..1e6babe4e2f2f1406ba1ea80b04608e2818e3b0e 100755 --- a/lib/models/OERMaterialUser.php +++ b/lib/models/OERMaterialUser.php @@ -5,10 +5,12 @@ class OERMaterialUser extends SimpleORMap protected static function configure($config = []) { $config['db_table'] = 'oer_material_users'; + $config['belongs_to']['oeruser'] = [ 'class_name' => ExternalUser::class, 'foreign_key' => 'user_id' ]; + parent::configure($config); } diff --git a/lib/models/OERReview.php b/lib/models/OERReview.php index a51892310658228a5376b14f96af5645d65b06e1..58a25e457f44f4781029c2fe24d2d6125a820e7c 100755 --- a/lib/models/OERReview.php +++ b/lib/models/OERReview.php @@ -2,17 +2,6 @@ class OERReview extends BlubberThread { - public static function findByMaterial_id($material_id) - { - return self::findBySQL(" - context_type = 'public' - AND context_id = :material_id - AND display_class = 'OERReview' - ", [ - 'material_id' => $material_id - ]); - } - protected static function configure($config = []) { $config['belongs_to']['material'] = [ @@ -30,6 +19,16 @@ class OERReview extends BlubberThread parent::configure($config); } + public static function findByMaterial_id($material_id) + { + return self::findBySQL(" + context_type = 'public' + AND context_id = :material_id + AND display_class = 'OERReview' + ", [ + 'material_id' => $material_id + ]); + } public function afterStoreCallback() { if (!$this->material['host_id'] && !$this->material->isMine() && $this->isDirty()) { diff --git a/lib/models/PersonalNotificationsUser.php b/lib/models/PersonalNotificationsUser.php index 0b7373f9e2d8438517a64e9e308b37ffe9f1d1e4..3363bb5b8a7bb487ea860fd23d6275421353db7d 100644 --- a/lib/models/PersonalNotificationsUser.php +++ b/lib/models/PersonalNotificationsUser.php @@ -5,10 +5,12 @@ class PersonalNotificationsUser extends SimpleORMap protected static function configure($config = []) { $config['db_table'] = 'personal_notifications_user'; + $config['belongs_to']['notification'] = [ - 'class_name' => 'PersonalNotifications', + 'class_name' => PersonalNotifications::class, 'foreign_key' => 'personal_notification_id' ]; + parent::configure($config); } } diff --git a/lib/models/Questionnaire.php b/lib/models/Questionnaire.php index 7483483df59b35c4963af70daf30dedee260b4fd..cd180820b424d1aabda8513c1191b027c6eb221a 100644 --- a/lib/models/Questionnaire.php +++ b/lib/models/Questionnaire.php @@ -2,30 +2,31 @@ class Questionnaire extends SimpleORMap implements PrivacyObject { - - public $answerable; - protected static function configure($config = []) { $config['db_table'] = 'questionnaires'; + $config['has_many']['questions'] = [ - 'class_name' => 'QuestionnaireQuestion', + 'class_name' => QuestionnaireQuestion::class, 'on_delete' => 'delete', 'on_store' => 'store' ]; $config['has_many']['assignments'] = [ - 'class_name' => 'QuestionnaireAssignment', + 'class_name' => QuestionnaireAssignment::class, 'on_delete' => 'delete', 'on_store' => 'store' ]; $config['has_many']['anonymousanswers'] = [ - 'class_name' => 'QuestionnaireAnonymousAnswer', + 'class_name' => QuestionnaireAnonymousAnswer::class, 'on_delete' => 'delete', 'on_store' => 'store' ]; + parent::configure($config); } + public $answerable; + public function countAnswers() { $statement = DBManager::get()->prepare(" diff --git a/lib/models/QuestionnaireAnonymousAnswer.php b/lib/models/QuestionnaireAnonymousAnswer.php index 141c690d25cbc3471c42f12f3af5ce9c40b2bc04..e2bf1cad081e698cea5c76b9261acd988abddd60 100644 --- a/lib/models/QuestionnaireAnonymousAnswer.php +++ b/lib/models/QuestionnaireAnonymousAnswer.php @@ -5,9 +5,11 @@ class QuestionnaireAnonymousAnswer extends SimpleORMap implements PrivacyObject protected static function configure($config = []) { $config['db_table'] = 'questionnaire_anonymous_answers'; + $config['belongs_to']['questionnaire'] = [ - 'class_name' => 'Questionnaire' + 'class_name' => Questionnaire::class, ]; + parent::configure($config); } diff --git a/lib/models/QuestionnaireAnswer.php b/lib/models/QuestionnaireAnswer.php index 98f146d3098af0738308a0e1711092c24bb5bc0c..6e895b63abe9ebf8775731e80140bd850e3669a0 100644 --- a/lib/models/QuestionnaireAnswer.php +++ b/lib/models/QuestionnaireAnswer.php @@ -5,10 +5,12 @@ class QuestionnaireAnswer extends SimpleORMap implements PrivacyObject protected static function configure($config = []) { $config['db_table'] = 'questionnaire_answers'; + $config['belongs_to']['question'] = [ - 'class_name' => 'QuestionnaireQuestion' + 'class_name' => QuestionnaireQuestion::class, ]; $config['serialized_fields']['answerdata'] = "JSONArrayObject"; + parent::configure($config); } diff --git a/lib/models/QuestionnaireAssignment.php b/lib/models/QuestionnaireAssignment.php index 463ce4efbc72b18b0ba59b5711e15d6c01926723..e8ef6d98479d3a5525824c09cd6e023d95dd59ff 100644 --- a/lib/models/QuestionnaireAssignment.php +++ b/lib/models/QuestionnaireAssignment.php @@ -5,8 +5,9 @@ class QuestionnaireAssignment extends SimpleORMap implements PrivacyObject protected static function configure($config = []) { $config['db_table'] = 'questionnaire_assignments'; + $config['belongs_to']['questionnaire'] = [ - 'class_name' => 'Questionnaire', + 'class_name' => Questionnaire::class, 'foreign_key' => 'questionnaire_id', 'assoc_foreign_key' => 'questionnaire_id', ]; diff --git a/lib/models/QuestionnaireQuestion.php b/lib/models/QuestionnaireQuestion.php index 5cb06ebdc59eee174dfc7264dfc8d4b0e8ec8cc4..93c3279b63f38ec2d29f60c2af42bc00530b4ea6 100644 --- a/lib/models/QuestionnaireQuestion.php +++ b/lib/models/QuestionnaireQuestion.php @@ -7,20 +7,23 @@ class QuestionnaireQuestion extends SimpleORMap protected static function configure($config = []) { $config['db_table'] = 'questionnaire_questions'; + $config['belongs_to']['questionnaire'] = [ - 'class_name' => 'Questionnaire', + 'class_name' => Questionnaire::class, 'foreign_key' => 'questionnaire_id' ]; $config['has_many']['answers'] = [ - 'class_name' => 'QuestionnaireAnswer', + 'class_name' => QuestionnaireAnswer::class, 'on_delete' => 'delete', 'on_store' => 'store' ]; $config['belongs_to']['etask'] = [ - 'class_name' => '\\eTask\\Task', + 'class_name' => \eTask\Task::class, 'foreign_key' => 'etask_task_id' ]; + parent::configure($config); + } public static function findByQuestionnaire_id($questionnaire_id) diff --git a/lib/models/SeminarCycleDate.class.php b/lib/models/SeminarCycleDate.class.php index aed6fd9f2e7579753b4dca547b4528ac35a4d072..5f6c08ba34ce425f41f383507aec0c01190d173d 100644 --- a/lib/models/SeminarCycleDate.class.php +++ b/lib/models/SeminarCycleDate.class.php @@ -43,30 +43,6 @@ require_once 'lib/dates.inc.php'; */ class SeminarCycleDate extends SimpleORMap { - /** - * returns array of instances of SeminarCycleDates of the given seminar_id - * - * @param string seminar_id: selected seminar to search for SeminarCycleDates - * @return array of instances of SeminarCycleDates of the given seminar_id or - * an empty array - */ - public static function findBySeminar($seminar_id) - { - return self::findBySeminar_id($seminar_id, "ORDER BY sorter ASC, weekday ASC, start_time ASC"); - } - - /** - * return instance of SeminarCycleDates of given termin_id - * - * @param string termin_id: selected seminar to search for SeminarCycleDates - * @return array - */ - public static function findByTermin($termin_id) - { - return self::findOneBySql("metadate_id=(SELECT metadate_id FROM termine WHERE termin_id = ? " - . "UNION SELECT metadate_id FROM ex_termine WHERE termin_id = ? )", [$termin_id, $termin_id]); - } - /** * Configures this model. * @@ -76,24 +52,24 @@ class SeminarCycleDate extends SimpleORMap { $config['db_table'] = 'seminar_cycle_dates'; $config['belongs_to']['course'] = array( - 'class_name' => 'Course', + 'class_name' => Course::class, 'foreign_key' => 'seminar_id', ); $config['has_many']['room_requests'] = [ - 'class_name' => 'RoomRequest', + 'class_name' => RoomRequest::class, 'on_store' => 'store', 'on_delete' => 'delete', 'assoc_func' => 'findByMetadate_id' ]; $config['has_many']['dates'] = [ - 'class_name' => 'CourseDate', + 'class_name' => CourseDate::class, 'on_delete' => 'delete', 'on_store' => 'store', 'order_by' => 'ORDER BY date' ]; $config['has_many']['exdates'] = [ - 'class_name' => 'CourseExDate', + 'class_name' => CourseExDate::class, 'on_delete' => 'delete', 'on_store' => 'store', 'order_by' => 'ORDER BY date' @@ -107,6 +83,29 @@ class SeminarCycleDate extends SimpleORMap parent::configure($config); } + /** + * returns array of instances of SeminarCycleDates of the given seminar_id + * + * @param string seminar_id: selected seminar to search for SeminarCycleDates + * @return array of instances of SeminarCycleDates of the given seminar_id or + * an empty array + */ + public static function findBySeminar($seminar_id) + { + return self::findBySeminar_id($seminar_id, "ORDER BY sorter ASC, weekday ASC, start_time ASC"); + } + + /** + * return instance of SeminarCycleDates of given termin_id + * + * @param string termin_id: selected seminar to search for SeminarCycleDates + * @return array + */ + public static function findByTermin($termin_id) + { + return self::findOneBySql("metadate_id=(SELECT metadate_id FROM termine WHERE termin_id = ? " + . "UNION SELECT metadate_id FROM ex_termine WHERE termin_id = ? )", [$termin_id, $termin_id]); + } /** * Returns the time fraction for a given field. * diff --git a/lib/models/StatusgruppeUser.php b/lib/models/StatusgruppeUser.php index 04b42b6833d3d49f838b3b7c3cf57883806ae803..3cd67f0bf88642dc6c6ed761f339d54b98be6f6b 100644 --- a/lib/models/StatusgruppeUser.php +++ b/lib/models/StatusgruppeUser.php @@ -39,7 +39,7 @@ class StatusgruppeUser extends SimpleORMap implements PrivacyObject ]; $config['has_many']['datafields'] = [ - 'class_name' => 'DatafieldEntryModel', + 'class_name' => DatafieldEntryModel::class, 'foreign_key' => function($group_member) { return [$group_member]; }, diff --git a/lib/models/Statusgruppen.php b/lib/models/Statusgruppen.php index 873386ab1f32c7d809e662ade3d3ccde19b309d9..a11e211f11d335105d9e3389c494efb9e9c39461 100644 --- a/lib/models/Statusgruppen.php +++ b/lib/models/Statusgruppen.php @@ -39,8 +39,6 @@ */ class Statusgruppen extends SimpleORMap implements PrivacyObject { - public $keep_children = false; - protected static function configure($config = []) { $config['db_table'] = 'statusgruppen'; @@ -93,6 +91,8 @@ class Statusgruppen extends SimpleORMap implements PrivacyObject parent::configure($config); } + public $keep_children = false; + public static function findAllByRangeId($range_id, $as_collection = false) { $groups = self::findBySQL('range_id IN (?)', [$range_id]); diff --git a/lib/models/StgteilAbschnitt.php b/lib/models/StgteilAbschnitt.php index 69a4a07e82ff4b34d4712a4524cd5cc242a2ffb5..6e758a505516b7698fd83331dc6b2b924ad818ad 100644 --- a/lib/models/StgteilAbschnitt.php +++ b/lib/models/StgteilAbschnitt.php @@ -16,34 +16,31 @@ class StgteilAbschnitt extends ModuleManagementModelTreeItem { - - private $count_module; - protected static function configure($config = []) { $config['db_table'] = 'mvv_stgteilabschnitt'; $config['has_and_belongs_to_many']['module'] = [ - 'class_name' => 'Modul', + 'class_name' => Modul::class, 'thru_table' => 'mvv_stgteilabschnitt_modul', 'thru_key' => 'abschnitt_id', 'thru_assoc_key' => 'modul_id', 'order_by' => 'ORDER BY position,mkdate' ]; $config['belongs_to']['version'] = [ - 'class_name' => 'StgteilVersion', + 'class_name' => StgteilVersion::class, 'foreign_key' => 'version_id', 'assoc_func' => 'findCached', ]; $config['has_many']['modul_zuordnungen'] = [ - 'class_name' => 'StgteilabschnittModul', + 'class_name' => StgteilabschnittModul::class, 'assoc_foreign_key' => 'abschnitt_id', 'order_by' => 'ORDER BY position,mkdate', 'on_delete' => 'delete', 'on_store' => 'store' ]; $config['has_many']['modulteil_abschnitte'] = [ - 'class_name' => 'ModulteilStgteilabschnitt', + 'class_name' => ModulteilStgteilabschnitt::class, 'assoc_foreign_key' => 'abschnitt_id', 'order_by' => 'ORDER BY fachsemester', 'on_delete' => 'delete', @@ -61,6 +58,8 @@ class StgteilAbschnitt extends ModuleManagementModelTreeItem parent::configure($config); } + private $count_module; + /** * @see ModuleManagementModel::getClassDisplayName */ diff --git a/lib/models/StgteilBezeichnung.php b/lib/models/StgteilBezeichnung.php index 26e3c4a954a63c2026fbbcdd8eef8b05a3512b9d..926e6ab81b9995fdb6ca6ef57bf5c795934fb795 100644 --- a/lib/models/StgteilBezeichnung.php +++ b/lib/models/StgteilBezeichnung.php @@ -16,10 +16,6 @@ class StgteilBezeichnung extends ModuleManagementModel { - - private $count_stgteile; - private $count_studiengaenge; - protected static function configure($config = []) { $config['db_table'] = 'mvv_stgteil_bez'; @@ -37,6 +33,9 @@ class StgteilBezeichnung extends ModuleManagementModel parent::configure($config); } + private $count_stgteile; + private $count_studiengaenge; + public function __construct($id = null) { parent::__construct($id); diff --git a/lib/models/StgteilVersion.php b/lib/models/StgteilVersion.php index 61be13c94e8677f69adc2790ca175e2ba00c14ca..7d7137470979d0967c8e7f74eb39647f63f70526 100644 --- a/lib/models/StgteilVersion.php +++ b/lib/models/StgteilVersion.php @@ -16,33 +16,29 @@ class StgteilVersion extends ModuleManagementModelTreeItem { - - private $count_abschnitte; - private $count_dokumente; - protected static function configure($config = []) { $config['db_table'] = 'mvv_stgteilversion'; $config['belongs_to']['studiengangteil'] = [ - 'class_name' => 'StudiengangTeil', + 'class_name' => StudiengangTeil::class, 'foreign_key' => 'stgteil_id', 'assoc_func' => 'findCached', ]; $config['has_many']['abschnitte'] = [ - 'class_name' => 'StgteilAbschnitt', + 'class_name' => StgteilAbschnitt::class, 'assoc_foreign_key' => 'version_id', 'order_by' => 'ORDER BY position,mkdate', 'on_delete' => 'delete', 'on_store' => 'store' ]; $config['has_many']['documents'] = [ - 'class_name' => 'MvvFile', + 'class_name' => MvvFile::class, 'assoc_func' => 'findbyrange_id', 'assoc_func_params_func' => function ($stg) { return $stg; } ]; $config['has_many']['document_assignments'] = [ - 'class_name' => 'MvvFile', + 'class_name' => MvvFile::class, 'assoc_foreign_key' => 'range_id', 'order_by' => 'ORDER BY position', 'on_delete' => 'delete', @@ -59,6 +55,9 @@ class StgteilVersion extends ModuleManagementModelTreeItem parent::configure($config); } + private $count_abschnitte; + private $count_dokumente; + public function __construct($id = null) { $this->object_real_name = _('Studiengangteil-Version'); diff --git a/lib/models/StgteilabschnittModul.php b/lib/models/StgteilabschnittModul.php index 9e6d53b3e5bd71ecb4196fdb9ec7a9e11b6f032a..020c0deedec8d0bd0439fbbbfe740b86d3ca70c5 100644 --- a/lib/models/StgteilabschnittModul.php +++ b/lib/models/StgteilabschnittModul.php @@ -17,18 +17,17 @@ class StgteilabschnittModul extends ModuleManagementModelTreeItem { - protected static function configure($config = []) { $config['db_table'] = 'mvv_stgteilabschnitt_modul'; $config['belongs_to']['modul'] = [ - 'class_name' => 'Modul', + 'class_name' => Modul::class, 'foreign_key' => 'modul_id', 'assoc_func' => 'findCached', ]; $config['belongs_to']['abschnitt'] = [ - 'class_name' => 'StgteilAbschnitt', + 'class_name' => StgteilAbschnitt::class, 'foreign_key' => 'abschnitt_id', 'assoc_func' => 'findCached', ]; diff --git a/lib/models/Studiengang.php b/lib/models/Studiengang.php index 795f3bf50420d5760c1bc75c1215da924b2d4cc5..ad2173c1c000e3b42cbebc9cf199f1ade23a8e47 100644 --- a/lib/models/Studiengang.php +++ b/lib/models/Studiengang.php @@ -16,80 +16,73 @@ class Studiengang extends ModuleManagementModelTreeItem { - - private $count_dokumente; - private $count_faecher; - private $institut_name; - private $kategorie_name; - private $count_module; - protected static function configure($config = []) { $config['db_table'] = 'mvv_studiengang'; $config['belongs_to']['abschluss'] = [ - 'class_name' => 'Abschluss', + 'class_name' => Abschluss::class, 'foreign_key' => 'abschluss_id', 'assoc_func' => 'findCached', ]; $config['has_and_belongs_to_many']['studiengangteile'] = [ - 'class_name' => 'StudiengangTeil', + 'class_name' => StudiengangTeil::class, 'thru_table' => 'mvv_stg_stgteil', 'thru_key' => 'studiengang_id', 'thru_assoc_key' => 'stgteil_id' ]; $config['has_many']['stgteil_assignments'] = [ - 'class_name' => 'StudiengangStgteil', + 'class_name' => StudiengangStgteil::class, 'foreign_key' => 'studiengang_id', 'order_by' => 'ORDER BY position', 'on_delete' => 'delete', 'on_store' => 'store' ]; $config['has_and_belongs_to_many']['stgteil_bezeichnungen'] = [ - 'class_name' => 'StgteilBezeichnung', + 'class_name' => StgteilBezeichnung::class, 'thru_table' => 'mvv_stg_stgteil', 'thru_key' => 'studiengang_id', 'thru_assoc_key' => 'stgteil_bez_id', 'order_by' => 'GROUP BY stgteil_bez_id ORDER BY position' ]; $config['has_many']['documents'] = [ - 'class_name' => 'MvvFile', + 'class_name' => MvvFile::class, 'assoc_func' => 'findbyrange_id', 'assoc_func_params_func' => function ($stg) { return $stg; } ]; $config['has_many']['document_assignments'] = [ - 'class_name' => 'MvvFileRange', + 'class_name' => MvvFileRange::class, 'assoc_foreign_key' => 'range_id', 'order_by' => 'ORDER BY position', 'on_delete' => 'delete', 'on_store' => 'store' ]; $config['has_many']['contact_assignments'] = [ - 'class_name' => 'MvvContactRange', + 'class_name' => MvvContactRange::class, 'assoc_foreign_key' => 'range_id', 'order_by' => 'ORDER BY position' ]; $config['has_one']['responsible_institute'] = [ - 'class_name' => 'Fachbereich', + 'class_name' => Fachbereich::class, 'foreign_key' => 'institut_id', 'assoc_func' => 'findCached', ]; $config['has_many']['studycourse_types'] = [ - 'class_name' => 'StudycourseType', + 'class_name' => StudycourseType::class, 'foreign_key' => 'studiengang_id', 'on_delete' => 'delete', 'on_store' => 'store' ]; $config['has_many']['languages'] = [ - 'class_name' => 'StudycourseLanguage', + 'class_name' => StudycourseLanguage::class, 'assoc_foreign_key' => 'studiengang_id', 'order_by' => 'ORDER BY position,mkdate', 'on_delete' => 'delete', 'on_store' => 'store' ]; $config['has_many']['datafields'] = [ - 'class_name' => 'DatafieldEntryModel', + 'class_name' => DatafieldEntryModel::class, 'assoc_foreign_key' => function($model, $params) { $model->setValue('range_id', $params[0]->id); @@ -103,14 +96,14 @@ class Studiengang extends ModuleManagementModelTreeItem } ]; $config['has_many']['grundstg_assignments'] = [ - 'class_name' => 'Aufbaustudiengang', + 'class_name' => Aufbaustudiengang::class, 'assoc_func' => 'findByaufbau_stg_id', 'assoc_foreign_key' => 'aufbau_stg_id', 'on_delete' => 'delete', 'on_store' => 'store' ]; $config['has_many']['aufbaustg_assignments'] = [ - 'class_name' => 'Aufbaustudiengang', + 'class_name' => Aufbaustudiengang::class, 'assoc_func' => 'findBygrund_stg_id', 'assoc_foreign_key' => 'grund_stg_id', 'on_delete' => 'delete', @@ -139,6 +132,12 @@ class Studiengang extends ModuleManagementModelTreeItem parent::configure($config); } + private $count_dokumente; + private $count_faecher; + private $institut_name; + private $kategorie_name; + private $count_module; + public function __construct($id = null) { parent::__construct($id); diff --git a/lib/models/StudiengangStgteil.php b/lib/models/StudiengangStgteil.php index 0b177261392781edb3c1b38637971760a72b913a..76d01ff4e83a1bbbfe8ab84a974b2c902823ecb5 100644 --- a/lib/models/StudiengangStgteil.php +++ b/lib/models/StudiengangStgteil.php @@ -17,27 +17,22 @@ class StudiengangStgteil extends ModuleManagementModel { - - private $stgteil_name; - private $stgbez_name; - private $stgbez_id; - protected static function configure($config = []) { $config['db_table'] = 'mvv_stg_stgteil'; $config['belongs_to']['studiengang'] = [ - 'class_name' => 'Studiengang', + 'class_name' => Studiengang::class, 'foreign_key' => 'studiengang_id', 'assoc_func' => 'findCached', ]; $config['has_one']['stgteil_bezeichnung'] = [ - 'class_name' => 'StgteilBezeichnung', + 'class_name' => StgteilBezeichnung::class, 'foreign_key' => 'stgteil_bez_id', 'assoc_func' => 'findCached', ]; $config['belongs_to']['studiengangteil'] = [ - 'class_name' => 'StudiengangTeil', + 'class_name' => StudiengangTeil::class, 'foreign_key' => 'stgteil_id', 'assoc_func' => 'findCached', ]; @@ -52,6 +47,10 @@ class StudiengangStgteil extends ModuleManagementModel parent::configure($config); } + private $stgteil_name; + private $stgbez_name; + private $stgbez_id; + function __construct($id = null) { $this->default_values['position'] = 10000; diff --git a/lib/models/StudiengangTeil.php b/lib/models/StudiengangTeil.php index 549577218077b49903ae3bc10263e33aca63b7f1..0d73c3d8bb239a24d1c2fc594be65ffdce9e4148 100644 --- a/lib/models/StudiengangTeil.php +++ b/lib/models/StudiengangTeil.php @@ -16,42 +16,36 @@ class StudiengangTeil extends ModuleManagementModelTreeItem { - - private $count_versionen; - private $fach_name; - private $stgteil_name; - private $count_contacts; - protected static function configure($config = []) { $config['db_table'] = 'mvv_stgteil'; $config['has_many']['versionen'] = [ - 'class_name' => 'StgteilVersion', + 'class_name' => StgteilVersion::class, 'assoc_foreign_key' => 'stgteil_id', 'on_delete' => 'delete' ]; $config['has_many']['contact_assignments'] = [ - 'class_name' => 'MvvContactRange', + 'class_name' => MvvContactRange::class, 'assoc_foreign_key' => 'range_id', 'order_by' => 'ORDER BY position' ]; // The assigned Fach $config['belongs_to']['fach'] = [ - 'class_name' => 'Fach', + 'class_name' => Fach::class, 'foreign_key' => 'fach_id', 'assoc_func' => 'findCached', ]; $config['has_and_belongs_to_many']['studiengang'] = [ - 'class_name' => 'Studiengang', + 'class_name' => Studiengang::class, 'thru_table' => 'mvv_stg_stgteil', 'thru_key' => 'stgteil_id', 'thru_assoc_key' => 'studiengang_id' ]; $config['has_many']['studiengang_assignments'] = [ - 'class_name' => 'StudiengangStgteil', + 'class_name' => StudiengangStgteil::class, 'assoc_foreign_key' => 'stgteil_id', 'on_delete' => 'delete', 'on_store' => 'store' @@ -72,6 +66,11 @@ class StudiengangTeil extends ModuleManagementModelTreeItem parent::configure($config); } + private $count_versionen; + private $fach_name; + private $stgteil_name; + private $count_contacts; + public function __construct($id = null) { parent::__construct($id); diff --git a/lib/models/StudipComment.class.php b/lib/models/StudipComment.class.php index 9f32e665e46d365e73fd60a5b6e659d5af5597bf..226daab8b180fac3b2884622f31b4bcd6c3c07fa 100644 --- a/lib/models/StudipComment.class.php +++ b/lib/models/StudipComment.class.php @@ -43,6 +43,18 @@ class StudipComment extends SimpleORMap implements PrivacyObject { + protected static function configure($config = []) + { + $config['db_table'] = 'comments'; + + $config['belongs_to']['news'] = [ + 'class_name' => StudipNews::class, + 'foreign_key' => 'object_id', + ]; + + parent::configure($config); + } + public static function NumCommentsForObject($object_id) { return self::countBySql('object_id = ?', [$object_id]); @@ -57,7 +69,7 @@ class StudipComment extends SimpleORMap implements PrivacyObject } return self::countBySql($query, [$object_id, $comments_since, $exclude_user_id]); } - + public static function GetCommentsForObject($object_id) { global $_fullname_sql; @@ -72,7 +84,7 @@ class StudipComment extends SimpleORMap implements PrivacyObject $statement->execute([$object_id]); return $statement->fetchAll(PDO::FETCH_BOTH); } - + public static function DeleteCommentsByObject($object_ids) { if (!is_array($object_ids)) { @@ -81,17 +93,6 @@ class StudipComment extends SimpleORMap implements PrivacyObject $where = "object_id IN (?)"; return self::deleteBySQL($where, [$object_ids]); } - - protected static function configure($config = []) - { - $config['db_table'] = 'comments'; - $config['belongs_to']['news'] = [ - 'class_name' => 'StudipNews', - 'foreign_key' => 'object_id', - ]; - parent::configure($config); - } - /** * Export available data of a given user into a storage object * (an instance of the StoredUserData class) for that user. diff --git a/lib/models/StudipEvaluation.php b/lib/models/StudipEvaluation.php index dea25d04589203b0e326f57ea455a5f92c93c240..58a8f53bfbb928d70d97b32335013aed3d60767e 100644 --- a/lib/models/StudipEvaluation.php +++ b/lib/models/StudipEvaluation.php @@ -35,25 +35,29 @@ class StudipEvaluation extends SimpleORMap protected static function configure($config = []) { $config['db_table'] = 'eval'; + $config['belongs_to']['author'] = [ - 'class_name' => 'User', + 'class_name' => User::class, 'foreign_key' => 'author_id' ]; $config['has_and_belongs_to_many']['participants'] = [ - 'class_name' => 'User', + 'class_name' => User::class, 'thru_table' => 'eval_user' ]; + $config['additional_fields']['enddate'] = true; + parent::configure($config); } - + /** * Fetches all evaluations for a specific range_id - * + * * @param String $range_id the range id * @return Array All evaluations for that range */ - public static function findByRange_id($range_id) { + public static function findByRange_id($range_id) + { return self::findThru($range_id, [ 'thru_table' => 'eval_range', 'thru_key' => 'range_id', @@ -61,13 +65,14 @@ class StudipEvaluation extends SimpleORMap 'assoc_foreign_key' => 'eval_id' ]); } - + /** * Returns the enddate of a evaluation. Returns null if stop is manual - * + * * @return stopdate or null */ - public function getEnddate() { + public function getEnddate() + { if ($this->stopdate) { return $this->stopdate; } @@ -77,7 +82,8 @@ class StudipEvaluation extends SimpleORMap return null; } - function getNumberOfVotes () { + function getNumberOfVotes () + { return DBManager::get()->fetchColumn("SELECT count(DISTINCT user_id) FROM eval_user WHERE eval_id = ?", [$this->id]); -} + } } diff --git a/lib/models/StudipNews.class.php b/lib/models/StudipNews.class.php index 66f41090eea343beb9b8a9163822a0554f379342..643f9eba6bbccf6f2f905e23e70b53baa9684536 100644 --- a/lib/models/StudipNews.class.php +++ b/lib/models/StudipNews.class.php @@ -50,19 +50,19 @@ class StudipNews extends SimpleORMap implements PrivacyObject { $config['db_table'] = 'news'; $config['has_many']['news_ranges'] = [ - 'class_name' => 'NewsRange', + 'class_name' => NewsRange::class, 'assoc_foreign_key' => 'news_id', 'on_delete' => 'delete', 'on_store' => 'store', ]; $config['has_many']['comments'] = [ - 'class_name' => 'StudipComment', + 'class_name' => StudipComment::class, 'assoc_foreign_key' => 'object_id', 'on_delete' => 'delete', 'on_store' => 'store', ]; $config['belongs_to']['owner'] = [ - 'class_name' => 'User', + 'class_name' => User::class, 'foreign_key' => 'user_id', ]; $config['has_many']['news_roles'] = [ diff --git a/lib/models/StudipStudyArea.class.php b/lib/models/StudipStudyArea.class.php index 67b20c05507e8c9cbd0523b39fcb7a608916a3ba..fe9ae73c9ee687e91d7951c96f66a1823da7d05b 100644 --- a/lib/models/StudipStudyArea.class.php +++ b/lib/models/StudipStudyArea.class.php @@ -36,36 +36,36 @@ class StudipStudyArea extends SimpleORMap */ const ROOT = 'root'; - /** - * This is required, if the nodes are added backwards - */ - public $required_children = []; - protected static function configure($config = []) { $config['db_table'] = 'sem_tree'; $config['has_many']['_children'] = [ - 'class_name' => 'StudipStudyArea', + 'class_name' => StudipStudyArea::class, 'assoc_foreign_key' => 'parent_id', 'assoc_func' => 'findByParent', 'on_delete' => 'delete', 'on_store' => 'store', ]; $config['has_and_belongs_to_many']['courses'] = [ - 'class_name' => 'Course', + 'class_name' => Course::class, 'thru_table' => 'seminar_sem_tree', ]; $config['belongs_to']['institute'] = [ - 'class_name' => 'Institute', + 'class_name' => Institute::class, 'foreign_key' => 'studip_object_id', ]; $config['belongs_to']['_parent'] = [ - 'class_name' => 'StudipStudyArea', + 'class_name' => StudipStudyArea::class, 'foreign_key' => 'parent_id', ]; parent::configure($config); } + /** + * This is required, if the nodes are added backwards + */ + public $required_children = []; + /** * Returns the children of the study area with the specified ID. */ diff --git a/lib/models/StudyCourse.class.php b/lib/models/StudyCourse.class.php index ff2525cc8a65b7b40a41dfedcbef0812c9482c06..a99e1cd33183e802f8a878721b653cce1ad09800 100644 --- a/lib/models/StudyCourse.class.php +++ b/lib/models/StudyCourse.class.php @@ -25,20 +25,20 @@ class StudyCourse extends SimpleORMap protected static function configure($config = []) { $config['db_table'] = 'fach'; - + $config['has_and_belongs_to_many']['degrees'] = [ - 'class_name' => 'Degree', + 'class_name' => Degree::class, 'thru_table' => 'user_studiengang', 'thru_key' => 'fach_id', 'thru_assoc_key' => 'abschluss_id', 'order_by' => 'GROUP BY abschluss_id ORDER BY name' ]; - + $config['additional_fields']['count_user']['get'] = 'countUser'; - + parent::configure($config); } - + public function countUser() { $stmt = DBManager::get()->prepare('SELECT COUNT(DISTINCT user_id) ' @@ -46,7 +46,7 @@ class StudyCourse extends SimpleORMap $stmt->execute([$this->id]); return $stmt->fetchColumn(); } - + public function countUserByDegree($degree_id) { $stmt = DBManager::get()->prepare('SELECT COUNT(DISTINCT user_id) ' @@ -55,7 +55,7 @@ class StudyCourse extends SimpleORMap $stmt->execute([$this->id, $degree_id]); return $stmt->fetchColumn(); } - + public function store() { if ($this->isNew() || $this->isDirty()) { @@ -64,8 +64,8 @@ class StudyCourse extends SimpleORMap $this->author_id = $GLOBALS['user']->id; } } - + return parent::store(); } - + } diff --git a/lib/models/StudycourseLanguage.php b/lib/models/StudycourseLanguage.php index 5b32e33c39a30754419ad843757143fb84f7cae8..22747b31e647163e44d60cf4b1cde9fbdd188600 100644 --- a/lib/models/StudycourseLanguage.php +++ b/lib/models/StudycourseLanguage.php @@ -17,13 +17,12 @@ class StudycourseLanguage extends ModuleManagementModel { - protected static function configure($config = array()) { $config['db_table'] = 'mvv_studycourse_language'; $config['belongs_to']['studycourse'] = array( - 'class_name' => 'Studiengang', + 'class_name' => Studiengang::class, 'foreign_key' => 'studiengang_id', 'assoc_func' => 'findCached', ); diff --git a/lib/models/StudycourseType.php b/lib/models/StudycourseType.php index 0888bb2094d22dba72e786dce24a924e1f0bd1c3..ad2ee68461789a2368fcb96f8f007afa54f28128 100644 --- a/lib/models/StudycourseType.php +++ b/lib/models/StudycourseType.php @@ -17,13 +17,12 @@ class StudycourseType extends ModuleManagementModel { - protected static function configure($config = array()) { $config['db_table'] = 'mvv_studycourse_type'; $config['belongs_to']['studycourse'] = array( - 'class_name' => 'Studiengang', + 'class_name' => Studiengang::class, 'foreign_key' => 'studiengang_id', 'assoc_func' => 'findCached', ); diff --git a/lib/models/TFASecret.php b/lib/models/TFASecret.php index 8b9f86c1219c2abf7c7db810feb1ea1b1abeb3c2..29f42eb3fb2b527750f0493294fafcb7c3f93279 100644 --- a/lib/models/TFASecret.php +++ b/lib/models/TFASecret.php @@ -13,7 +13,6 @@ class TFASecret extends SimpleORMap { // Possible authentication types (email may require more tokens in a short // period of time with a larger window to accept them). - const TYPES = [ 'email' => [ 'window' => 60, @@ -25,21 +24,6 @@ class TFASecret extends SimpleORMap ], ]; - /** - * Returns the duration in seconds for which a token is valid. - * - * @param string $type Type of token - * @return int duration in seconds - */ - public static function getValidationDuration($type) - { - if (!isset(self::TYPES[$type])) { - throw new InvalidArgumentException("Unknown tfa type {$type}"); - } - $t = self::TYPES[$type]; - return $t['window'] * $t['period']; - } - /** * Configures the model. * @@ -60,6 +44,20 @@ class TFASecret extends SimpleORMap parent::configure($config); } + /** + * Returns the duration in seconds for which a token is valid. + * + * @param string $type Type of token + * @return int duration in seconds + */ + public static function getValidationDuration($type) + { + if (!isset(self::TYPES[$type])) { + throw new InvalidArgumentException("Unknown tfa type {$type}"); + } + $t = self::TYPES[$type]; + return $t['window'] * $t['period']; + } /** * Overwrites the SORM setNew() method. This will create the secret string. * diff --git a/lib/models/ToolActivation.php b/lib/models/ToolActivation.php index bcf40ecab4be9840ab3ab37be67f8fe56d4d4b7f..14da02f6cb7ce5af6eca267f2f5883faab8aa9ed 100644 --- a/lib/models/ToolActivation.php +++ b/lib/models/ToolActivation.php @@ -26,6 +26,7 @@ class ToolActivation extends SimpleORMap protected static function configure($config = []) { $config['db_table'] = 'tools_activated'; + $config['belongs_to']['institute'] = [ 'class_name' => Institute::class, 'foreign_key' => 'range_id', @@ -34,6 +35,7 @@ class ToolActivation extends SimpleORMap 'class_name' => Course::class, 'foreign_key' => 'range_id', ]; + $config['serialized_fields']['metadata'] = 'JSONArrayObject'; $config['registered_callbacks']['before_create'][] = 'setMaxPosition'; diff --git a/lib/models/User.class.php b/lib/models/User.class.php index db670fba351260583d944c0cf64a9b45e6570e8e..23756c2dcd142056cb9455bf13be01c7ae0489b0 100644 --- a/lib/models/User.class.php +++ b/lib/models/User.class.php @@ -76,28 +76,28 @@ class User extends AuthUserMd5 implements Range, PrivacyObject protected static function configure($config = []) { $config['has_many']['course_memberships'] = [ - 'class_name' => 'CourseMember', + 'class_name' => CourseMember::class, 'on_delete' => 'delete', 'on_store' => 'store', ]; $config['has_many']['institute_memberships'] = [ - 'class_name' => 'InstituteMember', + 'class_name' => InstituteMember::class, 'order_by' => 'ORDER BY priority ASC', 'on_delete' => 'delete', 'on_store' => 'store', ]; $config['has_many']['admission_applications'] = [ - 'class_name' => 'AdmissionApplication', + 'class_name' => AdmissionApplication::class, 'on_delete' => 'delete', 'on_store' => 'store', ]; $config['has_many']['archived_course_memberships'] = [ - 'class_name' => 'ArchivedCourseMember', + 'class_name' => ArchivedCourseMember::class, 'on_delete' => 'delete', 'on_store' => 'store', ]; $config['has_many']['datafields'] = [ - 'class_name' => 'DatafieldEntryModel', + 'class_name' => DatafieldEntryModel::class, 'foreign_key' => function ($user) { return [$user]; }, @@ -109,13 +109,13 @@ class User extends AuthUserMd5 implements Range, PrivacyObject 'on_store' => 'store', ]; $config['has_many']['studycourses'] = [ - 'class_name' => 'UserStudyCourse', + 'class_name' => UserStudyCourse::class, 'assoc_func' => 'findByUser', 'on_delete' => 'delete', 'on_store' => 'store', ]; $config['has_and_belongs_to_many']['contacts'] = [ - 'class_name' => 'User', + 'class_name' => User::class, 'thru_table' => 'contact', 'thru_key' => 'owner_id', 'thru_assoc_key' => 'user_id', @@ -124,28 +124,28 @@ class User extends AuthUserMd5 implements Range, PrivacyObject 'on_store' => 'store', ]; $config['has_many']['contactgroups'] = [ - 'class_name' => 'Statusgruppen', + 'class_name' => Statusgruppen::class, 'assoc_foreign_key' => 'range_id', 'on_delete' => 'delete', 'on_store' => 'store', ]; $config['has_one']['info'] = [ - 'class_name' => 'UserInfo', + 'class_name' => UserInfo::class, 'on_delete' => 'delete', 'on_store' => 'store', ]; $config['has_one']['online'] = [ - 'class_name' => 'UserOnline', + 'class_name' => UserOnline::class, 'on_delete' => 'delete', 'on_store' => 'store', ]; $config['has_many']['resource_permissions'] = [ - 'class_name' => 'ResourcePermission', + 'class_name' => ResourcePermission::class, 'on_delete' => 'delete', 'on_store' => 'store' ]; $config['has_many']['resource_temporary_permissions'] = [ - 'class_name' => 'ResourceTemporaryPermission', + 'class_name' => ResourceTemporaryPermission::class, 'on_delete' => 'delete', 'on_store' => 'store' ]; @@ -166,7 +166,7 @@ class User extends AuthUserMd5 implements Range, PrivacyObject ]; $config['has_and_belongs_to_many']['domains'] = [ - 'class_name' => 'UserDomain', + 'class_name' => UserDomain::class, 'thru_table' => 'user_userdomains', 'on_delete' => 'delete', 'on_store' => 'store', diff --git a/lib/models/UserDomain.php b/lib/models/UserDomain.php index 08deb49189884e518278f13fa4a99e78ee7453b7..44befce2c51608fcab433143fb38e236f7cdea23 100644 --- a/lib/models/UserDomain.php +++ b/lib/models/UserDomain.php @@ -16,7 +16,7 @@ class UserDomain extends SimpleORMap $config['db_table'] = 'userdomains'; $config['has_and_belongs_to_many']['users'] = [ - 'class_name' => 'User', + 'class_name' => User::class, 'thru_table' => 'user_userdomains', 'assoc_foreign_key' => 'user_id', 'on_delete' => 'delete', @@ -24,7 +24,7 @@ class UserDomain extends SimpleORMap ]; $config['has_and_belongs_to_many']['courses'] = [ - 'class_name' => 'Course', + 'class_name' => Course::class, 'thru_table' => 'seminar_userdomains', 'on_delete' => 'delete', 'on_store' => 'store', diff --git a/lib/models/UserStudyCourse.class.php b/lib/models/UserStudyCourse.class.php index 8fe6454cf90bda44ec60308ceedc21afae3dec69..ac7670c198f1d6d5cf2b9c07493cde701e9b043d 100644 --- a/lib/models/UserStudyCourse.class.php +++ b/lib/models/UserStudyCourse.class.php @@ -26,6 +26,27 @@ */ class UserStudyCourse extends SimpleORMap implements PrivacyObject { + protected static function configure($config = []) + { + $config['db_table'] = 'user_studiengang'; + + $config['belongs_to']['user'] = [ + 'class_name' => 'User', + 'foreign_key' => 'user_id', + ]; + $config['belongs_to']['degree'] = [ + 'class_name' => 'Abschluss', + 'foreign_key' => 'abschluss_id', + ]; + $config['belongs_to']['studycourse'] = [ + 'class_name' => 'Fach', + 'foreign_key' => 'fach_id', + ]; + + $config['additional_fields']['degree_name'] = []; + $config['additional_fields']['studycourse_name'] = []; + parent::configure($config); + } public static function findByUser($user_id) { @@ -48,27 +69,6 @@ class UserStudyCourse extends SimpleORMap implements PrivacyObject { return self::findBySql("fach_id = ? AND abschluss_id = ?", [$study_course_id, $degree_id]); } - - protected static function configure($config = []) - { - $config['db_table'] = 'user_studiengang'; - $config['belongs_to']['user'] = [ - 'class_name' => 'User', - 'foreign_key' => 'user_id', - ]; - $config['belongs_to']['degree'] = [ - 'class_name' => 'Abschluss', - 'foreign_key' => 'abschluss_id', - ]; - $config['belongs_to']['studycourse'] = [ - 'class_name' => 'Fach', - 'foreign_key' => 'fach_id', - ]; - $config['additional_fields']['degree_name'] = []; - $config['additional_fields']['studycourse_name'] = []; - parent::configure($config); - } - /** * Export available data of a given user into a storage object * (an instance of the StoredUserData class) for that user. diff --git a/lib/models/WebserviceAccessRule.class.php b/lib/models/WebserviceAccessRule.class.php index 5ee9ac5795c1504c14c78d7411ed13e47d129756..51eceeea40ccf958689dbe7b1bf1a0e7e3acba95 100644 --- a/lib/models/WebserviceAccessRule.class.php +++ b/lib/models/WebserviceAccessRule.class.php @@ -32,6 +32,13 @@ */ class WebserviceAccessRule extends SimpleORMap { + protected static function configure($config = []) + { + $config['db_table'] = 'webservice_access_rules'; + $config['serialized_fields']['ip_range'] = 'CSVArrayObject'; + parent::configure($config); + } + /** * returns all rules for an given api key * @@ -81,13 +88,6 @@ class WebserviceAccessRule extends SimpleORMap return $access; } - protected static function configure($config = []) - { - $config['db_table'] = 'webservice_access_rules'; - $config['serialized_fields']['ip_range'] = 'CSVArrayObject'; - parent::configure($config); - } - /** * checks, if a given IP Address is in the range specified * for this rule. If there is no specified range, it returns true diff --git a/lib/models/resources/Resource.class.php b/lib/models/resources/Resource.class.php index b012daed85471e699cde1dca19ce66d5e7ec118b..660b3e87b83a087ac2db0802b55d2d62005c2292 100644 --- a/lib/models/resources/Resource.class.php +++ b/lib/models/resources/Resource.class.php @@ -43,60 +43,53 @@ */ class Resource extends SimpleORMap implements StudipItem { - /** - * This is a cache for permissions that users have on resources. - * It is meant to reduce the database requests in cases where the - * same permission is queried a lot of times. - */ - protected static $permission_cache; - protected static function configure($config = []) { $config['db_table'] = 'resources'; $config['belongs_to']['category'] = [ - 'class_name' => 'ResourceCategory', + 'class_name' => ResourceCategory::class, 'foreign_key' => 'category_id', 'assoc_func' => 'find' ]; $config['has_many']['properties'] = [ - 'class_name' => 'ResourceProperty', + 'class_name' => ResourceProperty::class, 'assoc_foreign_key' => 'resource_id', 'on_delete' => 'delete', 'on_store' => 'store' ]; $config['has_many']['permissions'] = [ - 'class_name' => 'ResourcePermission', + 'class_name' => ResourcePermission::class, 'assoc_foreign_key' => 'resource_id', 'on_delete' => 'delete', 'on_store' => 'store' ]; $config['has_many']['requests'] = [ - 'class_name' => 'ResourceRequest', + 'class_name' => ResourceRequest::class, 'assoc_foreign_key' => 'resource_id', 'on_delete' => 'delete', 'on_store' => 'store' ]; $config['has_many']['bookings'] = [ - 'class_name' => 'ResourceBooking', + 'class_name' => ResourceBooking::class, 'assoc_foreign_key' => 'resource_id', 'on_delete' => 'delete', 'on_store' => 'store' ]; $config['has_many']['children'] = [ - 'class_name' => 'Resource', + 'class_name' => Resource::class, 'assoc_func' => 'findChildren', 'on_delete' => 'delete', 'on_store' => 'store' ]; $config['belongs_to']['parent'] = [ - 'class_name' => 'Resource', + 'class_name' => Resource::class, 'foreign_key' => 'parent_id' ]; @@ -108,6 +101,13 @@ class Resource extends SimpleORMap implements StudipItem parent::configure($config); } + /** + * This is a cache for permissions that users have on resources. + * It is meant to reduce the database requests in cases where the + * same permission is queried a lot of times. + */ + protected static $permission_cache; + /** * Returns the children of a resource. * The children are converted to an instance of the derived class, diff --git a/lib/models/resources/ResourceBooking.class.php b/lib/models/resources/ResourceBooking.class.php index f925cba58b5bf36d066bb13cf5da7b3d2fd56586..fe4e4be817b57905c684d3591b683c2a836975df 100644 --- a/lib/models/resources/ResourceBooking.class.php +++ b/lib/models/resources/ResourceBooking.class.php @@ -59,34 +59,32 @@ */ class ResourceBooking extends SimpleORMap implements PrivacyObject, Studip\Calendar\EventSource { - private $assigned_user_type; - protected static function configure($config = []) { $config['db_table'] = 'resource_bookings'; $config['belongs_to']['resource'] = [ - 'class_name' => 'Resource', + 'class_name' => Resource::class, 'foreign_key' => 'resource_id', 'assoc_func' => 'find' ]; $config['belongs_to']['assigned_user'] = [ - 'class_name' => 'User', + 'class_name' => User::class, 'foreign_key' => 'range_id', 'assoc_func' => 'find' ]; $config['belongs_to']['assigned_course_date'] = [ - 'class_name' => 'CourseDate', + 'class_name' => CourseDate::class, 'foreign_key' => 'range_id', 'assoc_func' => 'find' ]; $config['has_many']['time_intervals'] = [ - 'class_name' => 'ResourceBookingInterval', + 'class_name' => ResourceBookingInterval::class, 'assoc_foreign_key' => 'booking_id', 'on_delete' => 'delete' ]; $config['belongs_to']['booking_user'] = [ - 'class_name' => 'User', + 'class_name' => User::class, 'foreign_key' => 'booking_user_id', 'assoc_func' => 'find' ]; @@ -109,6 +107,7 @@ class ResourceBooking extends SimpleORMap implements PrivacyObject, Studip\Calen parent::configure($config); } + private $assigned_user_type; public function createStoreLogEntry() { diff --git a/lib/models/resources/ResourceBookingInterval.class.php b/lib/models/resources/ResourceBookingInterval.class.php index adfc681b1ec8ec5f55bb5e4c73bd413fa0dea426..a5b0e437600a027ecdb6f5f9a5ec16a894d46f69 100644 --- a/lib/models/resources/ResourceBookingInterval.class.php +++ b/lib/models/resources/ResourceBookingInterval.class.php @@ -45,13 +45,13 @@ class ResourceBookingInterval extends SimpleORMap $config['db_table'] = 'resource_booking_intervals'; $config['belongs_to']['booking'] = [ - 'class_name' => 'ResourceBooking', + 'class_name' => ResourceBooking::class, 'foreign_key' => 'booking_id', 'assoc_func' => 'find' ]; $config['belongs_to']['resource'] = [ - 'class_name' => 'Resource', + 'class_name' => Resource::class, 'foreign_key' => 'resource_id', 'assoc_func' => 'find' ]; @@ -97,7 +97,7 @@ class ResourceBookingInterval extends SimpleORMap } return true; } - + /** * Converts this ResourceBookingInterval object to a DateInterval object. * diff --git a/lib/models/resources/ResourceCategory.class.php b/lib/models/resources/ResourceCategory.class.php index 00465cd28cecd8b4cf012dc0885289a66fbd65bd..0f7fae1e51d3977b510cfff353f72c156b206473 100644 --- a/lib/models/resources/ResourceCategory.class.php +++ b/lib/models/resources/ResourceCategory.class.php @@ -40,7 +40,7 @@ class ResourceCategory extends SimpleORMap $config['db_table'] = 'resource_categories'; $config['has_and_belongs_to_many']['property_definitions'] = [ - 'class_name' => 'ResourcePropertyDefinition', + 'class_name' => ResourcePropertyDefinition::class, 'assoc_foreign_key' => 'property_id', 'thru_table' => 'resource_category_properties', 'thru_key' => 'category_id', @@ -48,7 +48,7 @@ class ResourceCategory extends SimpleORMap ]; $config['has_many']['property_links'] = [ - 'class_name' => 'ResourceCategoryProperty', + 'class_name' => ResourceCategoryProperty::class, 'assoc_func' => 'findByCategory_id', 'foreign_key' => 'id', 'on_delete' => 'delete' diff --git a/lib/models/resources/ResourceCategoryProperty.class.php b/lib/models/resources/ResourceCategoryProperty.class.php index f52e5cdc6795e76e13c7648c28d3fa5f5734e451..2b465185f129c04688358bb4704f29d7ead3c28e 100644 --- a/lib/models/resources/ResourceCategoryProperty.class.php +++ b/lib/models/resources/ResourceCategoryProperty.class.php @@ -34,13 +34,13 @@ class ResourceCategoryProperty extends SimpleORMap $config['db_table'] = 'resource_category_properties'; $config['belongs_to']['category'] = [ - 'class_name' => 'ResourceCategory', + 'class_name' => ResourceCategory::class, 'foreign_key' => 'category_id', 'assoc_func' => 'find' ]; $config['belongs_to']['definition'] = [ - 'class_name' => 'ResourcePropertyDefinition', + 'class_name' => ResourcePropertyDefinition::class, 'foreign_key' => 'property_id', 'assoc_func' => 'find' ]; diff --git a/lib/models/resources/ResourcePermission.class.php b/lib/models/resources/ResourcePermission.class.php index e0c3c398582c4a9cfd8a679ce0497ea2735154bb..7d6a16342787bb0c8ceb8297d2489934ece6c4a5 100644 --- a/lib/models/resources/ResourcePermission.class.php +++ b/lib/models/resources/ResourcePermission.class.php @@ -41,13 +41,13 @@ class ResourcePermission extends SimpleORMap implements PrivacyObject $config['db_table'] = 'resource_permissions'; $config['belongs_to']['user'] = [ - 'class_name' => 'User', + 'class_name' => User::class, 'foreign_key' => 'user_id', 'assoc_func' => 'find' ]; $config['belongs_to']['resource'] = [ - 'class_name' => 'Resource', + 'class_name' => Resource::class, 'foreign_key' => 'resource_id', 'assoc_func' => 'find' ]; diff --git a/lib/models/resources/ResourceProperty.class.php b/lib/models/resources/ResourceProperty.class.php index 78101aac786a55291ce4e2ef73a6f76608aa3e5e..6db96158957bfd11dd9d68da37e2873327e83963 100644 --- a/lib/models/resources/ResourceProperty.class.php +++ b/lib/models/resources/ResourceProperty.class.php @@ -32,13 +32,13 @@ class ResourceProperty extends SimpleORMap $config['db_table'] = 'resource_properties'; $config['belongs_to']['definition'] = [ - 'class_name' => 'ResourcePropertyDefinition', + 'class_name' => ResourcePropertyDefinition::class, 'foreign_key' => 'property_id', 'assoc_func' => 'find' ]; $config['belongs_to']['resource'] = [ - 'class_name' => 'Resource', + 'class_name' => Resource::class, 'foreign_key' => 'resource_id', 'assoc_func' => 'find' ]; diff --git a/lib/models/resources/ResourcePropertyDefinition.class.php b/lib/models/resources/ResourcePropertyDefinition.class.php index 933a1ce67e62ef653734075b989bf3f22770c5b7..878baf80e9904ff136d66af1148054d4516c46ea 100644 --- a/lib/models/resources/ResourcePropertyDefinition.class.php +++ b/lib/models/resources/ResourcePropertyDefinition.class.php @@ -55,7 +55,7 @@ class ResourcePropertyDefinition extends SimpleORMap $config['db_table'] = 'resource_property_definitions'; $config['belongs_to']['group'] = [ - 'class_name' => 'ResourcePropertyGroup', + 'class_name' => ResourcePropertyGroup::class, 'foreign_key' => 'property_group_id' ]; $config['i18n_fields']['display_name'] = true; diff --git a/lib/models/resources/ResourcePropertyGroup.class.php b/lib/models/resources/ResourcePropertyGroup.class.php index 83dd90dce8668ed6a64eace7a993d3be19bba604..9da6762a79b2a3a2bd3bb52dfeae81829e42e0b8 100644 --- a/lib/models/resources/ResourcePropertyGroup.class.php +++ b/lib/models/resources/ResourcePropertyGroup.class.php @@ -28,7 +28,7 @@ class ResourcePropertyGroup extends SimpleORMap $config['db_table'] = 'resource_property_groups'; $config['has_many']['properties'] = [ - 'class_name' => 'ResourcePropertyDefinition', + 'class_name' => ResourcePropertyDefinition::class, 'assoc_foreign_key' => 'property_group_id', 'assoc_func' => 'findByPropertyGroup' ]; diff --git a/lib/models/resources/ResourceRequest.class.php b/lib/models/resources/ResourceRequest.class.php index 9ac498342b33f91234f5c75a8abe8d7548929464..b66fb54072c3acba43a6c46cc1d07af52d488c04 100644 --- a/lib/models/resources/ResourceRequest.class.php +++ b/lib/models/resources/ResourceRequest.class.php @@ -70,47 +70,47 @@ class ResourceRequest extends SimpleORMap implements PrivacyObject, Studip\Calen $config['db_table'] = 'resource_requests'; $config['belongs_to']['resource'] = [ - 'class_name' => 'Resource', + 'class_name' => Resource::class, 'foreign_key' => 'resource_id', 'assoc_func' => 'find' ]; $config['belongs_to']['category'] = [ - 'class_name' => 'ResourceCategory', + 'class_name' => ResourceCategory::class, 'foreign_key' => 'category_id', 'assoc_func' => 'find' ]; $config['belongs_to']['user'] = [ - 'class_name' => 'User', + 'class_name' => User::class, 'foreign_key' => 'user_id', 'assoc_func' => 'find' ]; $config['belongs_to']['last_modifier'] = [ - 'class_name' => 'User', + 'class_name' => User::class, 'foreign_key' => 'last_modified_by', 'assoc_func' => 'find' ]; $config['belongs_to']['course'] = [ - 'class_name' => 'Course', + 'class_name' => Course::class, 'foreign_key' => 'course_id', 'assoc_func' => 'find' ]; $config['belongs_to']['cycle'] = [ - 'class_name' => 'SeminarCycleDate', + 'class_name' => SeminarCycleDate::class, 'foreign_key' => 'metadate_id' ]; $config['belongs_to']['date'] = [ - 'class_name' => 'CourseDate', + 'class_name' => CourseDate::class, 'foreign_key' => 'termin_id' ]; $config['has_many']['properties'] = [ - 'class_name' => 'ResourceRequestProperty', + 'class_name' => ResourceRequestProperty::class, 'foreign_key' => 'id', 'assoc_foreign_key' => 'request_id', 'on_store' => 'store', @@ -118,7 +118,7 @@ class ResourceRequest extends SimpleORMap implements PrivacyObject, Studip\Calen ]; $config['has_many']['appointments'] = [ - 'class_name' => 'ResourceRequestAppointment', + 'class_name' => ResourceRequestAppointment::class, 'foreign_key' => 'id', 'assoc_foreign_key' => 'request_id', 'on_store' => 'store', diff --git a/lib/models/resources/ResourceRequestAppointment.class.php b/lib/models/resources/ResourceRequestAppointment.class.php index 58ec3b3e90acf67abbf48053f6f993c22176ed91..9914462691ff51478277001715e180bb0a91fb47 100644 --- a/lib/models/resources/ResourceRequestAppointment.class.php +++ b/lib/models/resources/ResourceRequestAppointment.class.php @@ -36,18 +36,18 @@ class ResourceRequestAppointment extends SimpleORMap protected static function configure($config = []) { $config['db_table'] = 'resource_request_appointments'; - + $config['belongs_to']['resource_request'] = [ - 'class_name' => 'ResourceRequest', + 'class_name' => ResourceRequest::class, 'foreign_key' => 'request_id', 'assoc_func' => 'find' ]; $config['belongs_to']['appointment'] = [ - 'class_name' => 'CourseDate', + 'class_name' => CourseDate::class, 'foreign_key' => 'appointment_id', 'assoc_func' => 'find' ]; - + parent::configure($config); } } diff --git a/lib/models/resources/ResourceRequestProperty.class.php b/lib/models/resources/ResourceRequestProperty.class.php index 688063d84ad58ab9ac72de87fdc414d9e6a4d588..ec275deae963db075e70bb2d2458c4404969f981 100644 --- a/lib/models/resources/ResourceRequestProperty.class.php +++ b/lib/models/resources/ResourceRequestProperty.class.php @@ -33,13 +33,13 @@ class ResourceRequestProperty extends SimpleORMap $config['db_table'] = 'resource_request_properties'; $config['belongs_to']['definition'] = [ - 'class_name' => 'ResourcePropertyDefinition', + 'class_name' => ResourcePropertyDefinition::class, 'foreign_key' => 'property_id', 'assoc_func' => 'find' ]; $config['belongs_to']['request'] = [ - 'class_name' => 'ResourceRequest', + 'class_name' => ResourceRequest::class, 'foreign_key' => 'request_id', 'assoc_func' => 'find' ]; @@ -50,7 +50,7 @@ class ResourceRequestProperty extends SimpleORMap parent::configure($config); } - + /** * Creates a string containing the appropriate value * of this resource property. diff --git a/lib/models/resources/ResourceTemporaryPermission.class.php b/lib/models/resources/ResourceTemporaryPermission.class.php index 59bb298073114752394caf4f00504a81de2d2265..1f0bedb0795b2f1f377347a60dffece63bb5767e 100644 --- a/lib/models/resources/ResourceTemporaryPermission.class.php +++ b/lib/models/resources/ResourceTemporaryPermission.class.php @@ -38,25 +38,25 @@ class ResourceTemporaryPermission extends SimpleORMap implements PrivacyObject protected static function configure($config = []) { $config['db_table'] = 'resource_temporary_permissions'; - + $config['belongs_to']['resource'] = [ - 'class_name' => 'Resource', + 'class_name' => Resource::class, 'foreign_key' => 'resource_id', 'assoc_func' => 'find' ]; - + $config['belongs_to']['user'] = [ - 'class_name' => 'User', + 'class_name' => User::class, 'foreign_key' => 'user_id', 'assoc_func' => 'find' ]; - + $config['registered_callbacks']['before_store'][] = 'cbLogChanges'; $config['registered_callbacks']['before_delete'][] = 'cbLogDeletion'; - + parent::configure($config); } - + /** * @inheritDoc */ @@ -69,12 +69,12 @@ class ResourceTemporaryPermission extends SimpleORMap implements PrivacyObject 'user_id' => $storage->user_id ] ); - + $rows = []; foreach ($permissions as $permission) { $rows[] = $permission->toRawArray(); } - + $storage->addTabularData( _('Temporäre Berechtigungen an Ressourcen'), self::$config['db_table'], @@ -82,7 +82,7 @@ class ResourceTemporaryPermission extends SimpleORMap implements PrivacyObject $user ); } - + /** * Returns the current permission a user has for a resource. * @@ -110,8 +110,8 @@ class ResourceTemporaryPermission extends SimpleORMap implements PrivacyObject } return ''; } - - + + public static function userHasPermissionInTimeRange( User $user, string $resource_id, @@ -139,17 +139,17 @@ class ResourceTemporaryPermission extends SimpleORMap implements PrivacyObject 'end' => $end->getTimestamp() ] ); - + if (!$perm) { //If no permission object can be found the user obviously //doesn't have the requested permissions. return false; } - + return ResourceManager::comparePermissionLevels($perm->perm, $perm) >= 0; } - - + + /** * This is a callback method to create an entry in the Stud.IP log * when a ResourceTemporaryPermission object is stored. @@ -170,7 +170,7 @@ class ResourceTemporaryPermission extends SimpleORMap implements PrivacyObject $this->perms ) ); - + } elseif ($this->resource_id) { //Resource-specific permissions StudipLog::log( @@ -222,7 +222,7 @@ class ResourceTemporaryPermission extends SimpleORMap implements PrivacyObject } } } - + /** * This is a callback method to create an entry in the Stud.IP log * when a ResourceTemporaryPermission object is deleted. diff --git a/lib/models/resources/RoomRequest.class.php b/lib/models/resources/RoomRequest.class.php index 0c8b37a8612271bd1a032702bfce853d218ce3e2..c0898d7a0b8630f811e26e665853140b68b2620e 100644 --- a/lib/models/resources/RoomRequest.class.php +++ b/lib/models/resources/RoomRequest.class.php @@ -29,17 +29,17 @@ class RoomRequest extends ResourceRequest protected static function configure($config = []) { $config['belongs_to']['room'] = [ - 'class_name' => 'Room', + 'class_name' => Room::class, 'foreign_key' => 'resource_id', 'assoc_func' => 'find' ]; - + $required_properties = [ 'seats', 'room_type', 'booking_plan_is_public' ]; - + $config['additional_fields'] = []; foreach ($required_properties as $property) { $config['additional_fields'][$property] = [ @@ -47,11 +47,11 @@ class RoomRequest extends ResourceRequest 'set' => 'setProperty' ]; } - + parent::configure($config); - + } - + public function checkOpen($also_change = false) { $db = DBManager::get(); @@ -72,7 +72,7 @@ class RoomRequest extends ResourceRequest if ($query) { $existing_assign = $db->query($query)->fetchColumn(); } - + if ($existing_assign && $also_change) { $this->closed = 1; $this->store(); diff --git a/lib/models/resources/SeparableRoom.class.php b/lib/models/resources/SeparableRoom.class.php index 4c9e73b165e4028ab24d0458c295a54b1065bcd5..81861632a2b168fbc0766ffb29abcf9fd721b535 100644 --- a/lib/models/resources/SeparableRoom.class.php +++ b/lib/models/resources/SeparableRoom.class.php @@ -29,23 +29,23 @@ class SeparableRoom extends SimpleORMap protected static function configure($config = []) { $config['db_table'] = 'separable_rooms'; - + $config['belongs_to']['building'] = [ - 'class_name' => 'Building', + 'class_name' => Building::class, 'foreign_key' => 'building_id', 'assoc_func' => 'find' ]; $config['has_many']['parts'] = [ - 'class_name' => 'SeparableRoomPart', + 'class_name' => SeparableRoomPart::class, 'assoc_foreign_key' => 'separable_room_id', 'on_store' => 'store', 'on_delete' => 'delete' ]; - + parent::configure($config); } - - + + /** * Creates a SeparableRoom object from a list of room objects. * @param string $building_id @@ -58,7 +58,7 @@ class SeparableRoom extends SimpleORMap if (count($rooms) === 0) { return null; } - + //Check if all array items are room objects: $room_names = []; foreach ($rooms as $room) { @@ -69,7 +69,7 @@ class SeparableRoom extends SimpleORMap } $room_names[] = $room->name; } - + //Now we can create the separable room: if (!$name) { //First we create a common name from all the room names. @@ -95,10 +95,10 @@ class SeparableRoom extends SimpleORMap } $name = $common_name; } - + //At this point we have either found the common name //or $common_name is empty. - + $separable_room = new SeparableRoom(); $separable_room->building_id = $building_id; if ($name) { @@ -111,7 +111,7 @@ class SeparableRoom extends SimpleORMap _('Fehler beim Speichern des teilbaren Raumes!') ); } - + $successfully_stored = 0; foreach ($rooms as $room) { $part = new SeparableRoomPart(); @@ -121,7 +121,7 @@ class SeparableRoom extends SimpleORMap $successfully_stored++; } } - + if ($successfully_stored < count($rooms)) { throw new SeparableRoomException( sprintf( @@ -131,11 +131,11 @@ class SeparableRoom extends SimpleORMap ) ); } - + return $separable_room; } - - + + public static function findByRoomPart(Room $room) { return self::findOneBySql( @@ -148,8 +148,8 @@ class SeparableRoom extends SimpleORMap ] ); } - - + + public function findOtherRoomParts(array $known_parts = []) { $known_part_ids = []; @@ -158,7 +158,7 @@ class SeparableRoom extends SimpleORMap $known_part_ids[] = $known_part->id; } } - + $resources = Resource::findBySql( 'INNER JOIN separable_room_parts ON resources.id = separable_room_parts.room_id @@ -171,12 +171,12 @@ class SeparableRoom extends SimpleORMap 'separable_room_id' => $this->id ] ); - + if (!$resources) { //There are no other room parts. return []; } - + $room_parts = []; foreach ($resources as $resource) { $resource = $resource->getDerivedClassInstance(); @@ -184,7 +184,7 @@ class SeparableRoom extends SimpleORMap $room_parts[] = $resource; } } - + return $room_parts; } } diff --git a/lib/models/resources/SeparableRoomPart.class.php b/lib/models/resources/SeparableRoomPart.class.php index 18d2f1d6f9f468665cdfe37a14ee1751c6180b2b..a4a5fb54f400450d90da0d448e7129d9008d612e 100644 --- a/lib/models/resources/SeparableRoomPart.class.php +++ b/lib/models/resources/SeparableRoomPart.class.php @@ -28,27 +28,27 @@ class SeparableRoomPart extends SimpleORMap protected static function configure($config = []) { $config['db_table'] = 'separable_room_parts'; - + $config['belongs_to']['separable_room'] = [ - 'class_name' => 'SeparableRoom', + 'class_name' => SeparableRoom::class, 'foreign_key' => 'separable_room_id', 'assoc_func' => 'find' ]; $config['belongs_to']['room'] = [ - 'class_name' => 'Room', + 'class_name' => Room::class, 'foreign_key' => 'room_id', 'assoc_func' => 'find' ]; - + parent::configure($config); } - + public function getRoomName() { if ($this->room) { return $this->room->name; } - + return ''; } }