diff --git a/db/migrations/5.4.6.1_restore_studip_object_id.php b/db/migrations/5.4.6.1_restore_studip_object_id.php new file mode 100644 index 0000000000000000000000000000000000000000..b79b93344c5b45aeb322102234b60591764a3fbd --- /dev/null +++ b/db/migrations/5.4.6.1_restore_studip_object_id.php @@ -0,0 +1,26 @@ +<? + +final class RestoreStudipObjectId extends Migration +{ + + public function description() + { + return 'Restores the studip_object_id column for sem_tree'; + } + + protected function up() + { + // Add database column for sem_tree institute assignments. + DBManager::get()->exec("ALTER TABLE `sem_tree` ADD + `studip_object_id` CHAR(32) CHARACTER SET latin1 COLLATE latin1_bin NULL DEFAULT NULL AFTER `name`"); + // Add index for studip_object_id. + DBManager::get()->exec("ALTER TABLE `sem_tree` ADD INDEX `studip_object_id` (`studip_object_id`)"); + } + + protected function down() + { + // Remove institute assignments for sem_tree entries. + DBManager::get()->exec("ALTER TABLE `sem_tree` DROP `studip_object_id`"); + } + +} diff --git a/lib/classes/StudipSemTree.class.php b/lib/classes/StudipSemTree.class.php index 203bec15e389324bb18aa56919bfe993af2cf654..70743ade9a7395a5d0205b7d3e782d643124b703 100644 --- a/lib/classes/StudipSemTree.class.php +++ b/lib/classes/StudipSemTree.class.php @@ -76,12 +76,8 @@ class StudipSemTree extends TreeAbstract $db = $this->view->get_query("view:SEM_TREE_GET_DATA_NO_ENTRIES"); while ($db->next_record()){ - $this->tree_data[$db->f("sem_tree_id")] = ['type' => $db->f('type'), "info" => $db->f("info"),"studip_object_id" => $db->f("studip_object_id"), "entries" => 0]; - if ($db->f("studip_object_id")){ - $name = $db->f("studip_object_name"); - } else { - $name = $db->f("name"); - } + $this->tree_data[$db->f("sem_tree_id")] = ['type' => $db->f('type'), "info" => $db->f("info"), "entries" => 0]; + $name = $db->f("name"); $this->storeItem($db->f("sem_tree_id"), $db->f("parent_id"), $name, $db->f("priority")); } } @@ -205,10 +201,8 @@ class StudipSemTree extends TreeAbstract if ($item_id == "root") return "root"; $ret_id = $item_id; - while (!$this->tree_data[$ret_id]['studip_object_id']){ + while ($ret_id != "root"){ $ret_id = $this->tree_data[$ret_id]['parent_id']; - if ($ret_id == "root") - break; } return $ret_id; } diff --git a/lib/dbviews/sem_tree.view.php b/lib/dbviews/sem_tree.view.php index f82767dd1ebec9f264280409f2d0ffece0dbf941..008ee933b0ca00f03b166c56fd80c12d056e2ab4 100644 --- a/lib/dbviews/sem_tree.view.php +++ b/lib/dbviews/sem_tree.view.php @@ -36,8 +36,8 @@ $_views['sem_number_sql'] = "INTERVAL(start_time," . join(",",$sem_start_times) $_views['sem_number_end_sql'] = "IF(duration_time=-1,-1,INTERVAL(start_time+duration_time," . join(",",$sem_start_times) ."))"; $_views["SEM_TREE_GET_DATA_NO_ENTRIES"] = ["pk"=>"sem_tree_id","temp_table_type"=>"HEAP", - "query"=>"SELECT a.*, c.Name AS studip_object_name - FROM sem_tree a LEFT JOIN Institute c ON (a.studip_object_id = c.Institut_id) + "query"=>"SELECT a.* + FROM sem_tree a ORDER BY priority"]; $_views["SEM_TREE_GET_ENTRIES"] = ["pk"=>"sem_tree_id","temp_table_type"=>"HEAP", "query" => "SELECT st.sem_tree_id, count(b.Seminar_id) AS entries