aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/classes/MvvPerm.php9
-rw-r--r--lib/models/Abschluss.php16
-rw-r--r--lib/models/Fach.php51
-rw-r--r--lib/models/Fachbereich.php14
4 files changed, 63 insertions, 27 deletions
diff --git a/lib/classes/MvvPerm.php b/lib/classes/MvvPerm.php
index 693b7b7..d75a35d 100644
--- a/lib/classes/MvvPerm.php
+++ b/lib/classes/MvvPerm.php
@@ -638,9 +638,12 @@ class MvvPerm {
}
if (count($institutes)) {
- $stmt = DBManager::get()->prepare('SELECT DISTINCT(Institut_id) '
- . 'FROM Institute WHERE Institut_id IN (:inst_ids) '
- . 'OR fakultaets_id IN (:inst_ids)');
+ $stmt = DBManager::get()->prepare('
+ SELECT DISTINCT(`Institut_id`)
+ FROM `Institute`
+ WHERE `Institut_id` IN (:inst_ids)
+ OR `fakultaets_id` IN (:inst_ids)
+ ');
$stmt->execute(['inst_ids' => $institutes]);
self::$user_role_institutes[$user_id] = $stmt->fetchAll(PDO::FETCH_COLUMN);
} else {
diff --git a/lib/models/Abschluss.php b/lib/models/Abschluss.php
index 4f26563..7bab324 100644
--- a/lib/models/Abschluss.php
+++ b/lib/models/Abschluss.php
@@ -152,14 +152,13 @@ class Abschluss extends ModuleManagementModelTreeItem implements PrivacyObject
/**
* Returns all Abschluesse assigned to a given Fach.
- * An Abschluss is assigned to a Fach if a Studiengangteil (that holds th Fach)
+ * An Abschluss is assigned to a Fach if a Studiengangteil (that holds the Fach)
* is assigned to a Studiengang (as the home of the Abschluss).
*
* @param string $fach_id The id of the fach.
- * @return array An array of abschluss objects.
+ * @return static[] An array of abschluss objects.
* REMOVED
*/
- /*
public static function findByFach($fach_id)
{
return self::findBySQL(
@@ -169,10 +168,11 @@ class Abschluss extends ModuleManagementModelTreeItem implements PrivacyObject
WHERE `mvv_stgteil`.`fach_id` = ?
GROUP BY `abschluss`.`abschluss_id`
ORDER BY `abschluss`.`name`',
- [$fach_id]
+ [
+ $fach_id
+ ]
);
}
- */
/**
* Returns all Abschluesse assigned to Studiengaenge.
@@ -304,16 +304,20 @@ class Abschluss extends ModuleManagementModelTreeItem implements PrivacyObject
* Returns all Faecher this Abschluss is assigned to.
*
* @return array All Faecher this Abschluss is assigned to.
+ * REMOVED
*/
+ /*
public function getFaecher()
{
return Fach::findByAbschluss($this->getId());
}
+ */
/**
- * Returns all assigned institutes of this Abschluss.
+ * Returns all institutes implicitly assigned by study courses (responsible institute).
*
* @return array An array of institutes.
+ * TODO (remove)
*/
public function getAssignedInstitutes()
{
diff --git a/lib/models/Fach.php b/lib/models/Fach.php
index 802fcd4..73e6377 100644
--- a/lib/models/Fach.php
+++ b/lib/models/Fach.php
@@ -70,10 +70,11 @@ class Fach extends ModuleManagementModelTreeItem implements PrivacyObject
'on_store' => 'store',
'on_delete' => 'delete'
];
-
+/*
$config['additional_fields']['count_abschluesse']['get'] = function ($fach) {
return $fach->count_abschluesse;
};
+*/
$config['additional_fields']['count_user']['get'] = function ($fach) {
return $fach->count_user;
};
@@ -151,7 +152,9 @@ class Fach extends ModuleManagementModelTreeItem implements PrivacyObject
* @param array $filter Key-value pairs of filed names and values
* to filter the result set.
* @return int The number of Fächer
+ * REMOVED
*/
+ /*
public static function getCount($filter = null)
{
$query = '
@@ -163,6 +166,7 @@ class Fach extends ModuleManagementModelTreeItem implements PrivacyObject
$db->execute();
return $db->fetchColumn(0);
}
+ */
/**
* Returns all Faecher which are assigned to Studiengangteile. Sorted and
@@ -240,35 +244,46 @@ class Fach extends ModuleManagementModelTreeItem implements PrivacyObject
* Retrieves all Faecher implicitly assigned to the given Abschluss.
*
* @param string $abschluss_id The id of the Abschluss.
- * @return object Collection of Faecher assigned to the given Abschluss.
+ * @return static[] An array of Faecher assigned to the given Abschluss.
*/
public static function findByAbschluss($abschluss_id)
{
- return parent::getEnrichedByQuery('
- SELECT mf.*
- FROM fach mf
- LEFT JOIN mvv_stgteil USING (fach_id)
- LEFT JOIN mvv_stg_stgteil USING (stgteil_id)
- LEFT JOIN mvv_studiengang ms USING (studiengang_id)
- WHERE ms.abschluss_id = ?
- ORDER BY name',
- [$abschluss_id]
+ return self::findBySQL(
+ 'JOIN `mvv_stgteil` USING (`fach_id`)
+ JOIN `mvv_stg_stgteil` USING (`stgteil_id`)
+ JOIN `mvv_studiengang` USING (`studiengang_id`)
+ WHERE `mvv_studiengang`.`abschluss_id` = ?
+ GROUP BY `fach`.`fach_id`
+ ORDER BY `name`',
+ [
+ $abschluss_id
+ ]
);
}
/**
- * Retrieves all Faecher the giveb Fachbereich is assigned to. If the 2nd
+ * Retrieves all Faecher the given Fachbereich is assigned to. If the 2nd
* parameter is true, only Faecher assigned to Studiengangteile will be
* returned.
*
* @param string $abschluss_id The id of the Abschluss.
- * @return object Collection of Faecher assigned to the given Abschluss.
+ * @return static[] Collection of Faecher assigned to the given Abschluss.
*/
public static function findByFachbereich($fachbereich_id, $has_stgteile = false)
{
$has_stgteile_sql = $has_stgteile
- ? 'INNER JOIN mvv_stgteil USING (fach_id) '
+ ? 'INNER JOIN `mvv_stgteil` USING (`fach_id`) '
: '';
+ return self::findBySQL(
+ $has_stgteile_sql .
+ 'LEFT JOIN `mvv_fach_inst` USING(`fach_id`)
+ WHERE `mvv_fach_inst`.`institut_id` = ?
+ ORDER BY `name`',
+ [
+ $fachbereich_id
+ ]
+ );
+ /*
return parent::getEnrichedByQuery('
SELECT mf.*
FROM fach mf
@@ -278,6 +293,7 @@ class Fach extends ModuleManagementModelTreeItem implements PrivacyObject
ORDER BY name',
[$fachbereich_id]
);
+ */
}
/**
@@ -485,7 +501,7 @@ class Fach extends ModuleManagementModelTreeItem implements PrivacyObject
/**
- * Returns names ans ids of all Fachbereiche (institutes) with number of
+ * Returns names and ids of all Fachbereiche (institutes) with number of
* related Faecher. Sorted and filtered by optional parameters.
*
* @param string $sortby Column names to sort by.
@@ -493,7 +509,9 @@ class Fach extends ModuleManagementModelTreeItem implements PrivacyObject
* @param array $filter Array of filter parameters (name of column as key,
* see ModulManagementModel::getFilterSql()).
* @return array Associative array of Fachbereiche (id as key).
+ * REMOVED
*/
+ /*
public static function getAllFachbereiche($sortby = 'name', $order = 'ASC',
$filter = null)
{
@@ -516,6 +534,7 @@ class Fach extends ModuleManagementModelTreeItem implements PrivacyObject
}
return $fachbereiche;
}
+ */
/**
* Returns an array with all faecher which are used by given Fachbereich
@@ -553,7 +572,7 @@ class Fach extends ModuleManagementModelTreeItem implements PrivacyObject
}
/**
- * Assignes fachbereiche to this fach.
+ * Assigns fachbereiche to this fach.
* Returns true only if all given fachbereich ids are valid.
*
* @param string[]|object[] Array of $fachbereich_ids or
diff --git a/lib/models/Fachbereich.php b/lib/models/Fachbereich.php
index 1a8fe0a..e9d64a5 100644
--- a/lib/models/Fachbereich.php
+++ b/lib/models/Fachbereich.php
@@ -39,6 +39,13 @@ class Fachbereich extends ModuleManagementModelTreeItem
{
$config['db_table'] = 'Institute';
+ $config['has_and_belongs_to_many']['faecher'] = [
+ 'class_name' => Fach::class,
+ 'thru_table' => 'mvv_fach_inst',
+ 'thru_key' => 'institut_id',
+ 'thru_assoc_key' => 'fach_id'
+ ];
+
$config['additional_fields']['count_objects']['get'] =
function($fb) { return $fb->count_objects; };
$config['additional_fields']['count_module']['get'] =
@@ -69,7 +76,7 @@ class Fachbereich extends ModuleManagementModelTreeItem
/**
* Retrieves all Fachbereiche which are implicitly related to the given
* modules. The relation is done through the hole MVV structure. If an
- * object has a status field, the status has to be public. Otherwise the
+ * object has a status field, the status has to be public. Otherwise, the
* related Fachbereich will not be retrieved.
*
* @param array $module_ids An array of module ids.
@@ -215,7 +222,7 @@ class Fachbereich extends ModuleManagementModelTreeItem
];
$replacements = [
$this->name,
- static::findCached($this->fakultaets_id)->getShortName()
+ static::findCached($this->fakultaets_id)->name
];
return self::formatDisplayName($template, $placeholders, $replacements);
}
@@ -282,7 +289,9 @@ class Fachbereich extends ModuleManagementModelTreeItem
* the display name.
*
* @return string The (short) name of the faculty.
+ * REMOVED
*/
+ /*
public function getShortName()
{
// Gießen
@@ -290,5 +299,6 @@ class Fachbereich extends ModuleManagementModelTreeItem
return $this->getDisplayName();
}
+ */
}