function get_sem_class() { $db = new DB_Seminar("SELECT Seminar_id from seminare WHERE seminare.visible=1 AND seminare.status IN ('" . join("','", $this->sem_browse_data['sem_status']) . "')"); $snap = new DbSnapshot($db); $sem_ids = $snap->getRows("Seminar_id"); if (is_array($sem_ids)) { $this->sem_browse_data['search_result'] = array_flip($sem_ids); } $this->show_result = true; }
public function doSearch() { if (!count($this->params)) { return false; } $this->params = array_map('mysql_escape_string', $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)) "; } if (isset($this->params['category']) && $this->params['category'] != 'all') { foreach ($GLOBALS['SEM_TYPE'] as $type_key => $type_value) { if ($type_value['class'] == $this->params['category']) { $sem_types[] = $type_key; } } } if (isset($this->params['type']) && $this->params['type'] != 'all') { unset($sem_types); $sem_types[0] = $this->params['type']; } if (is_array($sem_types)) { $clause = " AND c.status IN('" . join("','", $sem_types) . "') " . $clause; } if ($this->params['scope_choose'] && $this->params['scope_choose'] != 'root') { $sem_tree = TreeAbstract::GetInstance("StudipSemTree", false); $view->params[0] = is_array($sem_types) ? $sem_types : $sem_tree->sem_status; $view->params[1] = $this->visible_only ? "c.visible=1" : "1"; $view->params[2] = $sem_tree->getKidsKids($this->params['scope_choose']); $view->params[2][] = $this->params['scope_choose']; $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->params['range_choose'] && $this->params['range_choose'] != 'root') { $range_object = RangeTreeObject::GetInstance($this->params['range_choose']); $view->params[0] = $range_object->getAllObjectKids(); $view->params[0][] = $range_object->item_data['studip_object_id']; $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; } unset($snap); } if (isset($this->params['lecturer']) && strlen($this->params['lecturer']) > 2) { $view->params[0] = "%" . trim($this->params['lecturer']) . "%"; $view->params[1] = "%" . trim($this->params['lecturer']) . "%"; $view->params[2] = "%" . trim($this->params['lecturer']) . "%"; $view->params[3] = "%" . trim($this->params['lecturer']) . "%"; $view->params[4] = "%" . trim($this->params['lecturer']) . "%"; $result = $view->get_query("view:SEM_SEARCH_LECTURER"); $lecturers = array(); 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']) && strlen($this->params['title']) > 2 || isset($this->params['sub_title']) && strlen($this->params['sub_title']) > 2 || isset($this->params['number']) && strlen($this->params['number']) > 2 || isset($this->params['comment']) && strlen($this->params['comment']) > 2) { $toFilter = explode(" ", $this->params['title']); $search_for = "(Name LIKE '%" . implode("%' AND Name LIKE '%", $toFilter) . "%')"; $view->params[0] .= $this->params['title'] ? $search_for . " " : " "; $view->params[0] .= $this->params['title'] && $this->params['sub_title'] ? $combination : " "; $view->params[0] .= $this->params['sub_title'] ? " Untertitel LIKE '%" . trim($this->params['sub_title']) . "%' " : " "; $view->params[0] .= ($this->params['title'] || $this->params['sub_title']) && $this->params['comment'] ? $combination : " "; $view->params[0] .= $this->params['comment'] ? " Beschreibung LIKE '%" . trim($this->params['comment']) . "%' " : " "; $view->params[0] .= ($this->params['title'] || $this->params['sub_title'] || $this->params['comment']) && $this->params['number'] ? $combination : " "; $view->params[0] .= $this->params['number'] ? " VeranstaltungsNummer LIKE '%" . 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); } $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['scope']) && strlen($this->params['scope']) > 2) { $view->params[0] = $this->visible_only ? "c.visible=1" : "1"; $view->params[1] = "%" . 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; }
function get_sem_range_tree($item_id, $with_kids) { $range_object = RangeTreeObject::GetInstance($item_id); if ($with_kids) { $inst_ids = $range_object->getAllObjectKids(); } $inst_ids[] = $range_object->item_data['studip_object_id']; $db_view = DbView::getView('sem_tree'); $db_view->params[0] = $inst_ids; $db_view->params[1] = is_object($GLOBALS['perm']) && $GLOBALS['perm']->have_perm(get_config('SEM_VISIBILITY_PERM')) ? '' : ' AND c.visible=1'; $db_view->params[1] .= is_array($this->sem_browse_data['sem_status']) ? " AND c.status IN('" . join("','", $this->sem_browse_data['sem_status']) . "')" : ""; $db_view->params[2] = is_array($this->sem_number) ? " HAVING sem_number IN (" . join(",", $this->sem_number) . ") OR (sem_number <= " . $this->sem_number[count($this->sem_number) - 1] . " AND (sem_number_end >= " . $this->sem_number[count($this->sem_number) - 1] . " OR sem_number_end = -1)) " : ""; $db_snap = new DbSnapshot($db_view->get_query("view:SEM_INST_GET_SEM")); if ($db_snap->numRows) { $sem_ids = $db_snap->getRows("Seminar_id"); $this->sem_browse_data['search_result'] = array_flip($sem_ids); } else { $this->sem_browse_data['search_result'] = array(); } }