aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMoritz Strohm <strohm@data-quest.de>2024-09-03 12:55:41 +0000
committerMoritz Strohm <strohm@data-quest.de>2024-09-03 12:55:41 +0000
commitc5fd2ec69e7f181497a0bf4a3d03e3df465cae9a (patch)
tree69e62ace8f9be01ce301d09d87a7cb7018f2ced7
parente8f8537e827df2c263dc51591f167223eb9be9f9 (diff)
TIC 4390, closes #4390
Closes #4390 Merge request studip/studip!3210
-rw-r--r--RELEASE-NOTES.md2
-rw-r--r--lib/classes/DbSnapshot.php370
-rw-r--r--lib/classes/DbView.php378
-rw-r--r--lib/classes/JsonApi/Routes/Courses/CoursesIndex.php4
-rw-r--r--lib/classes/StudipSemSearchHelper.php204
-rw-r--r--lib/classes/searchtypes/SeminarSearch.php3
-rw-r--r--lib/dbviews/range_tree.view.php88
-rw-r--r--lib/dbviews/sem_tree.view.php109
-rw-r--r--tests/unit/lib/classes/MarkupClassTest.php3
9 files changed, 77 insertions, 1084 deletions
diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md
index 6491ae1..9acc8e7 100644
--- a/RELEASE-NOTES.md
+++ b/RELEASE-NOTES.md
@@ -64,6 +64,8 @@
- Anstelle von `CalendarView` sollte `\Studip\Fullcalendar` verwendet werden.
- Das Datenbankschema des Stundenplans wurde geändert. ([Issue #4421](https://gitlab.studip.de/studip/studip/-/issues/4421))
- Die Evaluationen wurden ausgebaut. Stattdessen sollte man nun die neuen Fragebögen verwenden ([Issue #3787]https://gitlab.studip.de/studip/studip/-/issues/3787)
+- Die Klassen `DbView`, `DbSnapshot` und die zugehörigen Dateien in `lib/dbviews` wurden ausgebaut. ([Issue #4390](https://gitlab.studip.de/studip/studip/-/issues/4390))
+ - Als Ersatz dienen Datenbankabfragen mittels der `DBManager`-Klasse oder mittels `SimpleORMap`-Modellen.
## Security related issues
diff --git a/lib/classes/DbSnapshot.php b/lib/classes/DbSnapshot.php
deleted file mode 100644
index 33ea660..0000000
--- a/lib/classes/DbSnapshot.php
+++ /dev/null
@@ -1,370 +0,0 @@
-<?php
-# Lifter002: TODO
-# Lifter007: TODO
-# Lifter003: TODO
-# Lifter010: TODO
-// +---------------------------------------------------------------------------+
-// This file is part of Stud.IP
-// DbSnapshot.php
-// Class to provide snapshots of mysql result sets
-// Uses PHPLib DB Abstraction
-// Copyright (c) 2002 André Noack <andre.noack@gmx.net>
-// +---------------------------------------------------------------------------+
-// This program is free software; you can redistribute it and/or
-// modify it under the terms of the GNU General Public License
-// as published by the Free Software Foundation; either version 2
-// of the License, or any later version.
-// +---------------------------------------------------------------------------+
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-// +---------------------------------------------------------------------------+
-
-
-/**
- * Class to provide snapshots of mysql result sets
- *
- * Uses DB abstraction layer of PHPLib
- *
- * @access public
- * @author André Noack <andre.noack@gmx.net>
- * @package DBTools
- **/
-class DbSnapshot
-{
-
- /**
- * the used db abstraction class
- *
- *
- * @access private
- * @var string $DbClass
- */
- var $DbClass = "DB_Sql";
- /**
- * the used db result set
- *
- *
- * @access private
- * @var object DB_Sql $dbResult
- */
- var $dbResult = null;
- /**
- * array to store the result set
- *
- *
- * @access private
- * @var array $result
- */
- var $result = [];
- /**
- * array to store metadata oh the result set
- *
- *
- * @access private
- * @var array $metaData
- */
- var $metaData = [];
- /**
- * the number of fields in the result set
- *
- *
- * @access public
- * @var integer $numFields
- */
- var $numFields = 0;
- /**
- * the number of rows in the result set
- *
- *
- * @access public
- * @var integer $numRows
- */
- var $numRows = 0;
- /**
- * the internal row pointer
- *
- *
- * @access private
- * @var mixed $pos
- */
- var $pos = false;
- /**
- * turn on/off debugging
- *
- *
- * @access public
- * @var boolean $debug
- */
- var $debug = false;
-
- /**
- * Constructor
- *
- * Pass instance of DbClass or nothing to specify result set later
- *
- * @access public
- *
- * @param object DB_Sql $dbresult
- */
- public function __construct($dbresult = null)
- {
- if (is_object($dbresult)) {
- $this->dbResult = $dbresult;
- $this->getSnapshot();
- }
-
- }
-
- function isDbResult()
- {
- if (!is_subclass_of($this->dbResult, $this->DbClass))
- $this->halt("Result set has wrong type!");
- if (!$this->dbResult->query_id())
- $this->halt("No result set (missing query?)");
-
- return true;
- }
-
- public function getSnapshot()
- {
- if ($this->isDbResult()) {
- $this->numFields = $this->dbResult->num_fields();
- $this->numRows = $this->dbResult->num_rows();
- $this->metaData = $this->dbResult->metadata();
- $this->result = [];
- while ($this->dbResult->next_record()) {
- $this->result[] = $this->dbResult->Record;
- }
- unset($this->dbResult);
- $this->pos = false;
-
- return true;
- }
-
- return false;
- }
-
- public function nextRow()
- {
- if (!$this->numRows)
- $this->halt("No snapshot available or empty result!");
- if ($this->pos === false) {
- $this->pos = 0;
-
- return true;
- }
- if (++$this->pos < $this->numRows)
- return true;
- else
- return false;
- }
-
- public function resetPos()
- {
- $this->pos = false;
- }
-
- public function isField($name)
- {
- for ($i = 0; $i < $this->numFields; ++$i) {
- if ($name == $this->metaData[$i]['name']) {
- return true;
- }
- }
-
- return false;
- }
-
- public function getRow($row = false)
- {
- if (!$row === false AND !$this->result[$row])
- $this->halt("Snapshot has only " . ($this->numRows - 1) . " rows!");
-
- return ($row === false) ? $this->result[$this->pos] : $this->result[$row];
- }
-
- public function getFieldList()
- {
- if (!$this->numRows)
- $this->halt("No snapshot available or empty result!");
- $ret = [];
- for ($i = 0; $i < $this->numFields; ++$i) {
- $ret[] = $this->metaData[$i]['name'];
- }
-
- return $ret;
- }
-
- public function getField($field = 0)
- {
- if (!$this->numRows)
- $this->halt("No snapshot available or empty result!");
-
- return ($this->pos === false) ? false : $this->result[$this->pos][$field];
- }
-
- public function getRows($fieldname = 0)
- {
- if (!$this->numRows)
- $this->halt("No snapshot available or empty result!");
- $ret = [];
- for ($i = 0; $i < $this->numRows; ++$i) {
- $ret[] = $this->result[$i][$fieldname];
- }
-
- return $ret;
- }
-
- public function getDistinctRows($fieldname)
- {
- if (!$this->isField($fieldname))
- $this->halt("Field: $fieldname not found in result set!");
- $ret = [];
- for ($i = 0; $i < $this->numRows; ++$i) {
- $ret[$this->result[$i][$fieldname]] = $this->result[$i];
- $ret[$this->result[$i][$fieldname]]['row'] = $i;
- }
-
- return $ret;
- }
-
- public function sortRows($fieldname = 0, $order = "ASC", $stype = false)
- {
- if (!$this->numRows)
- $this->halt("No snapshot available or empty result!");
- $sortfields = $this->getRows($fieldname);
- if ($stype !== false) {
- $sortfunc = ($order == "ASC") ? "asort" : "arsort";
- $sortfunc($sortfields, $stype);
- } else {
- uasort($sortfields, function ($a,$b) {
- $a = mb_strtolower($a);
- $a = str_replace('ä', 'ae', $a);
- $a = str_replace('ö', 'oe', $a);
- $a = str_replace('ü', 'ue', $a);
-
- $b = mb_strtolower($b);
- $b = str_replace('ä', 'ae', $b);
- $b = str_replace('ö', 'oe', $b);
- $b = str_replace('ü', 'ue', $b);
-
- return strnatcasecmp($a, $b);
- });
- if ($order == "DESC") {
- $sortfields = array_reverse($sortfields, true);
- }
- }
- $sortresult = [];
- foreach ($sortfields as $key => $value) {
- $sortresult[] = $this->result[$key];
- }
- $this->result = $sortresult;
- $this->resetPos();
-
- return true;
- }
-
- public function searchFields($fieldname, $searchstr)
- {
- if (!$this->numRows)
- $this->halt("No snapshot available or empty result!");
- $ret = false;
- $sortfields = $this->getRows($fieldname);
- foreach ($sortfields as $key => $value) {
- if (preg_match($searchstr, $value)) {
- $ret = true;
- $this->pos = $key;
- break;
- }
- }
-
- return $ret;
- }
-
- public function getGroupedResult($group_by_field, $fields_to_group = null)
- {
- if (!$this->numRows)
- $this->halt("No snapshot available or empty result!");
- $fieldlist = $this->getFieldList();
- if (!in_array($group_by_field, $fieldlist))
- $this->halt("group_by_field not found in result set!");
- if (is_array($fields_to_group))
- $fieldlist = $fields_to_group;
- $num_fields = count($fieldlist);
- $ret = [];
- for ($i = 0; $i < $this->numRows; ++$i) {
- for ($j = 0; $j < $num_fields; ++$j) {
- if ($fieldlist[$j] != $group_by_field) {
- if (empty($ret[$this->result[$i][$group_by_field]][$fieldlist[$j]][$this->result[$i][$fieldlist[$j]]])) {
- $ret[$this->result[$i][$group_by_field]][$fieldlist[$j]][$this->result[$i][$fieldlist[$j]]] = 0;
- }
- ++$ret[$this->result[$i][$group_by_field]][$fieldlist[$j]][$this->result[$i][$fieldlist[$j]]];
- }
- }
- }
-
- return $ret;
- }
-
- public function mergeSnapshot($m_snap, $key_field = false, $mode = "ADD")
- {
- if ($mode == "ADD") {
- for ($i = 0; $i < $m_snap->numRows; ++$i) {
- $this->result[] = $m_snap->result[$i];
- }
- } elseif ($mode == "AND") {
- if (!$this->numRows || !$m_snap->numRows) {
- $this->result = [];
- } elseif ($m_snap->numRows) {
- $m_result = $m_snap->getDistinctRows($key_field);
- for ($i = 0; $i < $this->numRows; ++$i) {
- if (!($m_result[$this->result[$i][$key_field]] && $this->result[$i][$key_field])) {
- unset($this->result[$i]);
- }
- }
- }
- } elseif ($mode == "OR") {
- if (!$this->numRows) {
- $this->result = $m_snap->result;
- } elseif ($m_snap->numRows) {
- $result = $this->getDistinctRows($key_field);
- for ($i = 0; $i < $m_snap->numRows; ++$i) {
- if (empty($result[$m_snap->result[$i][$key_field]])) {
- $this->result[] = $m_snap->result[$i];
- }
- }
- }
- }
- $this->result = array_merge([], (array)$this->result);
- $this->numRows = count($this->result);
- $this->resetPos();
-
- return $this->numRows;
- }
-
- /**
- * print error message and exit script
- *
- * @access private
- *
- * @param string $msg the message to print
- */
- public function halt($msg)
- {
- echo "<hr>$msg<hr>";
- if ($this->debug) {
- echo "<pre>";
- print_r($this);
- echo "</pre>";
- die;
- }
-
- }
-}
-
-?>
diff --git a/lib/classes/DbView.php b/lib/classes/DbView.php
deleted file mode 100644
index 0215f8e..0000000
--- a/lib/classes/DbView.php
+++ /dev/null
@@ -1,378 +0,0 @@
-<?php
-# Lifter002: TODO
-# Lifter007: TODO
-# Lifter003: TODO
-# Lifter010: TODO
-// +---------------------------------------------------------------------------+
-// This file is part of Stud.IP
-// DbView.php
-// Class to provide simple Views and Prepared Statements
-// Mainly for MySql, may work with other DBs (not tested)
-// Copyright (c) 2002 André Noack <andre.noack@gmx.net>
-// +---------------------------------------------------------------------------+
-// This program is free software; you can redistribute it and/or
-// modify it under the terms of the GNU General Public License
-// as published by the Free Software Foundation; either version 2
-// of the License, or any later version.
-// +---------------------------------------------------------------------------+
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-// +---------------------------------------------------------------------------+
-
-
-/**
- * Class to provide simple Views and Prepared Statements
- *
- * Only tested with MySql, needs MySql >= 3.23
- * Uses DB abstraction layer of PHPLib
- *
- * @access public
- * @author André Noack <andre.noack@gmx.net>
- * @package DBTools
- */
-class DbView
-{
- /**
- * the processed list of queries
- *
- *
- * @access private
- * @var array $query_list
- */
- private $query_list = [];
- /**
- * list of parameters
- *
- *
- * @access public
- * @var array $params
- */
- public $params = [];
-
- /**
- * Database Object
- *
- *
- * @access private
- * @var object $db
- */
- private $db;
- /**
- * Database Object Type
- *
- * Use your subclass of db_mysql here, or pass existing object to constuctor
- *
- * @access private
- * @var string $db_class_name
- * @see DbView()
- */
- private $db_class_name = "DB_Seminar";
- /**
- * Temp Table Type
- *
- * MyISAM is always safe, HEAP may provide better performance
- *
- * @access private
- * @var string $temp_table_type
- */
- private $temp_table_type = "MyISAM";
- /**
- * Primary Key used in Temp Table
- *
- * If none is set in your view, an auto_increment row is used
- *
- * @access private
- * @var string $pk
- * @see get_temp_table()
- */
- private $pk = "";
- /**
- * delete the params array after each query execution
- *
- *
- * @access public
- * @var boolean $auto_free_params
- */
- public $auto_free_params = true;
- /**
- * turn on/off debugging
- *
- *
- * @access public
- * @var boolean $debug
- */
- public $debug = false;
-
- static protected $dbviewfiles = [];
-
- static protected $dbviews = [];
-
- public static function addView($view)
- {
- $view = mb_strtolower($view);
- if (!isset(self::$dbviewfiles[$view])) {
- self::$dbviewfiles[$view] = 0;
- }
- }
-
- /**
- * Convenience method that combines addView() and returns an instance.
- *
- * @param String $view Required view (at least this will be present in the
- * returned instance)
- * @param mixed $db classname of db abstraction or existing db object
- *
- * @return DbView Instance of self with at least the required view loaded
- */
- public static function getView($view, $db = '')
- {
- self::addView($view);
-
- return new self($db);
- }
-
- /**
- * Constructor
- *
- * Pass nothing to use a new instance of db_class_name, the classname for a new instance, or existing instance
- *
- * @access public
- *
- * @param mixed $db classname of used db abstraction or existing db object
- */
- public function __construct($db = "")
- {
- if (is_object($db)) {
- $this->db = $db;
- } else if ($db != "") {
- $this->db = new $db;
- $this->db_class_name = $db;
- } else {
- $this->db = new $this->db_class_name;
- }
- $this->init_views();
- }
-
- public function init_views()
- {
- foreach (self::$dbviewfiles as $view => $status) {
- if ($status === 0) {
- $views = include 'lib/dbviews/' . $view . '.view.php';
- self::$dbviews += $views;
-
- self::$dbviewfiles[$view] = 1;
- }
- }
- }
-
- public function __get($view)
- {
- if (isset(self::$dbviews[$view])) {
- return self::$dbviews[$view];
- } else {
- return null;
- }
- }
-
- /**
- * print error message and exit script
- *
- * @access private
- *
- * @param string $msg the message to print
- */
- public function halt($msg)
- {
- echo "<hr>$msg<hr>";
- if ($this->debug) {
- echo "<pre>";
- print_r($this);
- echo "</pre>";
- }
- die;
- }
-
- public function get_query()
- {
- $parsed_query = $this->get_parsed_query(func_get_args());
- $this->db->query($parsed_query);
- return $this->db;
- }
-
- public function get_parsed_query($query_list)
- {
- $parsed_query = "";
- $this->query_list = [];
- (is_array($query_list)) ? $this->query_list = $query_list : $this->query_list[] = $query_list;
- if (count($this->query_list) == 1) {
- $spl = explode(":", $this->query_list[0]);
- if ($spl[0] == "view") {
- $this->query_list = $this->get_view(trim($spl[1]));
- }
- }
- $this->parse_query($this->query_list);
- if (is_array($this->query_list)) {
- $parsed_query = $this->query_list[0];
- } else {
- $parsed_query = $this->query_list;
- }
-
- return $parsed_query;
- }
-
-
- public function parse_query(&$query)
- {
- if (is_array($query)) {
- for ($i = (count($query) - 1); $i > 0; --$i) {
- $spl = explode(":", $query[$i]);
- if ($spl[0] == "view") {
- $query[$i] = $this->get_view(trim($spl[1]), $spl[2]);
- }
- $query[$i] = $this->parse_query($query[$i]);
- $repl_query = (is_array($query[$i])) ? $query[$i][0] : $query[$i];
- for ($j = 0; $j < $i; ++$j) {
- $spl = mb_stristr($query[$j], "where");
- if (!$spl)
- $spl = mb_stristr($query[$j], "having");
- if ($spl) {
- $pos = mb_strpos($spl, "{" . $i . "}");
- if (!$pos === false)
- $repl_query = $this->get_temp_values($repl_query);
- }
- if (!$spl OR $pos === false) {
- $pos = mb_strpos($query[$j], "{" . $i . "}");
- if (!$pos === false)
- $repl_query = $this->get_temp_table($repl_query);
- }
- $query[$j] = str_replace("{" . $i . "}", $repl_query, $query[$j]);
- }
- }
- }
-
- return $query;
- }
-
-
- public function get_temp_table($sub_query)
- {
- $id = self::get_uniqid();
- $pk = $this->pk ? "PRIMARY KEY($this->pk)" : "auto_" . $id . " INT NOT NULL AUTO_INCREMENT PRIMARY KEY";
- $query = "CREATE TEMPORARY TABLE temp_$id ($pk) ENGINE=$this->temp_table_type $sub_query";
- $this->db->query($query);
-
- return " temp_" . $id . " ";
- }
-
-
- public function get_temp_values($sub_query)
- {
- $this->db->query($sub_query);
- if (!$this->db->num_rows())
- $this->halt("Sub Query: <b>$sub_query</b> returns nothing!");
- else {
- while ($this->db->next_record()) {
- $result[] = $this->db->Record[0];
- }
- $value_list = $this->get_value_list($result);
- }
-
- return $value_list;
- }
-
- public static function get_uniqid()
- {
- mt_srand((double)microtime() * 1000000);
-
- return md5(uniqid(mt_rand(), 1));
- }
-
- public function get_value_list($list)
- {
- $value_list = false;
- if (count($list) == 1)
- $value_list = "'$list[0]'";
- else
- $value_list = "'" . join("','", $list) . "'";
-
- return $value_list;
- }
-
- public function get_view($name)
- {
- if (!empty(self::$dbviews[$name]["pk"])) {
- $this->pk = self::$dbviews[$name]["pk"];
- }
- if (!empty(self::$dbviews[$name]["temp_table_type"])) {
- $this->temp_table_type = self::$dbviews[$name]["temp_table_type"];
- }
- if (!$query_list = self::$dbviews[$name]["query"])
- $this->halt("View not found: $name");
- (is_array($query_list)) ? $query = $query_list[0] : $query = $query_list;
- $tokens = preg_split("/[\?§\&]/u", $query);
- if (count($tokens) > 1) {
- $types = [];
- $token = 0;
- foreach (preg_split('//u', $query, null, PREG_SPLIT_NO_EMPTY) as $i => $c) {
- switch ($c) {
- case '?':
- $types[$token++] = 1;
- break;
- case '§':
- $types[$token++] = 2;
- break;
- case '&':
- $types[$token++] = 3;
- break;
- }
- }
- if (count($this->params) != count($types))
- $this->halt("Wrong parameter count in view: $name");
- $query = "";
- for ($i = 0; $i < count($this->params); ++$i) {
- $query .= $tokens[$i];
- if (is_null($this->params[$i])) {
- $query .= 'NULL';
- } else {
- switch ($types[$i]) {
- case 1:
- $query .= "'" . $this->params[$i] . "'";
- break;
- case 2:
- $query .= $this->params[$i];
- break;
- case 3:
- $query .= (is_array($this->params[$i])) ? "'" . join("','", $this->params[$i]) . "'" : "'" . $this->params[$i] . "'";
- break;
- }
- }
- }
- $query .= $tokens[$i];
- if ($this->auto_free_params)
- $this->params = [];
- }
- (is_array($query_list)) ? $query_list[0] = $query : $query_list = $query;
- return $query_list;
- }
-
- public function Get_union()
- {
- $queries = func_get_args();
- $view = new DbView();
- $union_table = $view->get_temp_table($view->get_parsed_query($queries[0]));
- if ($queries[1]) {
- for ($i = 1; $i < count($queries); ++$i) {
- $view->db->query("REPLACE INTO $union_table " . $view->get_parsed_query($queries[$i]));
- }
- }
-
- return $union_table;
- }
-}
-
-?>
diff --git a/lib/classes/JsonApi/Routes/Courses/CoursesIndex.php b/lib/classes/JsonApi/Routes/Courses/CoursesIndex.php
index fcbad91..77870f9 100644
--- a/lib/classes/JsonApi/Routes/Courses/CoursesIndex.php
+++ b/lib/classes/JsonApi/Routes/Courses/CoursesIndex.php
@@ -127,8 +127,6 @@ class CoursesIndex extends JsonApiController
],
$visibleOnly
);
- $searchHelper->doSearch();
-
- return $searchHelper->getSearchResultAsArray();
+ return $searchHelper->doSearch();
}
}
diff --git a/lib/classes/StudipSemSearchHelper.php b/lib/classes/StudipSemSearchHelper.php
index 821a039..57b699b 100644
--- a/lib/classes/StudipSemSearchHelper.php
+++ b/lib/classes/StudipSemSearchHelper.php
@@ -37,7 +37,6 @@ class StudipSemSearchHelper {
'scope' => _("Bereich")];
}
- private $search_result;
private $found_rows = false;
private $params = [];
private $visible_only;
@@ -80,16 +79,24 @@ class StudipSemSearchHelper {
return false;
}
$this->params = array_map('addslashes', $this->params);
- $clause = "";
- $and_clause = "";
- $this->search_result = new DbSnapshot();
- $combination = $this->params['combination'];
- $view = DbView::getView('sem_tree');
-
- if (isset($this->params['sem']) && $this->params['sem'] !== 'all'){
- $sem_number = (int)$this->params['sem'];
- $clause = " HAVING (sem_number <= $sem_number AND (sem_number_end >= $sem_number OR sem_number_end = -1)) ";
+ $db = DBManager::get();
+ $join_sql = [];
+ $where_sql = [];
+ $sql_params = [];
+
+ if (isset($this->params['sem']) && $this->params['sem'] !== 'all') {
+ $all_semesters = Semester::getAll();
+ if (array_key_exists($this->params['sem'], $all_semesters)) {
+ $semester = $all_semesters[$this->params['sem']];
+ //Use that semester for filtering courses:
+ $join_sql[] = "LEFT JOIN `semester_courses` ON `seminare`.`seminar_id` = `semester_courses`.`course_id`";
+ $where_sql[] = "(`semester_courses`.`semester_id` IS NULL OR `semester_courses`.`semester_id` = :semester_id)";
+ $sql_params['semester_id'] = $semester->id;
+ } else {
+ //Nothing can be found when the semester is unknown:
+ return [];
+ }
}
$sem_types = [];
@@ -101,149 +108,84 @@ class StudipSemSearchHelper {
}
}
- if (isset($this->params['type']) && $this->params['type'] != 'all'){
+ if (isset($this->params['type']) && $this->params['type'] !== 'all') {
$sem_types = [$this->params['type']];
}
if ($sem_types) {
- $clause = " AND c.status IN('" . join("','",$sem_types) . "') " . $clause;
+ $where_sql[] = "`seminare`.`status` IN ( :course_types )";
+ $sql_params['course_types'] = $sem_types;
}
- $view->params = [];
-
- if ($this->params['scope_choose'] && $this->params['scope_choose'] != 'root'){
- $tree_node = StudipStudyArea::find($this->params['scope_choose']);
- $sem_tree_ids = [];
- if ($tree_node) {
- $all_children = $tree_node->getAllChildNodes();
- foreach ($all_children as $child) {
- $sem_tree_ids[] = $child->id;
- }
- $sem_tree_ids[] = $tree_node->id;
- }
-
- $all_sem_type_ids = [];
- foreach (SemType::getTypes() as $sem_type) {
- $all_sem_type_ids[] = $sem_type->id;
- }
- $view->params[0] = $sem_types ?: $all_sem_type_ids;
- $view->params[1] = $this->visible_only ? "c.visible=1" : "1";
- $view->params[2] = $sem_tree_ids;
- $view->params[3] = $clause;
- $snap = new DbSnapshot($view->get_query("view:SEM_TREE_GET_SEMIDS"));
- if ($snap->numRows){
- $clause = " AND c.seminar_id IN('" . join("','",$snap->getRows("seminar_id")) ."')" . $clause;
- } else {
- return 0;
- }
- unset($snap);
+ if ($this->visible_only) {
+ //Visible courses only:
+ $where_sql[] = "`seminare`.`visible` = 1";
}
- if ($this->params['range_choose'] && $this->params['range_choose'] != 'root'){
- $range_node = RangeTreeNode::find($this->params['range_choose']);
- $range_ids = [];
- if ($range_node) {
- $children = $range_node->getChildNodes();
+ if (!empty($this->params['scope_choose']) && $this->params['scope_choose'] !== 'root') {
+ //Filter by study areas:
+ $study_area_ids = [];
+ $study_area = StudipStudyArea::find($this->params['scope_choose']);
+ if ($study_area) {
+ $children = $study_area->getChildren();
foreach ($children as $child) {
- $range_ids[] = $child->studip_object_id;
+ $study_area_ids[] = $child->id;
+ $grand_children = $child->getChildren();
+ foreach ($grand_children as $grand_child) {
+ $study_area_ids[] = $grand_child->id;
+ }
}
- $range_ids[] = $range_node->studip_object_id;
}
- $view->params[0] = $range_ids;
- $view->params[1] = ($this->visible_only ? " AND c.visible=1 " : "");
- $view->params[2] = $clause;
- $snap = new DbSnapshot($view->get_query("view:SEM_INST_GET_SEM"));
- if ($snap->numRows){
- $clause = " AND c.seminar_id IN('" . join("','",$snap->getRows("Seminar_id")) ."')" . $clause;
- } else {
- return 0;
+ if (!empty($study_area_ids)) {
+ $join_sql[] = "JOIN `seminar_sem_tree` USING (`seminar_id`)";
+ $where_sql[] = "`seminar_sem_tree`.`sem_tree_id` IN ( :study_area_ids )";
+ $sql_params['study_area_ids'] = $study_area_ids;
}
- unset($snap);
}
-
- if (isset($this->params['lecturer']) && mb_strlen($this->params['lecturer']) > 2){
- $view->params[0] = "%" . $this->trim($this->params['lecturer']) . "%";
- $view->params[1] = "%" . $this->trim($this->params['lecturer']) . "%";
- $view->params[2] = "%" . $this->trim($this->params['lecturer']) . "%";
- $view->params[3] = "%" . $this->trim($this->params['lecturer']) . "%";
- $view->params[4] = "%" . $this->trim($this->params['lecturer']) . "%";
- $result = $view->get_query("view:SEM_SEARCH_LECTURER");
-
- $lecturers = [];
- while ($result->next_record()) {
- $lecturers[] = $result->f('user_id');
- }
-
- if (count($lecturers)) {
- $view->params[0] = $this->visible_only ? "c.visible=1" : "1";
- $view->params[1] = $lecturers;
- $view->params[2] = $clause;
- $snap = new DbSnapshot($view->get_query("view:SEM_SEARCH_LECTURER_ID"));
- $this->search_result = $snap;
- $this->found_rows = $this->search_result->numRows;
- }
- }
-
-
- if ($combination == "AND" && $this->search_result->numRows){
- $and_clause = " AND c.seminar_id IN('" . join("','",$this->search_result->getRows("seminar_id")) ."')";
- }
-
- if ((isset($this->params['title']) && mb_strlen($this->params['title']) > 2) ||
- (isset($this->params['sub_title']) && mb_strlen($this->params['sub_title']) > 2) ||
- (isset($this->params['number']) && mb_strlen($this->params['number']) > 2) ||
- (isset($this->params['comment']) && mb_strlen($this->params['comment']) > 2)){
-
- $toFilter = explode(" ", $this->params['title']);
- $search_for = "(Name LIKE '%" . implode("%' AND Name LIKE '%", $toFilter) . "%')";
- if (!array_key_exists(0, $view->params)) {
- $view->params[0] = '';
+ if (!empty($this->params['range_choose']) && $this->params['range_choose'] !== 'root') {
+ //Filter by institutes:
+ $institute = Institute::find($this->params['range_choose']);
+ $institute_ids = [];
+ if ($institute) {
+ $institute_ids[] = $institute->id;
+ if ($institute->isFaculty()) {
+ $institute_ids[] = array_merge(
+ $institute_ids,
+ $institute->sub_institutes->pluck('id')
+ );
+ }
}
- $view->params[0] .= ($this->params['title']) ? $search_for . " " : " ";
- $view->params[0] .= ($this->params['title'] && !empty($this->params['sub_title'])) ? $combination : " ";
- $view->params[0] .= (!empty($this->params['sub_title'])) ? " Untertitel LIKE '%" . $this->trim($this->params['sub_title']) . "%' " : " ";
- $view->params[0] .= (($this->params['title'] || !empty($this->params['sub_title'])) && !empty($this->params['comment'])) ? $combination : " ";
- $view->params[0] .= (!empty($this->params['comment'])) ? " Beschreibung LIKE '%" . $this->trim($this->params['comment']) . "%' " : " ";
- $view->params[0] .= (($this->params['title'] || !empty($this->params['sub_title']) || empty($this->params['comment'])) && $this->params['number']) ? $combination : " ";
- $view->params[0] .= ($this->params['number']) ? " VeranstaltungsNummer LIKE '%" . $this->trim($this->params['number']) . "%' " : " ";
- $view->params[0] = ($this->visible_only ? " c.visible=1 AND " : "") . "(" . $view->params[0] .")";
- $view->params[1] = $and_clause . $clause;
- $snap = new DbSnapshot($view->get_query("view:SEM_SEARCH_SEM"));
- if ($this->found_rows === false){
- $this->search_result = $snap;
- } else {
- $this->search_result->mergeSnapshot($snap,"seminar_id",$combination);
+ if (empty($institute_ids)) {
+ //We cannot search for courses if the institutes they shall belong to cannot be found:
+ return [];
}
- $this->found_rows = $this->search_result->numRows;
+ $where_sql[] = "(`seminare`.`Institut_id` IN (:institute_ids) OR `seminar_inst`.`institut_id` IN (:institute_ids))";
+ $sql_params['institute_ids'] = $institute_ids;
}
- if ($combination == "AND" && $this->search_result->numRows){
- $and_clause = " AND c.seminar_id IN('" . join("','",$this->search_result->getRows("seminar_id")) ."')";
+ if (isset($this->params['lecturer']) && mb_strlen($this->params['lecturer']) > 2) {
+ //Search for lecturers:
+ $join_sql[] = "JOIN `seminar_user` USING (`seminar_id`)";
+ $join_sql[] = "JOIN `auth_user_md5` USING (`user_id`)";
+ $where_sql[] = "(
+ CONCAT(`auth_user_md5`.`Nachname`, ', ', `auth_user_md5`.`Vorname`, ' ', `auth_user_md5`.`Nachname`) LIKE CONCAT('%', :lecturer_name, '%')
+ OR `auth_user_md5`.`username` LIKE CONCAT('%', :lecturer_name, '%')
+ )";
+ $sql_params['lecturer_name'] = $this->params['lecturer'];
}
- if (isset($this->params['scope']) && mb_strlen($this->params['scope']) > 2){
- $view->params[0] = $this->visible_only ? "c.visible=1" : "1";
- $view->params[1] = "%" . $this->trim($this->params['scope']) . "%";
- $view->params[2] = $and_clause . $clause;
- $snap = new DbSnapshot($view->get_query("view:SEM_TREE_SEARCH_SEM"));
- if ($this->found_rows === false){
- $this->search_result = $snap;
- } else {
- $this->search_result->mergeSnapshot($snap,"seminar_id",$combination);
- }
- $this->found_rows = $this->search_result->numRows;
- }
- return $this->found_rows;
+ $stmt = $db->prepare(
+ sprintf(
+ 'SELECT `seminar_id` FROM `seminare` %s WHERE %s',
+ implode(' ', $join_sql),
+ implode(' AND ', $where_sql)
+ )
+ );
+ $stmt->execute($sql_params);
+ return $stmt->fetchAll();
}
- public function getSearchResultAsArray(){
- if($this->search_result instanceof DBSnapshot && $this->search_result->numRows){
- return array_unique($this->search_result->getRows('seminar_id'));
- } else {
- return [];
- }
- }
private function trim($what)
{
diff --git a/lib/classes/searchtypes/SeminarSearch.php b/lib/classes/searchtypes/SeminarSearch.php
index fd7bf8a..0cefedf 100644
--- a/lib/classes/searchtypes/SeminarSearch.php
+++ b/lib/classes/searchtypes/SeminarSearch.php
@@ -57,8 +57,7 @@ class SeminarSearch extends SearchType
!(is_object($GLOBALS['perm'])
&& $GLOBALS['perm']->have_perm(
Config::Get()->SEM_VISIBILITY_PERM)));
- $search_helper->doSearch();
- $result = $search_helper->getSearchResultAsArray();
+ $result = $search_helper->doSearch();
if (empty($result)) {
return [];
diff --git a/lib/dbviews/range_tree.view.php b/lib/dbviews/range_tree.view.php
deleted file mode 100644
index 913330d..0000000
--- a/lib/dbviews/range_tree.view.php
+++ /dev/null
@@ -1,88 +0,0 @@
-<?
-# Lifter002: TODO
-# Lifter007: TODO
-# Lifter003: TODO
-# Lifter010: TODO
-// +---------------------------------------------------------------------------+
-// This file is part of Stud.IP
-// range_tree.view.php
-// Database views used with "range_tree"
-//
-// Copyright (c) 2002 André Noack <noack@data-quest.de>
-// Suchi & Berg GmbH <info@data-quest.de>
-// +---------------------------------------------------------------------------+
-// This program is free software; you can redistribute it and/or
-// modify it under the terms of the GNU General Public License
-// as published by the Free Software Foundation; either version 2
-// of the License, or any later version.
-// +---------------------------------------------------------------------------+
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-// +---------------------------------------------------------------------------+
-
-$sem_start_times = [];
-foreach (Semester::findAllVisible() as $key => $value){
- if (isset($value['beginn']) && $value['beginn'])
- $sem_start_times[] = $value['beginn'];
-}
-
-$_views = [];
-
-$_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["TREE_KIDS"] = ["pk"=>"item_id","temp_table_type"=>"HEAP",
- "query"=>"SELECT item_id FROM range_tree WHERE parent_id=? ORDER BY priority"];
-$_views["TREE_GET_DATA"] = ["pk"=>"item_id","temp_table_type"=>"HEAP",
- "query"=>"SELECT a.*, b.Name AS studip_object_name, b.fakultaets_id FROM range_tree a
- LEFT JOIN Institute b ON (a.studip_object_id = b.Institut_id) ORDER BY priority"];
-$_views["TREE_GET_SEM_ENTRIES"] = ["pk"=>"item_id","temp_table_type"=>"HEAP",
- "query"=>"SELECT item_id,count(d.Seminar_id) AS entries FROM range_tree a
- INNER JOIN seminar_inst c ON (a.studip_object_id = c.institut_id)
- INNER JOIN seminare d ON(c.seminar_id=d.Seminar_id §) § GROUP BY a.item_id"];
-
-$_views["TREE_OBJECT_NAME"] = ["pk"=>"","temp_table_type"=>"HEAP",
- "query"=>"SELECT Name FROM § WHERE § LIKE ? "];
-$_views["TREE_OBJECT_DETAIL"] = ["pk"=>"","temp_table_type"=>"HEAP",
- "query"=>"SELECT * FROM § WHERE § LIKE ? "];
-$_views["TREE_OBJECT_CAT"] = ["pk"=>"kategorie_id","temp_table_type"=>"MyISAM",
- "query"=>"SELECT * FROM kategorien WHERE range_id LIKE ? ORDER BY priority"];
-$_views["TREE_INST_STATUS"] = ["pk"=>"","temp_table_type"=>"HEAP",
- "query"=>"SELECT Institut_id FROM user_inst WHERE Institut_id IN(&) AND user_id=? AND inst_perms='admin'"];
-$_views["TREE_FAK_STATUS"] = ["pk"=>"","temp_table_type"=>"HEAP",
- "query"=>"SELECT b.fakultaets_id,a.Institut_id FROM user_inst a LEFT JOIN Institute b ON(a.Institut_id = b.Institut_id AND b.Institut_id=b.fakultaets_id) WHERE a.Institut_id IN(&) AND NOT ISNULL(b.Institut_id) AND user_id=? AND inst_perms='admin'"];
-$_views["TREE_ITEMS_OBJECT"] = ["pk"=>"item_id","temp_table_type"=>"HEAP",
- "query"=>"SELECT item_id FROM range_tree WHERE studip_object_id LIKE ?"];
-
-$_views["TREE_UPD_PRIO"] = ["query" => "UPDATE range_tree SET priority=§ WHERE item_id=?"];
-$_views["TREE_INS_ITEM"] = ["query" => "INSERT INTO range_tree (item_id,parent_id,name,priority,studip_object,studip_object_id) VALUES (?,?,?,§,?,?)"];
-$_views["TREE_UPD_ITEM"] = ["query" => "UPDATE range_tree SET name=?, studip_object=?, studip_object_id=? WHERE item_id=?"];
-$_views["TREE_MOVE_ITEM"] = ["query" => "UPDATE range_tree SET parent_id=?, priority=§ WHERE item_id=?"];
-$_views["TREE_DEL_ITEM"] = ["query" => "DELETE FROM range_tree WHERE item_id IN (&)"];
-
-$_views["TREE_SEARCH_INST"] = ["query" => "SELECT Name,Institut_id FROM Institute WHERE fakultaets_id!=Institut_id AND Name LIKE '%§%'"];
-$_views["TREE_SEARCH_FAK"] = ["query" => "SELECT Name,Institut_id AS Fakultaets_id FROM Institute WHERE fakultaets_id=Institut_id AND Name LIKE '%§%'"];
-$_views["TREE_SEARCH_ITEM"] = ["pk"=>"item_id","temp_table_type"=>"HEAP",
- "query"=>"SELECT a.item_id FROM range_tree a LEFT JOIN Institute b ON (a.studip_object_id = b.Institut_id) WHERE a.name LIKE ? OR b.Name LIKE ? "];
-$_views["TREE_SEARCH_USER"] = ["pk"=>"item_id","temp_table_type"=>"HEAP",
- "query"=>"SELECT rt.item_id FROM auth_user_md5 a LEFT JOIN user_inst b ON (a.user_id=b.user_id AND b.inst_perms!='user')
-LEFT JOIN range_tree rt ON (rt.studip_object_id=b.Institut_id ) WHERE NOT ISNULL(rt.item_id) AND (CONCAT(a.username,' ',a.Vorname,' ',a.Nachname) LIKE ? OR CONCAT(a.Nachname, ', ', a.Vorname) LIKE ?)"];
-$_views["TREE_SEARCH_SEM"] = ["pk"=>"item_id","temp_table_type"=>"HEAP",
- "query"=>"SELECT rt.item_id FROM seminare a LEFT JOIN seminar_inst b USING (Seminar_id)LEFT JOIN range_tree rt ON (rt.studip_object_id=b.institut_id)
- WHERE NOT ISNULL(rt.item_id) AND a.Name LIKE ?"];
-
-
-$_views["CAT_UPD_PRIO"] = ["query" => "UPDATE kategorien SET priority=§,chdate=UNIX_TIMESTAMP() WHERE kategorie_id=?"];
-$_views["CAT_UPD_CONTENT"] = ["query" => "UPDATE kategorien SET name=?, content=?, chdate=UNIX_TIMESTAMP() WHERE kategorie_id=?"];
-$_views["CAT_INS_ALL"] = ["query" => "INSERT INTO kategorien (kategorie_id,range_id,name,content,priority,mkdate,chdate)VALUES (?,?,?,?,§,UNIX_TIMESTAMP(),UNIX_TIMESTAMP())"];
-$_views["CAT_DEL"] = ["query" => "DELETE FROM kategorien WHERE kategorie_id IN (&)"];
-$_views["CAT_DEL_RANGE"] = ["query" => "DELETE FROM kategorien WHERE range_id IN (&)"];
-
-$_views["STATUS_COUNT"] = ["query"=>"SELECT count(DISTINCT user_id) AS anzahl FROM statusgruppen LEFT JOIN statusgruppe_user USING(statusgruppe_id) WHERE range_id=?"];
-
-return $_views;
diff --git a/lib/dbviews/sem_tree.view.php b/lib/dbviews/sem_tree.view.php
deleted file mode 100644
index 8980e71..0000000
--- a/lib/dbviews/sem_tree.view.php
+++ /dev/null
@@ -1,109 +0,0 @@
-<?
-# Lifter002: TODO
-# Lifter007: TODO
-# Lifter003: TODO
-# Lifter010: TODO
-// +---------------------------------------------------------------------------+
-// This file is part of Stud.IP
-// sem_tree.view.php
-// Database views used with "sem_tree"
-//
-// Copyright (c) 2003 André Noack <noack@data-quest.de>
-// Suchi & Berg GmbH <info@data-quest.de>
-// +---------------------------------------------------------------------------+
-// This program is free software; you can redistribute it and/or
-// modify it under the terms of the GNU General Public License
-// as published by the Free Software Foundation; either version 2
-// of the License, or any later version.
-// +---------------------------------------------------------------------------+
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-// +---------------------------------------------------------------------------+
-
-$sem_start_times = [];
-foreach (Semester::findAllVisible() as $key => $value){
- if (isset($value['beginn']) && $value['beginn'])
- $sem_start_times[] = $value['beginn'];
-}
-
-$_views = [];
-$_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.*
- 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
- FROM seminare b INNER JOIN seminar_sem_tree st ON(st.seminar_id = b.Seminar_id)
- WHERE b.status IN(&) AND §
- GROUP BY st.sem_tree_id ORDER BY NULL"];
-$_views["SEM_TREE_GET_SEMIDS"] = ["pk"=>"seminar_id","temp_table_type"=>"HEAP",
- "query" => "SELECT b.seminar_id, " . $_views['sem_number_sql'] . " AS sem_number, " . $_views['sem_number_end_sql'] . " AS sem_number_end FROM seminar_sem_tree b INNER JOIN seminare c ON(b.seminar_id=c.Seminar_id AND c.status IN(&) AND §) WHERE sem_tree_id IN(&) §"];
-$_views["SEM_TREE_GET_SEMIDS_ROOT"] = ["pk"=>"seminar_id","temp_table_type"=>"HEAP",
- "query" => "SELECT b.seminar_id, " . $_views['sem_number_sql'] . " AS sem_number, " . $_views['sem_number_end_sql'] . " AS sem_number_end FROM seminar_sem_tree b INNER JOIN seminare c ON(b.seminar_id=c.Seminar_id AND c.status IN(&) AND §) WHERE 1 §"];
-
-$_views["SEM_TREE_GET_SEMDATA"] = ["query" => "SELECT a.seminar_id,IF(b.visible=0,CONCAT(Name, ' "._("(versteckt)")."'), Name) AS Name,username AS doz_uname, Nachname AS doz_name, " . $_views['sem_number_sql'] . " AS sem_number , " . $_views['sem_number_end_sql'] . " AS sem_number_end
- FROM seminar_sem_tree a INNER JOIN seminare b ON(a.seminar_id=b.Seminar_id AND b.status IN(&) AND §) LEFT JOIN seminar_user c ON (b.seminar_id=c.seminar_id AND c.status='dozent' )
- LEFT JOIN auth_user_md5 USING(user_id) WHERE sem_tree_id IN(&) § ORDER BY sem_number DESC,Name ASC"];
-$_views["SEM_TREE_GET_SEMDATA_ROOT"] = ["query" => "SELECT a.seminar_id,IF(b.visible=0,CONCAT(Name, ' "._("(versteckt)")."'), Name) AS Name,username AS doz_uname, Nachname AS doz_name, " . $_views['sem_number_sql'] . " AS sem_number , " . $_views['sem_number_end_sql'] . " AS sem_number_end
- FROM seminar_sem_tree a INNER JOIN seminare b ON(a.seminar_id=b.Seminar_id AND b.status IN(&) AND §) LEFT JOIN seminar_user c ON (b.seminar_id=c.seminar_id AND c.status='dozent' )
- LEFT JOIN auth_user_md5 USING(user_id) WHERE 1 § ORDER BY sem_number DESC,Name ASC"];
-
-$_views["SEM_TREE_GET_NUM_SEM"] = ["query" => "SELECT count(DISTINCT(seminar_id)) , " . $_views['sem_number_sql'] . " AS sem_number, " . $_views['sem_number_end_sql'] . " AS sem_number_end FROM seminar_sem_tree
- LEFT JOIN seminare USING (seminar_id) WHERE sem_tree_id IN(&) §"];
-
-$_views["SEM_TREE_GET_LONELY_SEM_DATA"] = ["query" => "SELECT d.Seminar_id AS seminar_id,IF(d.visible=0,CONCAT(d.Name, ' "._("(versteckt)")."'), d.Name) AS Name, " . $_views['sem_number_sql'] . " AS sem_number, " . $_views['sem_number_end_sql'] . " AS sem_number_end ,username AS doz_uname, Nachname AS doz_name
- FROM Institute a LEFT JOIN seminar_inst b USING(Institut_id) INNER JOIN seminare d ON(b.seminar_id=d.Seminar_id AND d.status IN(&) AND §) LEFT JOIN seminar_user e ON (d.Seminar_id = e.seminar_id AND e.status='dozent')
- LEFT JOIN auth_user_md5 USING(user_id) LEFT JOIN seminar_sem_tree c ON (c.seminar_id=b.seminar_id)
- WHERE ISNULL(c.sem_tree_id)
- AND a.fakultaets_id LIKE ? AND NOT ISNULL(b.seminar_id) GROUP BY d.Seminar_id § ORDER BY sem_number DESC,d.Name ASC"];
-$_views["SEM_TREE_GET_NUM_LONELY_SEM"] = ["query" => "SELECT COUNT(DISTINCT(b.seminar_id)) AS num_sem , " . $_views['sem_number_sql'] . " AS sem_number , " . $_views['sem_number_end_sql'] . " AS sem_number_end FROM Institute a LEFT JOIN seminar_inst b USING(Institut_id)
- INNER JOIN seminare d ON(b.seminar_id=d.Seminar_id AND d.status IN(&) AND §) LEFT JOIN seminar_sem_tree c ON(c.seminar_id=d.Seminar_id)
- WHERE ISNULL(c.sem_tree_id)
- AND a.fakultaets_id LIKE ? AND NOT ISNULL(b.seminar_id) GROUP BY sem_number,sem_number_end § "];
-$_views["SEM_TREE_GET_LONELY_FAK"] = ["query" => "SELECT Institut_id,a.Name FROM Institute a LEFT JOIN sem_tree b ON(studip_object_id=Institut_id) WHERE Institut_id = fakultaets_id AND ISNULL(studip_object_id) ORDER BY a.Name"];
-$_views["SEM_TREE_UPD_PRIO"] = ["query" => "UPDATE sem_tree SET priority=§ WHERE sem_tree_id=?"];
-$_views["SEM_TREE_INS_ITEM"] = ["query" => "INSERT INTO sem_tree (sem_tree_id,parent_id,name,priority,info,studip_object_id,type) VALUES (?,?,?,?,?,?,?)"];
-$_views["SEM_TREE_UPD_ITEM"] = ["query" => "UPDATE sem_tree SET name=?, info=?, type=? WHERE sem_tree_id=?"];
-$_views["SEM_TREE_DEL_ITEM"] = ["query" => "DELETE FROM sem_tree WHERE sem_tree_id IN (&)"];
-$_views["SEM_TREE_MOVE_ITEM"] = ["query" => "UPDATE sem_tree SET parent_id=?, priority=§ WHERE sem_tree_id=?"];
-$_views["SEM_TREE_SEARCH_SEM"] = ["query" => "SELECT b.seminar_id, " . $_views['sem_number_sql'] . " AS sem_number, " . $_views['sem_number_end_sql'] . " AS sem_number_end FROM sem_tree a LEFT JOIN seminar_sem_tree b USING(sem_tree_id)
- LEFT JOIN seminare c USING(seminar_id)
- WHERE § AND NOT ISNULL(b.seminar_id) AND a.name LIKE ? §"];
-$_views["SEM_TREE_CHECK_PERM"] = ["query" => "SELECT inst_perms FROM user_inst WHERE inst_perms='admin' AND user_id=? AND Institut_id=?"];
-$_views["SEM_TREE_SEARCH_ITEM"] = ["query" => "SELECT a.sem_tree_id,a.parent_id FROM sem_tree a LEFT JOIN sem_tree b ON(a.sem_tree_id=b.parent_id) WHERE a.name LIKE ? AND ISNULL(b.sem_tree_id) AND a.sem_tree_id NOT IN(&)"];
-
-$_views["SEMINAR_SEM_TREE_DEL_RANGE"] = ["query" => "DELETE FROM seminar_sem_tree WHERE sem_tree_id IN (&)"];
-$_views["SEMINAR_SEM_TREE_DEL_SEM_RANGE"] = ["query" => "DELETE FROM seminar_sem_tree WHERE sem_tree_id IN (&) AND seminar_id IN (&)"];
-$_views["SEMINAR_SEM_TREE_DEL_SEMID_RANGE"] = ["query" => "DELETE FROM seminar_sem_tree WHERE seminar_id IN (&)"];
-$_views["SEMINAR_SEM_TREE_INS_ITEM"] = ["query" => "INSERT IGNORE INTO seminar_sem_tree (seminar_id,sem_tree_id) VALUES (?,?)"];
-$_views["SEMINAR_SEM_TREE_GET_IDS"] = ["query" => "SELECT DISTINCT a.sem_tree_id,b.parent_id FROM seminar_sem_tree a INNER JOIN sem_tree b USING(sem_tree_id) WHERE seminar_id=? ORDER BY parent_id,priority"];
-$_views["SEMINAR_SEM_TREE_GET_EXP_IDS"] = ["query" => "SELECT DISTINCT b.sem_tree_id,c.parent_id FROM seminare a LEFT JOIN seminar_sem_tree b USING(seminar_id) LEFT JOIN sem_tree c USING(sem_tree_id) WHERE a.Institut_id=? AND b.sem_tree_id NOT IN(&)"];
-
-
-$_views["SEMINAR_GET_SEMDATA"] = ["query" => "SELECT a.seminar_id,IF(a.visible=0,CONCAT(Name, ' "._("(versteckt)")."'), Name) AS Name,username AS doz_uname, Nachname AS doz_name, " . $_views['sem_number_sql'] . " AS sem_number , " . $_views['sem_number_end_sql'] . " AS sem_number_end
- FROM seminare a LEFT JOIN seminar_user b ON (a.seminar_id=b.seminar_id AND b.status='dozent' )
- LEFT JOIN auth_user_md5 USING(user_id) WHERE a.seminar_id IN (&) ORDER BY sem_number DESC,Name ASC"];
-$_views["SEM_SEARCH_LECTURER"] = ["query" => "SELECT user_id FROM auth_user_md5 WHERE perms = 'dozent' AND (username LIKE ? OR Vorname LIKE ? OR Nachname LIKE ? OR CONCAT(Vorname, ' ', Nachname) LIKE ? OR CONCAT(Nachname, ', ', Vorname) LIKE ?)"];
-$_views["SEM_SEARCH_LECTURER_ID"] = ["query" => "SELECT b.seminar_id, " . $_views['sem_number_sql'] . " AS sem_number, " . $_views['sem_number_end_sql'] . " AS sem_number_end FROM seminar_user b
- INNER JOIN seminare c USING (seminar_id) WHERE § AND b.status='dozent' AND b.user_id IN (&) §"];
-$_views["SEM_SEARCH_SEM"] = ["query" =>"SELECT c.seminar_id, " . $_views['sem_number_sql'] . " AS sem_number , " . $_views['sem_number_end_sql'] . " AS sem_number_end FROM seminare c WHERE § §"];
-$_views["SEM_GET_FAKS"] = ["query" => "SELECT DISTINCT b.fakultaets_id,d.sem_tree_id FROM seminar_inst a LEFT JOIN Institute b USING(Institut_id) LEFT JOIN sem_tree d ON (b.fakultaets_id=d.studip_object_id) WHERE a.seminar_id=?"];
-$_views["SEM_GET_INST"] = ["query" => "SELECT institut_id FROM seminar_inst WHERE seminar_id=?"];
-$_views["SEM_TREE_GET_FAK"] = ["query" => "SELECT DISTINCT sem_tree_id FROM Institute LEFT JOIN sem_tree ON (fakultaets_id=studip_object_id) WHERE Institut_id IN (&) AND NOT ISNULL(sem_tree_id)"];
-
-
-$_views["SEM_INST_GET_SEM"] = ["query" => "SELECT c.Seminar_id, " . $_views['sem_number_sql'] . " AS sem_number , " . $_views['sem_number_end_sql'] . " AS sem_number_end FROM seminar_inst a LEFT JOIN seminare c USING (seminar_id) WHERE a.Institut_id IN (&) AND c.Seminar_id IS NOT NULL
- § § "];
-
-$_views["SEM_USER_GET_SEM"] = ["query" =>"SELECT b.Seminar_id,b.Name, " . $_views['sem_number_sql'] . " AS sem_number , " . $_views['sem_number_end_sql'] . " AS sem_number_end FROM seminar_user a LEFT JOIN seminare b USING(Seminar_id)
- WHERE b.visible=1 AND a.user_id=? AND a.status=? §"];
-
-return $_views;
diff --git a/tests/unit/lib/classes/MarkupClassTest.php b/tests/unit/lib/classes/MarkupClassTest.php
index cba0009..8dad6e9 100644
--- a/tests/unit/lib/classes/MarkupClassTest.php
+++ b/tests/unit/lib/classes/MarkupClassTest.php
@@ -20,9 +20,6 @@
*/
require_once 'tests/unit/fakeserver.php';
-# needed by visual.inc.php
-require_once 'lib/classes/DbView.php';
-
# needed by Markup.php
require_once 'lib/visual.inc.php';
require_once 'lib/classes/Config.php';