function StudipLitSearchPluginStudip()
 {
     parent::StudipLitSearchPluginAbstract();
     $this->dbv = DbView::getView('literatur');
     $rs = $this->dbv->get_query("view:LIT_GET_CATALOG_COUNT");
     $rs->next_record();
     $this->description = sprintf(_("Stud.IP Literaturkatalog. Inhalt des Kataloges: %s Einträge."), $rs->f(0));
 }
Esempio n. 2
0
 public function StudipLitCatElement($catalog_id = false, $with_form = false)
 {
     $this->dbv = DbView::getView('literatur');
     $this->init_form = $with_form;
     $this->initFields();
     if ($catalog_id) {
         $this->getElementData($catalog_id);
     }
 }
Esempio n. 3
0
 function StudipSemTreeSearch($seminar_id, $form_name = "search_sem_tree", $auto_search = true)
 {
     $this->view = DbView::getView('sem_tree');
     $this->form_name = $form_name;
     $this->tree = TreeAbstract::GetInstance("StudipSemTree", false);
     $this->seminar_id = $seminar_id;
     $this->view->params[0] = $seminar_id;
     $rs = $this->view->get_query("view:SEM_GET_INST");
     while ($rs->next_record()) {
         $this->institut_id[] = $rs->f(0);
     }
     $this->init();
     if ($auto_search) {
         $this->doSearch();
     }
 }
Esempio n. 4
0
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
// +---------------------------------------------------------------------------+
use Studip\Button, Studip\LinkButton;
require '../lib/bootstrap.php';
page_open(array("sess" => "Seminar_Session", "auth" => "Seminar_Auth", "perm" => "Seminar_Perm", "user" => "Seminar_User"));
$perm->check('user');
include 'lib/seminar_open.php';
// initialise Stud.IP-Session
require_once 'lib/visual.inc.php';
PageLayout::setHelpKeyword("Basis.SuchenEinrichtungen");
PageLayout::setTitle(_("Einrichtungssuche"));
Navigation::activateItem('/search/institutes');
// Start of Output
ob_start();
$view = DbView::getView('range_tree');
$the_tree = new StudipRangeTreeView();
$the_tree->open_ranges['root'] = true;
if (Request::option('cmd') == "suche") {
    if (Request::get('search_name') && strlen(Request::get('search_name')) > 1) {
        $view->params[0] = "%" . Request::quoted('search_name') . "%";
        $rs = $view->get_query("view:TREE_SEARCH_ITEM");
        while ($rs->next_record()) {
            $found_items[] = htmlReady($the_tree->tree->getItemPath($rs->f("item_id")));
            $the_tree->openItem($rs->f("item_id"));
        }
    }
    if (Request::get('search_user') && strlen(Request::get('search_user')) > 1) {
        $view->params[0] = "%" . Request::quoted('search_user') . "%";
        $view->params[1] = "%" . Request::quoted('search_user') . "%";
        $rs = $view->get_query("view:TREE_SEARCH_USER");
    function getContent () {
        global $SEM_TYPE, $SEM_CLASS, $sem_type_tmp;

        if (is_array($this->sem_browse_data['search_result']) && count($this->sem_browse_data['search_result'])) {

            // show only selected subject areas
            $selected_ranges = (array) $this->module->config->getValue('SelectSubjectAreas', 'subjectareasselected');
            $selected_ranges[] = $this->sem_browse_data['start_item_id'];
            if (!$this->module->config->getValue('SelectSubjectAreas', 'selectallsubjectareas')
                    && count($selected_ranges)) {
                if ($this->module->config->getValue('SelectSubjectAreas', 'reverseselection')) {
                    $sem_range_query =  "AND seminar_sem_tree.sem_tree_id NOT IN ('".implode("','", $selected_ranges)."')";
                } else {
                    $sem_range_query =  "AND seminar_sem_tree.sem_tree_id IN ('".implode("','", $selected_ranges)."')";
                }
            } else {
                $sem_range_query = '';
            }

            // show only selected SemTypes
            $selected_semtypes = $this->module->config->getValue('ReplaceTextSemType', 'visibility');
            $sem_types_array = array();
            if (count($selected_semtypes)) {
                for ($i = 0; $i < count($selected_semtypes); $i++) {
                    if ($selected_semtypes[$i] == '1') {
                        $sem_types_array[] = $i + 1;
                    }
                }
                $sem_types_query = "AND seminare.status IN ('" . implode("','", $sem_types_array) . "')";
            } else {
                $sem_types_query = '';
            }

            // number of visible columns
            $group_colspan = array_count_values((array) $this->module->config->getValue("Main", "visible"));

            if ($this->sem_browse_data['group_by'] == 1){
                if (!is_object($this->sem_tree)){
                    $the_tree = TreeAbstract::GetInstance("StudipSemTree");
                } else {
                    $the_tree =& $this->sem_tree->tree;
                }
            $the_tree->buildIndex();
            }

            if (!$this->module->config->getValue("Main", "allseminars")){
                $sem_inst_query = " AND seminare.Institut_id='{$this->module->config->range_id}' ";
            }
            if (!$nameformat = $this->module->config->getValue("Main", "nameformat"))
                $nameformat = "no_title_short";

            $dbv = DbView::getView('sem_tree');

            $query = "SELECT seminare.*
                , Institute.Name AS Institut,Institute.Institut_id,
                seminar_sem_tree.sem_tree_id AS bereich, " . $GLOBALS['_fullname_sql'][$nameformat] ." AS fullname, auth_user_md5.username, Vorname, Nachname, title_front, title_rear,
                " . $dbv->sem_number_sql . " AS sem_number, " . $dbv->sem_number_end_sql . " AS sem_number_end,
                seminar_user.position AS position FROM seminare
                LEFT JOIN seminar_user ON (seminare.Seminar_id=seminar_user.Seminar_id AND seminar_user.status='dozent')
                LEFT JOIN auth_user_md5 USING (user_id)
                LEFT JOIN user_info USING (user_id)
                LEFT JOIN seminar_sem_tree ON (seminare.Seminar_id = seminar_sem_tree.seminar_id)
                LEFT JOIN seminar_inst ON (seminare.Seminar_id = seminar_inst.Seminar_id)
                LEFT JOIN Institute ON (seminar_inst.institut_id = Institute.Institut_id)
                WHERE seminare.Seminar_id IN('" . join("','", array_keys($this->sem_browse_data['search_result']))
                 . "') $sem_inst_query $sem_range_query $sem_types_query";

            $db = new DB_Seminar($query);
            $snap = new DbSnapshot($db);
            $group_field = $this->group_by_fields[$this->sem_browse_data['group_by']]['group_field'];
            $data_fields[0] = "Seminar_id";
            if ($this->group_by_fields[$this->sem_browse_data['group_by']]['unique_field']){
                $data_fields[1] = $this->group_by_fields[$this->sem_browse_data['group_by']]['unique_field'];
            }
            $group_by_data = $snap->getGroupedResult($group_field, $data_fields);
            $sem_data = $snap->getGroupedResult("Seminar_id");
            if ($this->sem_browse_data['group_by'] == 0){
                $group_by_duration = $snap->getGroupedResult("sem_number_end", array("sem_number","Seminar_id"));
                foreach ($group_by_duration as $sem_number_end => $detail){
                    if ($sem_number_end != -1 && ($detail['sem_number'][$sem_number_end - 1] && count($detail['sem_number']) == 1)){
                        continue;
                    } else {
                        foreach ($detail['Seminar_id'] as $seminar_id => $foo){
                            $start_sem = key($sem_data[$seminar_id]["sem_number"]);
                            if ($sem_number_end == -1){
                                if (is_array($this->sem_number)){
                                    $sem_number_end = $this->sem_number[0];
                                } else {
                                    $sem_number_end = count($this->sem_dates)-1;
                                }
                            }
                            for ($i = $start_sem; $i <= $sem_number_end; ++$i){
                                if ($this->sem_number === false || (is_array($this->sem_number) && in_array($i,$this->sem_number))){
                                    if ($group_by_data[$i] && !$tmp_group_by_data[$i]){
                                        foreach($group_by_data[$i]['Seminar_id'] as $id => $bar){
                                            $tmp_group_by_data[$i]['Seminar_id'][$id] = true;
                                        }
                                    }
                                    $tmp_group_by_data[$i]['Seminar_id'][$seminar_id] = true;
                                }
                            }
                        }
                    }
                }
                if (is_array($tmp_group_by_data)){
                    if ($this->sem_number !== false){
                        unset($group_by_data);
                    }
                    foreach ($tmp_group_by_data as $start_sem => $detail){
                        $group_by_data[$start_sem] = $detail;
                    }
                }
            }

            foreach ($group_by_data as $group_field => $sem_ids){
                foreach ($sem_ids['Seminar_id'] as $seminar_id => $foo){
                    $name = strtolower(key($sem_data[$seminar_id]["Name"]));
                    $name = str_replace("ä","ae",$name);
                    $name = str_replace("ö","oe",$name);
                    $name = str_replace("ü","ue",$name);
                    $group_by_data[$group_field]['Seminar_id'][$seminar_id] = $name;
                }
                uasort($group_by_data[$group_field]['Seminar_id'], 'strnatcmp');
            }

            switch ($this->sem_browse_data["group_by"]){
                    case 0:
                    krsort($group_by_data, SORT_NUMERIC);
                    break;

                    case 1:
                    uksort($group_by_data, create_function('$a,$b',
                            '$the_tree = TreeAbstract::GetInstance("StudipSemTree", false);
                            return (int)($the_tree->tree_data[$a]["index"] - $the_tree->tree_data[$b]["index"]);
                            '));
                    break;

                    case 3:
                    if ($order = $this->module->config->getValue("ReplaceTextSemType", "order")) {
                        foreach ((array) $order as $position) {
                            if (isset($group_by_data[$position]))
                                $group_by_data_tmp[$position] = $group_by_data[$position];
                        }
                        $group_by_data = $group_by_data_tmp;
                        unset($group_by_data_tmp);
                    }
                    else {
                        uksort($group_by_data, create_function('$a,$b',
                                'global $SEM_CLASS,$SEM_TYPE;
                                return strnatcasecmp($SEM_TYPE[$a]["name"]." (". $SEM_CLASS[$SEM_TYPE[$a]["class"]]["name"].")",
                                                $SEM_TYPE[$b]["name"]." (". $SEM_CLASS[$SEM_TYPE[$b]["class"]]["name"].")");'));
                    }
                    break;
                    default:
                    uksort($group_by_data, 'strnatcasecmp');
                    break;

            }

            // generic datafields
            $generic_datafields = $this->module->config->getValue("Main", "genericdatafields");

            $content['__GLOBAL__']['LECTURES-COUNT'] = count($sem_data);
            $group_by_name = $this->module->config->getValue("Main", "aliasesgrouping");
            $content['__GLOBAL__']['LECTURES-SUBSTITUTE-GROUPED-BY'] = $group_by_name[$this->sem_browse_data['group_by']];

            $i = 0;
            foreach ((array) $group_by_data as $group_field => $sem_ids) {
                $content['LECTURES']['GROUP'][$i]['GROUP'] = $this->getGroupContent($the_tree, $group_field);
                $content['LECTURES']['GROUP'][$i]['GROUP-NO'] = $i + 1;

                if (is_array($sem_ids['Seminar_id'])) {
                    $zebra = 0;
                    $j = 0;
                    while (list($seminar_id,) = each($sem_ids['Seminar_id'])) {

                //      $sem_name = key($sem_data[$seminar_id]["Name"]);

                        $content['LECTURES']['GROUP'][$i]['LECTURE'][$j]['TITLE'] = ExternModule::ExtHtmlReady(key($sem_data[$seminar_id]['Name']));

                        $sem_number_start = key($sem_data[$seminar_id]['sem_number']);
                        $sem_number_end = key($sem_data[$seminar_id]['sem_number_end']);
                        $sem_semester = $this->sem_dates[$sem_number_start]['name'];
                        if ($sem_number_start != $sem_number_end){
                            $sem_semester .= ' - ' . ($sem_number_end == -1 ? _("unbegrenzt") : $this->sem_dates[$sem_number_end]['name']);
                        }

                        $content['LECTURES']['GROUP'][$i]['LECTURE'][$j]['SEMESTER'] = $sem_semester;

                        // create turnus field
                        $sem_turnus = Seminar::getInstance($seminar_id)->getDatesExport(array('show_room' => true));

                        // shorten, if string too long
                        if (strlen($sem_turnus) > 70) {
                            $sem_turnus = substr($sem_turnus, 0,
                                    strpos(substr($sem_turnus, 70, strlen($sem_turnus)), ",") +71);
                            $sem_turnus .= "...";
                        }
                        $content['LECTURES']['GROUP'][$i]['LECTURE'][$j]['CYCLE'] = ExternModule::ExtHtmlReady($sem_turnus);

                        $doz_name = array_keys($sem_data[$seminar_id]['fullname']);
                        $doz_lastname = array_keys($sem_data[$seminar_id]['Nachname']);
                        $doz_firstname = array_keys($sem_data[$seminar_id]['Vorname']);
                        $doz_titlefront = array_keys($sem_data[$seminar_id]['title_front']);
                        $doz_titlerear = array_keys($sem_data[$seminar_id]['title_rear']);
                        $doz_uname = array_keys($sem_data[$seminar_id]['username']);
                        $doz_position = array_keys($sem_data[$seminar_id]['position']);
                        if (sizeof($doz_position) < $doz_name) $doz_position = array_fill(0, sizeof($doz_name), 0);
                        if (is_array($doz_name)){
                            array_multisort($doz_position, $doz_name, $doz_uname);
                            $k = 0;
                            foreach ($doz_name as $index => $value) {
                                $content['LECTURES']['GROUP'][$i]['LECTURE'][$j]['LECTURERS'][$k]['PERSONDETAIL-HREF'] = $this->module->elements['LinkInternPersondetails']->createUrl(array('link_args' => 'username='******'LECTURES']['GROUP'][$i]['LECTURE'][$j]['LECTURERS'][$k]['FULLNAME'] = ExternModule::ExtHtmlReady($doz_name[$index]);
                                $content['LECTURES']['GROUP'][$i]['LECTURE'][$j]['LECTURERS'][$k]['LASTNAME'] = ExternModule::ExtHtmlReady($doz_lastname[$index]);
                                $content['LECTURES']['GROUP'][$i]['LECTURE'][$j]['LECTURERS'][$k]['FIRSTNAME'] = ExternModule::ExtHtmlReady($doz_firstname[$index]);
                                $content['LECTURES']['GROUP'][$i]['LECTURE'][$j]['LECTURERS'][$k]['TITLEFRONT'] = ExternModule::ExtHtmlReady($doz_titlefront[$index]);
                                $content['LECTURES']['GROUP'][$i]['LECTURE'][$j]['LECTURERS'][$k]['TITLEREAR'] = ExternModule::ExtHtmlReady($doz_titlerear[$index]);
                                $content['LECTURES']['GROUP'][$i]['LECTURE'][$j]['LECTURERS'][$k]['UNAME'] = $doz_uname[$index];
                                $content['LECTURES']['GROUP'][$i]['LECTURE'][$j]['LECTURERS'][$k]['LECTURER-NO'] = $k + 1;
                                $k++;
                            }
                        }

                        $content['LECTURES']['GROUP'][$i]['LECTURE'][$j]['LECTUREDETAILS-HREF'] = $this->module->elements['LinkInternLecturedetails']->createUrl(array('link_args' => 'seminar_id=' . $seminar_id));
                        $content['LECTURES']['GROUP'][$i]['LECTURE'][$j]['NUMBER'] = ExternModule::ExtHtmlReady(key($sem_data[$seminar_id]['VeranstaltungsNummer']));
                        $content['LECTURES']['GROUP'][$i]['LECTURE'][$j]['SUBTITLE'] = ExternModule::ExtHtmlReady(key($sem_data[$seminar_id]['Untertitel']));
                        $aliases_sem_type = $this->module->config->getValue('ReplaceTextSemType', 'class_' . $SEM_TYPE[key($sem_data[$seminar_id]['status'])]['class']);
                        $content['LECTURES']['GROUP'][$i]['LECTURE'][$j]['SEMTYPE-SUBSTITUTE'] = $aliases_sem_type[$this->sem_types_position[key($sem_data[$seminar_id]['status'])] - 1];
                        $content['LECTURES']['GROUP'][$i]['LECTURE'][$j]['SEMTYPE'] = ExternModule::ExtHtmlReady($SEM_TYPE[key($sem_data[$seminar_id]['status'])]['name']
                                    .' ('. $SEM_CLASS[$SEM_TYPE[key($sem_data[$seminar_id]['status'])]['class']]['name'] . ')');
                        $content['LECTURES']['GROUP'][$i]['LECTURE'][$j]['ROOM'] = ExternModule::ExtHtmlReady(Seminar::getInstance($seminar_id)->getDatesTemplate('dates/seminar_export_location'));
                        $content['LECTURES']['GROUP'][$i]['LECTURE'][$j]['FORM'] = ExternModule::ExtHtmlReady(key($sem_data[$seminar_id]['art']));

                        // generic data fields
                        if (is_array($generic_datafields)) {
                            $localEntries = DataFieldEntry::getDataFieldEntries($seminar_id, 'sem');
                            #$datafields = $datafields_obj->getLocalFields($seminar_id);
                            $l = 1;
                            foreach ($generic_datafields as $datafield) {
                                if (isset($localEntries[$datafield]) && is_object($localEntries[$datafield])) {
                                    $localEntry = $localEntries[$datafield]->getDisplayValue();
                                    if ($localEntry) {
                                        $content['LECTURES']['GROUP'][$i]['LECTURE'][$j]['DATAFIELD_' . $l] = $localEntry;
                                    }
                                }
                                $l++;
                            }

                        }

                        $j++;
                    }
                }
                $i++;
            }
        } else {
            $content['__GLOBAL__']['LECTURES-COUNT'] = 0;
            $group_by_name = $this->module->config->getValue('Main', 'aliasesgrouping');
            $content['__GLOBAL__']['LECTURES-SUBSTITUTE-GROUPED-BY'] = $group_by_name[$this->sem_browse_data['group_by']];
            $content['LECTURES']['NO-LECTURES']['NO-LECTURES-TEXT'] = ExternModule::ExtHtmlReady($this->module->config->getValue('Main', 'nodatatext'));
        }
        return $content;

    }
Esempio n. 6
0
    function print_result ($args) {
        global $_fullname_sql,$SEM_TYPE,$SEM_CLASS;

        if (is_array($this->sem_browse_data['search_result']) && count($this->sem_browse_data['search_result'])) {
            
            // show only selected subject areas
            $selected_ranges = $this->config->getValue('SelectSubjectAreas', 'subjectareasselected');
            if ($stid = Request::option('sem_tree_id')) {
                if (!is_object($this->sem_tree)){
                    $the_tree = TreeAbstract::GetInstance("StudipSemTree");
                } else {
                    $the_tree =& $this->sem_tree->tree;
                }
                $the_tree->buildIndex();
                $selected_ranges = array_merge(array($stid), $the_tree->getKidsKids($stid));
            }
            if (!$this->config->getValue('SelectSubjectAreas', 'selectallsubjectareas')
                    && count($selected_ranges)) {
                if ($this->config->getValue('SelectSubjectAreas', 'reverseselection')) {
                    $sem_range_query =  "AND seminar_sem_tree.sem_tree_id NOT IN ('".implode("','", $selected_ranges)."')";
                } else {
                    $sem_range_query =  "AND seminar_sem_tree.sem_tree_id IN ('".implode("','", $selected_ranges)."')";
                }
            } else {
                $sem_range_query = '';
            }
            
            // show only selected SemTypes
            $selected_semtypes = $this->config->getValue('ReplaceTextSemType', 'visibility');
            if (Request::get('semstatus')) {
                $selected_semtypes = array(Request::get('semstatus'));
            }
            $sem_types_array = array();
            if (count($selected_semtypes)) {
                for ($i = 0; $i < count($selected_semtypes); $i++) {
                    if ($selected_semtypes[$i] == '1') {
                        $sem_types_array[] = $i + 1;
                    }
                }
                $sem_types_query = "AND seminare.status IN ('" . implode("','", $sem_types_array) . "')";
            } else {
                $sem_types_query = '';
            }
            
            if ($this->sem_browse_data['group_by'] == 1){
                if (!is_object($this->sem_tree)){
                    $the_tree = TreeAbstract::GetInstance("StudipSemTree");
                } else {
                    $the_tree =& $this->sem_tree->tree;
                }
                $the_tree->buildIndex();
            }
            
            if (!$this->config->getValue("Main", "allseminars") && !Request::get('allseminars')) {
                $sem_inst_query = " AND seminare.Institut_id='{$this->config->range_id}' ";
            }
            if (Request::option('aggregation')) {
                $i = Institute::find($this->config->range_id);
                $children = $i->sub_institutes->pluck('institut_id');
                $sem_inst_query = " AND seminare.Institut_id IN ('".(implode("', '", $children))."')";
            }

            $dbv = DbView::getView('sem_tree');
            
            if (!$nameformat = $this->config->getValue("Main", "nameformat"))
                $nameformat = "no_title_short";
            $query = "SELECT seminare.Seminar_id, seminare.status, seminare.Name  
                , seminare.Institut_id, Institute.Name AS Institut,Institute.Institut_id,
                seminar_sem_tree.sem_tree_id AS bereich, "
                . $_fullname_sql[$nameformat]
                . " AS fullname, auth_user_md5.username,
                " . $dbv->sem_number_sql . " AS sem_number, " . $dbv->sem_number_end_sql . " AS sem_number_end, " . 
            " seminar_user.position AS position " . 
            " FROM seminare 
                LEFT JOIN seminar_user ON (seminare.Seminar_id=seminar_user.Seminar_id AND seminar_user.status='dozent') 
                LEFT JOIN auth_user_md5 USING (user_id) 
                LEFT JOIN user_info USING (user_id) 
                LEFT JOIN seminar_sem_tree ON (seminare.Seminar_id = seminar_sem_tree.seminar_id)
                LEFT JOIN seminar_inst ON (seminare.Seminar_id = seminar_inst.Seminar_id) 
                LEFT JOIN Institute ON (seminar_inst.institut_id = Institute.Institut_id) 
                WHERE seminare.Seminar_id IN('" . join("','", array_keys($this->sem_browse_data['search_result']))
                 . "')$sem_inst_query $sem_range_query $sem_types_query";
            
            $db = new DB_Seminar($query);
            $snap = new DbSnapshot($db);
            if (isset($args['group']) && $args['group'] >= 0 && $args['group'] < 5) {
                $this->sem_browse_data['group_by'] = $args['group'];
            }
            $group_field = $this->group_by_fields[$this->sem_browse_data['group_by']]['group_field'];
            $data_fields[0] = "Seminar_id";
            if ($this->group_by_fields[$this->sem_browse_data['group_by']]['unique_field']){
                $data_fields[1] = $this->group_by_fields[$this->sem_browse_data['group_by']]['unique_field'];
            }
            $group_by_data = $snap->getGroupedResult($group_field, $data_fields);
            $sem_data = $snap->getGroupedResult("Seminar_id");
            
            if ($this->sem_browse_data['group_by'] == 0){
                $group_by_duration = $snap->getGroupedResult("sem_number_end", array("sem_number","Seminar_id"));
                foreach ($group_by_duration as $sem_number_end => $detail){
                    if ($sem_number_end != -1 && ($detail['sem_number'][$sem_number_end - 1] && count($detail['sem_number']) == 1)){
                        continue;
                    } else {
                        foreach ($detail['Seminar_id'] as $seminar_id => $foo){
                            $start_sem = key($sem_data[$seminar_id]["sem_number"]);
                            if ($sem_number_end == -1){
                                if (is_array($this->sem_number)){
                                    $sem_number_end = $this->sem_number[0];
                                } else {
                                    $sem_number_end = count($this->sem_dates) - 1;
                                }
                            }
                            for ($i = $start_sem; $i <= $sem_number_end; ++$i){
                                if ($this->sem_number === false || (is_array($this->sem_number) && in_array($i,$this->sem_number))){
                                    if ($group_by_data[$i] && !$tmp_group_by_data[$i]){
                                        foreach($group_by_data[$i]['Seminar_id'] as $id => $bar){
                                            $tmp_group_by_data[$i]['Seminar_id'][$id] = true;
                                        }
                                    }
                                    $tmp_group_by_data[$i]['Seminar_id'][$seminar_id] = true;
                                }
                            }
                        }
                    }
                }
                if (is_array($tmp_group_by_data)){
                    if ($this->sem_number !== false){
                        unset($group_by_data);
                    }
                    foreach ($tmp_group_by_data as $start_sem => $detail){
                        $group_by_data[$start_sem] = $detail;
                    }
                }
            }
            
            foreach ($group_by_data as $group_field => $sem_ids){
                foreach ($sem_ids['Seminar_id'] as $seminar_id => $foo){
                    $name = strtolower(key($sem_data[$seminar_id]["Name"]));
                    $name = str_replace("ä","ae",$name);
                    $name = str_replace("ö","oe",$name);
                    $name = str_replace("ü","ue",$name);
                    $group_by_data[$group_field]['Seminar_id'][$seminar_id] = $name;
                }
                uasort($group_by_data[$group_field]['Seminar_id'], 'strnatcmp');
            }
            
            switch ($this->sem_browse_data["group_by"]){
                    case 0:
                    krsort($group_by_data, SORT_NUMERIC);
                    break;
                    
                    case 1:
                    uksort($group_by_data, create_function('$a,$b',
                            '$the_tree = TreeAbstract::GetInstance("StudipSemTree");
                            return (int)($the_tree->tree_data[$a]["index"] - $the_tree->tree_data[$b]["index"]);
                            '));
                            
                    break;
                    
                    case 3:
                    if ($order = $this->module->config->getValue("ReplaceTextSemType", "order")) {
                        foreach ($order as $position) {
                            if (isset($group_by_data[$position]))
                                $group_by_data_tmp[$position] = $group_by_data[$position];
                        }
                        $group_by_data = $group_by_data_tmp;
                        unset($group_by_data_tmp);
                    }
                    else {
                        uksort($group_by_data, create_function('$a,$b',
                                'global $SEM_CLASS,$SEM_TYPE;
                                return strnatcasecmp($SEM_TYPE[$a]["name"]." (". $SEM_CLASS[$SEM_TYPE[$a]["class"]]["name"].")",
                                                $SEM_TYPE[$b]["name"]." (". $SEM_CLASS[$SEM_TYPE[$b]["class"]]["name"].")");'));
                    }
                    break;
                    
                    default:
                    uksort($group_by_data, 'strnatcasecmp');
                    break;
            }
            
            $show_time = $this->config->getValue("Main", "time");
            $show_lecturer = $this->config->getValue("Main", "lecturer");
            if ($show_time && $show_lecturer) {
                if (!$td2width = $this->config->getValue("LecturesInnerTable", "td2width"))
                    $td2width = 50;
                $colspan = " colspan=\"2\"";
                $td_time = $this->config->getAttributes("LecturesInnerTable", "td2");
                $td_time .= " width=\"$td2width%\"";
                $td_lecturer = " align=\"" . $this->config->getValue("LecturesInnerTable", "td3_align");
                $td_lecturer .= "\" valign=\"" . $this->config->getValue("LecturesInnerTable", "td2_valign");
                $td_lecturer .= "\" width=\"" . (100 - $td2width) . "%\"";
            }
            else {
                $colspan = "";
                $td_time = $this->config->getAttributes("LecturesInnerTable", "td2") . " width=\"100%\"";
                $td_lecturer = " align=\"" . $this->config->getValue("LecturesInnerTable", "td3_align");
                $td_lecturer .= "\" valign=\"" . $this->config->getValue("LecturesInnerTable", "td2_valign");
                $td_lecturer .= " width=\"100%\"";
            }
            // erase output buffer with warnings and start unbuffered output
            ob_end_clean();
            echo "\n<table" . $this->config->getAttributes("TableHeader", "table") . ">\n";
            if ($this->config->getValue("Main", "addinfo")) {
                echo "\n<tr" . $this->config->getAttributes("InfoCountSem", "tr") . ">";
                echo "<td" . $this->config->getAttributes("InfoCountSem", "td") . ">";
                echo "<font" . $this->config->getAttributes("InfoCountSem", "font") . ">&nbsp;";
                echo count($sem_data);
                echo $this->config->getValue("Main", "textlectures");
                echo ", " . $this->config->getValue("Main", "textgrouping");
                $group_by_name = $this->config->getValue("Main", "aliasesgrouping");
                echo $group_by_name[$this->sem_browse_data['group_by']];
                echo "</font></td></tr>";
            }
            if (count($group_by_data)) {
                foreach ($group_by_data as $group_field => $sem_ids) {
                    echo "\n<tr" . $this->config->getAttributes("Grouping", "tr") . ">";
                    echo "<td" . $this->config->getAttributes("Grouping", "td") . ">";
                    echo "<font" . $this->config->getAttributes("Grouping", "font") . ">";
                    switch ($this->sem_browse_data["group_by"]){
                        case 0:
                        echo $this->sem_dates[$group_field]['name'];
                        break;
                        
                        case 1:
                        if ($the_tree->tree_data[$group_field]) {
                            $range_path_level = $this->config->getValue("Main", "rangepathlevel");
                            echo htmlReady($the_tree->getShortPath($group_field, NULL, '>', $range_path_level ? $range_path_level - 1 : 0));
                        } else {
                            echo $this->config->getValue("Main", "textnogroups");
                        }
                        /*
                        $range_path_new = NULL;
                        if ($the_tree->tree_data[$group_field]) {
                            $range_path = explode(" ^ ", $the_tree->getShortPath($group_field, "^"));
                            $range_path_level = $this->config->getValue("Main", "rangepathlevel");
                            if ($range_path_level > sizeof($range_path))
                                $range_path_level = sizeof($range_path);
                            for ($i = $range_path_level - 1; $i < sizeof($range_path); $i++)
                                $range_path_new[] = $range_path[$i];
                            echo htmlReady(implode(" > ", $range_path_new));
                        }
                        else
                            echo $this->config->getValue("Main", "textnogroups");
                        */
                        break;
                        
                        case 2:
                        echo htmlReady($group_field);
                        break;
                        
                        case 3:
                        $aliases_sem_type = $this->config->getValue("ReplaceTextSemType",
                                "class_{$SEM_TYPE[$group_field]['class']}");
                        if ($aliases_sem_type[$this->sem_types_position[$group_field] - 1])
                            echo $aliases_sem_type[$this->sem_types_position[$group_field] - 1];
                        else {
                            echo htmlReady($SEM_TYPE[$group_field]["name"]
                                    ." (". $SEM_CLASS[$SEM_TYPE[$group_field]["class"]]["name"].")");
                        }
                        break;
                        
                        case 4:
                        echo htmlReady($group_field);
                        break;
                        
                    }
                    echo "</font></td></tr>";
                    if (is_array($sem_ids['Seminar_id'])) {
                        $zebra = 0;
                        while (list($seminar_id,) = each($sem_ids['Seminar_id'])) {
                            $sem_name = key($sem_data[$seminar_id]["Name"]);
                            $sem_number_start = key($sem_data[$seminar_id]["sem_number"]);
                            $sem_number_end = key($sem_data[$seminar_id]["sem_number_end"]);
                            if ($sem_number_start != $sem_number_end){
                                $sem_name .= " (" . $this->sem_dates[$sem_number_start]['name'] . " - ";
                                $sem_name .= (($sem_number_end == -1) ? _("unbegrenzt") : $this->sem_dates[$sem_number_end]['name']) . ")";
                            }
                            echo "\n<tr" . $this->config->getAttributes("LecturesInnerTable", "tr").">";
                            if ($zebra % 2 && $this->config->getValue("LecturesInnerTable", "td_bgcolor2_"))
                                echo "<td width=\"100%\"".$this->config->getAttributes("LecturesInnerTable", "td", TRUE)."\">\n";
                            else
                                echo "<td width=\"100%\"".$this->config->getAttributes("LecturesInnerTable", "td")."\">\n";
                            $zebra++;
                            echo "<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\n";
                            echo "<tr" . $this->config->getAttributes("LecturesInnerTable", "tr1") . ">";
                            echo "<td$colspan" . $this->config->getAttributes("LecturesInnerTable", "td1") . ">";
                            echo "<font" . $this->config->getAttributes("LecturesInnerTable", "font1") . ">";
                            $sem_link["module"] = "Lecturedetails";
                            $sem_link["link_args"] = "seminar_id=$seminar_id";
                            $sem_link["content"] = htmlReady($sem_name);
                            $this->module->elements["SemLink"]->printout($sem_link);
                            echo "</font></td></tr>\n";
                            //create Turnus field
                            $temp_turnus_string = Seminar::GetInstance($seminar_id)->getDatesExport(array('show_room' => true));
                            //Shorten, if string too long (add link for details.php)
                            if (strlen($temp_turnus_string) >70) {
                                $temp_turnus_string = substr($temp_turnus_string, 0, strpos(substr($temp_turnus_string, 70, strlen($temp_turnus_string)), ',') +71);
                                $temp_turnus_string .= '...';
                            }
                            if ($show_time || $show_lecturer) {
                                echo "\n<tr" . $this->config->getAttributes('LecturesInnerTable', 'tr2') . '>';
                                if ($show_time) {
                                    echo "<td$td_time>";
                                    echo '<font' . $this->config->getAttributes('LecturesInnerTable', 'font2') . '>';
                                    echo $temp_turnus_string . "</font></td>\n";
                                }
                                if ($show_lecturer) {
                                    echo "<td$td_lecturer>";
                                    echo '<font' . $this->config->getAttributes('LecturesInnerTable', 'font2') . '>(';
                                    $doz_position = array_keys($sem_data[$seminar_id]['position']);
                                    $doz_name = array_keys($sem_data[$seminar_id]['fullname']);
                                    $doz_uname = array_keys($sem_data[$seminar_id]['username']);
                                    if (is_array($doz_name)){
                                        $lecturer_link['module'] = 'Persondetails';
                                        if(count($doz_position) != count($doz_uname)) $doz_position = range(1, count($doz_uname));
                              array_multisort($doz_position, $doz_name, $doz_uname); 
                                        $i = 0;
                                        foreach ($doz_name as $index => $value) {
                                            if ($i == 4) { 
                                                echo '...';
                                                break;
                                            }
                                            $lecturer_link['link_args'] = "username={$doz_uname[$index]}&seminar_id=$seminar_id";
                                            $lecturer_link['content'] = htmlReady($value);
                                            $this->module->elements['LecturerLink']->printout($lecturer_link);
                                            if ($i != count($doz_name) - 1) {
                                                echo ', ';
                                            }
                                            ++$i;
                                        }
                                        echo ') ';
                                    }
                                    echo '</font></td>';
                                }
                                echo '</tr>';
                            }
                            echo "</table></td></tr>\n";
                        }
                    }
                }
            }
            echo "</table>";
        }
    }
Esempio n. 7
0
require '../lib/bootstrap.php';
page_open(array("sess" => "Seminar_Session", "auth" => "Seminar_Auth", "perm" => "Seminar_Perm", "user" => "Seminar_User"));
$perm->check(Config::get()->SEM_TREE_ADMIN_PERM ?: 'admin');
if (!$perm->is_fak_admin()) {
    $perm->perm_invalid(0, 0);
    page_close();
    die;
}
include 'lib/seminar_open.php';
// initialise Stud.IP-Session
include 'lib/msg.inc.php';
PageLayout::setTitle($UNI_NAME_CLEAN . " - " . _("Veranstaltungshierachie bearbeiten"));
Navigation::activateItem('/admin/locations/sem_tree');
// Start of Output
ob_start();
$view = DbView::getView('sem_tree');
$the_tree = new StudipSemTreeViewAdmin(Request::option('start_item_id'));
$search_obj = new StudipSemSearch();
$_open_items =& $the_tree->open_items;
$_open_ranges =& $the_tree->open_ranges;
$_possible_open_items = array();
if (!Config::GetInstance()->getValue('SEM_TREE_ALLOW_BRANCH_ASSIGN')) {
    if (is_array($_open_items)) {
        foreach ($_open_items as $item_id => $value) {
            if (!$the_tree->tree->getNumKids($item_id)) {
                $_possible_open_items[$item_id] = $value;
            }
        }
    }
} else {
    $_possible_open_items = $_open_items;
    private function getContentListInstitutes () {
        $selected_item_ids = $this->config->getValue('SelectInstitutes', 'institutesselected');
        // at least one institute has to be selected in the configuration
        if (!is_array($selected_item_ids)) {
            return array();
        }
        $content = array();
        
        $first_levels = $this->range_tree->getKids('root');
    //  var_dump($first_levels);
        $current_semester = get_sem_num(time());
        
        $db_count = new DB_Seminar();
        $dbv = DbView::getView('sem_tree');
        $mrks = str_repeat('?,', count($selected_item_ids) - 1) . '?';
        $query = "SELECT Institut_id, Name "
            . "FROM Institute "
            . "WHERE Institut_id IN ($mrks) "
            . "AND fakultaets_id != Institut_id "
            . "ORDER BY Name ASC";
        $parameters = $selected_item_ids;

        $statement = DBManager::get()->prepare($query);
        $statement->execute($parameters);

        while ($row = $statement->fetch(PDO::FETCH_ASSOC)) {
            if ($this->config->getValue('Main', 'onlylecturers')) {
                // get only users with status dozent in an visible seminar in the current semester
                $query = sprintf("SELECT COUNT(DISTINCT(su.user_id)) AS count_user "
                    . "FROM user_inst ui "
                    . "LEFT JOIN seminar_user su USING(user_id) "
                    . "LEFT JOIN seminare s USING (seminar_id) "
                    . "LEFT JOIN auth_user_md5 aum ON su.user_id = aum.user_id "
                    . "WHERE ui.Institut_id = '%s' "
                    . "AND su.status = 'dozent' "
                    . "AND ui.externdefault = 1 "
                    . "AND " . get_ext_vis_query()
                    . "AND ui.inst_perms = 'dozent' "
                    . "AND ((%s) = %s OR ((%s) <= %s  AND ((%s) >= %s OR (%s) = -1)))",
                    $row['Institut_id'],
                    $dbv->sem_number_sql,
                    $current_semester,
                    $dbv->sem_number_sql,
                    $current_semester,
                    $dbv->sem_number_end_sql,
                    $current_semester,
                    $dbv->sem_number_end_sql);
            } else {
                // get only users with the given status
                $query = sprintf("SELECT COUNT(DISTINCT(ui.user_id)) AS count_user "
                    . "FROM user_inst ui "
                    . "WHERE ui.Institut_id = '%s' "
                    . "AND ui.inst_perms IN('%s') "
                    . "AND ui.externdefault = 1"
                    . "AND " . get_ext_vis_query(),
                    $row['Institut_id'],
                    implode("','", $this->config->getValue('Main', 'instperms')));
            }
            
           
            $state = DBManager::get()->prepare($query);
            $state->execute($parameters);
            while ($row_count = $state->fetch(PDO::FETCH_ASSOC)) {
            
                if ($row_count['count_user'] > 0) {
                    $content['LIST_INSTITUTES']['INSTITUTE'][] = array(
                        'INSTITUTE_NAME' => ExternModule::ExtHtmlReady($row['Name']),
                        'INSTITUTE_COUNT_USER' => $row_count['count_user'],
                        'URL_LIST_PERSONS' => $this->getLinkToModule('LinkInternListInstitutes', array('item_id' => $row['Institut_id'])));
                }
            }
        }
        
        return $content;
    }
Esempio n. 9
0
 function StudipLitClipBoard()
 {
     $this->dbv = DbView::getView('literatur');
     $this->elements =& $_SESSION["_lit_clipboard_elements"];
 }
Esempio n. 10
0
 function GetFormattedListsByRange($range_id, $last_modified_since = false, $copy_link = true){
     $ret = false;
     $dbv = DbView::getView('literatur');
     $tree = TreeAbstract::GetInstance("StudipLitList", $range_id);
     if ( ($lists = $tree->getVisibleListIds()) ){
         for ($i = 0; $i < count($lists); ++$i){
             if ( ($tree->tree_data[$lists[$i]]['user_id'] != $GLOBALS['auth']->auth['uid'])
             && ($last_modified_since !== false)
             && ($tree->tree_data[$lists[$i]]['chdate'] > $last_modified_since) ){
                 $ret .= '<div align="left" style="color:red" title="' . htmlReady(sprintf(_("Letzte Änderung am %s von %s"),
                 date('d M Y H:i',$tree->tree_data[$lists[$i]]['chdate']),
                 $tree->tree_data[$lists[$i]]['fullname'])) . '">';
                 $ret .=  "<b><u>" . htmlReady($tree->tree_data[$lists[$i]]['name']) . "</u></b>\n<br>\n";
                 $ret .= '</div>';
             } else {
                 $ret .= "\n<h3>" . htmlReady($tree->tree_data[$lists[$i]]['name']) . "</h3>";
             }
             if ($copy_link){
                 $ret .= "\n<div align=\"right\" style=\"font-size:10pt\"><a href=\"".URLHelper::getLink("dispatch.php/literature/edit_list?cmd=CopyUserList&_range_id=self&user_list=".$lists[$i]."#anchor")."\">";
                 $ret .= Icon::create('literature+add', 'clickable')->asImg(16, ["class" => 'text-top']);
                 $ret .= " " . _("Literaturliste kopieren") . "</a></div>";
             } else {
                 $ret .= "\n<br>\n";
             }
             $ret .= "\n<ul>\n";
             if ($tree->hasKids($lists[$i])){
                 $dbv->params[0] = $lists[$i];
                 $rs = $dbv->get_query("view:LIT_LIST_GET_ELEMENTS");
                 while ($rs->next_record()){
                     if ( ($tree->tree_data[$rs->f('list_element_id')]['user_id'] != $GLOBALS['auth']->auth['uid'])
                     && ($last_modified_since !== false)
                     && ($tree->tree_data[$rs->f('list_element_id')]['chdate'] > $last_modified_since) ){
                         $ret .= '<li style="color:red" title="' . htmlReady(sprintf(_("Letzte Änderung am %s von %s"),
                         date('d M Y H:i',$tree->tree_data[$rs->f('list_element_id')]['chdate']),
                         $tree->tree_data[$rs->f('list_element_id')]['fullname'])) . '">';
                         $ret .=  formatReady($tree->getFormattedEntry($rs->f('list_element_id'), $rs->Record), false, true) . "\n<br>\n";
                         $ret .= '</li>';
                     } else {
                         $ret .= "<li>".formatReady($tree->getFormattedEntry($rs->f('list_element_id'), $rs->Record), false, true) . "</li>";
                     }
                 }
             }
             $ret .= "\n</ul><br>";
         }
     }
     return $ret;
 }
 function getResult($level_id = null)
 {
     global $_fullname_sql, $SEM_TYPE, $SEM_CLASS;
     $add_fields = '';
     $add_query = '';
     $sem_tree_query = '';
     $limit_sql = '';
     $orderby_field = $this->config->getValue('Main', 'resultorderby') ? $this->config->getValue('Main', 'resultorderby') : 'VeranstaltungsNummer';
     if ($this->sem_browse_data['group_by'] == 1 || sizeof($this->config->getValue('SelectSubjectAreas', 'subjectareasselected')) && !($this->config->getValue('SelectSubjectAreas', 'selectallsubjectareas') || $this->sem_browse_data['start_item_id'] == 'root')) {
         if ($this->config->getValue('Main', 'mode') == 'show_sem_range' && $this->sem_browse_data['start_item_id'] != 'root') {
             $allowed_ranges = array();
             if (is_null($level_id)) {
                 if (!is_object($this->sem_tree)) {
                     $this->sem_tree = TreeAbstract::GetInstance('StudipSemTree');
                 }
                 if ($kids = $this->sem_tree->getKidsKids($this->sem_browse_data['start_item_id'])) {
                     $allowed_ranges = $kids;
                 }
                 $allowed_ranges[] = $this->sem_browse_data['start_item_id'];
             } else {
                 $allowed_ranges[] = $level_id;
             }
             if ($this->config->getValue('SelectSubjectAreas', 'selectallsubjectareas')) {
                 $sem_tree_query = " AND sem_tree_id IN('" . join("','", $allowed_ranges) . "') ";
             } elseif (is_array($this->config->getValue('SelectSubjectAreas', 'subjectareasselected'))) {
                 if ($this->config->getValue('SelectSubjectAreas', 'reverseselection')) {
                     $allowed_ranges = array_diff($allowed_ranges, $this->config->getValue('SelectSubjectAreas', 'subjectareasselected'));
                 } else {
                     $allowed_ranges = array_intersect($allowed_ranges, $this->config->getValue('SelectSubjectAreas', 'subjectareasselected'));
                 }
                 $sem_tree_query = " AND sem_tree_id IN('" . join("','", $allowed_ranges) . "') ";
             } else {
                 return array(array(), array());
             }
         }
         $add_fields = 'seminar_sem_tree.sem_tree_id AS bereich,';
         $add_query = "LEFT JOIN seminar_sem_tree ON (seminare.Seminar_id = seminar_sem_tree.seminar_id)";
     } else {
         if ($this->config->getValue('Main', 'maxnumberofhits')) {
             $limit_sql = ' ORDER BY sem_number DESC, ' . $orderby_field . ' ASC LIMIT ' . ($this->module_params['start'] ? intval($this->module_params['start']) : '0') . ',' . $this->config->getValue('Main', 'maxnumberofhits');
         }
     }
     if ($this->sem_browse_data['group_by'] == 4) {
         $add_fields = 'Institute.Name AS Institut,Institute.Institut_id,';
         $add_query = 'LEFT JOIN seminar_inst ON (seminare.Seminar_id = seminar_inst.Seminar_id)
         LEFT JOIN Institute ON (Institute.Institut_id = seminar_inst.institut_id)';
     }
     // show only selected SemTypes
     $selected_semtypes = $this->config->getValue('ReplaceTextSemType', 'visibility');
     $sem_types_array = array();
     if (count($selected_semtypes)) {
         for ($i = 0; $i < count($selected_semtypes); $i++) {
             if ($selected_semtypes[$i] == '1') {
                 $sem_types_array[] = $i + 1;
             }
         }
         $sem_types_query = "AND seminare.status IN ('" . implode("','", $sem_types_array) . "')";
     } else {
         $sem_types_query = '';
     }
     // participated institutes (or show only courses located at this faculty)
     /*
     $sem_inst_query = '';
     if (!$this->config->getValue('Main', 'allseminars')) {
         $tree = TreeAbstract::GetInstance('StudipRangeTree');
         $kidskids = $tree->getKidsKids($this->sem_browse_data['start_item_id']);
         $institute_ids = array($tree->tree_data[$this->sem_browse_data['start_item_id']]['studip_object_id']);
         foreach ($kidskids as $kid) {
             $institute_ids[] = $tree->tree_data[$kid]['studip_object_id'];
         }
         $sem_inst_query = " AND seminare.Institut_id IN ('" . join("','", $institute_ids) . "')";
     }
     */
     if (!($nameformat = $this->config->getValue('Main', 'nameformat'))) {
         $nameformat = 'full_rev';
     }
     $dbv = DbView::getView('sem_tree');
     $query = "SELECT seminare.Seminar_id, VeranstaltungsNummer, seminare.status, seminare.Untertitel, seminare.Ort, seminare.art, seminare.Beschreibung, seminare.ects, IF(seminare.visible=0,CONCAT(seminare.Name, ' " . _("(versteckt)") . "'), seminare.Name) AS Name,\n                {$add_fields}" . $_fullname_sql[$nameformat] . " AS fullname, auth_user_md5.username, title_front, title_rear, Vorname, Nachname,\n                " . $dbv->sem_number_sql . " AS sem_number, " . $dbv->sem_number_end_sql . " AS sem_number_end, seminar_user.position AS position FROM seminare\n                LEFT JOIN seminar_user ON (seminare.Seminar_id=seminar_user.Seminar_id AND seminar_user.status='dozent')\n                LEFT JOIN auth_user_md5 USING (user_id)\n                LEFT JOIN user_info USING (user_id)\n                {$add_query}\n                WHERE seminare.Seminar_id IN('" . join("','", array_keys($this->sem_browse_data['search_result'])) . "') {$sem_types_query} {$sem_inst_query} {$sem_tree_query} {$limit_sql}";
     $db = new DB_Seminar($query);
     if (!$db->num_rows()) {
         return array(array(), array());
     }
     $snap = new DbSnapshot($db);
     $group_field = $this->group_by_fields[$this->sem_browse_data['group_by']]['group_field'];
     $data_fields[0] = 'Seminar_id';
     if ($this->group_by_fields[$this->sem_browse_data['group_by']]['unique_field']) {
         $data_fields[1] = $this->group_by_fields[$this->sem_browse_data['group_by']]['unique_field'];
     }
     $group_by_data = $snap->getGroupedResult($group_field, $data_fields);
     $sem_data = $snap->getGroupedResult('Seminar_id');
     if ($this->sem_browse_data['group_by'] == 0) {
         $semester = SemesterData::GetSemesterArray();
         $group_by_duration = $snap->getGroupedResult('sem_number_end', array('sem_number', 'Seminar_id'));
         foreach ($group_by_duration as $sem_number_end => $detail) {
             if ($sem_number_end != -1 && ($detail['sem_number'][$sem_number_end] && count($detail['sem_number']) == 1)) {
                 continue;
             } else {
                 foreach ($detail['Seminar_id'] as $seminar_id => $foo) {
                     $start_sem = key($sem_data[$seminar_id]['sem_number']);
                     if ($sem_number_end == -1) {
                         $sem_number_end = count($semester) - 1;
                     }
                     for ($i = $start_sem; $i <= $sem_number_end; ++$i) {
                         if ($this->sem_number === false || is_array($this->sem_number) && in_array($i, $this->sem_number)) {
                             if ($group_by_data[$i] && !$tmp_group_by_data[$i]) {
                                 foreach ($group_by_data[$i]['Seminar_id'] as $id => $bar) {
                                     $tmp_group_by_data[$i]['Seminar_id'][$id] = true;
                                 }
                             }
                             $tmp_group_by_data[$i]['Seminar_id'][$seminar_id] = true;
                         }
                     }
                 }
             }
         }
         if (is_array($tmp_group_by_data)) {
             if ($this->sem_number !== false) {
                 unset($group_by_data);
             }
             foreach ($tmp_group_by_data as $start_sem => $detail) {
                 $group_by_data[$start_sem] = $detail;
             }
         }
     }
     //release memory
     unset($snap);
     unset($tmp_group_by_data);
     foreach ($group_by_data as $group_field => $sem_ids) {
         foreach ($sem_ids['Seminar_id'] as $seminar_id => $foo) {
             if ($orderby_field) {
                 $name = strtolower(key($sem_data[$seminar_id][$orderby_field]));
             } else {
                 $name = strtolower(key($sem_data[$seminar_id]["VeranstaltungsNummer"]));
             }
             $name = str_replace(array('ä', 'ö', 'ü'), array('ae', 'oe', 'ue'), $name);
             $group_by_data[$group_field]['Seminar_id'][$seminar_id] = $name;
         }
         uasort($group_by_data[$group_field]['Seminar_id'], 'strnatcmp');
     }
     switch ($this->sem_browse_data['group_by']) {
         case 0:
             krsort($group_by_data, SORT_NUMERIC);
             break;
         case 1:
             uksort($group_by_data, create_function('$a,$b', '$the_tree = TreeAbstract::GetInstance("StudipSemTree", false);
         $the_tree->buildIndex();
         return (int)($the_tree->tree_data[$a]["index"] - $the_tree->tree_data[$b]["index"]);
         '));
             break;
         case 3:
             uksort($group_by_data, create_function('$a,$b', 'global $SEM_CLASS,$SEM_TYPE;
         return strnatcasecmp($SEM_TYPE[$a]["name"]." (". $SEM_CLASS[$SEM_TYPE[$a]["class"]]["name"].")",
         $SEM_TYPE[$b]["name"]." (". $SEM_CLASS[$SEM_TYPE[$b]["class"]]["name"].")");'));
             break;
         default:
             uksort($group_by_data, 'strnatcasecmp');
             break;
     }
     return array($group_by_data, $sem_data);
 }
Esempio n. 12
0
    function print_result () {
        global $_fullname_sql,$SEM_TYPE,$SEM_CLASS,$sem_type_tmp;
        
        $sem_link = $this->module->getModuleLink("Lecturedetails",
            $this->module->config->getValue("SemLink", "config"),
            $this->module->config->getValue("SemLink", "srilink"));
        
        $lecturer_link = $this->module->getModuleLink("Persondetails",
            $this->module->config->getValue("LecturerLink", "config"),
            $this->module->config->getValue("LecturerLink", "srilink"));
        
        if (is_array($this->sem_browse_data['search_result']) && count($this->sem_browse_data['search_result'])) {
            
            // show only selected subject areas
            $selected_ranges = $this->module->config->getValue('SelectSubjectAreas', 'subjectareasselected');
            if ($stid = Request::option('sem_tree_id')) {
                if (!is_object($this->sem_tree)){
                    $the_tree = TreeAbstract::GetInstance("StudipSemTree");
                } else {
                    $the_tree =& $this->sem_tree->tree;
                }
                $the_tree->buildIndex();
                $selected_ranges = array_merge(array($stid), $the_tree->getKidsKids($stid));
            }
            if (!$this->module->config->getValue('SelectSubjectAreas', 'selectallsubjectareas')
                    && count($selected_ranges)) {
                if ($this->module->config->getValue('SelectSubjectAreas', 'reverseselection')) {
                    $sem_range_query =  "AND seminar_sem_tree.sem_tree_id NOT IN ('".implode("','", $selected_ranges)."')";
                } else {
                    $sem_range_query =  "AND seminar_sem_tree.sem_tree_id IN ('".implode("','", $selected_ranges)."')";
                }
            } else {
                $sem_range_query = '';
            }
            
            // show only selected SemTypes
            $selected_semtypes = $this->module->config->getValue('ReplaceTextSemType', 'visibility');
            if (Request::get('semstatus')) {
                $selected_semtypes = array(Request::get('semstatus'));
            }
            $sem_types_array = array();
            if (count($selected_semtypes)) {
                for ($i = 0; $i < count($selected_semtypes); $i++) {
                    if ($selected_semtypes[$i] == '1') {
                        $sem_types_array[] = $i + 1;
                    }
                }
                $sem_types_query = "AND seminare.status IN ('" . implode("','", $sem_types_array) . "')";
            } else {
                $sem_types_query = '';
            }
            
            // number of visible columns
            $group_colspan = array_count_values($this->module->config->getValue("Main", "visible"));
            
            if ($this->sem_browse_data['group_by'] == 1){
                if (!is_object($this->sem_tree)){
                    $the_tree = TreeAbstract::GetInstance("StudipSemTree");
                } else {
                    $the_tree =& $this->sem_tree->tree;
                }
            $the_tree->buildIndex();
            }
            
            if (!$this->module->config->getValue("Main", "allseminars") && !Request::get('allseminars')){
                $sem_inst_query = " AND seminare.Institut_id='{$this->module->config->range_id}' ";
            }
            if (Request::option('aggregation')) {
                $i = Institute::find($this->config->range_id);
                $children = $i->sub_institutes->pluck('institut_id');
                $sem_inst_query = " AND seminare.Institut_id IN ('".(implode("', '", $children))."')";
            }
            if (!$nameformat = $this->module->config->getValue("Main", "nameformat"))
                $nameformat = "no_title_short";
            
            $dbv = DbView::getView('sem_tree');
                
            $query = "SELECT seminare.* 
                , Institute.Name AS Institut,Institute.Institut_id,
                seminar_sem_tree.sem_tree_id AS bereich, " . $_fullname_sql[$nameformat] ." AS fullname, auth_user_md5.username,
                " . $dbv->sem_number_sql . " AS sem_number, " . $dbv->sem_number_end_sql . " AS sem_number_end, " . 
            " seminar_user.position AS position " . 
            " FROM seminare 
                LEFT JOIN seminar_user ON (seminare.Seminar_id=seminar_user.Seminar_id AND seminar_user.status='dozent') 
                LEFT JOIN auth_user_md5 USING (user_id) 
                LEFT JOIN user_info USING (user_id) 
                LEFT JOIN seminar_sem_tree ON (seminare.Seminar_id = seminar_sem_tree.seminar_id)
                LEFT JOIN seminar_inst ON (seminare.Seminar_id = seminar_inst.Seminar_id) 
                LEFT JOIN Institute ON (seminar_inst.institut_id = Institute.Institut_id)
                WHERE seminare.Seminar_id IN('" . join("','", array_keys($this->sem_browse_data['search_result']))
                 . "') $sem_inst_query $sem_range_query $sem_types_query";
            
            $db = new DB_Seminar($query);
            $snap = new DbSnapshot($db);
            $group_field = $this->group_by_fields[$this->sem_browse_data['group_by']]['group_field'];
            $data_fields[0] = "Seminar_id";
            if ($this->group_by_fields[$this->sem_browse_data['group_by']]['unique_field']){
                $data_fields[1] = $this->group_by_fields[$this->sem_browse_data['group_by']]['unique_field'];
            }
            $group_by_data = $snap->getGroupedResult($group_field, $data_fields);
            $sem_data = $snap->getGroupedResult("Seminar_id");
            if ($this->sem_browse_data['group_by'] == 0){
                $group_by_duration = $snap->getGroupedResult("sem_number_end", array("sem_number","Seminar_id"));
                foreach ($group_by_duration as $sem_number_end => $detail){
                    if ($sem_number_end != -1 && ($detail['sem_number'][$sem_number_end - 1] && count($detail['sem_number']) == 1)){
                        continue;
                    } else {
                        foreach ($detail['Seminar_id'] as $seminar_id => $foo){
                            $start_sem = key($sem_data[$seminar_id]["sem_number"]);
                            if ($sem_number_end == -1){
                                if (is_array($this->sem_number)){
                                    $sem_number_end = $this->sem_number[0];
                                } else {
                                    $sem_number_end = count($this->sem_dates)-1;
                                }
                            }
                            for ($i = $start_sem; $i <= $sem_number_end; ++$i){
                                if ($this->sem_number === false || (is_array($this->sem_number) && in_array($i,$this->sem_number))){
                                    if ($group_by_data[$i] && !$tmp_group_by_data[$i]){
                                        foreach($group_by_data[$i]['Seminar_id'] as $id => $bar){
                                            $tmp_group_by_data[$i]['Seminar_id'][$id] = true;
                                        }
                                    }
                                    $tmp_group_by_data[$i]['Seminar_id'][$seminar_id] = true;
                                }
                            }
                        }
                    }
                }
                if (is_array($tmp_group_by_data)){
                    if ($this->sem_number !== false){
                        unset($group_by_data);
                    }
                    foreach ($tmp_group_by_data as $start_sem => $detail){
                        $group_by_data[$start_sem] = $detail;
                    }
                }
            }
            //release memory
            unset($snap);
            unset($tmp_group_by_data);
            
            foreach ($group_by_data as $group_field => $sem_ids){
                foreach ($sem_ids['Seminar_id'] as $seminar_id => $foo){
                    $name = strtolower(key($sem_data[$seminar_id]["Name"]));
                    $name = str_replace("ä","ae",$name);
                    $name = str_replace("ö","oe",$name);
                    $name = str_replace("ü","ue",$name);
                    $group_by_data[$group_field]['Seminar_id'][$seminar_id] = $name;
                }
                uasort($group_by_data[$group_field]['Seminar_id'], 'strnatcmp');
            }
            
            switch ($this->sem_browse_data["group_by"]){
                    case 0:
                    krsort($group_by_data, SORT_NUMERIC);
                    break;
                    
                    case 1:
                    uksort($group_by_data, create_function('$a,$b',
                            '$the_tree = TreeAbstract::GetInstance("StudipSemTree");
                            return (int)($the_tree->tree_data[$a]["index"] - $the_tree->tree_data[$b]["index"]);
                            '));
                    break;
                    
                    case 3:
                    if ($order = $this->module->config->getValue("ReplaceTextSemType", "order")) {
                        foreach ($order as $position) {
                            if (isset($group_by_data[$position]))
                                $group_by_data_tmp[$position] = $group_by_data[$position];
                        }
                        $group_by_data = $group_by_data_tmp;
                        unset($group_by_data_tmp);
                    }
                    else {
                        uksort($group_by_data, create_function('$a,$b',
                                'global $SEM_CLASS,$SEM_TYPE;
                                return strnatcasecmp($SEM_TYPE[$a]["name"]." (". $SEM_CLASS[$SEM_TYPE[$a]["class"]]["name"].")",
                                                $SEM_TYPE[$b]["name"]." (". $SEM_CLASS[$SEM_TYPE[$b]["class"]]["name"].")");'));
                    }
                    break;
                    default:
                    uksort($group_by_data, 'strnatcasecmp');
                    break;
                    
            }
            
            // generic datafields
            $generic_datafields = $this->module->config->getValue("Main", "genericdatafields");
//              $datafields_obj = new DataFields();
            
            if ($this->module->config->getValue("Main", "addinfo")) {
                $info = "&nbsp;" . count($sem_data);
                $info .= $this->module->config->getValue("Main", "textlectures");
                $info .= ", " . $this->module->config->getValue("Main", "textgrouping");
                $group_by_name = $this->module->config->getValue("Main", "aliasesgrouping");
                $info .= $group_by_name[$this->sem_browse_data['group_by']];
                $out = $this->module->elements["InfoCountSem"]->toString(array("content" => $info));
            }
            else
                $out = "";
            
            $first_loop = TRUE;
            $repeat_headrow = $this->module->config->getValue("Main", "repeatheadrow");
            foreach ($group_by_data as $group_field => $sem_ids) {
                
                $group_content = $this->getGroupContent($the_tree, $group_field);
                
                if ($repeat_headrow == "beneath") {
                    $out .= $this->module->elements["Grouping"]->toString(array("content" => $group_content));
                    $out .= $this->module->elements["TableHeadrow"]->toString();
                }
    
                if($first_loop && $repeat_headrow != "beneath")
                    $out .= $this->module->elements["TableHeadrow"]->toString();
    
                if ($repeat_headrow != "beneath") {
                    if ($repeat_headrow && !$first_loop)
                        $out .= $this->module->elements["TableHeadrow"]->toString();
                    $out .= $this->module->elements["Grouping"]->toString(array("content" => $group_content));
                }
                $first_loop = FALSE;
                                
                if (is_array($sem_ids['Seminar_id'])) {
                    $zebra = 0;
                    while (list($seminar_id,) = each($sem_ids['Seminar_id'])) {
                                                
                        $sem_name = key($sem_data[$seminar_id]["Name"]);
                        $sem_number_start = key($sem_data[$seminar_id]["sem_number"]);
                        $sem_number_end = key($sem_data[$seminar_id]["sem_number_end"]);
                        if ($sem_number_start != $sem_number_end){
                            $sem_name .= " (" . $this->sem_dates[$sem_number_start]['name'] . " - ";
                            $sem_name .= (($sem_number_end == -1) ? _("unbegrenzt") : $this->sem_dates[$sem_number_end]['name']) . ")";
                        }
                        
                        //create Turnus field
                        $data["content"]["zeiten"] = Seminar::GetInstance($seminar_id)->getDatesExport(array('show_room' => true));
                        //Shorten, if string too long
                        if (strlen($data["content"]["zeiten"]) >70) {
                            $data["content"]["zeiten"] = substr($data["content"]["zeiten"], 0,
                                    strpos(substr($data["content"]["zeiten"], 70, strlen($data["content"]["zeiten"])), ",") +71);
                            $data["content"]["zeiten"] .= "...";
                        }
                        $data["content"]["zeiten"] = htmlReady($data["content"]["zeiten"]);
                        $doz_position = array_keys($sem_data[$seminar_id]['position']);
                        $doz_name = array_keys($sem_data[$seminar_id]['fullname']);
                        $doz_uname = array_keys($sem_data[$seminar_id]['username']);
                        if (is_array($doz_name)){
                            if(count($doz_position) != count($doz_uname)) $doz_position = range(1, count($doz_uname));
                     array_multisort($doz_position, $doz_name, $doz_uname);
                            $data["content"]["dozent"] = "";
                            $i = 0;
                            foreach ($doz_name as $index => $value) {
                                if ($i == 4) {
                                    $data["content"]["dozent"] .= $this->module->elements["LecturerLink"]->toString(
                                        array("module" => "Lecturedetails", "link_args" => "seminar_id=$seminar_id",
                                        "content" => "..."));
                                    break;
                                }
                                $data["content"]["dozent"] .= $this->module->elements["LecturerLink"]->toString(
                                        array("module" => "Persondetails", "link_args" => "username="******"&seminar_id=$seminar_id",
                                        "content" =>  htmlReady($value)));
                                if ($i != count($doz_name) - 1) {
                                    $data["content"]["dozent"] .= ", ";
                                }
                                ++$i;
                            }
                        }
                        
                        $data["content"]["Name"] = $this->module->elements["SemLink"]->toString(
                                array("module" => "Lecturedetails", "link_args" => "seminar_id=$seminar_id",
                                "content" => htmlReady($sem_name)));
                        $data["content"]["VeranstaltungsNummer"] =
                                htmlReady(key($sem_data[$seminar_id]["VeranstaltungsNummer"]));
                        $data["content"]["Untertitel"] = htmlReady(key($sem_data[$seminar_id]["Untertitel"]));
                        
                        $aliases_sem_type = $this->module->config->getValue("ReplaceTextSemType",
                                "class_" . $SEM_TYPE[key($sem_data[$seminar_id]["status"])]['class']);
                        if ($aliases_sem_type[$this->sem_types_position[key($sem_data[$seminar_id]["status"])] - 1]) {
                            $data["content"]["status"] =
                                    $aliases_sem_type[$this->sem_types_position[key($sem_data[$seminar_id]["status"])] - 1];
                        }
                        else {
                            $data["content"]["status"] =
                                    htmlReady($SEM_TYPE[key($sem_data[$seminar_id]["status"])]["name"]
                                    ." (". $SEM_CLASS[$SEM_TYPE[key($sem_data[$seminar_id]["status"])]["class"]]["name"].")");
                        }
                        
                        $data["content"]["Ort"] = Seminar::getInstance($seminar_id)->getDatesTemplate('dates/seminar_export_location');
                        if ($sem_data[$seminar_id]["art"])
                            $data["content"]["art"] = htmlReady(key($sem_data[$seminar_id]["art"]));
                        else
                            $data["content"]["art"] = "";
                        
                        // generic data fields
                        if (is_array($generic_datafields)) {
                            $localEntries = DataFieldEntry::getDataFieldEntries($seminar_id);
                            foreach ($generic_datafields as $id) {
                                if (isset($localEntries[$id]) && is_object($localEntries[$id])) {
                                    $data["content"][$id] = $localEntries[$id]->getDisplayValue();
                                }
                            }
                        }
                        
                        $data["data_fields"] = $this->module->data_fields;
                        $out .= $this->module->elements["TableRow"]->toString($data);
                    }
                }
            }
            ob_end_clean();
            $this->module->elements["TableHeader"]->printout(array("content" => $out));
        }
    }
 function isItemAdmin($item_id){
     global $auth;
     if ($auth->auth['perm'] == "root"){
         return true;
     }
     if (!($admin_id = $this->tree->tree_data[$this->tree->getAdminRange($item_id)]['studip_object_id'])){
         return false;
     }
     if(!isset($this->admin_ranges[$admin_id])){
         $view = DbView::getView('sem_tree');
         $view->params[0] = $auth->auth['uid'];
         $view->params[1] = $admin_id;
         $rs = $view->get_query("view:SEM_TREE_CHECK_PERM");
         $this->admin_ranges[$admin_id] = ($rs->next_record()) ? true : false;
     }
     if ($this->admin_ranges[$admin_id]){
         return true;
     } else {
         return false;
     }
 }
Esempio n. 14
0
 function get_result()
 {
     global $_fullname_sql, $SEM_TYPE, $SEM_CLASS;
     if ($this->sem_browse_data['group_by'] == 1) {
         if (!is_object($this->sem_tree)) {
             $the_tree = TreeAbstract::GetInstance("StudipSemTree", false);
         } else {
             $the_tree = $this->sem_tree->tree;
         }
         if ($this->sem_browse_data['start_item_id'] != 'root' && ($this->sem_browse_data['level'] == "vv" || $this->sem_browse_data['level'] == "sbb")) {
             $allowed_ranges = $the_tree->getKidsKids($this->sem_browse_data['start_item_id']);
             $allowed_ranges[] = $this->sem_browse_data['start_item_id'];
             $sem_tree_query = " AND sem_tree_id IN('" . join("','", $allowed_ranges) . "') ";
         }
         $add_fields = "seminar_sem_tree.sem_tree_id AS bereich,";
         $add_query = "LEFT JOIN seminar_sem_tree ON (seminare.Seminar_id = seminar_sem_tree.seminar_id {$sem_tree_query})";
     } else {
         if ($this->sem_browse_data['group_by'] == 4) {
             $add_fields = "Institute.Name AS Institut,Institute.Institut_id,";
             $add_query = "LEFT JOIN seminar_inst ON (seminare.Seminar_id = seminar_inst.Seminar_id)\n            LEFT JOIN Institute ON (Institute.Institut_id = seminar_inst.institut_id)";
         } else {
             $add_fields = "";
             $add_query = "";
         }
     }
     $dbv = DbView::getView('sem_tree');
     $query = "SELECT seminare.Seminar_id,VeranstaltungsNummer, seminare.status, IF(seminare.visible=0,CONCAT(seminare.Name, ' " . _("(versteckt)") . "'), seminare.Name) AS Name,\n                {$add_fields}" . $_fullname_sql['full'] . " AS fullname, auth_user_md5.username,\n                " . $dbv->sem_number_sql . " AS sem_number, " . $dbv->sem_number_end_sql . " AS sem_number_end, seminar_user.position AS position FROM seminare\n                LEFT JOIN seminar_user ON (seminare.Seminar_id=seminar_user.Seminar_id AND seminar_user.status='dozent')\n                LEFT JOIN auth_user_md5 USING (user_id)\n                LEFT JOIN user_info USING (user_id)\n                {$add_query}\n                WHERE seminare.Seminar_id IN('" . join("','", array_keys($this->sem_browse_data['search_result'])) . "')";
     $db = new DB_Seminar($query);
     $snap = new DbSnapshot($db);
     $group_field = $this->group_by_fields[$this->sem_browse_data['group_by']]['group_field'];
     $data_fields[0] = "Seminar_id";
     if ($this->group_by_fields[$this->sem_browse_data['group_by']]['unique_field']) {
         $data_fields[1] = $this->group_by_fields[$this->sem_browse_data['group_by']]['unique_field'];
     }
     $group_by_data = $snap->getGroupedResult($group_field, $data_fields);
     $sem_data = $snap->getGroupedResult("Seminar_id");
     if ($this->sem_browse_data['group_by'] == 0) {
         $group_by_duration = $snap->getGroupedResult("sem_number_end", array("sem_number", "Seminar_id"));
         foreach ($group_by_duration as $sem_number_end => $detail) {
             if ($sem_number_end != -1 && ($detail['sem_number'][$sem_number_end] && count($detail['sem_number']) == 1)) {
                 continue;
             } else {
                 $current_semester_index = SemesterData::GetInstance()->GetSemesterIndexById(Semester::findCurrent()->semester_id);
                 foreach ($detail['Seminar_id'] as $seminar_id => $foo) {
                     $start_sem = key($sem_data[$seminar_id]["sem_number"]);
                     if ($sem_number_end == -1) {
                         if ($this->sem_number === false) {
                             $sem_number_end = $current_semester_index && isset($this->search_obj->sem_dates[$current_semester_index + 1]) ? $current_semester_index + 1 : count($this->search_obj->sem_dates) - 1;
                         } else {
                             $sem_number_end = $this->sem_number[0];
                         }
                     }
                     for ($i = $start_sem; $i <= $sem_number_end; ++$i) {
                         if ($this->sem_number === false || is_array($this->sem_number) && in_array($i, $this->sem_number)) {
                             if ($group_by_data[$i] && !$tmp_group_by_data[$i]) {
                                 foreach ($group_by_data[$i]['Seminar_id'] as $id => $bar) {
                                     $tmp_group_by_data[$i]['Seminar_id'][$id] = true;
                                 }
                             }
                             $tmp_group_by_data[$i]['Seminar_id'][$seminar_id] = true;
                         }
                     }
                 }
             }
         }
         if (is_array($tmp_group_by_data)) {
             if ($this->sem_number !== false) {
                 unset($group_by_data);
             }
             foreach ($tmp_group_by_data as $start_sem => $detail) {
                 $group_by_data[$start_sem] = $detail;
             }
         }
     }
     //release memory
     unset($snap);
     unset($tmp_group_by_data);
     foreach ($group_by_data as $group_field => $sem_ids) {
         foreach ($sem_ids['Seminar_id'] as $seminar_id => $foo) {
             $name = strtolower(key($sem_data[$seminar_id]["Name"]));
             $name = str_replace("ä", "ae", $name);
             $name = str_replace("ö", "oe", $name);
             $name = str_replace("ü", "ue", $name);
             if (Config::get()->IMPORTANT_SEMNUMBER && key($sem_data[$seminar_id]['VeranstaltungsNummer'])) {
                 $name = key($sem_data[$seminar_id]['VeranstaltungsNummer']) . ' ' . $name;
             }
             $group_by_data[$group_field]['Seminar_id'][$seminar_id] = $name;
         }
         uasort($group_by_data[$group_field]['Seminar_id'], 'strnatcmp');
     }
     switch ($this->sem_browse_data["group_by"]) {
         case 0:
             krsort($group_by_data, SORT_NUMERIC);
             break;
         case 1:
             uksort($group_by_data, create_function('$a,$b', '$the_tree = TreeAbstract::GetInstance("StudipSemTree", false);
         $the_tree->buildIndex();
         return (int)($the_tree->tree_data[$a]["index"] - $the_tree->tree_data[$b]["index"]);
         '));
             break;
         case 3:
             uksort($group_by_data, create_function('$a,$b', 'global $SEM_CLASS,$SEM_TYPE;
         return strnatcasecmp($SEM_TYPE[$a]["name"]." (". $SEM_CLASS[$SEM_TYPE[$a]["class"]]["name"].")",
         $SEM_TYPE[$b]["name"]." (". $SEM_CLASS[$SEM_TYPE[$b]["class"]]["name"].")");'));
             break;
         default:
             uksort($group_by_data, 'strnatcasecmp');
             break;
     }
     return array($group_by_data, $sem_data);
 }
 function getItemContent($item_id)
 {
     if ($item_id == $this->edit_item_id) {
         return $this->getEditItemContent();
     }
     if ($item_id == $this->move_item_id) {
         $this->msg[$item_id] = "info§" . sprintf(_("Dieses Element wurde zum Verschieben markiert. Bitte wählen Sie ein Einfügesymbol %s aus, um das Element zu verschieben."), Icon::create('arr_2right', 'sort', ['title' => "Einfügesymbol"])->asImg(16, ["alt" => "Einfügesymbol"]));
     }
     $content = "\n<table width=\"90%\" cellpadding=\"2\" cellspacing=\"2\" align=\"center\" style=\"font-size:10pt\">";
     $content .= $this->getItemMessage($item_id);
     $content .= "\n<tr><td align=\"center\">";
     if ($this->isItemAdmin($item_id)) {
         $content .= LinkButton::create(_("Neues Objekt"), URLHelper::getURL($this->getSelf("cmd=NewItem&item_id={$item_id}")), array('title' => _("Innerhalb dieser Ebene ein neues Element einfügen")));
     }
     if ($this->isParentAdmin($item_id) && $item_id != $this->start_item_id && $item_id != "root") {
         $content .= LinkButton::create(_("Bearbeiten"), URLHelper::getURL($this->getSelf("cmd=EditItem&item_id={$item_id}")));
         $content .= LinkButton::create(_("Löschen"), URLHelper::getURL($this->getSelf("cmd=AssertDeleteItem&item_id={$item_id}")));
         if ($this->move_item_id == $item_id && $this->mode == "MoveItem") {
             $content .= LinkButton::create(_("Abbrechen"), URLHelper::getURL($this->getSelf("cmd=Cancel&item_id={$item_id}")));
         } else {
             $content .= LinkButton::create(_("Verschieben"), URLHelper::getURL($this->getSelf("cmd=MoveItem&item_id={$item_id}")));
         }
     }
     $content .= "</td></tr></table>";
     $content .= "\n<table width=\"90%\" cellpadding=\"2\" cellspacing=\"2\" align=\"center\" style=\"font-size:10pt\">";
     if ($item_id == "root") {
         if ($this->isItemAdmin($item_id)) {
             $view = DbView::getView('range_tree');
             $rs = $view->get_query("SELECT i1.Name,i1.Institut_id,COUNT(i2.Institut_id) as num FROM Institute i1 LEFT JOIN Institute i2 ON i1.Institut_id = i2.fakultaets_id AND i2.fakultaets_id<>i2.Institut_id WHERE i1.fakultaets_id=i1.Institut_id GROUP BY i1.Institut_id ORDER BY Name");
             $content .= "\n<tr><td align=\"center\">";
             $content .= "\n<form action=\"" . URLHelper::getLink($this->getSelf("cmd=InsertFak")) . "\" method=\"post\">" . CSRFProtection::tokenTag() . _("Stud.IP Fakultät einfügen:") . "&nbsp;\n<select style=\"width:300px;vertical-align:middle;\" name=\"insert_fak\">";
             while ($rs->next_record()) {
                 $content .= "\n<option value=\"" . $rs->f("Institut_id") . "\">" . htmlReady(my_substr($rs->f("Name") . '(' . $rs->f('num') . ')', 0, 60)) . "</option>";
             }
             $content .= "</select>" . Button::create(_("Fakultät einfügen")) . "</form>";
             $content .= " </td></tr>";
         }
         $content .= "\n<tr><td class=\"table_header_bold\" align=\"left\">" . htmlReady($this->tree->root_name) . " </td></tr>";
         $content .= "\n<tr><td class=\"blank\" align=\"left\">" . htmlReady($this->root_content) . " </td></tr>";
         $content .= "\n</table>";
         return $content;
     }
     $range_object = RangeTreeObject::GetInstance($item_id);
     $name = $range_object->item_data['type'] ? $range_object->item_data['type'] . ": " : "";
     $name .= $range_object->item_data['name'];
     $content .= "\n<tr><td class=\"table_header_bold\" align=\"left\" style=\"font-size:10pt\">" . htmlReady($name) . " </td></tr>";
     if (is_array($range_object->item_data_mapping)) {
         $content .= "\n<tr><td class=\"blank\" align=\"left\" style=\"font-size:10pt\">";
         foreach ($range_object->item_data_mapping as $key => $value) {
             if ($range_object->item_data[$key]) {
                 $content .= "<b>" . htmlReady($value) . ":</b>&nbsp;";
                 $content .= formatLinks($range_object->item_data[$key]) . "&nbsp; ";
             }
         }
         $content .= "&nbsp;";
     } elseif (!$range_object->item_data['studip_object']) {
         $content .= "\n<tr><td class=\"blank\" align=\"left\" style=\"font-size:10pt\">" . _("Dieses Element ist keine Stud.IP-Einrichtung, es hat daher keine Grunddaten.");
     } else {
         $content .= "\n<tr><td class=\"blank\" align=\"left\" style=\"font-size:10pt\">" . _("Keine Grunddaten vorhanden!");
     }
     $content .= "\n<div class=\"blank\" align=\"left\" style=\"font-size:10pt\"><b>" . _("Mitarbeiter:") . "</b> " . $range_object->getNumStaff() . "</b></div>";
     if ($this->isItemAdmin($item_id) && $range_object->item_data['studip_object']) {
         $content .= "\n<div class=\"blank\" align=\"center\" style=\"font-size:10pt\">";
         $content .= LinkButton::create(_("Grunddaten in Stud.IP bearbeiten"), "dispatch.php/institute/basicdata/index?admin_inst_id=" . $range_object->item_data['studip_object_id']);
         $content .= "</div>";
     }
     $content .= "</td></tr><tr><td>&nbsp;</td></tr>";
     if ($this->mode == "NewCat" && $this->edit_cat_item_id == $item_id) {
         $categories =& $this->edit_cat_snap;
     } else {
         $categories =& $range_object->getCategories();
     }
     if (!$this->isItemAdmin($item_id)) {
         if ($categories->numRows) {
             while ($categories->nextRow()) {
                 $content .= "\n<tr><td class=\"table_header_bold\" style=\"font-size:10pt\">" . formatReady($categories->getField("name")) . "</td></tr>";
                 $content .= "\n<tr><td class=\"blank\" style=\"font-size:10pt\">" . formatReady($categories->getField("content")) . "</td></tr>";
             }
         } else {
             $content .= "\n<tr><td class=\"blank\" style=\"font-size:10pt\">" . _("Keine weiteren Daten vorhanden!") . "</td></tr>";
         }
     } else {
         $content .= "<tr><td class=\"blank\" style=\"font-size:10pt\">" . $this->getEditCatContent($item_id, $categories) . "</td></tr>";
     }
     $content .= "</table>";
     return $content;
 }
Esempio n. 16
0
 /**
  * Display the notification settings of a user.
  */
 public function index_action()
 {
     $group_field = UserConfig::get($this->user->user_id)->MY_COURSES_GROUPING ?: 'not_grouped';
     $add_fields = $add_query = '';
     if ($group_field == 'sem_tree_id') {
         $add_fields = ',sem_tree_id';
         $add_query = "LEFT JOIN seminar_sem_tree sst ON (sst.seminar_id=seminare.Seminar_id)";
     } else {
         if ($group_field == 'dozent_id') {
             $add_fields = ', su1.user_id as dozent_id';
             $add_query = "LEFT JOIN seminar_user as su1 ON (su1.seminar_id=seminare.Seminar_id AND su1.status='dozent')";
         }
     }
     $dbv = DbView::getView('sem_tree');
     $query = "SELECT seminare.VeranstaltungsNummer AS sem_nr, seminare.Name, seminare.Seminar_id,\n                         seminare.status AS sem_status, seminar_user.gruppe, seminare.visible,\n                         {$dbv->sem_number_sql} AS sem_number, {$dbv->sem_number_end_sql} AS sem_number_end\n                         {$add_fields}\n                  FROM seminar_user\n                  LEFT JOIN seminare  USING (Seminar_id)\n                  {$add_query}\n                  WHERE seminar_user.user_id = ?";
     if (get_config('DEPUTIES_ENABLE')) {
         $query .= " UNION " . getMyDeputySeminarsQuery('notification', $dbv->sem_number_sql, $dbv->sem_number_end_sql, $add_fields, $add_query);
     }
     $query .= " ORDER BY sem_nr ASC";
     $statement = DBManager::get()->prepare($query);
     $statement->execute(array($this->user->user_id));
     $seminars = $statement->fetchAll(PDO::FETCH_ASSOC);
     if (!count($seminars)) {
         $message = sprintf(_('Sie haben zur Zeit keine Veranstaltungen belegt. Bitte nutzen Sie %s<b>Veranstaltung suchen / hinzufügen</b>%s um sch für Veranstaltungen anzumdelden.'), '<a href="' . URLHelper::getLink('dispatch.php/search/courses') . '">', '</a>');
         PageLayout::postMessage(MessageBox::info($message));
         $this->set_layout($GLOBALS['template_factory']->open('layouts/base_without_infobox'));
         $this->render_nothing();
         return;
     }
     $modules = new ModulesNotification();
     $enabled_modules = $modules->getGlobalEnabledNotificationModules('sem');
     $groups = array();
     $my_sem = array();
     foreach ($seminars as $seminar) {
         $my_sem[$seminar['Seminar_id']] = array('obj_type' => "sem", 'sem_nr' => $seminar['sem_nr'], 'name' => $seminar['Name'], 'visible' => $seminar['visible'], 'gruppe' => $seminar['gruppe'], 'sem_status' => $seminar['sem_status'], 'sem_number' => $seminar['sem_number'], 'sem_number_end' => $seminar['sem_number_end']);
         if ($group_field) {
             fill_groups($groups, $seminar[$group_field], array('seminar_id' => $seminar['Seminar_id'], 'sem_nr' => $seminar['sem_nr'], 'name' => $seminar['Name'], 'gruppe' => $seminar['gruppe']));
         }
     }
     if ($group_field == 'sem_number') {
         correct_group_sem_number($groups, $my_sem);
     } else {
         add_sem_name($my_sem);
     }
     sort_groups($group_field, $groups);
     $group_names = get_group_names($group_field, $groups);
     $notifications = $modules->getModuleNotification();
     $open = UserConfig::get($this->user->user_id)->MY_COURSES_OPEN_GROUPS;
     $checked = array();
     foreach ($groups as $group_id => $group_members) {
         if ($group_id !== 'not_grouped' && !isset($open[$group_id])) {
             continue;
         }
         foreach ($group_members as $member) {
             $checked[$member['seminar_id']] = array();
             foreach (array_values($enabled_modules) as $index => $m_data) {
                 $checked[$member['seminar_id']][$index] = $modules->isBit($notifications[$member['seminar_id']], $m_data['id']);
             }
             $checked[$member['seminar_id']]['all'] = count($enabled_modules) === count(array_filter($checked[$member['seminar_id']]));
         }
     }
     $this->modules = $enabled_modules;
     $this->groups = $groups;
     $this->group_names = $group_names;
     $this->group_field = $group_field;
     $this->open = $open;
     $this->seminars = $my_sem;
     $this->notifications = $modules->getModuleNotification();
     $this->checked = $checked;
 }
Esempio n. 17
0
 /**
  * Seminar group administration - cluster your seminars by colors or
  * change grouping mechanism
  */
 public function groups_action($sem = null, $studygroups = false)
 {
     if ($GLOBALS['perm']->have_perm('admin')) {
         throw new AccessDeniedException();
     }
     $this->title = _('Meine Veranstaltungen') . ' - ' . _('Farbgruppierungen');
     if (Request::isXhr()) {
         $this->set_layout(null);
         $this->response->add_header('Content-Type', 'text/html;charset=Windows-1252');
         header('X-Title: ' . $this->title);
     } else {
         PageLayout::setTitle($this->title);
         PageLayout::setHelpKeyword('Basis.VeranstaltungenOrdnen');
         Navigation::activateItem('/browse/my_courses/list');
     }
     $this->current_semester = $sem ?: Semester::findCurrent()->semester_id;
     $this->semesters = SemesterData::GetSemesterArray();
     $forced_grouping = Config::get()->MY_COURSES_FORCE_GROUPING;
     if ($forced_grouping == 'not_grouped') {
         $forced_grouping = 'sem_number';
     }
     $no_grouping_allowed = $forced_grouping == 'sem_number' || !in_array($forced_grouping, getValidGroupingFields());
     $group_field = $GLOBALS['user']->cfg->MY_COURSES_GROUPING ?: $forced_grouping;
     $groups = array();
     $add_fields = '';
     $add_query = '';
     if ($group_field == 'sem_tree_id') {
         $add_fields = ', sem_tree_id';
         $add_query = "LEFT JOIN seminar_sem_tree sst ON (sst.seminar_id=seminare.Seminar_id)";
     } else {
         if ($group_field == 'dozent_id') {
             $add_fields = ', su1.user_id as dozent_id';
             $add_query = "LEFT JOIN seminar_user as su1 ON (su1.seminar_id=seminare.Seminar_id AND su1.status='dozent')";
         }
     }
     $dbv = DbView::getView('sem_tree');
     $query = "SELECT seminare.VeranstaltungsNummer AS sem_nr, seminare.Name, seminare.Seminar_id,\n                         seminare.status AS sem_status, seminar_user.gruppe, seminare.visible,\n                         {$dbv->sem_number_sql} AS sem_number,\n                         {$dbv->sem_number_end_sql} AS sem_number_end {$add_fields}\n                  FROM seminar_user\n                  JOIN semester_data sd\n                  LEFT JOIN seminare USING (Seminar_id)\n                  {$add_query}\n                  WHERE seminar_user.user_id = ?";
     if (Config::get()->MY_COURSES_ENABLE_STUDYGROUPS && !$studygroups) {
         $query .= " AND seminare.status != 99";
     }
     if ($studygroups) {
         $query .= " AND seminare.status = 99";
     }
     if (get_config('DEPUTIES_ENABLE')) {
         $query .= " UNION " . getMyDeputySeminarsQuery('gruppe', $dbv->sem_number_sql, $dbv->sem_number_end_sql, $add_fields, $add_query);
     }
     $query .= " ORDER BY sem_nr ASC";
     $statement = DBManager::get()->prepare($query);
     $statement->execute(array($GLOBALS['user']->id));
     while ($row = $statement->fetch(PDO::FETCH_ASSOC)) {
         $my_sem[$row['Seminar_id']] = array('obj_type' => 'sem', 'sem_nr' => $row['sem_nr'], 'name' => $row['Name'], 'visible' => $row['visible'], 'gruppe' => $row['gruppe'], 'sem_status' => $row['sem_status'], 'sem_number' => $row['sem_number'], 'sem_number_end' => $row['sem_number_end']);
         if ($group_field) {
             fill_groups($groups, $row[$group_field], array('seminar_id' => $row['Seminar_id'], 'sem_nr' => $row['sem_nr'], 'name' => $row['Name'], 'gruppe' => $row['gruppe']));
         }
     }
     if ($group_field == 'sem_number') {
         correct_group_sem_number($groups, $my_sem);
     } else {
         add_sem_name($my_sem);
     }
     sort_groups($group_field, $groups);
     // Ensure that a seminar is never in multiple groups
     $sem_ids = array();
     foreach ($groups as $group_id => $seminars) {
         foreach ($seminars as $index => $seminar) {
             if (in_array($seminar['seminar_id'], $sem_ids)) {
                 unset($seminars[$index]);
             } else {
                 $sem_ids[] = $seminar['seminar_id'];
             }
         }
         if (empty($seminars)) {
             unset($groups[$group_id]);
         } else {
             $groups[$group_id] = $seminars;
         }
     }
     $this->studygroups = $studygroups;
     $this->no_grouping_allowed = $no_grouping_allowed;
     $this->groups = $groups;
     $this->group_names = get_group_names($group_field, $groups);
     $this->group_field = $group_field;
     $this->my_sem = $my_sem;
 }
Esempio n. 18
0
 function getContent ($args) {
     global $_fullname_sql;
     
     $content = array();
     $dbv = DbView::getView('literatur');
     if (is_array($args) && isset($args['user_id'])) {
         $tree = TreeAbstract::GetInstance("StudipLitList", $args['user_id']);
     } else {
         preg_match(':^([a-z_-]{0,50})$:i', Request::quoted('username'), $matches);
         $tree = TreeAbstract::GetInstance("StudipLitList", get_userid($matches[1]));
     }
     if ($lists = $tree->getVisibleListIds()) {
         for ($i = 0; $i < count($lists); ++$i) {
             if ($this->config->getValue($this->name, 'showlastchange')) {
 //          && ($tree->tree_data[$lists[$i]]['chdate'] > $last_modified_since) ){
                 $content['LITLISTS']['LITLIST'][$i]['LITLIST_CHANGE-DATE'] = strftime($this->config->getValue('Main', 'dateformat'),
                         $tree->tree_data[$lists[$i]]['chdate']);
                 $content['LITLISTS']['LITLIST'][$i]['LITLIST_FULLNAME'] = $tree->tree_data[$lists[$i]]['fullname'];
                 $content['LITLISTS']['LITLIST'][$i]['LITLIST_NAME'] = $tree->tree_data[$lists[$i]]['name'];
             } else {
                 $content['LITLISTS']['LITLIST'][$i]['LITLIST_NAME'] = $tree->tree_data[$lists[$i]]['name'];
             }
             if ($tree->hasKids($lists[$i])){
                 $dbv->params[0] = $lists[$i];
                 $rs = $dbv->get_query("view:LIT_LIST_GET_ELEMENTS");
                 $j = 0;
                 while ($rs->next_record()){
                     if ( ($this->config->getValue($this->name, 'showlastchange'))) {
             //      && ($tree->tree_data[$rs->f('list_element_id')]['chdate'] > $last_modified_since) ){
                         $content['LITLISTS']['LITLIST'][$i]['LITLIST_ITEM'][$j]['LITLIST_ITEM_CHANGE-DATE'] = strftime($this->config->getValue('Main', 'dateformat'),
                                 $tree->tree_data[$rs->f('list_element_id')]['chdate']);
                         $content['LITLISTS']['LITLIST'][$i]['LITLIST_ITEM'][$j]['LITLIST_ITEM_FULLNAME'] = $tree->tree_data[$rs->f('list_element_id')]['fullname'];
                     }
                     $content['LITLISTS']['LITLIST'][$i]['LITLIST_ITEM'][$j]['LITLIST_ITEM_ELEMENT'] = ExternModule::ExtFormatReady($tree->getFormattedEntry($rs->f('list_element_id'), $rs->Record));
                     $j++;
                 }
             }
         }
     }
     
     return $content;
 }
Esempio n. 19
0
 function GetPreferredPlugin()
 {
     $dbv = DbView::getView('literatur');
     $dbv->params[0] = $GLOBALS['user']->id;
     $rs = $dbv->get_query("view:LIT_GET_FAK_LIT_PLUGIN");
     $rs->next_record();
     return $rs->f('lit_plugin_name');
 }
Esempio n. 20
0
 function fetchNumStaff()
 {
     $view = DbView::getView('range_tree');
     if (!($view->params[0] = $this->item_data['studip_object_id'])) {
         $view->params[0] = $this->tree_item_id;
     }
     $rs = $view->get_query("view:STATUS_COUNT");
     if ($rs->next_record()) {
         $this->item_data['num_staff'] = $rs->f(0);
         return true;
     }
     return false;
 }
Esempio n. 21
0
 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;
 }
Esempio n. 22
0
 function initSubfolders($parent_id){
     $view = DbView::getView('core');
     $view->params[0] = $parent_id;
     $db = $view->get_query("view:FOLDER_GET_DATA_BY_RANGE");
     $p = 0;
     while($db->next_record()){
         //$this->tree_data[$db->f("folder_id")] = $db->Record;
         $this->tree_data[$db->f("folder_id")]["entries"] = 0;
         $this->tree_data[$db->f("folder_id")]["permission"] = $db->f('permission');
         $this->storeItem($db->f("folder_id"), $parent_id, $db->f('name'), $p++);
         $this->initSubfolders($db->f("folder_id"));
     }
 }
Esempio n. 23
0
/**
 * return all sem_tree-entries for the passed seminar
 *
 * @param string $seminar_id the seminar
 *
 * @return array  a list of sem_tree_id's
 */
function get_seminar_sem_tree_entries($seminar_id)
{
    $view = DbView::getView('sem_tree');
    $ret = null;
    $view->params[0] = $seminar_id;
    $rs = $view->get_query("view:SEMINAR_SEM_TREE_GET_IDS");
    while ($rs->next_record()) {
        $ret[] = $rs->f('sem_tree_id');
    }
    return $ret;
}
Esempio n. 24
0
 /**
  * @param $course_id
  * @return array
  */
 public static function getSemTree($course_id, $depth = false)
 {
     $the_tree = TreeAbstract::GetInstance("StudipSemTree");
     $view = DbView::getView('sem_tree');
     $ret = null;
     $view->params[0] = $course_id;
     $rs = $view->get_query("view:SEMINAR_SEM_TREE_GET_IDS");
     while ($rs->next_record()) {
         $ret[$rs->f('sem_tree_id')]['name'] = $the_tree->getShortPath($rs->f('sem_tree_id'), null, ">", $depth ? $depth - 1 : 0);
         $ret[$rs->f('sem_tree_id')]['info'] = $the_tree->getValue($rs->f('sem_tree_id'), 'info');
     }
     return $ret;
 }