/** * common tasks for all actions */ function before_filter(&$action, &$args) { global $perm; parent::before_filter($action, $args); if (Request::get('termin_id')) { $this->dates[0] = new SingleDate(Request::option('termin_id')); $this->course_id = $this->dates[0]->range_id; } if (Request::get('issue_id')) { $this->issue_id = Request::option('issue_id'); $this->dates = array_values(array_map(function ($data) { $d = new SingleDate(); $d->fillValuesFromArray($data); return $d; }, IssueDB::getDatesforIssue(Request::option('issue_id')))); $this->course_id = $this->dates[0]->range_id; } if (!get_object_type($this->course_id, array('sem')) || SeminarCategories::GetBySeminarId($this->course_id)->studygroup_mode || !$perm->have_studip_perm("tutor", $this->course_id)) { throw new Trails_Exception(400); } PageLayout::setHelpKeyword("Basis.VeranstaltungenVerwaltenAendernVonZeitenUndTerminen"); PageLayout::setTitle(Course::findCurrent()->getFullname() . " - " . _("Veranstaltungstermine absagen")); $this->set_content_type('text/html;charset=windows-1252'); if (Request::isXhr()) { $this->set_layout(null); $this->response->add_header('X-Title', PageLayout::getTitle()); $request = Request::getInstance(); foreach ($request as $key => $value) { $request[$key] = studip_utf8decode($value); } } }
/** * common tasks for all actions */ function before_filter(&$action, &$args) { global $perm; parent::before_filter($action, $args); $course_id = $args[0]; $this->course_id = Request::option('cid', $course_id); Navigation::activateItem('/course/admin/admission'); if (!get_object_type($this->course_id, array('sem')) || SeminarCategories::GetBySeminarId($this->course_id)->studygroup_mode || !$perm->have_studip_perm("tutor", $this->course_id)) { throw new Trails_Exception(403); } $this->course = Course::find($this->course_id); $this->user_id = $GLOBALS['user']->id; PageLayout::setHelpKeyword("Basis.VeranstaltungenVerwaltenZugangsberechtigungen"); PageLayout::setTitle($this->course->getFullname() . " - " . _("Verwaltung von Zugangsberechtigungen")); $lockrules = words('admission_turnout admission_type admission_endtime admission_binding passwort read_level write_level admission_prelim admission_prelim_txt admission_starttime admission_endtime_sem admission_disable_waitlist user_domain admission_binding admission_studiengang'); foreach ($lockrules as $rule) { $this->is_locked[$rule] = LockRules::Check($this->course_id, $rule) ? 'disabled readonly' : ''; } if (!SeminarCategories::GetByTypeId($this->course->status)->write_access_nobody) { $this->is_locked['write_level'] = 'disabled readonly'; } update_admission($this->course->id); PageLayout::addSqueezePackage('admission'); URLHelper::addLinkParam('return_to_dialog', Request::get('return_to_dialog')); }
/** * returns datafields belonging to given model * if a datafield entry not exists yet, a new DatafieldEntryModel is returned * second param filters for a given datafield id * * @param SimpleORMap $model Course,Institute,User,CourseMember or InstituteMember * @param string $datafield_id * @return array of DatafieldEntryModel */ public static function findByModel(SimpleORMap $model, $datafield_id = null) { $mask = array("user" => 1, "autor" => 2, "tutor" => 4, "dozent" => 8, "admin" => 16, "root" => 32); if (is_a($model, "Course")) { $object_class = SeminarCategories::GetByTypeId($model->status)->id; $object_type = 'sem'; $range_id = $model->getId(); } elseif (is_a($model, "Institute")) { $object_class = $model->type; $object_type = 'inst'; $range_id = $model->getId(); } elseif (is_a($model, "User")) { $object_class = $mask[$model->perms]; $object_type = 'user'; $range_id = $model->getId(); } elseif (is_a($model, "CourseMember")) { $object_class = $mask[$model->status]; $object_type = 'usersemdata'; $range_id = $model->user_id; $sec_range_id = $model->seminar_id; } elseif (is_a($model, "InstituteMember")) { $object_class = $mask[$model->inst_perms]; $object_type = 'userinstrole'; $range_id = $model->user_id; $sec_range_id = $model->institut_id; } if (!$object_type) { throw new InvalidArgumentException('Wrong type of model: ' . get_class($model)); } if ($datafield_id !== null) { $one_datafield = " AND a.datafield_id = " . DBManager::get()->quote($datafield_id); } $query = "SELECT a.*, b.*,a.datafield_id,b.datafield_id as isset_content "; $query .= "FROM datafields a LEFT JOIN datafields_entries b ON (a.datafield_id=b.datafield_id AND range_id = ? AND sec_range_id = ?) "; $query .= "WHERE object_type = ? AND ((object_class & ?) OR object_class IS NULL) {$one_datafield} ORDER BY priority"; $st = DBManager::get()->prepare($query); $st->execute(array((string) $range_id, (string) $sec_range_id, $object_type, (int) $object_class)); $ret = array(); $c = 0; $df_entry = new DatafieldEntryModel(); $df = new DataField(); while ($row = $st->fetch(PDO::FETCH_ASSOC)) { $ret[$c] = clone $df_entry; $ret[$c]->setData($row, true); if (!$row['isset_content']) { $ret[$c]->setValue('range_id', (string) $range_id); $ret[$c]->setValue('sec_range_id', (string) $sec_range_id); } $ret[$c]->setNew(!$row['isset_content']); $cloned_df = clone $df; $cloned_df->setData($row, true); $cloned_df->setNew(false); $ret[$c]->setValue('datafield', $cloned_df); ++$c; } return $ret; }
/** * Common tasks for all actions * * @param String $action Called action * @param Array $args Possible arguments */ public function before_filter(&$action, &$args) { parent::before_filter($action, $args); $course_id = $args[0]; $this->course_id = Request::option('cid', $course_id); if (!get_object_type($this->course_id, array('sem')) || SeminarCategories::GetBySeminarId($this->course_id)->studygroup_mode || !$GLOBALS['perm']->have_studip_perm("tutor", $this->course_id)) { throw new Trails_Exception(400); } PageLayout::addSqueezePackage('raumzeit'); PageLayout::setHelpKeyword('Basis.VeranstaltungenVerwaltenAendernVonZeitenUndTerminen'); PageLayout::setTitle(Course::findCurrent()->getFullname() . " - " . _('Blockveranstaltungstermine anlegen')); }
function before_filter(&$action, &$args) { parent::before_filter($action, $args); $course_id = Request::option('cid'); if (isset($_SESSION['seminar_change_view_' . $course_id])) { unset($_SESSION['seminar_change_view_' . $course_id]); // Reset simulated view, redirect to administration page. $this->redirect(URLHelper::getURL('dispatch.php/course/management')); } elseif (get_object_type($course_id, array('sem')) && !SeminarCategories::GetBySeminarId($course_id)->studygroup_mode && in_array($GLOBALS['perm']->get_studip_perm($course_id), words('tutor dozent'))) { // Set simulated view, redirect to overview page. $_SESSION['seminar_change_view_' . $course_id] = 'autor'; $this->redirect(URLHelper::getURL('seminar_main.php')); } else { throw new Trails_Exception(400); } }
/** * Common tasks for all actions * * @param String $action Called action * @param Array $args Possible arguments */ public function before_filter(&$action, &$args) { global $perm; $this->current_action = $action; parent::before_filter($action, $args); $course_id = $args[0]; $this->course_id = Request::option('cid', $course_id); if ($course_id != '-') { //Navigation in der Veranstaltung: Navigation::activateItem('/course/admin/room_requests'); if (!get_object_type($this->course_id, array('sem')) || SeminarCategories::GetBySeminarId($this->course_id)->studygroup_mode || !$perm->have_studip_perm("tutor", $this->course_id)) { throw new Trails_Exception(400); } PageLayout::setHelpKeyword("Basis.VeranstaltungenVerwaltenAendernVonZeitenUndTerminen"); PageLayout::setTitle(Course::find($this->course_id)->getFullname() . " - " . _("Verwaltung von Raumanfragen")); } }
function before_filter(&$action, &$args) { parent::before_filter($action, $args); if (Config::Get()->STUDYGROUPS_ENABLE || in_array($action, words('globalmodules savemodules deactivate'))) { // args at position zero is always the studygroup-id if ($args[0]) { if (SeminarCategories::GetBySeminarId($args[0])->studygroup_mode == false) { throw new Exception(_('Dieses Seminar ist keine Studiengruppe!')); } } PageLayout::setTitle(_("Studiengruppe bearbeiten")); PageLayout::setHelpKeyword('Basis.Studiengruppen'); PageLayout::addSqueezePackage('tablesorter'); } else { throw new Exception(_("Die von Ihnen gewählte Option ist im System nicht aktiviert.")); } Sidebar::get()->setImage('sidebar/studygroup-sidebar.png'); }
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); } } }
/** * Zeigt die Grunddaten an. Man beachte, dass eventuell zuvor eine andere * Action wie Set ausgeführt wurde, von der hierher weitergeleitet worden ist. * Wichtige Daten dazu wurden dann über $this->flash übertragen. * * @param md5 $course_id */ public function view_action($course_id = null) { global $user, $perm, $_fullname_sql; $deputies_enabled = get_config('DEPUTIES_ENABLE'); //damit QuickSearch funktioniert: Request::set('new_doz_parameter', $this->flash['new_doz_parameter']); if ($deputies_enabled) { Request::set('new_dep_parameter', $this->flash['new_dep_parameter']); } Request::set('new_tut_parameter', $this->flash['new_tut_parameter']); $this->course_id = Request::option('cid', $course_id); Navigation::activateItem('/course/admin/details'); //Berechtigungscheck: if (!$perm->have_studip_perm("tutor", $this->course_id)) { throw new AccessDeniedException(_("Sie haben keine Berechtigung diese " . "Veranstaltung zu verändern.")); } //Kopf initialisieren: PageLayout::setHelpKeyword("Basis.VeranstaltungenVerwaltenGrunddaten"); PageLayout::setTitle(_("Verwaltung der Grunddaten")); if ($this->course_id) { PageLayout::setTitle(Course::find($this->course_id)->getFullname() . " - " . PageLayout::getTitle()); } //Daten sammeln: $sem = Seminar::getInstance($this->course_id); $data = $sem->getData(); //Erster Reiter des Akkordions: Grundeinstellungen $this->attributes = array(); $this->attributes[] = array('title' => _("Name der Veranstaltung"), 'name' => "course_name", 'must' => true, 'type' => 'text', 'value' => $data['name'], 'locked' => LockRules::Check($this->course_id, 'Name')); $this->attributes[] = array('title' => _("Untertitel der Veranstaltung"), 'name' => "course_subtitle", 'type' => 'text', 'value' => $data['subtitle'], 'locked' => LockRules::Check($this->course_id, 'Untertitel')); $sem_types = array(); if ($perm->have_perm("admin")) { foreach (SemClass::getClasses() as $sc) { foreach ($sc->getSemTypes() as $st) { if (!$sc['course_creation_forbidden']) { $sem_types[$st['id']] = $st['name'] . ' (' . $sc['name'] . ')'; } } } } else { $sc = $sem->getSemClass(); foreach ($sc->getSemTypes() as $st) { $sem_types[$st['id']] = $st['name'] . ' (' . $sc['name'] . ')'; } } if (!isset($sem_types[$data['status']])) { $sem_types[$data['status']] = $sem->getSemType()->offsetGet('name'); } $this->attributes[] = array('title' => _("Typ der Veranstaltung"), 'name' => "course_status", 'must' => true, 'type' => 'select', 'value' => $data['status'], 'locked' => LockRules::Check($this->course_id, 'status'), 'choices' => array_map('htmlReady', $sem_types)); $this->attributes[] = array('title' => _("Art der Veranstaltung"), 'name' => "course_form", 'type' => 'text', 'value' => $data['form'], 'locked' => LockRules::Check($this->course_id, 'art')); $this->attributes[] = array('title' => _("Veranstaltungs-Nummer"), 'name' => "course_seminar_number", 'type' => 'text', 'value' => $data['seminar_number'], 'locked' => LockRules::Check($this->course_id, 'VeranstaltungsNummer')); $this->attributes[] = array('title' => _("ECTS-Punkte"), 'name' => "course_ects", 'type' => 'text', 'value' => $data['ects'], 'locked' => LockRules::Check($this->course_id, 'ects')); $this->attributes[] = array('title' => _("max. Teilnehmerzahl"), 'name' => "course_admission_turnout", 'must' => false, 'type' => 'number', 'value' => $data['admission_turnout'], 'locked' => LockRules::Check($this->course_id, 'admission_turnout'), 'min' => '0'); $this->attributes[] = array('title' => _("Beschreibung"), 'name' => "course_description", 'type' => 'textarea', 'value' => $data['description'], 'locked' => LockRules::Check($this->course_id, 'Beschreibung')); //Zweiter Reiter: Institute $this->institutional = array(); $institute = Institute::getMyInstitutes(); $choices = array(); foreach ($institute as $inst) { //$choices[$inst['Institut_id']] = $inst['Name']; $choices[$inst['Institut_id']] = ($inst['is_fak'] ? "<span style=\"font-weight: bold\">" : " ") . htmlReady($inst['Name']) . ($inst['is_fak'] ? "</span>" : ""); } $this->institutional[] = array('title' => _("Heimat-Einrichtung"), 'name' => "course_institut_id", 'must' => true, 'type' => 'select', 'value' => $data['institut_id'], 'choices' => $choices, 'locked' => LockRules::Check($this->course_id, 'Institut_id')); $institute = Institute::getInstitutes(); $choices = array(); foreach ($institute as $inst) { $choices[$inst['Institut_id']] = ($inst['is_fak'] ? "<span style=\"font-weight: bold\">" : " ") . htmlReady($inst['Name']) . ($inst['is_fak'] ? "</span>" : ""); } $sem_institutes = $sem->getInstitutes(); $inst = array_flip($sem_institutes); unset($inst[$sem->institut_id]); $inst = array_flip($inst); $this->institutional[] = array('title' => _("beteiligte Einrichtungen"), 'name' => "related_institutes[]", 'type' => 'multiselect', 'value' => $inst, 'choices' => $choices, 'locked' => LockRules::Check($this->course_id, 'seminar_inst')); $this->dozent_is_locked = LockRules::Check($this->course_id, 'dozent'); $this->tutor_is_locked = LockRules::Check($this->course_id, 'tutor'); //Dritter Reiter: Personal $this->dozenten = $sem->getMembers('dozent'); $instUsers = new SimpleCollection(InstituteMember::findByInstituteAndStatus($sem->getInstitutId(), 'dozent')); $this->lecturersOfInstitute = $instUsers->pluck('user_id'); if (SeminarCategories::getByTypeId($sem->status)->only_inst_user) { $search_template = "user_inst_not_already_in_sem"; } else { $search_template = "user_not_already_in_sem"; } $this->dozentUserSearch = new PermissionSearch($search_template, sprintf(_("%s suchen"), get_title_for_status('dozent', 1, $sem->status)), "user_id", array('permission' => 'dozent', 'seminar_id' => $this->course_id, 'sem_perm' => 'dozent', 'institute' => $sem_institutes)); $this->dozenten_title = get_title_for_status('dozent', 1, $sem->status); $this->deputies_enabled = $deputies_enabled; if ($this->deputies_enabled) { $this->deputies = getDeputies($this->course_id); $this->deputySearch = new PermissionSearch("user_not_already_in_sem_or_deputy", sprintf(_("%s suchen"), get_title_for_status('deputy', 1, $sem->status)), "user_id", array('permission' => getValidDeputyPerms(), 'seminar_id' => $this->course_id)); $this->deputy_title = get_title_for_status('deputy', 1, $sem->status); } $this->tutoren = $sem->getMembers('tutor'); $this->tutorUserSearch = new PermissionSearch($search_template, sprintf(_("%s suchen"), get_title_for_status('tutor', 1, $sem->status)), "user_id", array('permission' => array('dozent', 'tutor'), 'seminar_id' => $this->course_id, 'sem_perm' => array('dozent', 'tutor'), 'institute' => $sem_institutes)); $this->tutor_title = get_title_for_status('tutor', 1, $sem->status); $instUsers = new SimpleCollection(InstituteMember::findByInstituteAndStatus($sem->getInstitutId(), 'tutor')); $this->tutorsOfInstitute = $instUsers->pluck('user_id'); unset($instUsers); //Vierter Reiter: Beschreibungen (darunter Datenfelder) $this->descriptions[] = array('title' => _("Teilnehmde"), 'name' => "course_participants", 'type' => 'textarea', 'value' => $data['participants'], 'locked' => LockRules::Check($this->course_id, 'teilnehmer')); $this->descriptions[] = array('title' => _("Voraussetzungen"), 'name' => "course_requirements", 'type' => 'textarea', 'value' => $data['requirements'], 'locked' => LockRules::Check($this->course_id, 'voraussetzungen')); $this->descriptions[] = array('title' => _("Lernorganisation"), 'name' => "course_orga", 'type' => 'textarea', 'value' => $data['orga'], 'locked' => LockRules::Check($this->course_id, 'lernorga')); $this->descriptions[] = array('title' => _("Leistungsnachweis"), 'name' => "course_leistungsnachweis", 'type' => 'textarea', 'value' => $data['leistungsnachweis'], 'locked' => LockRules::Check($this->course_id, 'leistungsnachweis')); $this->descriptions[] = array('title' => _("Ort") . "<br><span style=\"font-size: 0.8em\"><b>" . _("Achtung:") . " </b>" . _("Diese Ortsangabe wird nur angezeigt, wenn keine " . "Angaben aus Zeiten oder Sitzungsterminen gemacht werden können.") . "</span>", 'name' => "course_location", 'type' => 'textarea', 'value' => $data['location'], 'locked' => LockRules::Check($this->course_id, 'Ort')); $datenfelder = DataFieldEntry::getDataFieldEntries($this->course_id, 'sem', $data["status"]); if ($datenfelder) { foreach ($datenfelder as $datenfeld) { if ($datenfeld->isVisible()) { $locked = !$datenfeld->isEditable() || LockRules::Check($this->course_id, $datenfeld->getID()); $this->descriptions[] = array('title' => $datenfeld->getName(), 'must' => $datenfeld->isRequired(), 'name' => "datafield_" . $datenfeld->getID(), 'type' => "datafield", 'html_value' => $datenfeld->getHTML("datafields"), 'display_value' => $datenfeld->getDisplayValue(), 'locked' => $locked, 'description' => !$datenfeld->isEditable() ? "Diese Felder werden zentral durch die zuständigen Administratoren erfasst." : $datenfeld->getDescription()); } } } $this->descriptions[] = array('title' => _("Sonstiges"), 'name' => "course_misc", 'type' => 'textarea', 'value' => $data['misc'], 'locked' => LockRules::Check($this->course_id, 'Sonstiges')); $this->perm_dozent = $perm->have_studip_perm("dozent", $this->course_id); $this->mkstring = $data['mkdate'] ? date("d.m.Y, G:i", $data['mkdate']) : _("unbekannt"); $this->chstring = $data['chdate'] ? date("d.m.Y, G:i", $data['chdate']) : _("unbekannt"); $lockdata = LockRules::getObjectRule($this->course_id); if ($lockdata['description'] && LockRules::CheckLockRulePermission($this->course_id, $lockdata['permission'])) { $this->flash['msg'] = array_merge((array) $this->flash['msg'], array(array("info", formatLinks($lockdata['description'])))); } $this->flash->discard(); //schmeißt ab jetzt unnötige Variablen aus der Session. $sidebar = Sidebar::get(); $sidebar->setImage("sidebar/admin-sidebar.png"); $widget = new ActionsWidget(); $widget->addLink(_('Bild ändern'), $this->url_for('course/avatar/update', $course_id), Icon::create('edit', 'clickable')); if ($this->deputies_enabled) { if (isDeputy($user->id, $this->course_id)) { $newstatus = 'dozent'; $text = _('Lehrende werden'); } else { if (in_array($user->id, array_keys($this->dozenten)) && sizeof($this->dozenten) > 1) { $newstatus = 'deputy'; $text = _('Vertretung werden'); } } $widget->addLink($text, $this->url_for('course/basicdata/switchdeputy', $this->course_id, $newstatus), Icon::create('persons', 'clickable')); } $sidebar->addWidget($widget); // Entry list for admin upwards. if ($perm->have_studip_perm("admin", $this->course_id)) { $list = new SelectorWidget(); $list->setUrl("?#admin_top_links"); $list->setSelectParameterName("cid"); foreach (AdminCourseFilter::get()->getCoursesForAdminWidget() as $seminar) { $list->addElement(new SelectElement($seminar['Seminar_id'], $seminar['Name']), 'select-' . $seminar['Seminar_id']); } $list->setSelection($this->course_id); $sidebar->addWidget($list); } }
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')); }
<tr> <td> <?php echo SemesterData::GetSemesterSelector(array('name' => 'tools_requests_sem_choose', 'onChange' => 'document.tools_requests_form.submit()'), $this->semester_id, 'semester_id', false); ?> <?php echo Button::create(_('Semester auswählen'), 'tools_requests_sem_choose_button'); ?> <br> <select name="tools_requests_sem_type_choose" onChange="document.tools_requests_form.submit()"> <option value=""><?php echo _("alle Veranstaltungen"); ?> </option> <? foreach (SeminarCategories::getAll() as $sc) { foreach ($sc->getTypes() as $key => $value) { if (!$sc->studygroup_mode) { ?> <option <?php echo $display_sem_type == $key ? 'selected' : ''; ?> value="<?php echo $key; ?> "><?php echo htmlReady($value . ' (' . $sc->name . ')'); ?> </option> <? }
public static function checkParticipants(&$my_obj, $user_id, $object_id, $is_admission) { if ($my_obj["modules"]["participants"]) { if (SeminarCategories::GetByTypeId($my_obj['status'])->studygroup_mode) { $nav = new Navigation('participants', 'dispatch.php/course/studygroup/members/' . $object_id); } else { $nav = new Navigation('participants', 'dispatch.php/course/members/index'); } if ($GLOBALS['perm']->have_perm('admin', $user_id) || in_array($my_obj['user_status'], words('dozent tutor'))) { $count = 0; $neue = 0; $all_auto_inserts = AutoInsert::getAllSeminars(true); $auto_insert_perm = Config::get()->AUTO_INSERT_SEM_PARTICIPANTS_VIEW_PERM; $sql = "SELECT\n COUNT(a.user_id) as count,\n COUNT(IF((mkdate > IFNULL(b.visitdate, :threshold) AND a.user_id !=:user_id), a.user_id, NULL)) AS neue,\n MAX(IF((mkdate > IFNULL(b.visitdate, :threshold) AND a.user_id != :user_id), mkdate, 0)) AS last_modified\n FROM admission_seminar_user a\n LEFT JOIN object_user_visits b ON (b.object_id = a.seminar_id AND b.user_id = :user_id AND b.type ='participants')\n WHERE a.seminar_id = :course_id"; $statement = DBManager::get()->prepare($sql); $statement->bindValue(':user_id', $user_id); $statement->bindValue(':course_id', $object_id); $statement->bindValue(':threshold', ($threshold = Config::get()->NEW_INDICATOR_THRESHOLD) ? strtotime("-{$threshold} days 0:00:00") : 0); $statement->execute(); $result = $statement->fetch(PDO::FETCH_ASSOC); if (!empty($result)) { if ($GLOBALS['perm']->have_perm('admin', $user_id) || in_array($my_obj['user_status'], words('dozent tutor'))) { $count = $result['count']; $neue = $result['neue']; if ($my_obj['last_modified'] < $result['last_modified']) { $my_obj['last_modified'] = $result['last_modified']; } } } $sql = "SELECT\n COUNT(a . user_id) as count,\n COUNT(IF((mkdate > IFNULL(b.visitdate, :threshold) AND a.user_id !=:user_id), a.user_id, NULL)) AS neue,\n MAX(IF ((mkdate > IFNULL(b.visitdate, :threshold) AND a.user_id != :user_id), mkdate, 0)) AS last_modified\n FROM seminar_user a\n LEFT JOIN object_user_visits b ON(b . object_id = a . seminar_id AND b . user_id = :user_id AND b . type = 'participants')\n WHERE seminar_id = :course_id"; $statement = DBManager::get()->prepare($sql); $statement->bindValue(':user_id', $user_id); $statement->bindValue(':course_id', $object_id); $statement->bindValue(':threshold', ($threshold = Config::get()->NEW_INDICATOR_THRESHOLD) ? strtotime("-{$threshold} days 0:00:00") : 0); $statement->execute(); $result = $statement->fetch(PDO::FETCH_ASSOC); if (!empty($result)) { // show the participants-icon only if the module is activated and it is not an auto-insert-sem if (in_array($object_id, $all_auto_inserts)) { if ($GLOBALS['perm']->have_perm('admin', $user_id) && !$GLOBALS['perm']->have_perm($auto_insert_perm, $user_id)) { return null; } else { if ($GLOBALS['perm']->permissions[$auto_insert_perm] > $GLOBALS['perm']->permissions[$my_obj['user_status']]) { return null; } } } $count += $result['count']; $neue += $result['neue']; if ($GLOBALS['perm']->have_perm('admin', $user_id) || in_array($my_obj['user_status'], words('dozent tutor'))) { if ($my_obj['last_modified'] < $result['last_modified']) { $my_obj['last_modified'] = $result['last_modified']; } } } if ($neue) { $nav->setImage(Icon::create('persons+new', 'attention', ["title" => sprintf('%s %s, %s %s', $count, _('Teilnehmende'), $neue, _('neue'))])); $nav->setBadgeNumber($neue); } else { if ($count) { $nav->setImage(Icon::create('persons', 'inactive', ["title" => sprintf('%s %s', $count, _('Teilnehmende'))])); } } } else { $nav->setImage(Icon::create('persons', 'inactive', ["title" => _('Teilnehmende')])); } return $nav; } return null; }
/** * Returns all courses matching set criteria. * * @param Array $params Additional parameters * @return Array of courses */ private function getCourses($params = array()) { // Init if ($GLOBALS['user']->cfg->MY_INSTITUTES_DEFAULT === "all") { $inst = new SimpleCollection($this->insts); $inst->filter(function ($a) use(&$inst_ids) { $inst_ids[] = $a->Institut_id; }); } else { $institut = new Institute($GLOBALS['user']->cfg->MY_INSTITUTES_DEFAULT); $inst_ids[] = $GLOBALS['user']->cfg->MY_INSTITUTES_DEFAULT; if ($institut->isFaculty()) { foreach ($institut->sub_institutes->pluck("Institut_id") as $institut_id) { $inst_ids[] = $institut_id; } } } $filter = AdminCourseFilter::get(true); $filter->where("sem_classes.studygroup_mode = '0'"); if (is_object($this->semester)) { $filter->filterBySemester($this->semester->getId()); } if ($params['typeFilter'] && $params['typeFilter'] !== "all") { list($class_filter, $type_filter) = explode('_', $params['typeFilter']); if (!$type_filter && !empty($GLOBALS['SEM_CLASS'][$class_filter])) { $type_filter = array_keys($GLOBALS['SEM_CLASS'][$class_filter]->getSemTypes()); } $filter->filterByType($type_filter); } if ($GLOBALS['user']->cfg->ADMIN_COURSES_SEARCHTEXT) { $filter->filterBySearchString($GLOBALS['user']->cfg->ADMIN_COURSES_SEARCHTEXT); } if ($GLOBALS['user']->cfg->ADMIN_COURSES_TEACHERFILTER && $GLOBALS['user']->cfg->ADMIN_COURSES_TEACHERFILTER !== "all") { $filter->filterByDozent($GLOBALS['user']->cfg->ADMIN_COURSES_TEACHERFILTER); } $filter->filterByInstitute($inst_ids); if ($params['sortby'] === "status") { $filter->orderBy(sprintf('sem_classes.name %s, sem_types.name %s, VeranstaltungsNummer', $params['sortFlag'], $params['sortFlag'], $params['sortFlag']), $params['sortFlag']); } elseif ($params['sortby'] === 'completion') { $filter->orderBy('is_complete', $params['sortFlag']); } elseif ($params['sortby']) { $filter->orderBy($params['sortby'], $params['sortFlag']); } $filter->storeSettings(); $this->count_courses = $filter->countCourses(); if ($this->count_courses && $this->count_courses <= $filter->max_show_courses) { $courses = $filter->getCourses(); } else { return array(); } if (in_array('contents', $params['view_filter'])) { $sem_types = SemType::getTypes(); $modules = new Modules(); } $seminars = array_map('reset', $courses); if (!empty($seminars)) { foreach ($seminars as $seminar_id => $seminar) { $dozenten = $this->getTeacher($seminar_id); $seminars[$seminar_id]['dozenten'] = $dozenten; if (in_array('teachers', $params['view_filter'])) { if (SeminarCategories::getByTypeId($seminar['status'])->only_inst_user) { $search_template = "user_inst_not_already_in_sem"; } else { $search_template = "user_not_already_in_sem"; } $sem_helper = new Seminar(Course::buildExisting($seminar)); $dozentUserSearch = new PermissionSearch($search_template, sprintf(_("%s suchen"), get_title_for_status('dozent', 1, $seminar['status'])), "user_id", array('permission' => 'dozent', 'seminar_id' => $this->course_id, 'sem_perm' => 'dozent', 'institute' => $sem_helper->getInstitutes())); $seminars[$seminar_id]['teacher_search'] = MultiPersonSearch::get("add_member_dozent" . $seminar_id)->setTitle(_('Mehrere Lehrende hinzufügen'))->setSearchObject($dozentUserSearch)->setDefaultSelectedUser(array_keys($dozenten))->setDataDialogStatus(Request::isXhr())->setExecuteURL(URLHelper::getLink('dispatch.php/course/basicdata/add_member/' . $seminar_id, array('from' => 'admin/courses'))); } if (in_array('contents', $params['view_filter'])) { $seminars[$seminar_id]['sem_class'] = $sem_types[$seminar['status']]->getClass(); $seminars[$seminar_id]['modules'] = $modules->getLocalModules($seminar_id, 'sem', $seminar['modules'], $seminar['status']); $seminars[$seminar_id]['navigation'] = MyRealmModel::getAdditionalNavigations($seminar_id, $seminars[$seminar_id], $seminars[$seminar_id]['sem_class'], $GLOBALS['user']->id); } if ($this->selected_action == 17) { $seminars[$seminar_id]['admission_locked'] = false; if ($seminar['course_set']) { $set = new CourseSet($seminar['course_set']); if (!is_null($set) && $set->hasAdmissionRule('LockedAdmission')) { $seminars[$seminar_id]['admission_locked'] = 'locked'; } else { $seminars[$seminar_id]['admission_locked'] = 'disable'; } unset($set); } } } } return $seminars; }
?> <td class="<?php echo $cssSw->getClass(); ?> " align="center"> <? if (SeminarCategories::getByTypeId($result['status'])) : ?> <?php echo htmlReady(SeminarCategories::GetByTypeId($result['status'])->getNameOfType($result['status'])); ?> <br> <?php echo _("Kategorie:"); ?> <b> <?php echo htmlReady(SeminarCategories::GetByTypeId($result['status'])->name); ?> </b> <? else : ?> <?php echo _('nicht zugeordnet'); ?> <? endif ?> </td> <? echo "<td class=\"".$cssSw->getClass()."\" nowrap align=\"center\">"; //Kommandos fuer die jeweilgen Seiten switch ($i_page) { case "adminarea_start.php":
/** * Enter description here... * * @param unknown_type $range_id * @param unknown_type $object_type * @param unknown_type $object_class_hint * @return unknown */ public static function getDataFieldEntries($range_id, $object_type = '', $object_class_hint = '') { if (!$range_id) { return false; // we necessarily need a range ID } $parameters = array(); if (is_array($range_id)) { // rangeID may be an array ("classic" rangeID and second rangeID used for user roles) $secRangeID = $range_id[1]; $rangeID = $range_id[0]; // to keep compatible with following code if ('usersemdata' !== $object_type && 'roleinstdata' !== $object_type) { $object_type = 'userinstrole'; } $clause1 = "AND sec_range_id= :sec_range_id"; $parameters[':sec_range_id'] = $secRangeID; } else { $rangeID = $range_id; } if (!$object_type) { $object_type = get_object_type($rangeID); } if ($object_type) { switch ($object_type) { case 'sem': if ($object_class_hint) { $object_class = SeminarCategories::GetByTypeId($object_class_hint); } else { $object_class = SeminarCategories::GetBySeminarId($rangeID); } $clause2 = "object_class = :object_class OR object_class IS NULL"; $parameters[':object_class'] = (int) $object_class->id; break; case 'inst': case 'fak': if ($object_class_hint) { $object_class = $object_class_hint; } else { $query = "SELECT type FROM Institute WHERE Institut_id = ?"; $statement = DBManager::get()->prepare($query); $statement->execute(array($rangeID)); $object_class = $statement->fetchColumn(); } $object_type = "inst"; $clause2 = "object_class = :object_class OR object_class IS NULL"; $parameters[':object_class'] = (int) $object_class; break; case 'roleinstdata': //hmm tja, vermutlich so $clause2 = '1'; break; case 'user': case 'userinstrole': case 'usersemdata': $object_class = is_object($GLOBALS['perm']) ? DataField::permMask($GLOBALS['perm']->get_perm($rangeID)) : 0; $clause2 = "((object_class & :object_class) OR object_class IS NULL)"; $parameters[':object_class'] = (int) $object_class; break; } $query = "SELECT a.*, content\n FROM datafields AS a\n LEFT JOIN datafields_entries AS b\n ON (a.datafield_id = b.datafield_id AND range_id = :range_id {$clause1})\n WHERE object_type = :object_type AND ({$clause2})\n ORDER BY priority"; $parameters[':range_id'] = $rangeID; $parameters[':object_type'] = $object_type; $rs = DBManager::get()->prepare($query); $rs->execute($parameters); $entries = array(); while ($data = $rs->fetch(PDO::FETCH_ASSOC)) { $datafield = DataField::buildExisting($data); $entries[$data['datafield_id']] = DataFieldEntry::createDataFieldEntry($datafield, $range_id, $data['content']); } } return $entries; }
<tbody> <? foreach ($waiting_list as $wait) { // wir sind in einer Anmeldeliste und brauchen Prozentangaben if ($wait["status"] == "claiming") { // Grün der Farbe nimmt mit Wahrscheinlichkeit ab $chance_color = dechex(55 + $wait['admission_chance'] * 2); } // wir sind in einer Warteliste else { $chance_color = $wait["position"] < 30 ? dechex(255 - $wait["position"] * 6) : 44; } $seminar_name = $wait["Name"]; if (SeminarCategories::GetByTypeId($wait['sem_status'])->studygroup_mode) { $seminar_name .= ' (' . _("Studiengruppe") . ', ' . _("geschlossen") . ')'; } ?> <tr> <td title="<?php echo _("Position oder Wahrscheinlichkeit"); ?> " style="background:#44<?php echo $chance_color; ?> 44"> </td> <td> <a href="<?php
/** * * @param unknown_type $my_obj * @param unknown_type $user_id * @param unknown_type $modules */ function get_my_obj_values(&$my_obj, $user_id, $modules = NULL) { $threshold = ($config = Config::get()->NEW_INDICATOR_THRESHOLD) ? strtotime("-{$config} days 0:00:00") : 0; $db2 = new DB_seminar(); $db2->query("CREATE TEMPORARY TABLE IF NOT EXISTS myobj_" . $user_id . " ( object_id char(32) NOT NULL, PRIMARY KEY (object_id)) ENGINE = MEMORY"); $db2->query("REPLACE INTO myobj_" . $user_id . " (object_id) VALUES ('" . join("'),('", array_keys($my_obj)) . "')"); //dokumente $unreadable_folders = array(); if (!$GLOBALS['perm']->have_perm('admin')) { foreach (array_keys($my_obj) as $obj_id) { if ($my_obj[$obj_id]['modules']['documents_folder_permissions'] || $my_obj[$obj_id]['obj_type'] == 'sem' && StudipDocumentTree::ExistsGroupFolders($obj_id)) { $must_have_perm = $my_obj[$obj_id]['obj_type'] == 'sem' ? 'tutor' : 'autor'; if ($GLOBALS['perm']->permissions[$my_obj[$obj_id]['status']] < $GLOBALS['perm']->permissions[$must_have_perm]) { $folder_tree = TreeAbstract::GetInstance('StudipDocumentTree', array('range_id' => $obj_id, 'entity_type' => $my_obj[$obj_id]['obj_type'])); $unreadable_folders = array_merge((array) $unreadable_folders, (array) $folder_tree->getUnReadableFolders($user_id)); } } } } $db2->query(get_obj_clause('dokumente a', 'Seminar_id', 'dokument_id', "(chdate > IFNULL(b.visitdate, {$threshold}) AND a.user_id !='{$user_id}')", 'documents', false, count($unreadable_folders) ? "AND a.range_id NOT IN('" . join("','", $unreadable_folders) . "')" : "", false, $user_id)); while ($db2->next_record()) { $object_id = $db2->f('object_id'); if ($my_obj[$object_id]["modules"]["documents"]) { $my_obj[$object_id]["neuedokumente"] = $db2->f("neue"); $my_obj[$object_id]["dokumente"] = $db2->f("count"); if ($my_obj[$object_id]['last_modified'] < $db2->f('last_modified')) { $my_obj[$object_id]['last_modified'] = $db2->f('last_modified'); } $nav = new Navigation('files'); if ($db2->f('neue')) { $nav->setURL('folder.php?cmd=all'); $nav->setImage(Icon::create('files+new', 'attention', ["title" => sprintf(_('%s Dokumente, %s neue'), $db2->f('count'), $db2->f('neue'))])); $nav->setBadgeNumber($db2->f('neue')); } else { if ($db2->f('count')) { $nav->setURL('folder.php?cmd=tree'); $nav->setImage(Icon::create('files', 'inactive', ["title" => sprintf(_('%s Dokumente'), $db2->f('count'))])); } } $my_obj[$object_id]['files'] = $nav; } } //Ankündigungen $db2->query(get_obj_clause('news_range a {ON_CLAUSE} LEFT JOIN news nw ON(a.news_id=nw.news_id AND UNIX_TIMESTAMP() BETWEEN date AND (date+expire))', 'range_id', 'nw.news_id', "(chdate > IFNULL(b.visitdate, {$threshold}) AND nw.user_id !='{$user_id}')", 'news', false, false, 'a.news_id', $user_id)); while ($db2->next_record()) { $object_id = $db2->f('object_id'); $my_obj[$object_id]["neuenews"] = $db2->f("neue"); $my_obj[$object_id]["news"] = $db2->f("count"); if ($my_obj[$object_id]['last_modified'] < $db2->f('last_modified')) { $my_obj[$object_id]['last_modified'] = $db2->f('last_modified'); } $nav = new Navigation('news', ''); if ($db2->f('neue')) { $nav->setURL('?new_news=true'); $nav->setImage(Icon::create('news+new', 'attention', ["title" => sprintf(_('%s Ankündigungen, %s neue'), $db2->f('count'), $db2->f('neue'))])); $nav->setBadgeNumber($db2->f('neue')); } else { if ($db2->f('count')) { $nav->setImage(Icon::create('news', 'inactive', ["title" => sprintf(_('%s Ankündigungen'), $db2->f('count'))])); } } $my_obj[$object_id]['news'] = $nav; } // scm? $db2->query(get_obj_clause('scm a', 'range_id', "IF(content !='',1,0)", "(chdate > IFNULL(b.visitdate, {$threshold}) AND a.user_id !='{$user_id}')", "scm", 'tab_name', false, false, $user_id)); while ($db2->next_record()) { $object_id = $db2->f('object_id'); if ($my_obj[$object_id]["modules"]["scm"]) { $my_obj[$object_id]["neuscmcontent"] = $db2->f("neue"); $my_obj[$object_id]["scmcontent"] = $db2->f("count"); $my_obj[$object_id]["scmtabname"] = $db2->f("tab_name"); if ($my_obj[$object_id]['last_modified'] < $db2->f('last_modified')) { $my_obj[$object_id]['last_modified'] = $db2->f('last_modified'); } $nav = new Navigation('scm', 'dispatch.php/course/scm'); if ($db2->f('count')) { if ($db2->f('neue')) { $image = Icon::create('infopage+new', 'new'); $nav->setBadgeNumber($db2->f('neue')); if ($db2->f('count') == 1) { $title = $db2->f('tab_name') . _(' (geändert)'); } else { $title = sprintf(_('%s Einträge, %s neue'), $db2->f('count'), $db2->f('neue')); } } else { $image = Icon::create('infopage', 'inactive'); if ($db2->f('count') == 1) { $title = $db2->f('tab_name'); } else { $title = sprintf(_('%s Einträge'), $db2->f('count')); } } $nav->setImage($image, array('title' => $title)); } $my_obj[$object_id]['scm'] = $nav; } } //Termine? $db2->query(get_obj_clause('ex_termine a', 'range_id', 'termin_id', "(chdate > IFNULL(b.visitdate, {$threshold}) AND autor_id !='{$user_id}')", 'schedule', false, " AND a.content <> '' ", false, $user_id)); while ($db2->next_record()) { $object_id = $db2->f('object_id'); if ($my_obj[$object_id]["modules"]["schedule"]) { $my_obj[$object_id]["neueausfalltermine"] = $db2->f("neue"); $my_obj[$object_id]["ausfalltermine"] = $db2->f("count"); if ($my_obj[$object_id]['last_modified'] < $db2->f('last_modified')) { $my_obj[$object_id]['last_modified'] = $db2->f('last_modified'); } } } $db2->query(get_obj_clause('termine a', 'range_id', 'termin_id', "(chdate > IFNULL(b.visitdate, {$threshold}) AND autor_id !='{$user_id}')", 'schedule', false, false, false, $user_id)); while ($db2->next_record()) { $object_id = $db2->f('object_id'); if ($my_obj[$object_id]["modules"]["schedule"]) { $my_obj[$object_id]["neuetermine"] = $db2->f("neue"); $my_obj[$object_id]["termine"] = $db2->f("count"); if ($my_obj[$object_id]['last_modified'] < $db2->f('last_modified')) { $my_obj[$object_id]['last_modified'] = $db2->f('last_modified'); } $nav = new Navigation('schedule', 'dispatch.php/course/dates'); $neue = $my_obj[$object_id]["neuetermine"] + $my_obj[$object_id]["neueausfalltermine"]; $count = $my_obj[$object_id]["termine"] + $my_obj[$object_id]["ausfalltermine"]; if ($neue) { $nav->setImage(Icon::create('schedule+new', 'attention', ["title" => sprintf(_('%s Termine, %s neue'), $count, $neue)])); $nav->setBadgeNumber($neue); } else { if ($count) { $nav->setImage(Icon::create('schedule', 'inactive', ["title" => sprintf(_('%s Termine'), $count)])); } } $my_obj[$object_id]['schedule'] = $nav; } } //Wiki-Eintraege? if (get_config('WIKI_ENABLE')) { $db2->query(get_obj_clause('wiki a', 'range_id', 'keyword', "(chdate > IFNULL(b.visitdate, {$threshold}) AND a.user_id !='{$user_id}')", 'wiki', "COUNT(DISTINCT keyword) as count_d", false, false, $user_id)); while ($db2->next_record()) { $object_id = $db2->f('object_id'); if ($my_obj[$object_id]["modules"]["wiki"]) { $my_obj[$object_id]["neuewikiseiten"] = $db2->f("neue"); $my_obj[$object_id]["wikiseiten"] = $db2->f("count_d"); if ($my_obj[$object_id]['last_modified'] < $db2->f('last_modified')) { $my_obj[$object_id]['last_modified'] = $db2->f('last_modified'); } $nav = new Navigation('wiki'); if ($db2->f('neue')) { $nav->setURL('wiki.php?view=listnew'); $nav->setImage(Icon::create('wiki+new', 'attention', ["title" => sprintf(_('%s WikiSeiten, %s Änderungen'), $db2->f('count_d'), $db2->f('neue'))])); $nav->setBadgeNumber($db2->f('neue')); } else { if ($db2->f('count')) { $nav->setURL('wiki.php'); $nav->setImage(Icon::create('wiki', 'inactive', ["title" => sprintf(_('%s WikiSeiten'), $db2->f('count_d'))])); } } $my_obj[$object_id]['wiki'] = $nav; } } } //Lernmodule? if (get_config('ELEARNING_INTERFACE_ENABLE')) { $db2->query(get_obj_clause('object_contentmodules a', 'object_id', 'module_id', "(chdate > IFNULL(b.visitdate, {$threshold}) AND a.module_type != 'crs')", 'elearning_interface', false, " AND a.module_type != 'crs'", false, $user_id)); // $db2->query(get_obj_clause('object_contentmodules a','object_id','module_id',"(chdate > IFNULL(b.visitdate, $threshold))", 'elearning_interface')); while ($db2->next_record()) { $object_id = $db2->f('object_id'); if ($my_obj[$object_id]["modules"]["elearning_interface"]) { $my_obj[$object_id]["neuecontentmodule"] = $db2->f("neue"); $my_obj[$object_id]["contentmodule"] = $db2->f("count"); if ($my_obj[$object_id]['last_modified'] < $db2->f('last_modified')) { $my_obj[$object_id]['last_modified'] = $db2->f('last_modified'); } $nav = new Navigation('elearning', 'elearning_interface.php?view=show'); if ($db2->f('neue')) { $nav->setImage(Icon::create('learnmodule+new', 'attention', ["title" => sprintf(_('%s Lernmodule, %s neue'), $db2->f('count'), $db2->f('neue'))])); $nav->setBadgeNumber($db2->f('neue')); } else { if ($db2->f('count')) { $nav->setImage(Icon::create('learnmodule', 'inactive', ["title" => sprintf(_('%s Lernmodule'), $db2->f('count'))])); } } $my_obj[$object_id]['elearning'] = $nav; } } } //Umfragen if (get_config('VOTE_ENABLE')) { $db2->query(get_obj_clause('vote a', 'range_id', 'vote_id', "(chdate > IFNULL(b.visitdate, {$threshold}) AND a.author_id !='{$user_id}' AND a.state != 'stopvis')", 'vote', false, " AND a.state IN('active','stopvis')", 'vote_id', $user_id)); while ($db2->next_record()) { $object_id = $db2->f('object_id'); $my_obj[$object_id]["neuevotes"] = $db2->f("neue"); $my_obj[$object_id]["votes"] = $db2->f("count"); if ($my_obj[$object_id]['last_modified'] < $db2->f('last_modified')) { $my_obj[$object_id]['last_modified'] = $db2->f('last_modified'); } } $db2->query(get_obj_clause('eval_range a {ON_CLAUSE} INNER JOIN eval d ON ( a.eval_id = d.eval_id AND d.startdate < UNIX_TIMESTAMP( ) AND (d.stopdate > UNIX_TIMESTAMP( ) OR d.startdate + d.timespan > UNIX_TIMESTAMP( ) OR (d.stopdate IS NULL AND d.timespan IS NULL)))', 'range_id', 'a.eval_id', "(chdate > IFNULL(b.visitdate, {$threshold}) AND d.author_id !='{$user_id}' )", 'eval', false, false, 'a.eval_id', $user_id)); while ($db2->next_record()) { $object_id = $db2->f('object_id'); $my_obj[$object_id]["neuevotes"] += $db2->f("neue"); $my_obj[$object_id]["votes"] += $db2->f("count"); if ($my_obj[$object_id]['last_modified'] < $db2->f('last_modified')) { $my_obj[$object_id]['last_modified'] = $db2->f('last_modified'); } } foreach (array_keys($my_obj) as $object_id) { $nav = new Navigation('vote', '#vote'); if ($my_obj[$object_id]['neuevotes']) { $nav->setImage(Icon::create('vote+new', 'attention', ["title" => sprintf(_('%s Umfrage(n), %s neue'), $my_obj[$object_id]['votes'], $my_obj[$object_id]['neuevotes'])])); $nav->setBadgeNumber($my_obj[$object_id]['neuevotes']); } else { if ($my_obj[$object_id]['votes']) { $nav->setImage(Icon::create('vote', 'inactive', ["title" => sprintf(_('%s Umfrage(n)'), $my_obj[$object_id]['votes'])])); } } $my_obj[$object_id]['vote'] = $nav; } } //Literaturlisten if (get_config('LITERATURE_ENABLE')) { $db2->query(get_obj_clause('lit_list a', 'range_id', 'list_id', "(chdate > IFNULL(b.visitdate, {$threshold}) AND a.user_id !='{$user_id}')", 'literature', false, " AND a.visibility=1", false, $user_id)); while ($db2->next_record()) { $object_id = $db2->f('object_id'); if ($my_obj[$object_id]["modules"]["literature"]) { $my_obj[$object_id]["neuelitlist"] = $db2->f("neue"); $my_obj[$object_id]["litlist"] = $db2->f("count"); if ($my_obj[$object_id]['last_modified'] < $db2->f('last_modified')) { $my_obj[$object_id]['last_modified'] = $db2->f('last_modified'); } $nav = new Navigation('literature', 'dispatch.php/course/literature'); if ($db2->f('neue')) { $nav->setImage(Icon::create('literature+new', 'attention', ["title" => sprintf(_('%s Literaturlisten, %s neue'), $db2->f('count'), $db2->f('neue'))])); $nav->setBadgeNumber($db2->f('neue')); } else { if ($db2->f('count')) { $nav->setImage(Icon::create('literature', 'inactive', ["title" => sprintf(_('%s Literaturlisten'), $db2->f('count'))])); } } $my_obj[$object_id]['literature'] = $nav; } } } // TeilnehmerInnen if ($GLOBALS['perm']->have_perm('tutor')) { //vorläufige Teilnahme $db2->query(get_obj_clause('admission_seminar_user a', 'seminar_id', 'a.user_id', "(mkdate > IFNULL(b.visitdate, {$threshold}) AND a.user_id !='{$user_id}')", 'participants', false, " AND a.status='accepted' ", false, $user_id, 'mkdate')); while ($db2->next_record()) { $object_id = $db2->f('object_id'); if ($my_obj[$object_id]["modules"]["participants"]) { if ($GLOBALS['perm']->have_perm('admin', $user_id) || in_array($my_obj[$object_id]['status'], words('dozent tutor'))) { $my_obj[$object_id]["new_accepted_participants"] = $db2->f("neue"); $my_obj[$object_id]["count_accepted_participants"] = $db2->f("count"); if ($my_obj[$object_id]['last_modified'] < $db2->f('last_modified')) { $my_obj[$object_id]['last_modified'] = $db2->f('last_modified'); } } } } $db2->query(get_obj_clause('seminar_user a', 'seminar_id', 'a.user_id', "(mkdate > IFNULL(b.visitdate, {$threshold}) AND a.user_id !='{$user_id}')", 'participants', false, false, false, $user_id, 'mkdate')); $all_auto_inserts = AutoInsert::getAllSeminars(true); $auto_insert_perm = Config::get()->AUTO_INSERT_SEM_PARTICIPANTS_VIEW_PERM; while ($db2->next_record()) { $object_id = $db2->f('object_id'); // show the participants-icon only if the module is activated and it is not an auto-insert-sem if ($my_obj[$object_id]["modules"]["participants"]) { if (in_array($object_id, $all_auto_inserts)) { if ($GLOBALS['perm']->have_perm('admin', $user_id) && !$GLOBALS['perm']->have_perm($auto_insert_perm, $user_id)) { continue; } else { if ($GLOBALS['perm']->permissions[$auto_insert_perm] > $GLOBALS['perm']->permissions[$my_obj[$object_id]['status']]) { continue; } } } $my_obj[$object_id]["newparticipants"] = $db2->f("neue"); $my_obj[$object_id]["countparticipants"] = $db2->f("count"); if ($GLOBALS['perm']->have_perm('admin', $user_id) || in_array($my_obj[$object_id]['status'], words('dozent tutor'))) { if ($my_obj[$object_id]['last_modified'] < $db2->f('last_modified')) { $my_obj[$object_id]['last_modified'] = $db2->f('last_modified'); } } if (SeminarCategories::GetByTypeId($my_obj[$object_id]['sem_status'])->studygroup_mode) { $nav = new Navigation('participants', 'dispatch.php/course/studygroup/members/' . $object_id); } else { $nav = new Navigation('participants', 'dispatch.php/course/members/index'); } $neue = $my_obj[$object_id]["newparticipants"] + $my_obj[$object_id]["new_accepted_participants"]; $count = $my_obj[$object_id]["countparticipants"] + $my_obj[$object_id]["count_accepted_participants"]; if ($neue && ($GLOBALS['perm']->have_perm('admin', $user_id) || in_array($my_obj[$object_id]['status'], words('dozent tutor')))) { $nav->setImage(Icon::create('persons+new', 'attention', ["title" => sprintf(_('%s Teilnehmende, %s neue'), $count, $neue)])); $nav->setBadgeNumber($neue); } else { if ($count) { $nav->setImage(Icon::create('persons', 'inactive', ["title" => sprintf(_('%s Teilnehmende'), $count)])); } } $my_obj[$object_id]['participants'] = $nav; } } } else { // show only the participants-icon, no colouring! foreach ($my_obj as $object_id => $data) { $all_auto_inserts = AutoInsert::getAllSeminars(true); $auto_insert_perm = Config::get()->AUTO_INSERT_SEM_PARTICIPANTS_VIEW_PERM; if (in_array($object_id, $all_auto_inserts)) { if ($GLOBALS['perm']->have_perm('admin', $user_id) && !$GLOBALS['perm']->have_perm($auto_insert_perm, $user_id)) { continue; } else { if ($GLOBALS['perm']->permissions[$auto_insert_perm] > $GLOBALS['perm']->permissions[$my_obj[$object_id]['status']]) { continue; } } } if ($my_obj[$object_id]["modules"]["participants"]) { if (SeminarCategories::GetByTypeId($my_obj[$object_id]['sem_status'])->studygroup_mode) { $nav = new Navigation('participants', 'dispatch.php/course/studygroup/members/' . $object_id); } else { $nav = new Navigation('participants', 'dispatch.php/course/members/index'); } $nav->setImage(Icon::create('persons', 'inactive', ["title" => _('Teilnehmende')])); $my_obj[$object_id]['participants'] = $nav; } } } $db2->query("DROP TABLE IF EXISTS myobj_" . $user_id); return; }
function create_result_xls($headline = '') { require_once "vendor/write_excel/OLEwriter.php"; require_once "vendor/write_excel/BIFFwriter.php"; require_once "vendor/write_excel/Worksheet.php"; require_once "vendor/write_excel/Workbook.php"; global $_fullname_sql, $SEM_TYPE, $SEM_CLASS, $TMP_PATH; if (!$headline) { $headline = _("Stud.IP Veranstaltungen") . ' - ' . $GLOBALS['UNI_NAME_CLEAN']; } if (is_array($this->sem_browse_data['search_result']) && count($this->sem_browse_data['search_result'])) { if (!is_object($this->sem_tree)) { $the_tree = TreeAbstract::GetInstance("StudipSemTree", false); } else { $the_tree = $this->sem_tree->tree; } list($group_by_data, $sem_data) = $this->get_result(); $tmpfile = $TMP_PATH . '/' . md5(uniqid('write_excel', 1)); // Creating a workbook $workbook = new Workbook($tmpfile); $head_format = $workbook->addformat(); $head_format->set_size(12); $head_format->set_bold(); $head_format->set_align("left"); $head_format->set_align("vcenter"); $head_format_merged = $workbook->addformat(); $head_format_merged->set_size(12); $head_format_merged->set_bold(); $head_format_merged->set_align("left"); $head_format_merged->set_align("vcenter"); $head_format_merged->set_merge(); $head_format_merged->set_text_wrap(); $caption_format = $workbook->addformat(); $caption_format->set_size(10); $caption_format->set_align("left"); $caption_format->set_align("vcenter"); $caption_format->set_bold(); //$caption_format->set_text_wrap(); $data_format = $workbook->addformat(); $data_format->set_size(10); $data_format->set_align("left"); $data_format->set_align("vcenter"); $caption_format_merged = $workbook->addformat(); $caption_format_merged->set_size(10); $caption_format_merged->set_merge(); $caption_format_merged->set_align("left"); $caption_format_merged->set_align("vcenter"); $caption_format_merged->set_bold(); // Creating the first worksheet $worksheet1 = $workbook->addworksheet(_("Veranstaltungen")); $worksheet1->set_row(0, 20); $worksheet1->write_string(0, 0, $headline, $head_format); $worksheet1->set_row(1, 20); $worksheet1->write_string(1, 0, sprintf(_(" %s Veranstaltungen gefunden %s, Gruppierung: %s"), count($sem_data), $this->sem_browse_data['sset'] ? _("(Suchergebnis)") : "", $this->group_by_fields[$this->sem_browse_data['group_by']]['name']), $caption_format); $worksheet1->write_blank(0, 1, $head_format); $worksheet1->write_blank(0, 2, $head_format); $worksheet1->write_blank(0, 3, $head_format); $worksheet1->write_blank(1, 1, $head_format); $worksheet1->write_blank(1, 2, $head_format); $worksheet1->write_blank(1, 3, $head_format); $worksheet1->set_column(0, 0, 70); $worksheet1->set_column(0, 1, 25); $worksheet1->set_column(0, 2, 25); $worksheet1->set_column(0, 3, 50); $row = 2; foreach ($group_by_data as $group_field => $sem_ids) { switch ($this->sem_browse_data["group_by"]) { case 0: $headline = $this->search_obj->sem_dates[$group_field]['name']; break; case 1: if ($the_tree->tree_data[$group_field]) { $headline = $the_tree->getShortPath($group_field); } else { $headline = _("keine Studienbereiche eingetragen"); } break; case 3: $headline = $SEM_TYPE[$group_field]["name"] . " (" . $SEM_CLASS[$SEM_TYPE[$group_field]["class"]]["name"] . ")"; break; default: $headline = $group_field; break; } ++$row; $worksheet1->write_string($row, 0, $headline, $caption_format); $worksheet1->write_blank($row, 1, $caption_format); $worksheet1->write_blank($row, 2, $caption_format); $worksheet1->write_blank($row, 3, $caption_format); ++$row; if (is_array($sem_ids['Seminar_id'])) { while (list($seminar_id, ) = each($sem_ids['Seminar_id'])) { $sem_name = key($sem_data[$seminar_id]["Name"]); $seminar_number = key($sem_data[$seminar_id]['VeranstaltungsNummer']); $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->search_obj->sem_dates[$sem_number_start]['name'] . " - "; $sem_name .= ($sem_number_end == -1 ? _("unbegrenzt") : $this->search_obj->sem_dates[$sem_number_end]['name']) . ")"; } elseif ($this->sem_browse_data["group_by"]) { $sem_name .= " (" . $this->search_obj->sem_dates[$sem_number_start]['name'] . ")"; } //create Turnus field $seminar_obj = new Seminar($seminar_id); // is this sem a studygroup? $studygroup_mode = SeminarCategories::GetByTypeId($seminar_obj->getStatus())->studygroup_mode; if ($studygroup_mode) { $sem_name = $seminar_obj->getName() . ' (' . _("Studiengruppe"); if ($seminar_obj->admission_prelim) { $sem_name .= ', ' . _("Zutritt auf Anfrage"); } $sem_name .= ')'; } $worksheet1->write_string($row, 0, $sem_name, $data_format); $temp_turnus_string = $seminar_obj->getFormattedTurnus(true); //Shorten, if string too long (add link for details.php) if (strlen($temp_turnus_string) > 245) { $temp_turnus_string = substr($temp_turnus_string, 0, strpos(substr($temp_turnus_string, 245, strlen($temp_turnus_string)), ",") + 246); $temp_turnus_string .= " ... (" . _("mehr") . ")"; } $worksheet1->write_string($row, 1, $seminar_number, $data_format); $worksheet1->write_string($row, 2, $temp_turnus_string, $data_format); $doz_name = array(); $c = 0; reset($sem_data[$seminar_id]['fullname']); foreach ($sem_data[$seminar_id]['username'] as $anzahl1) { if ($c == 0) { list($d_name, $anzahl2) = each($sem_data[$seminar_id]['fullname']); $c = $anzahl2 / $anzahl1; $doz_name = array_merge($doz_name, array_fill(0, $c, $d_name)); } --$c; } $doz_position = array_keys($sem_data[$seminar_id]['position']); if (is_array($doz_name)) { if (count($doz_position) != count($doz_name)) { $doz_position = range(1, count($doz_name)); } array_multisort($doz_position, $doz_name); $worksheet1->write_string($row, 3, join(', ', $doz_name), $data_format); } ++$row; } } } $workbook->close(); } return $tmpfile; }
/** * Checks if the current step needs to be executed according * to already given values. A good example are study areas which * are only needed for certain sem_classes. * * @param Array $values values specified from previous steps * @return bool Is the current step required for a new course? */ public function isRequired($values) { $coursetype = 1; foreach ($values as $class) { if ($class['coursetype']) { $coursetype = $class['coursetype']; break; } } $category = SeminarCategories::GetByTypeId($coursetype); return $category->bereiche; }
/** * Exports lecture-data. * * This function gets the data of the lectures at an institute and writes it into $data_object. * It calls output_data afterwards. * * @access public * @param string $inst_id Stud.IP-inst_id for export * @param string $ex_sem_id allows to choose if only a specific lecture is to be exported */ function export_sem($inst_id, $ex_sem_id = 'all') { global $range_id, $xml_file, $o_mode, $xml_names_lecture, $xml_groupnames_lecture, $object_counter, $SEM_TYPE, $SEM_CLASS, $filter, $ex_sem, $ex_sem_class, $ex_person_details, $persons; $ex_only_homeinst = Request::int('ex_only_homeinst', 0); // Prepare user count statement $query = "SELECT COUNT(user_id)\n FROM seminar_user\n WHERE seminar_id = ? AND status = 'autor'"; $count_statement = DBManager::get()->prepare($query); // Prepare inner statement $query = "SELECT seminar_user.position,\n auth_user_md5.user_id, auth_user_md5.username, auth_user_md5.Vorname, auth_user_md5.Nachname,\n user_info.title_front, user_info.title_rear\n FROM seminar_user\n LEFT JOIN user_info USING (user_id)\n LEFT JOIN auth_user_md5 USING (user_id)\n WHERE seminar_user.status = 'dozent' AND seminar_user.Seminar_id = ?\n ORDER BY seminar_user.position"; $inner_statement = DBManager::get()->prepare($query); // Prepare (build) and execute outmost query switch ($filter) { case "seminar": $order = " seminare.Name"; break; case "status": $order = "seminare.status, seminare.Name"; $group = "FIRSTGROUP"; $group_tab_zelle = "status"; $do_group = true; break; default: $order = "seminare.status, seminare.Name"; $group = "FIRSTGROUP"; $group_tab_zelle = "status"; $do_group = true; } $parameters = array(); if (isset($ex_sem) && ($semester = Semester::find($ex_sem))) { $addquery = " AND seminare.start_time <= :begin AND (:begin <= (seminare.start_time + seminare.duration_time) OR seminare.duration_time = -1) "; $parameters[':begin'] = $semester->beginn; } if ($ex_sem_id != 'all') { if ($ex_sem_id == 'root') { $addquery .= " AND EXISTS (SELECT * FROM seminar_sem_tree WHERE seminar_sem_tree.seminar_id = seminare.Seminar_id) "; } else { if (!is_array($ex_sem_id)) { $ex_sem_id = array($ex_sem_id); } $ex_sem_id = array_flip($ex_sem_id); } } if (!$GLOBALS['perm']->have_perm('root') && !$GLOBALS['perm']->have_studip_perm('admin', $inst_id)) { $addquery .= " AND visible = 1 "; } if (count($ex_sem_class) > 0) { $allowed_sem_types = array(); foreach (array_keys($ex_sem_class) as $semclassid) { $allowed_sem_types += array_keys(SeminarCategories::get($semclassid)->getTypes()); } $addquery .= " AND seminare.status IN (:status) "; $parameters[':status'] = $allowed_sem_types; } else { $addquery .= " AND seminare.status NOT IN (:status) "; $parameters[':status'] = studygroup_sem_types() ?: ''; } if ($ex_only_homeinst) { $query = "SELECT seminare.*,Seminar_id as seminar_id, Institute.Name AS heimateinrichtung\n FROM seminare\n LEFT JOIN Institute USING (Institut_id)\n WHERE Institut_id = :institute_id {$addquery}\n ORDER BY " . $order; $parameters[':institute_id'] = $inst_id; } else { $query = "SELECT seminare.*,Seminar_id as seminar_id, Institute.Name AS heimateinrichtung\n FROM seminar_inst\n LEFT JOIN seminare USING (Seminar_id)\n LEFT JOIN Institute ON seminare.Institut_id = Institute.Institut_id\n WHERE seminar_inst.Institut_id = :institute_id {$addquery}\n ORDER BY " . $order; $parameters[':institute_id'] = $inst_id; } $statement = DBManager::get()->prepare($query); $statement->execute($parameters); $data = $statement->fetchAll(PDO::FETCH_ASSOC); $data_object .= xml_open_tag($xml_groupnames_lecture['group']); foreach ($data as $row) { if (is_array($ex_sem_id) && !isset($ex_sem_id[$row['seminar_id']])) { continue; } $group_string = ''; if ($do_group && $group != $row[$group_tab_zelle]) { if ($group != 'FIRSTGROUP') { $group_string .= xml_close_tag($xml_groupnames_lecture['subgroup1']); } if ($group_tab_zelle == 'status') { $group_string .= xml_open_tag($xml_groupnames_lecture['subgroup1'], $SEM_TYPE[$row[$group_tab_zelle]]['name']); } else { $group_string .= xml_open_tag($xml_groupnames_lecture['subgroup1'], $row[$group_tab_zelle]); } $group = $row[$group_tab_zelle]; if ($do_subgroup && $subgroup == $row[$subgroup_tab_zelle]) { $subgroup = "NEXTGROUP"; } } if ($do_subgroup && $subgroup != $row[$subgroup_tab_zelle]) { if ($subgroup != 'FIRSTGROUP') { $group_string = xml_close_tag($xml_groupnames_lecture['subgroup2']) . $group_string; } $group_string .= xml_open_tag($xml_groupnames_lecture['subgroup2'], $row[$subgroup_tab_zelle]); $subgroup = $row[$subgroup_tab_zelle]; } $data_object .= $group_string; $object_counter += 1; $data_object .= xml_open_tag($xml_groupnames_lecture['object'], $row['seminar_id']); $sem_obj = new Seminar($row['seminar_id']); while (list($key, $val) = each($xml_names_lecture)) { if ($val == '') { $val = $key; } if ($key == 'status') { $data_object .= xml_tag($val, $SEM_TYPE[$row[$key]]['name']); } elseif ($key == 'ort') { $data_object .= xml_tag($val, $sem_obj->getDatesTemplate('dates/seminar_export_location')); } elseif ($key == 'bereich' && $SEM_CLASS[$SEM_TYPE[$row['status']]['class']]['bereiche']) { $data_object .= xml_open_tag($xml_groupnames_lecture['childgroup3']); $pathes = get_sem_tree_path($row['seminar_id']); if (is_array($pathes)) { foreach ($pathes as $path_name) { $data_object .= xml_tag($val, $path_name); } } else { $data_object .= xml_tag($val, 'n.a.'); } $data_object .= xml_close_tag($xml_groupnames_lecture['childgroup3']); } elseif ($key == 'admission_turnout') { $data_object .= xml_open_tag($val, $row['admission_type'] ? _('max.') : _('erw.')); $data_object .= $row[$key]; $data_object .= xml_close_tag($val); } elseif ($key == 'teilnehmer_anzahl_aktuell') { $count_statement->execute(array($row['seminar_id'])); $count = $count_statement->fetchColumn(); $count_statement->closeCursor(); $data_object .= xml_tag($val, $count); } elseif ($key == 'metadata_dates') { $data_object .= xml_open_tag($xml_groupnames_lecture['childgroup1']); $vorb = vorbesprechung($row['seminar_id'], 'export'); if ($vorb != false) { $data_object .= xml_tag($val[0], $vorb); } if (($first_date = SeminarDB::getFirstDate($row['seminar_id'])) && count($first_date)) { $really_first_date = new SingleDate($first_date[0]); $data_object .= xml_tag($val[1], $really_first_date->getDatesExport()); } $data_object .= xml_tag($val[2], $sem_obj->getDatesExport()); $data_object .= xml_close_tag($xml_groupnames_lecture["childgroup1"]); } elseif ($key == 'Institut_id') { $data_object .= xml_tag($val, $row['heimateinrichtung'], array('key' => $row[$key])); } elseif ($row[$key] != '') { $data_object .= xml_tag($val, $row[$key]); } } $data_object .= "<" . $xml_groupnames_lecture['childgroup2'] . ">\n"; $inner_statement->execute(array($row['seminar_id'])); while ($inner = $inner_statement->fetch(PDO::FETCH_ASSOC)) { if ($ex_person_details) { $persons[$inner['user_id']] = true; } $content_string = $inner['Vorname'] . ' ' . $inner['Nachname']; if ($inner['title_front'] != '') { $content_string = $inner['title_front'] . ' ' . $content_string; } if ($inner['title_rear'] != '') { $content_string .= ', ' . $inner['title_rear']; } $data_object .= xml_tag($xml_groupnames_lecture['childobject2'], $content_string, array('key' => $inner['username'])); } $data_object .= xml_close_tag($xml_groupnames_lecture['childgroup2']); // freie Datenfelder ausgeben $data_object .= export_datafields($row['seminar_id'], $xml_groupnames_lecture['childgroup4'], $xml_groupnames_lecture['childobject4'], 'sem', $row['status']); $data_object .= xml_close_tag($xml_groupnames_lecture['object']); reset($xml_names_lecture); output_data($data_object, $o_mode); $data_object = ''; } if ($do_subgroup && $subgroup != 'FIRSTGROUP') { $data_object .= xml_close_tag($xml_groupnames_lecture['subgroup2']); } if ($do_group && $group != 'FIRSTGROUP') { $data_object .= xml_close_tag($xml_groupnames_lecture['subgroup1']); } $data_object .= xml_close_tag($xml_groupnames_lecture['group']); output_data($data_object, $o_mode); }
/** * adds a user to the seminar with the given status * @param user_id string: ID of the user * @param status string: status of the user for the seminar "user", "autor", "tutor", "dozent" * @param force bool: if false (default) the user will only be upgraded and not degraded in his/her status */ public function addMember($user_id, $status = 'autor', $force = false) { if (in_array(get_global_perm($user_id), array("admin", "root"))) { $this->createError(_("Admin und Root dürfen nicht Mitglied einer Veranstaltung sein.")); return false; } $db = DBManager::get(); $rangordnung = array_flip(array('user', 'autor', 'tutor', 'dozent')); if ($rangordnung[$status] > $rangordnung['autor'] && SeminarCategories::getByTypeId($this->status)->only_inst_user) { //überprüfe, ob im richtigen Institut: $user_institute_stmt = $db->prepare( "SELECT Institut_id " . "FROM user_inst " . "WHERE user_id = :user_id " . ""); $user_institute_stmt->execute(array('user_id' => $user_id)); $user_institute = $user_institute_stmt->fetchAll(PDO::FETCH_COLUMN, 0); if (!in_array($this->institut_id, $user_institute) && !count(array_intersect($user_institute, $this->getInstitutes()))) { $this->createError(_("Einzutragender Nutzer stammt nicht einem beteiligten Institut an.")); return false; } } if (!$force) { $query = "SELECT status FROM seminar_user WHERE user_id = ? AND Seminar_id = ?"; $statement = DBManager::get()->prepare($query); $statement->execute(array($user_id, $this->id)); $old_status = $statement->fetchColumn(); } $query = "SELECT MAX(position) + 1 FROM seminar_user WHERE status = ? AND Seminar_id = ?"; $statement = DBManager::get()->prepare($query); $statement->execute(array($status, $this->id)); $new_position = $statement->fetchColumn(); $query = "SELECT COUNT(*) FROM seminar_user WHERE Seminar_id = ? AND status = 'dozent'"; $statement = DBManager::get()->prepare($query); $statement->execute(array($this->id)); $numberOfTeachers = $statement->fetchColumn(); if (!$old_status) { $query = "INSERT INTO seminar_user (Seminar_id, user_id, status, position, gruppe, visible, mkdate) VALUES (?, ?, ?, ?, ?, ?, UNIX_TIMESTAMP())"; $statement = DBManager::get()->prepare($query); $statement->execute(array( $this->id, $user_id, $status, $new_position ?: 0, (int)select_group($this->getSemesterStartTime()), in_array($status, words('tutor dozent')) ? 'yes' : 'unknown', )); // delete the entries, user is now in the seminar $stmt = DBManager::get()->prepare('DELETE FROM admission_seminar_user WHERE user_id = ? AND seminar_id = ?'); $stmt->execute(array($user_id, $this->getId())); if ($stmt->rowCount()) { //renumber the waiting/accepted/lot list, a user was deleted from it renumber_admission($this->getId()); } $cs = $this->getCourseSet(); if ($cs) { $prio_delete = AdmissionPriority::unsetPriority($cs->getId(), $user_id, $this->getId()); } removeScheduleEntriesMarkedAsVirtual($user_id, $this->getId()); NotificationCenter::postNotification("CourseDidGetMember", $this, $user_id); NotificationCenter::postNotification('UserDidEnterCourse', $this->id, $user_id); StudipLog::log('SEM_USER_ADD', $this->id, $user_id, $status, 'Wurde in die Veranstaltung eingetragen'); $this->course->resetRelation('members'); $this->course->resetRelation('admission_applicants'); return $this; } elseif (($force || $rangordnung[$old_status] < $rangordnung[$status]) && ($old_status !== "dozent" || $numberOfTeachers > 1)) { $query = "UPDATE seminar_user SET status = ?, visible = IFNULL(?, visible), position = ? WHERE Seminar_id = ? AND user_id = ?"; $statement = DBManager::get()->prepare($query); $statement->execute(array( $status, in_array($status, words('tutor dozent')) ? 'yes' : null, $new_position, $this->id, $user_id, )); if ($old_status === 'dozent') { $query = "SELECT termin_id FROM termine WHERE range_id = ?"; $statement = DBManager::get()->prepare($query); $statement->execute(array($this->id)); $termine = $statement->fetchAll(PDO::FETCH_COLUMN); $query = "DELETE FROM termin_related_persons WHERE range_id = ? AND user_id = ?"; $statement = DBManager::get()->prepare($query); foreach ($termine as $termin_id) { $statement->execute(array($termin_id, $user_id)); } } NotificationCenter::postNotification("CourseDidChangeMember", $this, $user_id); $this->course->resetRelation('members'); $this->course->resetRelation('admission_applicants'); return $this; } else { if ($old_status === "dozent" && $numberOfTeachers <= 1) { $this->createError(sprintf(_("Die Veranstaltung muss wenigstens <b>einen/eine</b> VeranstaltungsleiterIn (%s) eingetragen haben!"), get_title_for_status('dozent', 1, $this->status)) . ' ' . _("Tragen Sie zunächst einen anderen ein, um diesen herabzustufen.")); } return false; } }
$export_pagecontent .= "</select><br><br><br><br>"; $export_pagecontent .="<b>". _("Aus welchem Semester sollen die Daten exportiert werden (für Veranstaltungsexport): ") . "</b><br>"; if (!isset($ex_sem)) { $ex_sem = (Semester::findCurrent() ? Semester::findCurrent()->getId() : null); } $export_pagecontent .= SemesterData::GetSemesterSelector(array('name' => 'ex_sem'), $ex_sem, 'semester_id', true); $export_pagecontent .= "<br><br>"; $export_pagecontent .="<b>". _("Welche Arten von Veranstaltungen sollen exportiert werden? ") . "</b><br>"; if (!count($ex_sem_class)) { $ex_sem_class[1] = 1; } foreach (SeminarCategories::getAll() as $sem_class) { if(!$sem_class->studygroup_mode){ $export_pagecontent .= "<input type=\"checkbox\" name=\"ex_sem_class[$sem_class->id]\" value=\"1\""; if (isset($ex_sem_class[$sem_class->id])) $export_pagecontent .= " checked"; $export_pagecontent .= "> " . htmlready($sem_class->name) . " "; } } $export_pagecontent .= "<input type=\"hidden\" name=\"o_mode\" value=\"choose\">"; $export_pagecontent .= "<input type=\"hidden\" name=\"xslt_filename\" value=\"" . htmlReady($xslt_filename) . "\">"; $export_pagecontent .= "<input type=\"hidden\" name=\"choose\" value=\"" . htmlReady($choose) . "\">"; $export_pagecontent .= "<input type=\"hidden\" name=\"format\" value=\"" . htmlReady($format) . "\">"; $export_weiter_button = "<center>" . Button::create(_('Weiter') . ' >>' ) . "</center></form>";
. "username LIKE :input OR Vorname LIKE :input " . "OR CONCAT(Vorname,' ',Nachname) LIKE :input " . "OR CONCAT(Nachname,' ',Vorname) LIKE :input " . "OR Nachname LIKE :input OR {$GLOBALS['_fullname_sql']['full_rev']} LIKE :input " . " ORDER BY fullname ASC", _("Nutzer suchen"), "user_id"); $template->set_attribute('search_obj', $search_obj); // show the tree-view of the statusgroups echo $template->render(); } // there are no roles yet, so we show some informational text else { $template = $GLOBALS['template_factory']->open('statusgruppen/sem_no_statusgroups'); $template->set_layout('layouts/base.php'); $template->set_attribute('range_id', $range_id); $template->set_attribute('seminar_class', SeminarCategories::GetBySeminarId($range_id)->id); if (Request::submitted('choosePreset')) { $template->set_attribute('role_data', array('name' => Request::quoted('presetName'))); } // no parameters necessary, just display a static page echo $template->render(); } page_close();