Exemple #1
0
 function index_action()
 {
     $form_fields['comment'] = array('caption' => _("Kommentar"), 'type' => 'textarea', 'attributes' => array('rows' => 4, 'style' => 'width:100%'));
     $form_fields['snd_message'] = array('caption' => _("Benachrichtigung über ausfallende Termine an alle Teilnehmer verschicken"), 'type' => 'checkbox', 'attributes' => array('style' => 'vertical-align:middle'));
     $form_buttons['save_close'] = array('caption' => _('OK'), 'info' => _("Termine absagen und Dialog schließen"));
     $form = new StudipForm($form_fields, $form_buttons, 'cancel_dates', false);
     if ($form->isClicked('save_close')) {
         $sem = Seminar::getInstance($this->course_id);
         $comment = $form->getFormFieldValue('comment');
         foreach ($this->dates as $date) {
             $sem->cancelSingleDate($date->getTerminId(), $date->getMetadateId());
             $date->setComment($comment);
             $date->setExTermin(true);
             $date->store();
         }
         if ($form->getFormFieldValue('snd_message') && count($this->dates)) {
             $snd_messages = raumzeit_send_cancel_message($comment, $this->dates);
             if ($snd_messages) {
                 $msg = sprintf(_("Es wurden %s Benachrichtigungen gesendet."), $snd_messages);
             }
         }
         PageLayout::postMessage(MessageBox::success(_("Folgende Termine wurden abgesagt") . ($msg ? ' (' . $msg . '):' : ':'), array_map(function ($d) {
             return $d->toString();
         }, $this->dates)));
         $this->redirect($this->url_for('course/dates'));
     }
     $this->form = $form;
 }
Exemple #2
0
 function before_filter(&$action, &$args)
 {
     global $SEM_TYPE, $SEM_CLASS;
     parent::before_filter($action, $args);
     checkObject();
     $this->course = Course::findCurrent();
     if (!$this->course) {
         throw new CheckObjectException(_('Sie haben kein Objekt gewählt.'));
     }
     $this->course_id = $this->course->id;
     PageLayout::setHelpKeyword("Basis.InVeranstaltungKurzinfo");
     PageLayout::setTitle($GLOBALS['SessSemName']["header_line"] . " - " . _("Kurzinfo"));
     Navigation::activateItem('/course/main/info');
     // add skip link
     SkipLinks::addIndex(Navigation::getItem('/course/main/info')->getTitle(), 'main_content', 100);
     $this->sem = Seminar::getInstance($this->course_id);
     $sem_class = $this->sem->getSemClass();
     $this->studygroup_mode = $sem_class["studygroup_mode"];
 }
Exemple #3
0
 function before_filter(&$action, &$args)
 {
     parent::before_filter($action, $args);
     $this->course_id = current($args);
     if ($this->course_id === '' || get_object_type($this->course_id) !== 'sem' || !$GLOBALS['perm']->have_studip_perm("tutor", $this->course_id)) {
         $this->set_status(403);
         return FALSE;
     }
     $this->body_id = 'custom_avatar';
     PageLayout::setTitle(Course::findCurrent()->getFullname() . ' - ' . _('Bild ändern'));
     $sem = Seminar::getInstance($this->course_id);
     $this->studygroup_mode = $sem->getSemClass()->offsetget("studygroup_mode");
     if ($this->studygroup_mode) {
         $this->avatar = StudygroupAvatar::getAvatar($this->course_id);
     } else {
         $this->avatar = CourseAvatar::getAvatar($this->course_id);
     }
     Navigation::activateItem('/course/admin/avatar');
 }
Exemple #4
0
 /**
  * Common actions before any other action
  *
  * @param String $action Action to be executed
  * @param Array $args Arguments passed to the action
  * @throws Trails_Exception when either no course was found or the user
  *                          may not access this area
  */
 public function before_filter(&$action, &$args)
 {
     parent::before_filter($action, $args);
     // Try to find a valid course
     if (Course::findCurrent()) {
         $course_id = Course::findCurrent()->id;
     } else {
         throw new Trails_Exception(404, _('Es wurde keine Veranstaltung ausgewählt!'));
     }
     if (!$GLOBALS['perm']->have_studip_perm('tutor', $course_id)) {
         throw new Trails_Exception(400);
     }
     // Get seminar instance
     $this->course = Seminar::getInstance($course_id);
     if (Navigation::hasItem('course/admin/dates')) {
         Navigation::activateItem('course/admin/dates');
     }
     $this->show = array('regular' => true, 'irregular' => true, 'roomRequest' => true);
     PageLayout::setHelpKeyword('Basis.Veranstaltungen');
     PageLayout::addSqueezePackage('raumzeit');
     $title = _('Verwaltung von Zeiten und Räumen');
     $title = $this->course->getFullname() . ' - ' . $title;
     PageLayout::setTitle($title);
     $_SESSION['raumzeitFilter'] = Request::get('newFilter');
     // bind linkParams for chosen semester and opened dates
     URLHelper::bindLinkParam('raumzeitFilter', $_SESSION['raumzeitFilter']);
     $this->checkFilter();
     $this->selection = $this->getSemestersForCourse($this->course, $_SESSION['raumzeitFilter']);
     if (!Request::isXhr()) {
         $this->setSidebar();
     } elseif (Request::isXhr() && $this->flash['update-times']) {
         $semester_id = $GLOBALS['user']->cfg->MY_COURSES_SELECTED_CYCLE;
         if ($semester_id === 'all') {
             $semester_id = '';
         }
         $this->response->add_header('X-Raumzeit-Update-Times', json_encode(studip_utf8encode(array('course_id' => $this->course->id, 'html' => Seminar::GetInstance($this->course->id)->getDatesHTML(array('semester_id' => $semester_id, 'show_room' => true)) ?: _('nicht angegeben')))));
     }
 }
Exemple #5
0
 public function before_filter(&$action, &$args)
 {
     $this->set_layout($GLOBALS['template_factory']->open('layouts/base_without_infobox'));
     $this->course = Course::findCurrent();
     if (!$this->course) {
         throw new CheckObjectException(_('Sie haben kein Objekt gewählt.'));
     } else {
         if (Navigation::hasItem('/course/admin')) {
             Navigation::activateItem('/course/admin/seminar_tabs');
         } else {
             if (Navigation::hasItem('/admin/course/seminar_tabs')) {
                 Navigation::activateItem('/admin/course/seminar_tabs');
             }
         }
         $this->ignore_tabs = array('modules', 'mini_course');
         $this->ignore_visibility_tabs = array('admin', 'main');
         $this->course_id = $this->course->id;
         $this->sem = Seminar::getInstance($this->course_id);
         $sem_class = $GLOBALS['SEM_CLASS'][$GLOBALS['SEM_TYPE'][$this->sem->status]['class']];
         $sem_class || ($sem_class = SemClass::getDefaultSemClass());
         $this->studygroup_mode = $SEM_CLASS[$SEM_TYPE[$this->sem->status]["class"]]["studygroup_mode"];
     }
 }
 function getMetaDateAssignObjects($cycle_id) {
     $sem = Seminar::getInstance($this->seminar_id);
     // get the assigned singledates
     $dates = $sem->getSingleDatesForCycle($cycle_id);
     foreach ($dates as $date) {
         $assignObjects[$date->getSingleDateId()] = $this->getDateAssignObject($date->getSingleDateId());
     }
     return $assignObjects;
 }
    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;

    }
 function index_action()
 {
     if (!$GLOBALS['perm']->have_perm("admin")) {
         throw new AccessDeniedException(_("Sie sind nicht berechtigt, dieses Plugin zu benutzen."));
     }
     $db = DBManager::get();
     if (Request::submitted('do_search_source')) {
         $result = search_range(Request::quoted('search_source'));
         if (is_array($result)) {
             $result = array_filter($result, function ($r) {
                 return $r["type"] == "sem";
             });
             if (count($result)) {
                 PageLayout::postMessage(MessageBox::success(sprintf(_("Ihre Sucher ergab %s Treffer."), count($result))));
                 $show_source_result = true;
             }
         } else {
             PageLayout::postMessage(MessageBox::info(_("Ihre Suche ergab keine Treffer.")));
         }
     }
     if (Request::submitted('do_choose_source')) {
         $source_id = Request::option('search_source_result');
         $copy_count = 5;
         Request::set('to_copy', null);
     } else {
         if (Request::submitted('source_id')) {
             $source_id = Request::option('source_id');
             $copy_count = Request::int('copy_count');
             if ($copy_count < 1) {
                 $copy_count = 1;
             }
         }
     }
     if ($source_id) {
         $source = Seminar::getInstance($source_id);
         $source_name = $source->getName() . ' (' . $source->getStartSemesterName() . ')';
         $copy_type = Request::int('copy_type', $source->status);
         if (SeminarCategories::getByTypeId($copy_type)->course_creation_forbidden) {
             $copy_type = 0;
         }
         if (SeminarCategories::getByTypeId($source->status)->only_inst_user) {
             $search_template = "user_inst";
         } else {
             $search_template = "user";
         }
         $bet_inst = $db->query("SELECT institut_id FROM seminar_inst WHERE seminar_id=" . $db->quote($source_id))->fetchAll(PDO::FETCH_COLUMN);
         $source_dozenten = array_keys($source->getMembers('dozent'));
         if ($copy_count) {
             $r = Request::getArray('to_copy');
             $delete_lecturer = Request::getArray('delete_lecturer');
             $add_lecturer = count(Request::getArray('add_lecturer')) ? (int) key(Request::getArray('add_lecturer')) : null;
             for ($i = 0; $i < $copy_count; $i++) {
                 $to_copy['nr'][$i] = isset($r['nr'][$i]) ? $r['nr'][$i] : $source->getNumber();
                 $to_copy['name'][$i] = isset($r['name'][$i]) ? $r['name'][$i] : $source->getName();
                 $to_copy['participants'][$i] = isset($r['participants'][$i]) ? 1 : 0;
                 $to_copy['lecturers'][$i] = $r['lecturers'][$i];
                 if (empty($to_copy['lecturers'][$i])) {
                     $to_copy['lecturers'][$i] = $source_dozenten;
                 } else {
                     if (isset($delete_lecturer[$i]) && count($to_copy['lecturers'][$i]) > 1) {
                         $to_delete = array_search(key($delete_lecturer[$i]), $to_copy['lecturers'][$i]);
                         if ($to_delete !== false) {
                             unset($to_copy['lecturers'][$i][$to_delete]);
                         }
                     }
                 }
                 if ($add_lecturer === $i && Request::option('add_doz_' . $add_lecturer)) {
                     $to_copy['lecturers'][$i][] = Request::option('add_doz_' . $add_lecturer);
                 }
                 $to_copy['search_lecturer'][$i] = new PermissionSearch($search_template, sprintf(_("%s auswählen"), get_title_for_status('dozent', 1, $source->status)), "user_id", array('permission' => 'dozent', 'exclude_user' => $to_copy['lecturers'][$i], 'institute' => $bet_inst));
             }
         }
         if (Request::submitted('do_copy') && count($to_copy)) {
             $copied = array();
             $lecturer_insert = $db->prepare("INSERT INTO seminar_user (seminar_id,user_id,status,position,gruppe,comment,visible,mkdate) VALUES (?,?,'dozent',?,?,'','yes',UNIX_TIMESTAMP())");
             $copy_seminar_inst = $db->prepare("INSERT INTO seminar_inst (seminar_id,institut_id) SELECT ?,institut_id FROM seminar_inst WHERE seminar_id=?");
             $copy_seminar_sem_tree = $db->prepare("INSERT INTO seminar_sem_tree (seminar_id,sem_tree_id) SELECT ?,sem_tree_id FROM seminar_sem_tree WHERE seminar_id=?");
             $copy_seminar_user = $db->prepare("INSERT IGNORE INTO seminar_user (seminar_id,user_id,status,gruppe, mkdate,comment,position) SELECT ?,user_id,status,gruppe,UNIX_TIMESTAMP(),'',0 FROM seminar_user WHERE status IN ('user','autor','tutor') AND seminar_id=?");
             $copy_seminar_userdomains = $db->prepare("INSERT INTO seminar_userdomains (seminar_id,userdomain_id) SELECT ?,userdomain_id FROM seminar_userdomains WHERE seminar_id=?");
             $copy_statusgruppen = $db->prepare("INSERT INTO statusgruppen (statusgruppe_id,name,range_id,position,size,selfassign,mkdate) SELECT MD5(CONCAT(statusgruppe_id, ?)),name,?,position,size,selfassign,UNIX_TIMESTAMP() FROM statusgruppen WHERE range_id=?");
             $copy_statusgruppe_user = $db->prepare("INSERT INTO statusgruppe_user (statusgruppe_id,user_id,position) SELECT MD5(CONCAT(statusgruppe_user.statusgruppe_id, ?)),user_id,statusgruppe_user.position FROM statusgruppen INNER JOIN statusgruppe_user USING(statusgruppe_id) WHERE range_id=?");
             for ($i = 0; $i < $copy_count; $i++) {
                 $new_sem = Course::build($source->toArray());
                 $new_sem->setId($new_sem->getNewId());
                 $new_sem_id = $new_sem->id;
                 $new_sem->status = Request::int('copy_type', 1);
                 $new_sem->name = $to_copy['name'][$i];
                 $new_sem->veranstaltungsnummer = $to_copy['nr'][$i];
                 $new_sem->store();
                 if (!$new_sem->isNew()) {
                     log_event("SEM_CREATE", $new_sem_id);
                     $gruppe = (int) select_group($new_sem->start_time);
                     $position = 1;
                     foreach ($to_copy['lecturers'][$i] as $lecturer) {
                         $lecturer_insert->execute(array($new_sem_id, $lecturer, $position, $gruppe));
                     }
                     $copy_seminar_inst->execute(array($new_sem_id, $source_id));
                     $copy_seminar_sem_tree->execute(array($new_sem_id, $source_id));
                     $copy_seminar_userdomains->execute(array($new_sem_id, $source_id));
                     if ($to_copy['participants'][$i]) {
                         $copy_seminar_user->execute(array($new_sem_id, $source_id));
                         $copy_statusgruppen->execute(array($new_sem_id, $new_sem_id, $source_id));
                         $copy_statusgruppe_user->execute(array($new_sem_id, $source_id));
                     }
                     $copied[] = $new_sem;
                 }
             }
             PageLayout::postMessage(MessageBox::success(sprintf(_("Es wurden %s Kopien erstellt."), count($copied))));
             $source_id = null;
         }
     }
     PageLayout::setTitle(_("Veranstaltungs-Vervielfältiger"));
     $template_factory = new Flexi_TemplateFactory(dirname(__FILE__) . "/templates");
     $template = $template_factory->open('index.php');
     $template->set_layout($GLOBALS['template_factory']->open('layouts/base.php'));
     echo $template->render(compact('source_id', 'source_name', 'show_source_result', 'result', 'copy_count', 'copy_type', 'to_copy', 'copied'));
 }
Exemple #9
0
 public function switchdeputy_action($course_id, $newstatus)
 {
     $course = Seminar::getInstance($course_id);
     switch ($newstatus) {
         case 'dozent':
             $dozent = new CourseMember();
             $dozent->seminar_id = $course_id;
             $dozent->user_id = $GLOBALS['user']->id;
             $dozent->status = 'dozent';
             $dozent->comment = '';
             if ($dozent->store()) {
                 deleteDeputy($GLOBALS['user']->id, $course_id);
                 PageLayout::postSuccess(sprintf(_('Sie wurden als %s eingetragen.'), get_title_for_status('dozent', 1)));
             } else {
                 PageLayout::postError(sprintf(_('Sie konnten nicht als %s eingetragen werden.'), get_title_for_status('dozent', 1)));
             }
             break;
         case 'deputy':
             $dozent = Course::find($course_id)->members->findOneBy('user_id', $GLOBALS['user']->id);
             if (addDeputy($GLOBALS['user']->id, $course_id)) {
                 $dozent->delete();
                 PageLayout::postSuccess(_('Sie wurden als Vertretung eingetragen.'));
             } else {
                 PageLayout::postError(_('Sie konnten nicht als Vertretung eingetragen werden.'));
             }
             break;
     }
     $this->flash['open'] = "bd_personal";
     $this->redirect($this->url_for('course/basicdata/view/' . $course_id));
 }
Exemple #10
0
 /**
  * Check, if the a user has the passed permission in a seminar.
  * Possible permissions are:
  *   edit_category     - Editing the name of a category<br>
  *   add_category      - Adding a new category<br>
  *   remove_category   - Removing an existing category<br>
  *   sort_category     - Sorting categories<br>
  *   edit_area         - Editing an area (title + content)<br>
  *   add_area          - Adding a new area<br>
  *   remove_area       - Removing an area and all belonging threads<br>
  *   sort_area         - Sorting of areas in categories and between categories<br>
  *   search            - Searching in postings<br>
  *   edit_entry        - Editing of foreign threads/postings<br>
  *   add_entry         - Creating a new thread/posting<br>
  *   remove_entry      - Removing of foreign threads/postings<br>
  *   fav_entry         - Marking a Posting as "favorite"<br>
  *   like_entry        - Liking a posting<br>
  *   move_thread       - Moving a thrad between ares<br>
  *   close_thread      - Close or open a thread<br>
  *   make_sticky       - Make a thread sticky<br>
  *   abo               - Signing up for mail-notifications for new entries<br>
  *   forward_entry     - Forwarding an existing entry as a message<br>
  *   pdfexport         - Exporting parts of the forum as PDF<br>
  *   admin             - Allowed to mass-administrate the forum<br>
  *   view              - Allowed to view the forum at all<br>
  *   edit_closed       - Editing entries in a closed thread
  * 
  * @param string $perm        one of the modular permissions
  * @param string $seminar_id  the seminar to check for
  * @param string $user_id     the user to check for
  * @return boolean  true, if the user has the perms, false otherwise
  */
 static function has($perm, $seminar_id, $user_id = null)
 {
     static $permissions = array();
     // if no user-id is passed, use the current user (for your convenience)
     if (!$user_id) {
         $user_id = $GLOBALS['user']->id;
     }
     // get the status for the user in the passed seminar
     if (!$permissions[$seminar_id][$user_id]) {
         $permissions[$seminar_id][$user_id] = $GLOBALS['perm']->get_studip_perm($seminar_id, $user_id);
     }
     $status = $permissions[$seminar_id][$user_id];
     // take care of the not logged in user
     if ($user_id == 'nobody') {
         // which status has nobody - read only or read/write?
         if (get_object_type($seminar_id) == 'sem') {
             $sem = Seminar::getInstance($seminar_id);
             if ($sem->write_level == 0) {
                 $status = 'nobody_write';
             } else {
                 if ($sem->read_level == 0) {
                     $status = 'nobody_read';
                 } else {
                     return false;
                 }
             }
         } else {
             return false;
         }
     }
     // root and admins have all possible perms
     if (in_array($status, words('root admin')) !== false) {
         return true;
     }
     // eCULT Notlösung
     if ($status == 'tutor' && $seminar_id == '30e0b89dcc9173d5fccf9f22b13b87bd') {
         $status = 'autor';
     }
     // check the status and the passed permission
     if (($status == 'dozent' || $status == 'tutor') && in_array($perm, words('edit_category add_category remove_category sort_category ' . 'edit_area add_area remove_area sort_area ' . 'search edit_entry add_entry remove_entry fav_entry like_entry move_thread ' . 'make_sticky close_thread abo forward_entry pdfexport view edit_closed')) !== false) {
         return true;
     } else {
         if ($status == 'autor' && in_array($perm, words('search add_entry fav_entry like_entry forward_entry abo pdfexport view')) !== false) {
             return true;
         } else {
             if ($status == 'user' && in_array($perm, words('search add_entry forward_entry pdfexport view')) !== false) {
                 return true;
             } else {
                 if ($status == 'nobody_write' && in_array($perm, words('search add_entry pdfexport view')) !== false) {
                     return true;
                 } else {
                     if ($status == 'nobody_read' && in_array($perm, words('search pdfexport view')) !== false) {
                         return true;
                     }
                 }
             }
         }
     }
     // user has no permission
     return false;
 }
    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 toString ($args) {
        $out = "";
        $this->seminar_id = $args["seminar_id"];
        $query = "SELECT * FROM seminare WHERE Seminar_id = ?";
        $parameters = array($this->seminar_id);
        $statement = DBManager::get()->prepare($query);
        $statement->execute($parameters);
        $row = $statement->fetch(PDO::FETCH_ASSOC);
        
        $visible = $this->config->getValue("Main", "visible");
        $j = -1;
        if ($row !== false) {

            $data["name"] = htmlReady($row['Name']);

            if ($visible[++$j] && $row['Untertitel'])
                $data["subtitle"] = htmlReady($row['Untertitel']);

            if ($visible[++$j]) {
                if (!$name_sql = $this->config->getValue("Main", "nameformat"))
                    $name_sql = "full";
                $name_sql = $GLOBALS['_fullname_sql'][$name_sql];

                $query = "SELECT $name_sql AS name, username, position FROM seminar_user su LEFT JOIN
                        auth_user_md5 USING(user_id) LEFT JOIN user_info USING(user_id)
                        WHERE su.Seminar_id = ? AND su.status='dozent' ORDER BY position, username";
                $parameters = array($this->seminar_id);
                $statement = DBManager::get()->prepare($query);
                $statement->execute($parameters);
                while ($res = $statement->fetch(PDO::FETCH_ASSOC)) {
                    $data["lecturer"][] = $this->elements["LinkInternSimple"]->toString(
                            array("module" => "Persondetails",
                            "link_args" => "username="******"&seminar_id=" . $this->seminar_id,
                            "content" => $res['name'] ));
                }
                if (is_array($data["lecturer"]))
                    $data["lecturer"] = implode(", ", $data["lecturer"]);
            }

            if ($visible[++$j] && $row['art'])
                $data["art"] = htmlReady($row['art']);

            if ($visible[++$j]) {
                // reorganize the $SEM_TYPE-array
                foreach ($GLOBALS["SEM_CLASS"] as $key_class => $class) {
                    $i = 0;
                    foreach ($GLOBALS["SEM_TYPE"] as $key_type => $type) {
                        if ($type["class"] == $key_class) {
                            $i++;
                            $sem_types_position[$key_type] = $i;
                        }
                    }
                }

                $aliases_sem_type = $this->config->getValue("ReplaceTextSemType",
                        "class_" . $GLOBALS["SEM_TYPE"][$row['status']]['class']);
                if ($aliases_sem_type[$sem_types_position[$row['status']] - 1])
                    $data["status"] =  $aliases_sem_type[$sem_types_position[$row['status']] - 1];
                else
                    $data["status"] = htmlReady($GLOBALS["SEM_TYPE"][$row['status']]["name"]);
            }

            if ($visible[++$j] && $row['Beschreibung'])
                $data["description"] = formatLinks($row['Beschreibung']);

            if ($visible[++$j])
                $data["location"] = htmlReady(Seminar::getInstance($this->seminar_id)->getDatesTemplate('dates/seminar_export_location'));

            if ($visible[++$j])
                $data["semester"] = get_semester($this->seminar_id);

            if ($visible[++$j]) {
                $data["time"] = htmlReady(Seminar::getInstance($this->seminar_id)->getDatesExport());
                if ($first_app = vorbesprechung($this->seminar_id, 'export')) {
                    $data["time"] .= "<br>" . $this->config->getValue("Main", "aliaspredisc") . htmlReady($first_app);
                }
                if ($begin = Seminar::getInstance($this->seminar_id)->getFirstDate('export')) {
                    $data["time"] .= "<br>" . $this->config->getValue("Main", "aliasfirstmeeting") . htmlReady($begin);
                }
            }

            if ($visible[++$j] && $row['VeranstaltungsNummer'])
                $data["number"] = htmlReady($row['VeranstaltungsNummer']);

            if ($visible[++$j] && $row['teilnehmer'])
                $data["teilnehmer"] = htmlReady($row['teilnehmer']);

            if ($visible[++$j] && $row['vorrausetzungen'])
                $data["requirements"] = htmlReady($row['vorrausetzungen']);

            if ($visible[++$j] && $row['lernorga'])
                $data["lernorga"] = htmlReady($row['lernorga']);

            if ($visible[++$j] && $row['leistungsnachweis'])
                $data["leistung"] = htmlReady($row['leistungsnachweis']);

            if ($visible[++$j]) {
                $range_path_level = $this->config->getValue("Main", "rangepathlevel");
                $pathes = get_sem_tree_path($this->seminar_id, $range_path_level);
                if (is_array($pathes)) {
                    $data["range_path"] = htmlReady(implode("\n", array_values($pathes)),true,true);
                }
            }

            if ($visible[++$j] && $row['Sonstiges'])
                $data["misc"] = formatLinks($row['Sonstiges']);

            if ($visible[++$j] && $row['ects'])
                $data["ects"] = htmlReady($row['ects']);

            // generic data fields
            if ($generic_datafields = $this->config->getValue("Main", "genericdatafields")) {
                $localEntries = DataFieldEntry::getDataFieldEntries($this->seminar_id);
                foreach ($generic_datafields as $id) {
                    if ($visible[++$j] && isset($localEntries[$id]) && is_object($localEntries[$id])) {
                        $data[$id] = $localEntries[$id]->getDisplayValue();
                    }
                }
            }
            $out = $this->toStringMainTable($data, FALSE);
        }

        return $out;
    }
Exemple #13
0
 $statement->execute(array($eval_id));
 $number_of_votes = $statement->fetchColumn();
 $eval_ranges_names = array();
 $query = "SELECT range_id FROM eval_range WHERE eval_id = ?";
 $statement = DBManager::get()->prepare($query);
 $statement->execute(array($eval_id));
 $eval_ranges = $statement->fetchAll(PDO::FETCH_COLUMN);
 foreach ($eval_ranges as $eval_range) {
     $o_type = get_object_type($eval_range, array('studip', 'user', 'sem', 'inst'));
     switch ($o_type) {
         case 'global':
             $name = _("Systemweite Evaluationen");
             break;
         case 'sem':
             $name = _("Veranstaltung:");
             $seminar = Seminar::getInstance($eval_range);
             $name .= ' ' . $seminar->getName();
             $name .= ' (' . Semester::findByTimestamp($seminar->semester_start_time)->name;
             if ($seminar->semester_duration_time == -1) {
                 $name .= ' - ' . _("unbegrenzt");
             }
             if ($seminar->semester_duration_time > 0) {
                 $name .= ' - ' . Semester::findByTimestamp($seminar->semester_start_time + $seminar->semester_duration_time)->name;
             }
             $name .= ')';
             $dozenten = array_map(function ($v) {
                 return $v['Nachname'];
             }, $seminar->getMembers('dozent'));
             $name .= ' (' . join(', ', $dozenten) . ')';
             break;
         case 'user':
Exemple #14
0
 /**
  * Adds given users to the course waitlist, either at list beginning or end.
  * System messages are sent to affected users.
  *
  * @param mixed $users array of user ids to add
  * @param String $which_end 'last' or 'first': which list end to append to
  * @return mixed Array of messages (stating success and/or errors)
  */
 public function moveToWaitlist($users, $which_end)
 {
     $course = Seminar::getInstance($this->course_id);
     foreach ($users as $user_id) {
         // Delete member from seminar
         if ($course->deleteMember($user_id)) {
             setTempLanguage($user_id);
             $message = sprintf(_('Sie wurden von der Veranstaltung **%s** von ' . '%s oder der Administration abgemeldet, ' . 'Sie wurden auf die Warteliste dieser Veranstaltung gesetzt.'), $this->course_title, get_title_for_status('dozent', 1));
             restoreLanguage();
             messaging::sendSystemMessage($user_id, sprintf('%s %s', _('Systemnachricht:'), _('Anmeldung aufgehoben, auf Warteliste gesetzt')), $message);
             // Insert user in waitlist at current position.
             if ($course->addToWaitlist($user_id, $which_end)) {
                 $temp_user = User::find($user_id);
                 $msgs['success'][] = $temp_user->getFullname('no_title');
                 $curpos++;
                 // Something went wrong on removing the user from course.
             } else {
                 $msgs['error'][] = $temp_user->getFullname('no_title');
             }
             // Something went wrong on inserting the user in waitlist.
         } else {
             $msgs['error'][] = $temp_user->getFullname('no_title');
         }
     }
     return $msgs;
 }
Exemple #15
0
 private function createSidebar($filtered_members)
 {
     $sidebar = Sidebar::get();
     $sem = Seminar::GetInstance($this->course_id);
     if ($this->is_tutor) {
         $widget = new ActionsWidget();
         $url = URLHelper::getLink('dispatch.php/messages/write', array('course_id' => $this->course_id, 'default_subject' => $this->subject, 'filter' => 'all', 'emailrequest' => 1));
         $widget->addLink(_('Nachricht an alle (Rundmail)'), $url, Icon::create('inbox', 'clickable'), array('data-dialog' => "buttons"));
         if ($this->is_dozent) {
             if (!$this->dozent_is_locked) {
                 $sem_institutes = $sem->getInstitutes();
                 if (SeminarCategories::getByTypeId($sem->status)->only_inst_user) {
                     $search_template = "user_inst";
                 } else {
                     $search_template = "user";
                 }
                 // create new search for dozent
                 $searchtype = new PermissionSearch($search_template, sprintf(_("%s suchen"), get_title_for_status('dozent', 1, $sem->status)), "user_id", array('permission' => 'dozent', 'exclude_user' => array(), 'institute' => $sem_institutes));
                 // quickfilter: dozents of institut
                 $sql = "SELECT user_id FROM user_inst WHERE Institut_id = ? AND inst_perms = 'dozent'";
                 $db = DBManager::get();
                 $statement = $db->prepare($sql, array(PDO::FETCH_NUM));
                 $statement->execute(array(Seminar::getInstance($this->course_id)->getInstitutId()));
                 $membersOfInstitute = $statement->fetchAll(PDO::FETCH_COLUMN, 0);
                 // add "add dozent" to infobox
                 $mp = MultiPersonSearch::get('add_dozent' . $this->course_id)->setLinkText(sprintf(_('Neue/n %s eintragen'), $this->status_groups['dozent']))->setDefaultSelectedUser($filtered_members['dozent']->pluck('user_id'))->setLinkIconPath("")->setTitle(sprintf(_('Neue/n %s eintragen'), $this->status_groups['dozent']))->setExecuteURL(URLHelper::getLink('dispatch.php/course/members/execute_multipersonsearch_dozent'))->setSearchObject($searchtype)->addQuickfilter(sprintf(_('%s der Einrichtung'), $this->status_groups['dozent']), $membersOfInstitute)->setNavigationItem('/course/members/view')->render();
                 $element = LinkElement::fromHTML($mp, Icon::create('community+add', 'clickable'));
                 $widget->addElement($element);
             }
             if (!$this->tutor_is_locked) {
                 $sem_institutes = $sem->getInstitutes();
                 if (SeminarCategories::getByTypeId($sem->status)->only_inst_user) {
                     $search_template = 'user_inst';
                 } else {
                     $search_template = 'user';
                 }
                 // create new search for tutor
                 $searchType = new PermissionSearch($search_template, sprintf(_('%s suchen'), get_title_for_status('tutor', 1, $sem->status)), 'user_id', array('permission' => array('dozent', 'tutor'), 'exclude_user' => array(), 'institute' => $sem_institutes));
                 // quickfilter: tutors of institut
                 $sql = "SELECT user_id FROM user_inst WHERE Institut_id = ? AND inst_perms = 'tutor'";
                 $db = DBManager::get();
                 $statement = $db->prepare($sql, array(PDO::FETCH_NUM));
                 $statement->execute(array(Seminar::getInstance($this->course_id)->getInstitutId()));
                 $membersOfInstitute = $statement->fetchAll(PDO::FETCH_COLUMN, 0);
                 // add "add tutor" to infobox
                 $mp = MultiPersonSearch::get("add_tutor" . $this->course_id)->setLinkText(sprintf(_('Neue/n %s eintragen'), $this->status_groups['tutor']))->setDefaultSelectedUser($filtered_members['tutor']->pluck('user_id'))->setLinkIconPath("")->setTitle(sprintf(_('Neue/n %s eintragen'), $this->status_groups['tutor']))->setExecuteURL(URLHelper::getLink('dispatch.php/course/members/execute_multipersonsearch_tutor'))->setSearchObject($searchType)->addQuickfilter(sprintf(_('%s der Einrichtung'), $this->status_groups['tutor']), $membersOfInstitute)->setNavigationItem('/course/members/view')->render();
                 $element = LinkElement::fromHTML($mp, Icon::create('community+add', 'clickable'));
                 $widget->addElement($element);
             }
         }
         if (!$this->is_locked) {
             // create new search for members
             $searchType = new SQLSearch("SELECT auth_user_md5.user_id, CONCAT(" . $GLOBALS['_fullname_sql']['full'] . ", \" (\", auth_user_md5.username, \")\") as fullname " . "FROM auth_user_md5 " . "LEFT JOIN user_info ON (user_info.user_id = auth_user_md5.user_id) " . "WHERE (CONCAT(auth_user_md5.Vorname, \" \", auth_user_md5.Nachname) LIKE :input " . "OR CONCAT(auth_user_md5.Nachname, \" \", auth_user_md5.Vorname) LIKE :input " . "OR auth_user_md5.username LIKE :input) " . "AND auth_user_md5.perms IN ('autor', 'tutor', 'dozent') " . " AND auth_user_md5.visible <> 'never' " . "ORDER BY Vorname, Nachname", _("Teilnehmer suchen"), "username");
             // quickfilter: tutors of institut
             $sql = "SELECT user_id FROM user_inst WHERE Institut_id = ? AND inst_perms = 'autor'";
             $db = DBManager::get();
             $statement = $db->prepare($sql, array(PDO::FETCH_NUM));
             $statement->execute(array(Seminar::getInstance($this->course_id)->getInstitutId()));
             $membersOfInstitute = $statement->fetchAll(PDO::FETCH_COLUMN, 0);
             // add "add autor" to infobox
             $mp = MultiPersonSearch::get("add_autor" . $this->course_id)->setLinkText(sprintf(_('Neue/n %s eintragen'), $this->status_groups['autor']))->setDefaultSelectedUser($filtered_members['autor']->pluck('user_id'))->setLinkIconPath("")->setTitle(sprintf(_('Neue/n %s eintragen'), $this->status_groups['autor']))->setExecuteURL(URLHelper::getLink('dispatch.php/course/members/execute_multipersonsearch_autor'))->setSearchObject($searchType)->addQuickfilter(sprintf(_('%s der Einrichtung'), $this->status_groups['autor']), $membersOfInstitute)->setNavigationItem('/course/members/view')->render();
             $element = LinkElement::fromHTML($mp, Icon::create('community+add', 'clickable'));
             $widget->addElement($element);
             // add "add person to waitlist" to sidebar
             if ($sem->isAdmissionEnabled() && !$sem->admission_disable_waitlist && (!$sem->getFreeSeats() || $sem->admission_disable_waitlist_move)) {
                 $ignore = array_merge($filtered_members['dozent']->pluck('user_id'), $filtered_members['tutor']->pluck('user_id'), $filtered_members['autor']->pluck('user_id'), $filtered_members['user']->pluck('user_id'), $filtered_members['awaiting']->pluck('user_id'));
                 $mp = MultiPersonSearch::get('add_waitlist' . $this->course_id)->setLinkText(_('Neue/n Person auf Warteliste eintragen'))->setDefaultSelectedUser($ignore)->setLinkIconPath('')->setTitle(_('Neue/n Person auf Warteliste eintragen'))->setExecuteURL(URLHelper::getLink('dispatch.php/course/members/execute_multipersonsearch_waitlist'))->setSearchObject($searchType)->addQuickfilter(_('Mitglieder der Einrichtung'), $membersOfInstitute)->setNavigationItem('/course/members/view')->render();
                 $element = LinkElement::fromHTML($mp, Icon::create('community+add', 'clickable'));
                 $widget->addElement($element);
             }
         }
         $widget->addLink(_('Teilnehmerliste importieren'), $this->url_for('course/members/import_autorlist'), Icon::create('community+add', 'clickable'));
         $sidebar->addWidget($widget);
         if (Config::get()->EXPORT_ENABLE) {
             include_once $GLOBALS['PATH_EXPORT'] . '/export_linking_func.inc.php';
             $widget = new ExportWidget();
             // create csv-export link
             $csvExport = export_link($this->course_id, "person", sprintf('%s %s', htmlReady($this->status_groups['autor']), htmlReady($this->course_title)), 'csv', 'csv-teiln', '', _('Teilnehmendenliste als csv-Dokument exportieren'), 'passthrough');
             $widget->addLink(_('Teilnehmendenliste als CSV-Dokument exportieren'), $this->parseHref($csvExport), Icon::create('file-office', 'clickable'));
             // create csv-export link
             $rtfExport = export_link($this->course_id, "person", sprintf('%s %s', htmlReady($this->status_groups['autor']), htmlReady($this->course_title)), 'rtf', 'rtf-teiln', '', _('Teilnehmendenliste als rtf-Dokument exportieren'), 'passthrough');
             $widget->addLink(_('Teilnehmendenliste als rtf-Dokument exportieren'), $this->parseHref($rtfExport), Icon::create('file-text', 'clickable'));
             if (count($this->awaiting) > 0) {
                 $awaiting_rtf = export_link($this->course_id, "person", sprintf('%s %s', _("Warteliste"), htmlReady($this->course_title)), "rtf", "rtf-warteliste", $this->waiting_type, _("Warteliste als Textdokument (.rtf) exportieren"), 'passthrough');
                 $widget->addLink(_('Warteliste als rtf-Dokument exportieren'), $this->parseHref($awaiting_rtf), Icon::create('file-office+export', 'clickable'));
                 $awaiting_csv = export_link($this->course_id, "person", sprintf('%s %s', _("Warteliste"), htmlReady($this->course_title)), "csv", "csv-warteliste", $this->waiting_type, _("Warteliste als Tabellendokument (.csv) exportieren"), 'passthrough');
                 $widget->addLink(_('Warteliste als csv-Dokument exportieren'), $this->parseHref($awaiting_csv), Icon::create('file-text+export', 'clickable'));
             }
             $sidebar->addWidget($widget);
         }
     } else {
         if ($this->is_autor || $this->is_user) {
             // Visibility preferences
             if (!$this->my_visibility['iam_visible']) {
                 $text = _('Sie sind für andere Teilnehmenden auf der Teilnehmendenliste nicht sichtbar.');
                 $icon = Icon::create('visibility-visible', 'clickable');
                 $modus = 'make_visible';
                 $link_text = _('Klicken Sie hier, um sichtbar zu werden.');
             } else {
                 $text = _('Sie sind für andere Teilnehmenden auf der Teilnehmendenliste sichtbar.');
                 $icon = Icon::create('visibility-invisible', 'clickable');
                 $modus = 'make_invisible';
                 $link_text = _('Klicken Sie hier, um unsichtbar zu werden.');
             }
             $actions = new ActionsWidget();
             $actions->addLink($link_text, $this->url_for('course/members/change_visibility', $modus, $this->my_visibility['visible_mode']), $icon, array('title' => $text));
             $sidebar->addWidget($actions);
         }
     }
 }
Exemple #16
0
 /**
  * Create a new banner
  */
 public function new_action()
 {
     // add new banner input
     if (Request::submitted('anlegen')) {
         $description = Request::get('description');
         $alttext = Request::get('alttext');
         $target_type = Request::option('target_type');
         //add the right target
         if ($target_type == 'url') {
             $target = Request::get('target');
         } else {
             if ($target_type == 'inst') {
                 $target = Request::option('institut');
             } else {
                 if ($target_type == 'user') {
                     $target = Request::username('user');
                 } else {
                     if ($target_type == 'seminar') {
                         $target = Request::option('seminar');
                     } else {
                         $target = Request::get('target');
                     }
                 }
             }
         }
         $priority = Request::int('priority');
         $errors = array();
         $upload = $_FILES['imgfile'];
         if (!$upload['name']) {
             $errors[] = _('Es wurde kein Bild ausgewählt.');
         } else {
             $banner_path = $this->bannerupload($upload['tmp_name'], $upload['size'], $upload['name'], $errors);
         }
         $startDate = explode('.', Request::get('start_date'));
         if (($x = $this->valid_date(Request::int('start_hour'), Request::int('start_minute'), $startDate[0], $startDate[1], $startDate[2])) == -1) {
             $errors[] = _('Bitte geben Sie einen gültiges Startdatum ein.');
         } else {
             $startdate = $x;
         }
         $endDate = explode('.', Request::get('end_date'));
         if (($x = $this->valid_date(Request::int('end_hour'), Request::int('end_minute'), $endDate[0], $endDate[1], $endDate[2])) == -1) {
             $errors[] = _('Bitte geben Sie einen gültiges Enddatum ein.');
         } else {
             $enddate = $x;
         }
         if (!$target && $target_type != 'none') {
             $errors[] = _('Es wurde kein Verweisziel angegeben.');
         } else {
             switch ($target_type) {
                 case 'url':
                     if (!preg_match('~^(https?|ftp)://~i', $target)) {
                         $errors[] = _('Das Verweisziel muss eine gültige URL sein (incl. http://).');
                     }
                     break;
                 case 'inst':
                     if (Institute::find($target) === null) {
                         $errors[] = _('Die angegebene Einrichtung existiert nicht. ' . 'Bitte geben Sie eine gültige Einrichtungs-ID ein.');
                     }
                     break;
                 case 'user':
                     if (User::findByUsername($target) === null) {
                         $errors[] = _('Der angegebene Benutzername existiert nicht.');
                     }
                     break;
                 case 'seminar':
                     try {
                         Seminar::getInstance($target);
                     } catch (Exception $e) {
                         $errors[] = _('Die angegebene Veranstaltung existiert nicht. ' . 'Bitte geben Sie eine gültige Veranstaltungs-ID ein.');
                     }
                     break;
                 case 'none':
                     $target = '';
                     break;
             }
         }
         if (count($errors) > 0) {
             PageLayout::postMessage(MessageBox::error(_('Es sind folgende Fehler aufgetreten:'), $errors));
         } else {
             $banner = new Banner();
             $banner->banner_path = $banner_path;
             $banner->description = $description;
             $banner->alttext = $alttext;
             $banner->target_type = $target_type;
             $banner->target = $target;
             $banner->startdate = $startdate;
             $banner->enddate = $enddate;
             $banner->priority = $priority;
             $banner->store();
             PageLayout::postMessage(MessageBox::success(_('Der Banner wurde erfolgreich gespeichert.')));
             $this->redirect('admin/banner');
         }
     }
 }
Exemple #17
0
 /**
  * Adds the appointments of a course to your schedule.
  *
  * @param  string  the ID of the course
  * @return void
  */
 function addvirtual_action($seminar_id)
 {
     $sem = Seminar::getInstance($seminar_id);
     foreach ($sem->getCycles() as $cycle) {
         $data = array('id' => $seminar_id, 'cycle_id' => $cycle->getMetaDateId(), 'color' => false);
         CalendarScheduleModel::storeSeminarEntry($data);
     }
     $this->redirect('calendar/schedule');
 }
Exemple #18
0
 public static function haveRangePermission($operation, $range_id, $user_id = '')
 {
     static $news_range_perm_cache;
     if (isset($news_range_perm_cache[$user_id . $range_id . $operation])) {
         return $news_range_perm_cache[$user_id . $range_id . $operation];
     }
     if (!$user_id) {
         $user_id = $GLOBALS['auth']->auth['uid'];
     }
     if ($GLOBALS['perm']->have_perm('root', $user_id)) {
         return $news_range_perm_cache[$user_id . $range_id . $operation] = true;
     }
     $type = get_object_type($range_id, array('global', 'sem', 'inst', 'fak', 'user'));
     switch ($type) {
         case 'global':
             if ($operation == 'view') {
                 return $news_range_perm_cache[$user_id . $range_id . $operation] = true;
             }
             break;
         case 'fak':
         case 'inst':
         case 'sem':
             if ($operation == 'view' && ($type != 'sem' || $GLOBALS['perm']->have_studip_perm('user', $range_id) || get_config('ENABLE_FREE_ACCESS') && Seminar::getInstance($range_id)->read_level == 0)) {
                 return $news_range_perm_cache[$user_id . $range_id . $operation] = true;
             }
             if ($operation == 'edit' or $operation == 'copy') {
                 if ($GLOBALS['perm']->have_studip_perm('tutor', $range_id)) {
                     return $news_range_perm_cache[$user_id . $range_id . $operation] = true;
                 }
             }
             break;
         case 'user':
             if ($operation == 'view') {
                 if ($range_id == $user_id or get_visibility_by_id($range_id)) {
                     return $news_range_perm_cache[$user_id . $range_id . $operation] = true;
                 }
             } elseif ($operation == 'edit' or $operation == 'copy') {
                 if ($GLOBALS['perm']->have_profile_perm('user', $range_id)) {
                     return $news_range_perm_cache[$user_id . $range_id . $operation] = true;
                 }
             }
             break;
     }
     return $news_range_perm_cache[$user_id . $range_id . $operation] = false;
 }
Exemple #19
0
 function setForum($newForumValue)
 {
     // only do something, if we enable the link to a thread in a forum
     if ($newForumValue) {
         // find the ForumModule which takes the role of the CoreForum in the current Seminar
         $sem = Seminar::getInstance($this->seminar_id);
         $forum_slot = $GLOBALS['SEM_CLASS'][$GLOBALS['SEM_TYPE'][$sem->status]['class']]->getSlotModule('forum');
         foreach (PluginEngine::getPlugins('ForumModule') as $plugin) {
             if (get_class($plugin) == $forum_slot) {
                 // only link if there is none yet
                 if (!$plugin->getLinkToThread($this->issue_id)) {
                     $plugin->setThreadForIssue($this->issue_id, $this->title, $this->description);
                     $this->messages[] = sprintf(_("Ordner im Forum für das Thema \"%s\" angelegt."), $this->toString());
                 }
             }
         }
     }
 }
Exemple #20
0
 /**
  * edit one room requests
  */
 public function edit_action()
 {
     Helpbar::get()->addPlainText(_('Information'), _('Hier können Sie Angaben zu gewünschten Raumeigenschaften machen.'));
     if (Request::option('new_room_request_type')) {
         $request = new RoomRequest();
         $request->seminar_id = $this->course_id;
         $request->user_id = $GLOBALS['user']->id;
         list($new_type, $id) = explode('_', Request::option('new_room_request_type'));
         if ($new_type == 'course') {
             if ($existing_request = RoomRequest::existsByCourse($this->course_id)) {
                 $request = RoomRequest::find($existing_request);
             }
         }
         if ($new_type == 'date') {
             $request->termin_id = $id;
             if ($existing_request = RoomRequest::existsByDate($id)) {
                 $request = RoomRequest::find($existing_request);
             }
         } elseif ($new_type == 'cycle') {
             $request->metadate_id = $id;
             if ($existing_request = RoomRequest::existsByCycle($id)) {
                 $request = RoomRequest::find($existing_request);
             }
         }
     } else {
         $request = RoomRequest::find(Request::option('request_id'));
     }
     $admission_turnout = Seminar::getInstance($this->course_id)->admission_turnout;
     $attributes = self::process_form($request, $admission_turnout);
     $this->params = array('request_id' => $request->getId());
     $this->params['fromDialog'] = Request::get('fromDialog');
     if (Request::get('origin') !== null) {
         $this->params['origin'] = Request::get('origin');
     }
     if (Request::submitted('save') || Request::submitted('save_close')) {
         if (!($request->getSettedPropertiesCount() || $request->getResourceId())) {
             PageLayout::postMessage(MessageBox::error(_("Die Anfrage konnte nicht gespeichert werden, da Sie mindestens einen Raum oder mindestens eine Eigenschaft (z.B. Anzahl der Sitzplätze) angeben müssen!")));
         } else {
             $request->setClosed(0);
             $this->request_stored = $request->store();
             if ($this->request_stored) {
                 PageLayout::postMessage(MessageBox::success(_("Die Raumanfrage und gewünschte Raumeigenschaften wurden gespeichert")));
             }
             if (Request::submitted('save_close')) {
                 if (!Request::isXhr()) {
                     $this->redirect('course/room_requests/index/' . $this->course_id);
                 } else {
                     if (Request::get('fromDialog') == true && !isset($this->params['origin'])) {
                         $this->relocate('course/room_requests/index/' . $this->course_id);
                     } else {
                         if (isset($this->params['origin'])) {
                             $this->relocate(str_replace('_', '/', $this->params['origin']) . '?cid=' . $this->course_id);
                         } else {
                             $this->relocate('course/room_requests/index/' . $this->course_id);
                         }
                     }
                 }
             }
         }
     }
     if (!$request->isNew() && $request->isDirty()) {
         PageLayout::postMessage(MessageBox::info(_("Die Änderungen an der Raumanfrage wurden noch nicht gespeichert!")));
     }
     $room_categories = array_values(array_filter(getResourcesCategories(), create_function('$a', 'return $a["is_room"] == 1;')));
     if (!$request->getCategoryId() && count($room_categories) == 1) {
         $request->setCategoryId($room_categories[0]['category_id']);
     }
     $this->search_result = $attributes['search_result'];
     $this->search_by_properties = $attributes['search_by_properties'];
     $this->admission_turnout = $admission_turnout;
     $this->request = $request;
     $this->room_categories = $room_categories;
     $this->new_room_request_type = Request::option('new_room_request_type');
     $this->is_resources_admin = getGlobalPerms($GLOBALS['user']->id);
     $actions = new ActionsWidget();
     $actions->addLink(_('Bearbeitung abbrechen'), $this->link_for('index/' . $this->course_id), Icon::create('decline', 'clickable'));
     if (getGlobalPerms($GLOBALS['user']->id) == 'admin' || $GLOBALS['perm']->have_perm('admin') && count(getMyRoomRequests(null, null, true, $request->getId()))) {
         $actions->addLink(_('Raumanfrage auflösen'), URLHelper::getLink('resources.php', array('view' => 'edit_request', 'single_request' => $request->getId())), Icon::create('admin', 'clickable'));
     }
     if (Request::isXhr()) {
         Sidebar::Get()->addWidget($actions);
         $widget = new SidebarWidget();
         $widget->setTitle(_('Informationen'));
         if ($request->isNew()) {
             $widget->addElement(new WidgetElement(_('Dies ist eine neue Raumanfrage.')));
         } else {
             $info_txt = '<p>' . sprintf(_('Erstellt von: %s'), User::find($request->user_id)->getFullname()) . '</p>';
             $info_txt .= '<p>' . sprintf(_('Erstellt am: %s'), strftime('%x %H:%M', $request->mkdate)) . '</p>';
             $info_txt .= '<p>' . sprintf(_('Letzte Änderung: %s'), strftime('%x %H:%M', $request->chdate)) . '</p>';
             $widget->addElement(new WidgetElement($info_txt));
         }
         Sidebar::Get()->addWidget($widget);
     }
 }
 /**
  * create course
  *
  * creates new ilias course
  * @access public
  * @param string $seminar_id seminar-id
  * @return boolean successful
  */
 function createCourse($seminar_id)
 {
     global $messages, $SessSemName, $DEFAULT_LANGUAGE, $ELEARNING_INTERFACE_MODULES;
     $crs_id = ObjectConnections::getConnectionModuleId($seminar_id, "crs", $this->cms_type);
     $this->soap_client->setCachingStatus(false);
     $this->soap_client->clearCache();
     if ($crs_id == false) {
         $seminar = Seminar::getInstance($seminar_id);
         $home_institute = Institute::find($seminar->getInstitutId());
         if ($home_institute) {
             $ref_id = ObjectConnections::getConnectionModuleId($home_institute->getId(), "cat", $this->cms_type);
         }
         if ($ref_id < 1) {
             // Kategorie für Heimateinrichtung anlegen
             $object_data["title"] = sprintf("%s", $home_institute->name);
             $object_data["description"] = sprintf(_("Hier befinden sich die Veranstaltungsdaten zur Stud.IP-Einrichtung \"%s\"."), $home_institute->name);
             $object_data["type"] = "cat";
             $object_data["owner"] = $this->soap_client->LookupUser($ELEARNING_INTERFACE_MODULES[$this->cms_type]["soap_data"]["username"]);
             $ref_id = $this->soap_client->addObject($object_data, $this->main_category_node_id);
             ObjectConnections::setConnection($home_institute->getId(), $ref_id, "cat", $this->cms_type);
         }
         if ($ref_id < 1) {
             $ref_id = $this->main_category_node_id;
         }
         // Kurs anlegen
         $lang_array = explode("_", $DEFAULT_LANGUAGE);
         $course_data["language"] = $lang_array[0];
         $course_data["title"] = "Stud.IP-Kurs " . $seminar->getName();
         $course_data["description"] = "";
         $crs_id = $this->soap_client->addCourse($course_data, $ref_id);
         if ($crs_id == false) {
             $messages["error"] .= _("Zuordnungs-Fehler: Kurs konnte nicht angelegt werden.");
             return false;
         }
         ObjectConnections::setConnection($seminar_id, $crs_id, "crs", $this->cms_type);
         // Rollen zuordnen
         $this->permissions->CheckUserPermissions($crs_id);
     }
     return $crs_id;
 }
Exemple #22
0
 <tr>
     <td style="vertical-align: top">
         <?
         printf("<b>" . _("Erster Termin:") . "</b><br>%s", veranstaltung_beginn($_SESSION['archiv_assi_data']["sems"][$_SESSION['archiv_assi_data']["pos"]]["id"]));
         ?>
     </td>
     <td style="vertical-align: top">
         <?
         printf("<b>" . _("Vorbesprechung:") . "</b><br>%s", (vorbesprechung($_SESSION['archiv_assi_data']["sems"][$_SESSION['archiv_assi_data']["pos"]]["id"])) ? htmlReady(vorbesprechung($_SESSION['archiv_assi_data']["sems"][$_SESSION['archiv_assi_data']["pos"]]["id"])) : _("keine"));
         ?>
     </td>
 </tr>
 <tr>
     <td style="vertical-align: top">
         <?
         $sem = Seminar::getInstance($_SESSION['archiv_assi_data']['sems'][$_SESSION['archiv_assi_data']['pos']]['id']);
         printf("<b>" . _("Veranstaltungsort:") . "</b><br>%s",
             htmlReady($sem->getDatesTemplate('dates/seminar_export_location')));
         ?>
     </td>
     <td style="vertical-align: top">
         <?
         if ($seminar['VeranstaltungsNummer'])
             printf("<b>" . _("Veranstaltungsnummer:") . "</b><br>%s", htmlReady($seminar['VeranstaltungsNummer']));
         else
             print "&nbsp; ";
         ?>
     </td>
 </tr>
 <tr>
     <td style="vertical-align: top">
Exemple #23
0
 function get_title($seminar_id)
 {
     $seminar_id = preg_replace('/\\W/', '', $seminar_id);
     return Seminar::getInstance($seminar_id)->getName();
 }
Exemple #24
0
 /**
  * Returns an HTML fragment of a grouped entry in the schedule of an institute.
  *
  * @param string $start the start time of the group, e.g. "1000"
  * @param string $end   the end time of the group, e.g. "1200"
  * @param string $seminars  the IDs of the courses
  * @param string $day  numeric day to show
  *
  * @return void
  */
 function groupedentry_action($start, $end, $seminars, $day)
 {
     $this->response->add_header('Content-Type', 'text/html; charset=windows-1252');
     // strucutre of an id: seminar_id-cycle_id
     // we do not need the cycle id here, so we trash it.
     $seminar_list = array();
     foreach (explode(',', $seminars) as $seminar) {
         $zw = explode('-', $seminar);
         $this->seminars[$zw[0]] = Seminar::getInstance($zw[0]);
     }
     $this->start = substr($start, 0, 2) . ':' . substr($start, 2, 2);
     $this->end = substr($end, 0, 2) . ':' . substr($end, 2, 2);
     $day_names = array(_("Montag"), _("Dienstag"), _("Mittwoch"), _("Donnerstag"), _("Freitag"), _("Samstag"), _("Sonntag"));
     $this->day = $day_names[(int) $day];
     $this->render_template('calendar/instschedule/_entry_details');
 }
Exemple #25
0
 function getForumThreadURL()
 {
     if ($this->seminar_id) {
         $forum_module = Seminar::getInstance($this->seminar_id)->getSlotModule('forum');
         if ($forum_module instanceof ForumModule) {
             return html_entity_decode($forum_module->getLinkToThread($this->id));
         }
     }
     return '';
 }
Exemple #26
0
 /**
  * This action remove a user from course
  * @param $course_id
  */
 public function decline_action($course_id, $waiting = null)
 {
     $current_seminar = Seminar::getInstance($course_id);
     $ticket_check = Seminar_Session::check_ticket(Request::option('studipticket'));
     if (LockRules::Check($course_id, 'participants')) {
         $lockdata = LockRules::getObjectRule($course_id);
         PageLayout::postMessage(MessageBox::error(sprintf(_("Sie können sich nicht von der Veranstaltung <b>%s</b> abmelden."), htmlReady($current_seminar->name))));
         if ($lockdata['description']) {
             PageLayout::postMessage(MessageBox::info(formatLinks($lockdata['description'])));
         }
         $this->redirect('my_courses/index');
         return;
     }
     if (Request::option('cmd') == 'back') {
         $this->redirect('my_courses/index');
         return;
     }
     if (Request::option('cmd') != 'kill' && Request::option('cmd') != 'kill_admission') {
         if ($current_seminar->admission_binding && Request::get('cmd') != 'suppose_to_kill_admission' && !LockRules::Check($current_seminar->getId(), 'participants')) {
             PageLayout::postMessage(MessageBox::error(sprintf(_("Die Veranstaltung <b>%s</b> ist als <b>bindend</b> angelegt.\n                    Wenn Sie sich abmelden wollen, müssen Sie sich an die Lehrende der Veranstaltung wenden."), htmlReady($current_seminar->name))));
             $this->redirect('my_courses/index');
             return;
         }
         if (Request::get('cmd') == 'suppose_to_kill') {
             // check course admission
             list(, $admission_end_time) = @array_values($current_seminar->getAdmissionTimeFrame());
             $admission_enabled = $current_seminar->isAdmissionEnabled();
             $admission_locked = $current_seminar->isAdmissionLocked();
             if ($admission_enabled || $admission_locked || (int) $current_seminar->admission_prelim == 1) {
                 $message = sprintf(_('Wollen Sie sich von der teilnahmebeschränkten Veranstaltung "%s" wirklich abmelden? Sie verlieren damit die Berechtigung für die Veranstaltung und müssen sich ggf. neu anmelden!'), $current_seminar->name);
             } else {
                 if (isset($admission_end_time) && $admission_end_time < time()) {
                     $message = sprintf(_('Wollen Sie sich von der teilnahmebeschränkten Veranstaltung "%s" wirklich abmelden? Der Anmeldzeitraum ist abgelaufen und Sie können sich nicht wieder anmelden!'), $current_seminar->name);
                 } else {
                     $message = sprintf(_('Wollen Sie sich von der Veranstaltung "%s" wirklich abmelden?'), $current_seminar->name);
                 }
             }
             $this->flash['cmd'] = 'kill';
         } else {
             if (admission_seminar_user_get_position($GLOBALS['user']->id, $course_id) === false) {
                 $message = sprintf(_('Wollen Sie sich von der Anmeldeliste der Veranstaltung "%s" wirklich abmelden?'), $current_seminar->name);
             } else {
                 $message = sprintf(_('Wollen Sie sich von der Warteliste der Veranstaltung "%s" wirklich abmelden? Sie verlieren damit die bereits erreichte Position und müssen sich ggf. neu anmelden!'), $current_seminar->name);
             }
             $this->flash['cmd'] = 'kill_admission';
         }
         $this->flash['decline_course'] = true;
         $this->flash['course_id'] = $course_id;
         $this->flash['message'] = $message;
         $this->flash['studipticket'] = Seminar_Session::get_ticket();
         $this->redirect('my_courses/index');
         return;
     } else {
         if (!LockRules::Check($course_id, 'participants') && $ticket_check && Request::option('cmd') != 'back' && Request::get('cmd') != 'kill_admission') {
             $query = "DELETE FROM seminar_user WHERE user_id = ? AND Seminar_id = ?";
             $statement = DBManager::get()->prepare($query);
             $statement->execute(array($GLOBALS['user']->id, $course_id));
             if ($statement->rowCount() == 0) {
                 PageLayout::postMessage(MessageBox::error(_('In der ausgewählten Veranstaltung wurde die gesuchten Personen nicht gefunden und konnte daher nicht ausgetragen werden.')));
             } else {
                 // LOGGING
                 StudipLog::log('SEM_USER_DEL', $course_id, $GLOBALS['user']->id, 'Hat sich selbst ausgetragen');
                 // enable others to do something after the user has been deleted
                 NotificationCenter::postNotification('UserDidLeaveCourse', $course_id, $GLOBALS['user']->id);
                 // Delete from statusgroups
                 RemovePersonStatusgruppeComplete(get_username(), $course_id);
                 // Are successor available
                 update_admission($course_id);
                 PageLayout::postMessage(MessageBox::success(sprintf(_("Erfolgreich von Veranstaltung <b>%s</b> abgemeldet."), htmlReady($current_seminar->name))));
             }
         } else {
             // LOGGING
             StudipLog::log('SEM_USER_DEL', $course_id, $GLOBALS['user']->id, 'Hat sich selbst aus der Warteliste ausgetragen');
             if ($current_seminar->isAdmissionEnabled()) {
                 $prio_delete = AdmissionPriority::unsetPriority($current_seminar->getCourseSet()->getId(), $GLOBALS['user']->id, $course_id);
             }
             $query = "DELETE FROM admission_seminar_user WHERE user_id = ? AND seminar_id = ?";
             $statement = DBManager::get()->prepare($query);
             $statement->execute(array($GLOBALS['user']->id, $course_id));
             if ($statement->rowCount() || $prio_delete) {
                 //Warteliste neu sortieren
                 renumber_admission($course_id);
                 //Pruefen, ob es Nachruecker gibt
                 update_admission($course_id);
                 PageLayout::postMessage(MessageBox::success(sprintf(_("Der Eintrag in der Anmelde- bzw. Warteliste der Veranstaltung <b>%s</b> wurde aufgehoben.\n                    Wenn Sie an der Veranstaltung teilnehmen wollen, müssen Sie sich erneut bewerben."), htmlReady($current_seminar->name))));
             }
         }
         $this->redirect('my_courses/index');
         return;
     }
 }
Exemple #27
0
 /**
  * gets all user_ids of related persons of this date
  * @return array of user_ids
  */
 public function getRelatedPersons()
 {
     if (count($this->related_persons)) {
         return $this->related_persons;
     } else {
         $sem = Seminar::getInstance($this->getSeminarID());
         return array_keys($sem->getMembers('dozent'));
     }
 }
Exemple #28
0
function dump_sem($sem_id, $print_view = false)
{
    global $TERMIN_TYP, $SEM_TYPE, $SEM_CLASS, $_fullname_sql, $AUTO_INSERT_SEM;

    $Modules = new Modules;
    $Modules = $Modules->getLocalModules($sem_id);

    $query = "SELECT status, Name, Untertitel, art, VeranstaltungsNummer,
                     ects, Beschreibung, teilnehmer, vorrausetzungen,
                     lernorga, leistungsnachweis, Sonstiges, Institut_id,
                     admission_turnout
              FROM seminare
              WHERE Seminar_id = ?";
    $statement = DBManager::get()->prepare($query);
    $statement->execute(array($sem_id));
    $seminar = $statement->fetch(PDO::FETCH_ASSOC);

    $sem_type = $seminar['status'];

    $sem = Seminar::getInstance($sem_id);

    $dump  = '<table width="100%" border="1" cellpadding="2" cellspacing="0">';
    $dump .= '<tr><td colspan="2" align="left" class="table_header_bold">';
    $dump .= '<h1 class="table_header_bold">&nbsp;' . htmlReady($seminar['Name'], 1, 1) . '</h1>';
    $dump .= '</td></tr>' . "\n";

    // Helper function that dumps into a single table row
    $dumpRow = function ($title, $content, $escape = false) use (&$dump) {
        $content = trim($content);
        if ($content) {
            if ($escape) {
                $content = htmlReady($content, 1, 1);
            }
            $dump .= sprintf('<tr><td width="15%%"><b>%s</b></td><td>%s</td></tr>' . "\n",
                             htmlReady($title), $content);
        }
    };

    //Grunddaten des Seminars, wie in den seminar_main
    $dumpRow(_('Untertitel:'), $seminar['Untertitel'], true);

    if ($data = $sem->getDatesExport()) {
        $dumpRow(_('Zeit:'), nl2br($data));
    }

    $dumpRow(_('Semester:'), get_semester($sem_id));
    $dumpRow(_('Erster Termin:'), veranstaltung_beginn($sem_id, 'export'));

    if ($temp = vorbesprechung($sem_id, 'export')) {
        $dumpRow(_('Vorbesprechung:'), htmlReady($temp));
    }

    if ($data = $sem->getDatesTemplate('dates/seminar_export_location')) {
        $dumpRow(_('Ort:'), nl2br($data));
    }

    //wer macht den Dozenten?
    $query = "SELECT {$_fullname_sql['full']} AS fullname
              FROM seminar_user
              LEFT JOIN auth_user_md5 USING (user_id)
              LEFT JOIN user_info USING (user_id)
              WHERE Seminar_id = ? AND status = 'dozent'
              ORDER BY position, Nachname";
    $statement = DBManager::get()->prepare($query);
    $statement->execute(array($sem_id));
    $teachers = $statement->fetchAll(PDO::FETCH_COLUMN);
    if (count($teachers) > 0) {
        $title = get_title_for_status('dozent', count($teachers), $sem_type);
        $dumpRow($title, implode('<br>', array_map('htmlReady', $teachers)));
    }

    //und wer ist Tutor?
    $query = "SELECT {$_fullname_sql['full']} AS fullname
              FROM seminar_user
              LEFT JOIN auth_user_md5 USING (user_id)
              LEFT JOIN user_info USING (user_id)
              WHERE Seminar_id = ? AND status = 'tutor'
              ORDER BY position, Nachname";
    $statement = DBManager::get()->prepare($query);
    $statement->execute(array($sem_id));
    $tutors = $statement->fetchAll(PDO::FETCH_COLUMN);
    if (count($tutors) > 0) {
        $title = get_title_for_status('tutor', count($tutors), $sem_type);
        $dumpRow($title, implode('<br>', array_map('htmlReady', $tutors)));
    }

    if ($seminar['status'] != '' && isset($SEM_TYPE[$seminar['status']])) {
        $content  = $SEM_TYPE[$seminar['status']]['name'];
        $content .= ' ' . _('in der Kategorie') . ' ';
        $content .= '<b>' . $SEM_CLASS[$SEM_TYPE[$seminar['status']]['class']]['name'] . '</b>';
        $dumpRow(_('Typ der Veranstaltung'), $content);
    }

    $dumpRow(_('Art der Veranstaltung:'), $seminar['art'], true);
    $dumpRow(_('VeranstaltungsNummer:'), htmlReady($seminar['VeranstaltungsNummer']));
    $dumpRow(_('ECTS-Punkte:'), htmlReady($seminar['ects']));
    $dumpRow(_('Beschreibung:'), $seminar['Beschreibung'], true);
    $dumpRow(_('Teilnehmende:'), $seminar['teilnehmende'], true);
    $dumpRow(_('Voraussetzungen:'), $seminar['vorrausetzungen'], true);
    $dumpRow(_('Lernorganisation:'), $seminar['lernorga'], true);
    $dumpRow(_('Leistungsnachweis:'), $seminar['leistungsnachweis'], true);

    //add the free adminstrable datafields
    $localEntries = DataFieldEntry::getDataFieldEntries($sem_id);
    foreach ($localEntries as $entry) {
        $dumpRow($entry->getName(), $entry->getDisplayValue());
    }

    $dumpRow(_('Sonstiges:'), $seminar['Sonstiges'], true);

    // Fakultaeten...
    $query = "SELECT DISTINCT c.Name
              FROM seminar_inst AS a
              LEFT JOIN Institute AS b USING (Institut_id)
              LEFT JOIN Institute AS c ON (c.Institut_id = b.fakultaets_id)
              WHERE a.seminar_id = ?";
    $statement = DBManager::get()->prepare($query);
    $statement->execute(array($sem_id));
    $faculties = $statement->fetchAll(PDO::FETCH_COLUMN);
    if (count($faculties) > 0) {
        $dumpRow(_('Fakultät(en):'), implode('<br>', array_map('htmlReady', $faculties)));
    }

    //Studienbereiche
    if (isset($SEM_TYPE[$seminar['status']]) && $SEM_CLASS[$SEM_TYPE[$seminar['status']]['class']]['bereiche']) {
        $sem_path = get_sem_tree_path($sem_id) ?: array();
        $dumpRow(_('Studienbereiche') . ':', implode('<br>', array_map('htmlReady', $sem_path)));
    }

    $iid = $seminar['Institut_id'];
    $query = "SELECT Name FROM Institute WHERE Institut_id = ?";
    $statement = DBManager::get()->prepare($query);
    $statement->execute(array($iid));
    $inst_name = $statement->fetchColumn();
    $dumpRow(_('Heimat-Einrichtung:'), $inst_name, true);

    $query = "SELECT Name
              FROM seminar_inst
              LEFT JOIN Institute USING (institut_id)
              WHERE seminar_id = ? AND Institute.institut_id != ?";
    $statement = DBManager::get()->prepare($query);
    $statement->execute(array($sem_id, $iid));
    $other_institutes = $statement->fetchAll(PDO::FETCH_COLUMN);
    if (count($other_institutes) > 0) {
        $title = (count($other_institutes) == 1)
               ? _('Beteiligte Einrichtung:')
               : _('Beteiligte Einrichtungen:');
        $dumpRow($title, implode(', ', array_map('htmlReady', $other_institutes)));
    }

    //Teilnehmeranzahl
    $dumpRow(_('max. Personenanzahl:'), $seminar['admission_turnout']);

    //Statistikfunktionen
    $query = "SELECT COUNT(*) FROM seminar_user WHERE Seminar_id = ?";
    $statement = DBManager::get()->prepare($query);
    $statement->execute(array($sem_id));
    $count = $statement->fetchColumn();
    $dumpRow(_('Anzahl der angemeldeten Personen:'), $count);

    // number of postings for all forum-modules in this seminar
    $count = 0;
    $forum_modules = PluginEngine::getPlugins('ForumModule', $sem_id);
    foreach ($forum_modules as $plugin) {
        $count += $plugin->getNumberOfPostingsForSeminar($sem_id);
    }
    $dumpRow(_('Forenbeiträge:'), $count);

    if ($Modules['documents']) {
        //do not show hidden documents
        $unreadable_folders = array();
        if ($print_view) {
            $check_user = $print_view === true ? $GLOBALS['user']->id : $print_view;
            if ($Modules['documents_folder_permissions'] || StudipDocumentTree::ExistsGroupFolders($sem_id)) {
                if (!$GLOBALS['perm']->have_studip_perm('tutor', $sem_id, $check_user)) {
                    $folder_tree = TreeAbstract::GetInstance('StudipDocumentTree', array('range_id' => $sem_id,'entity_type' => 'sem'));
                    $unreadable_folders = $folder_tree->getUnReadableFolders($check_user);
                }
            }
        }
        $query = "SELECT COUNT(*) FROM dokumente WHERE seminar_id = ?";
        $parameters = array($sem_id);

        if (count($unreadable_folders) > 0) {
            $query .= " AND range_id NOT IN(?)";
            $parameters[] = $unreadable_folders;
        }
        $statement = DBManager::get()->prepare($query);
        $statement->execute($parameters);
        $docs = $statement->fetchColumn();
    }
    $dumpRow(_('Dokumente:'), $docs ?: 0);

    $dump.= '</table>' . "\n";

    // Ablaufplan
    if ($Modules['schedule']) {
        $dump.= dumpRegularDatesSchedule($sem_id);
        $dump.= dumpExtraDatesSchedule($sem_id);
    }

    //SCM
    if ($Modules['scm']) {
        foreach(StudipScmEntry::findByRange_id($sem_id, 'ORDER BY position ASC') as $scm) {
            if (!empty($scm->content)) {
                $dump .= '<br>';
                $dump .= '<table width="100%" border="1" cellpadding="2" cellspacing="0">';
                $dump .= ' <tr><td align="left" class="table_header_bold">';
                $dump .= '<h2 class="table_header_bold">&nbsp;' . htmlReady($scm->tab_name) . '</h2>';
                $dump .= '</td></tr>' . "\n";
                $dump .= '<tr><td align="left" width="100%"><br>'. formatReady($scm->content, 1, 1) .'<br></td></tr>' . "\n";
                $dump .= '</table>' . "\n";
            }
        }
    }

    if ($Modules['literature']) {
        $lit = StudipLitList::GetFormattedListsByRange($sem_id, false, false);
        if ($lit) {
            $dump .= '<br>';
            $dump .= '<table width="100%" border="1" cellpadding="2" cellspacing="0">';
            $dump .= '<tr><td align="left" class="table_header_bold">';
            $dump .= '<h2 class="table_header_bold">&nbsp;' . _('Literaturlisten') . '</h2>';
            $dump .= '</td></tr>' . "\n";
            $dump .= '<tr><td align="left" width="100%"><br>'. $lit .'<br></td></tr>' . "\n";
            $dump .= '</table>' . "\n";
        }
    }

    // Dateien anzeigen
    if ($Modules['documents']) {

        $link_text = _('Hinweis: Diese Datei wurde nicht archiviert, da sie lediglich verlinkt wurde.');
        $query = "SELECT name, filename, mkdate, filesize, Nachname AS nachname,
                         IF(url != '', CONCAT('{$link_text}', ' / ', description), description) AS description
                  FROM dokumente
                  LEFT JOIN auth_user_md5 USING (user_id)
                  WHERE seminar_id = ?";
        $parameters = array($sem_id);

        if (count($unreadable_folders) > 0) {
            $query .= " AND range_id NOT IN (?)";
            $parameters[] = $unreadable_folders;
        }

        $statement = DBManager::get()->prepare($query);
        $statement->execute($parameters);
        $dbresult = $statement->fetchAll(PDO::FETCH_ASSOC);

        if (count($dbresult) > 0) {
            $dump .= '<br>';
            $dump .= '<table width="100%" border="1" cellpadding="2" cellspacing="0">';
            $dump .= '<tr><td align="left" colspan="3" class="table_header_bold">';
            $dump .= '<h2 class="table_header_bold">&nbsp;' . _('Dateien:') . '</h2>';
            $dump .= '</td></tr>' . "\n";

            foreach ($dbresult as $row) {
                $name = ($row['name'] && $row['name'] != $row['filename'])
                      ? $row['name'] . ' (' . $row['filename'] . ')'
                      : $row['filename'];
                $dump .= sprintf('<tr><td width="100%%"><b>%s</b><br>%s (%u KB)</td><td>%s</td><td>%s</td></tr>' . "\n",
                                 htmlReady($name),
                                 htmlReady($row['description']),
                                 round($row['filesize'] / 1024),
                                 htmlReady($row['nachname']),
                                 date('d.m.Y', $row['mkdate']));
            }

            $dump .= '</table>' . "\n";
        }
    }

    // Teilnehmer
    if ($Modules['participants']
        && (Config::get()->AUTO_INSERT_SEM_PARTICIPANTS_VIEW_PERM || !in_array($sem_id, AutoInsert::getAllSeminars(true))))
    {
        $dump .= '<br>';

        // Prepare statement that obtains the number of document a specific
        // user has uploaded into a specific seminar
        $documents_params = array($sem_id, null);
        $query = "SELECT COUNT(*) FROM dokumente WHERE Seminar_id = ? AND user_id = ?";
        if (count($unreadable_folders) > 0) {
            $query .= " AND range_id NOT IN (?)";
            $documents_params[] = $unreadable_folders;

        }
        $documents_statement = DBManager::get()->prepare($query);
        // Prepare statement that obtains all participants of a specific
        // seminar with a specific status
        $ext_vis_query = get_ext_vis_query('seminar_user');
        $query = "SELECT user_id, {$_fullname_sql['full']} AS fullname,
                         {$ext_vis_query} AS user_is_visible
                    FROM seminar_user
                    LEFT JOIN auth_user_md5 USING (user_id)
                    LEFT JOIN user_info USING (user_id)
                    WHERE Seminar_id = ? AND status = ?
                    GROUP by user_id
                    ORDER BY Nachname, Vorname";
        $user_statement = DBManager::get()->prepare($query);

        foreach (words('dozent tutor autor user') as $key) {
            // die eigentliche Teil-Tabelle

            $user_statement->execute(array($sem_id, $key));
            $users = $user_statement->fetchAll(PDO::FETCH_ASSOC);
            $user_statement->closeCursor();

            //haben wir in der Personengattung ueberhaupt einen Eintrag?
            if (count($users) > 0) {
                $dump .= '<table width="100%" border="1" cellpadding="2" cellspacing="0">';
                $dump .= '<tr><td align="left" colspan="3" class="table_header_bold">';
                $dump .= '<h2 class="table_header_bold">&nbsp;' . get_title_for_status($key, count($users), $sem_type) . '</h2>';
                $dump .= '</td></tr>' . "\n";
                $dump .= '<th width="30%">' . _('Name') . '</th>';
                $dump .= '<th width="10%">' . _('Forenbeiträge') . '</th>';
                $dump .= '<th width="10%">' . _('Dokumente') . '</th></tr>' . "\n";

                foreach ($users as $user) {
                    $documents_params[1] = $user['user_id'];
                    $documents_statement->execute($documents_params);
                    $count = $documents_statement->fetchColumn() ?: 0;
                    $documents_statement->closeCursor();

                    // get number of postings for this user from all forum-modules
                    $postings = 0;
                    foreach ($forum_modules as $plugin) {
                        $postings += $plugin->getNumberOfPostingsForUser($user['user_id'], $sem_id);
                    }

                    $dump .= sprintf('<tr><td>%s</td><td align="center">%u</td><td align="center">%u</td></tr>' . "\n",
                                     $user['user_is_visible'] ? htmlReady($user['fullname']) : _('(unsichtbareR NutzerIn)'),
                                     $postings, $count);
                } // eine Zeile zuende

                $dump.= '</table>' . "\n";
            }
        } // eine Gruppe zuende
    }

    return $dump;
} // end function dump_sem($sem_id)
Exemple #29
0
// -- here you have to put initialisations for the current page
$course_id = $_SESSION['SessionSeminar'];
//set visitdate for course, when coming from my_courses
if (Request::get('auswahl')) {
    object_set_visit($course_id, "sem");
}
// gibt es eine Anweisung zur Umleitung?
if (Request::get('redirect_to')) {
    $query_parts = explode('&', stristr(urldecode($_SERVER['QUERY_STRING']), 'redirect_to'));
    list(, $where_to) = explode('=', array_shift($query_parts));
    $new_query = $where_to . '?' . join('&', $query_parts);
    $new_query = preg_replace('/[^:0-9a-z+_\\-.#?&=\\/]/i', '', $new_query);
    header('Location: ' . URLHelper::getURL($new_query, array('cid' => $course_id)));
    die;
}
$sem_class = Seminar::getInstance($course_id)->getSemClass();
if ($sem_class->getSlotModule("overview")) {
    foreach ($sem_class->getNavigationForSlot("overview") as $nav) {
        header('Location: ' . URLHelper::getURL($nav->getURL()));
        die;
    }
} else {
    $Modules = new Modules();
    $course_modules = $Modules->getLocalModules($course_id);
    if (!$course_modules['overview'] && !$sem_class->isSlotMandatory("overview")) {
        //Keine Übersichtsseite. Anstatt eines Fehler wird der Nutzer zum ersten
        //Reiter der Veranstaltung weiter geleitet.
        if (Navigation::hasItem("/course")) {
            foreach (Navigation::getItem("/course")->getSubNavigation() as $navigation) {
                header('Location: ' . URLHelper::getURL($navigation->getURL()));
                die;