/** * * @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 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"> ' . 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"> ' . 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"> ' . _('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"> ' . _('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"> ' . 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)
/** * Maintenance view for the manual insert parameters * */ function manual_action() { $_request = Request::GetInstance(); if (Request::submitted('submit')) { $filters = array_filter(Request::getArray('filter')); if (!Request::get('sem_id') || Request::get('sem_id') == 'false') { $this->flash['error'] = _('Ungültiger Aufruf'); } elseif (!count($filters)) { $this->flash['error'] = _('Keine Filterkriterien gewählt'); } else { $seminar = Seminar::GetInstance(Request::option('sem_id')); $group = select_group($seminar->getSemesterStartTime()); $userlookup = new UserLookup(); foreach ($filters as $type => $values) { $userlookup->setFilter($type, $values); } $user_ids = $userlookup->execute(); $real_users = 0; foreach ($user_ids as $user_id) { if (!AutoInsert::checkAutoInsertUser(Request::option('sem_id'), $user_id)) { $seminar->addMember($user_id); $real_users += AutoInsert::saveAutoInsertUser(Request::option('sem_id'), $user_id); } } //messagebox $text = sprintf(_('Es wurden %u von %u möglichen Personen in die Veranstaltung %s eingetragen.'), $real_users, count($user_ids), sprintf('<a href="%s">%s</a>', URLHelper::getLink('dispatch.php/course/details/', array('cid' => $seminar->getId())), htmlReady($seminar->getName()))); if ($real_users > 0) { $this->flash['success'] = $text; } else { $this->flash['message'] = $text; } $this->flash['detail'] = array(_('Etwaige Abweichungen der Personenzahlen enstehen durch bereits vorhandene bzw. wieder ausgetragene Personen.')); $this->redirect('admin/autoinsert/manual'); } } $this->sem_id = Request::option('sem_id'); $this->sem_search = Request::get('sem_search'); $this->sem_select = Request::option('sem_select'); $this->filtertype = Request::getArray('filtertype'); $this->filter = Request::getArray('filter'); if (count(Request::getArray('remove_filter'))) { $this->filtertype = array_diff($this->filtertype, array_keys(Request::getArray('remove_filter'))); } elseif (Request::submitted('add_filter')) { array_push($this->filtertype, Request::get('add_filtertype')); } if (Request::get('sem_search') and Request::get('sem_select')) { if (Request::get('sem_search')) { $search = new SeminarSearch('number-name'); $this->seminar_search = $search->getResults(Request::get('sem_search'), array('search_sem_sem' => $this->sem_select)); if (count($this->seminar_search) == 0) { $this->flash['message'] = _("Es wurden keine Veranstaltungen gefunden."); } } else { $this->flash['error'] = _("Im Suchfeld wurde nichts eingetragen!"); } } $this->values = array(); foreach ($this->filtertype as $type) { $this->values[$type] = UserLookup::getValuesForType($type); } $this->available_filtertypes = array('fach' => _('Studienfach'), 'abschluss' => _('Studienabschluss'), 'fachsemester' => _('Studienfachsemester'), 'institut' => _('Einrichtung'), 'status' => _('Statusgruppe'), 'domain' => _('Domäne')); }
$query = "UPDATE auth_user_md5 SET perms = 'autor' WHERE user_id = ?"; $statement = DBManager::get()->prepare($query); $statement->execute(array($user->id)); if ($statement->rowCount() == 0) { $error = _('Fehler! Bitte wenden Sie sich an den Systemadministrator.'); $details = array($query); $message = MessageBox::error($error, $details); } else { $success = _('Ihr Status wurde erfolgreich auf <em>autor</em> gesetzt.<br> Damit dürfen Sie in den meisten Veranstaltungen schreiben, für die Sie sich anmelden.'); $details = array(); $details[] = _('Einige Veranstaltungen erfordern allerdings bei der Anmeldung die Eingabe eines Passwortes. Dieses Passwort erfahren Sie von den Lehrenden der Veranstaltung.'); $message = MessageBox::success($success, $details); // Auto-Inserts AutoInsert::instance()->saveUser($user->id, "autor"); $auth->logout(); // einen Logout durchführen, um erneuten Login zu erzwingen $info = sprintf(_('Die Statusänderung wird erst nach einem erneuten %sLogin%s wirksam!<br> Deshalb wurden Sie jetzt automatisch ausgeloggt.'), '<a href="index.php?again=yes"><em>', '</em></a>'); $message .= MessageBox::info($info); } } } } } $template = $GLOBALS['template_factory']->open('email-validation'); $template->set_layout($GLOBALS['template_factory']->open('layouts/base_without_infobox')); $template->message = $message; echo $template->render(); page_close();
/** * Deletes the current seminar * * @return void returns success-message if seminar could be deleted * otherwise an error-message */ public function delete() { $s_id = $this->id; // Delete that Seminar. // Alle Benutzer aus dem Seminar rauswerfen. $query = "DELETE FROM seminar_user WHERE Seminar_id = ?"; $statement = DBManager::get()->prepare($query); $statement->execute(array($s_id)); if (($db_ar = $statement->rowCount()) > 0) { $this->createMessage(sprintf(_("%s Teilnehmende und Lehrende archiviert."), $db_ar)); } // Alle Benutzer aus Wartelisten rauswerfen $query = "DELETE FROM admission_seminar_user WHERE seminar_id = ?"; $statement = DBManager::get()->prepare($query); $statement->execute(array($s_id)); // Alle beteiligten Institute rauswerfen $query = "DELETE FROM seminar_inst WHERE Seminar_id = ?"; $statement = DBManager::get()->prepare($query); $statement->execute(array($s_id)); if (($db_ar = $statement->rowCount()) > 0) { $this->createMessage(sprintf(_("%s Zuordnungen zu Einrichtungen archiviert."), $db_ar)); } // user aus den Statusgruppen rauswerfen $count = DeleteAllStatusgruppen($s_id); if ($count > 0) { $this->createMessage(_("Einträge aus Funktionen / Gruppen gelöscht.")); } // Alle Eintraege aus dem Vorlesungsverzeichnis rauswerfen $db_ar = StudipSemTree::DeleteSemEntries(null, $s_id); if ($db_ar > 0) { $this->createMessage(sprintf(_("%s Zuordnungen zu Bereichen archiviert."), $db_ar)); } // Alle Termine mit allem was dranhaengt zu diesem Seminar loeschen. if (($db_ar = SingleDateDB::deleteAllDates($s_id)) > 0) { $this->createMessage(sprintf(_("%s Veranstaltungstermine archiviert."), $db_ar)); } //Themen IssueDB::deleteAllIssues($s_id); //Cycles SeminarCycleDate::deleteBySQL('seminar_id = ' . DBManager::get()->quote($s_id)); // Alle weiteren Postings zu diesem Seminar in den Forums-Modulen löschen foreach (PluginEngine::getPlugins('ForumModule') as $plugin) { $plugin->deleteContents($s_id); // delete content irrespective of plugin-activation in the seminar if ($plugin->isActivated($s_id)) { // only show a message, if the plugin is activated, to not confuse the user $this->createMessage(sprintf(_('Einträge in %s archiviert.'), $plugin->getPluginName())); } } // Alle Dokumente zu diesem Seminar loeschen. if (($db_ar = delete_all_documents($s_id)) > 0) { $this->createMessage(sprintf(_("%s Dokumente und Ordner archiviert."), $db_ar)); } // Freie Seite zu diesem Seminar löschen $query = "DELETE FROM scm WHERE range_id = ?"; $statement = DBManager::get()->prepare($query); $statement->execute(array($s_id)); if (($db_ar = $statement->rowCount()) > 0) { $this->createMessage(_("Freie Seite der Veranstaltung archiviert.")); } // delete literatur $del_lit = StudipLitList::DeleteListsByRange($s_id); if ($del_lit) { $this->createMessage(sprintf(_("%s Literaturlisten archiviert."),$del_lit['list'])); } // Alle News-Verweise auf dieses Seminar löschen if ( ($db_ar = StudipNews::DeleteNewsRanges($s_id)) ) { $this->createMessage(sprintf(_("%s Ankündigungen gelöscht."), $db_ar)); } //delete entry in news_rss_range StudipNews::UnsetRssId($s_id); //kill the datafields DataFieldEntry::removeAll($s_id); //kill all wiki-pages $query = "DELETE FROM wiki WHERE range_id = ?"; $statement = DBManager::get()->prepare($query); $statement->execute(array($s_id)); if (($db_wiki = $statement->rowCount()) > 0) { $this->createMessage(sprintf(_("%s Wiki-Seiten archiviert."), $db_wiki)); } $query = "DELETE FROM wiki_links WHERE range_id = ?"; $statement = DBManager::get()->prepare($query); $statement->execute(array($s_id)); $query = "DELETE FROM wiki_locks WHERE range_id = ?"; $statement = DBManager::get()->prepare($query); $statement->execute(array($s_id)); // kill all the ressources that are assigned to the Veranstaltung (and all the linked or subordinated stuff!) if (Config::get()->RESOURCES_ENABLE) { $killAssign = new DeleteResourcesUser($s_id); $killAssign->delete(); if ($rr = RoomRequest::existsByCourse($s_id)) { RoomRequest::find($rr)->delete(); } } // kill virtual seminar-entries in calendar $query = "DELETE FROM schedule_seminare WHERE seminar_id = ?"; $statement = DBManager::get()->prepare($query); $statement->execute(array($s_id)); if(get_config('ELEARNING_INTERFACE_ENABLE')){ global $connected_cms; $del_cms = 0; $cms_types = ObjectConnections::GetConnectedSystems($s_id); if(count($cms_types)){ foreach($cms_types as $system){ ELearningUtils::loadClass($system); $del_cms += $connected_cms[$system]->deleteConnectedModules($s_id); } $this->createMessage(sprintf(_("%s Verknüpfungen zu externen Systemen gelöscht."), $del_cms )); } } //kill the object_user_vists for this seminar object_kill_visits(null, $s_id); // Logging... $query = "SELECT CONCAT(seminare.VeranstaltungsNummer, ' ', seminare.name, '(', semester_data.name, ')') FROM seminare LEFT JOIN semester_data ON (seminare.start_time = semester_data.beginn) WHERE seminare.Seminar_id='$s_id'"; $statement = DBManager::get()->prepare($query); $statement->execute(array($s_id)); $semlogname = $statement->fetchColumn() ?: sprintf('unknown sem_id: %s', $s_id); StudipLog::log("SEM_ARCHIVE",$s_id,NULL,$semlogname); // ...logged // delete deputies if necessary deleteAllDeputies($s_id); UserDomain::removeUserDomainsForSeminar($s_id); AutoInsert::deleteSeminar($s_id); //Anmeldeset Zordnung entfernen $cs = $this->getCourseSet(); if ($cs) { CourseSet::removeCourseFromSet($cs->getId(), $this->getId()); $cs->load(); if (!count($cs->getCourses()) && $cs->isGlobal() && $cs->getUserid() != '') { $cs->delete(); } } AdmissionPriority::unsetAllPrioritiesForCourse($this->getId()); // und das Seminar loeschen. $this->course->delete(); $this->restore(); return true; }
/** * Imports a line of the table into the Stud.IP database if the check returns no errors. * @param array $line : array of fields * @return array : array('found' => true|false, 'errors' => "Error message", 'pk' => "primary key") */ public function importLine($line) { $plugin = $this->getPlugin(); $classname = $this['import_type']; if (!$classname) { return array(); } $data = $this->getMappedData($line); $pk = $this->getPrimaryKey($data); //Last chance to quit: $error = $this->checkLine($line, $data, $pk); $output = array(); $object = new $classname($pk); if (!$object->isNew()) { $output['found'] = true; $output['pk'] = $pk; foreach ((array) $this['tabledata']['ignoreonupdate'] as $fieldname) { unset($data[$fieldname]); } } else { $output['found'] = false; } foreach ($data as $fieldname => $value) { if ($value !== false && in_array($fieldname, $this->getTargetFields())) { $object[$fieldname] = $value; if ($classname === "User" && $fieldname === "password") { $object[$fieldname] = UserManagement::getPwdHasher()->HashPassword($value); } } } if (method_exists($object, "getFullName")) { $error['name'] = $output['name'] = $object->getFullName(); } elseif ($object->isField("name")) { $error['name'] = $output['name'] = $object['name']; } elseif ($object->isField("title")) { $error['name'] = $output['name'] = $object['title']; } if ($error && $error['errors']) { //exit here to have the name of the object in the log return $error; } if ($plugin) { $plugin->beforeUpdate($object, $line, $data); } $object->store(); $output['pk'] = (array) $object->getId(); //Dynamic special fields: switch ($classname) { case "Course": //fleximport_dozenten foreach ($data['fleximport_dozenten'] as $dozent_id) { $seminar = new Seminar($object->getId()); $seminar->addMember($dozent_id, 'dozent'); } //fleximport_related_institutes if (!$data['fleximport_related_institutes']) { $data['fleximport_related_institutes'] = array($object['institut_id']); } else { if (!in_array($object['institut_id'], $data['fleximport_related_institutes'])) { $data['fleximport_related_institutes'][] = $object['institut_id']; } } foreach ($data['fleximport_related_institutes'] as $institut_id) { $insert = DBManager::get()->prepare("\n INSERT IGNORE INTO seminar_inst\n SET seminar_id = :seminar_id,\n institut_id = :institut_id\n "); $insert->execute(array('seminar_id' => $object->getId(), 'institut_id' => $institut_id)); } if ($this['tabledata']['simplematching']["fleximport_course_userdomains"]['column'] || in_array("fleximport_course_userdomains", $this->fieldsToBeDynamicallyMapped())) { $statement = DBManager::get()->prepare("\n SELECT userdomain_id\n FROM seminar_userdomains\n WHERE seminar_id = ?\n "); $statement->execute(array($object->getId())); $olddomains = $statement->fetchAll(PDO::FETCH_COLUMN, 0); foreach (array_diff($data['fleximport_user_inst'], $olddomains) as $to_add) { $domain = new UserDomain($to_add); $domain->addSeminar($object->getId()); } foreach (array_diff($olddomains, $data['fleximport_user_inst']) as $to_remove) { $domain = new UserDomain($to_remove); $domain->removeSeminar($object->getId()); } } break; case "User": if ($this['tabledata']['simplematching']["fleximport_user_inst"]['column'] || in_array("fleximport_user_inst", $this->fieldsToBeDynamicallyMapped())) { if ($object['perms'] !== "root") { foreach ($data['fleximport_user_inst'] as $institut_id) { $member = new InstituteMember(array($object->getId(), $institut_id)); $member['inst_perms'] = $object['perms']; $member->store(); } } } if ($this['tabledata']['simplematching']["fleximport_userdomains"]['column'] || in_array("fleximport_userdomains", $this->fieldsToBeDynamicallyMapped())) { $olddomains = UserDomain::getUserDomainsForUser($object->getId()); foreach ($olddomains as $olddomain) { if (!in_array($olddomain->getID(), (array) $data['fleximport_userdomains'])) { $olddomain->removeUser($object->getId()); } } foreach ($data['fleximport_userdomains'] as $userdomain) { $domain = new UserDomain($userdomain); $domain->addUser($object->getId()); } AutoInsert::instance()->saveUser($object->getId()); foreach ($data['fleximport_userdomains'] as $domain_id) { if (!in_array($domain_id, $olddomains)) { $welcome = FleximportConfig::get("USERDOMAIN_WELCOME_" . $domain_id); if ($welcome) { foreach ($object->toArray() as $field => $value) { $welcome = str_replace("{{" . $field . "}}", $value, $welcome); } foreach ($line as $field => $value) { $welcome = str_replace("{{" . $field . "}}", $value, $welcome); } if (strpos($welcome, "\n") === false) { $subject = _("Willkommen!"); } else { $subject = strstr($welcome, "\n", true); $welcome = substr($welcome, strpos($welcome, "\n") + 1); } $messaging = new messaging(); $count = $messaging->insert_message($welcome, $object->username, '____%system%____', null, null, null, null, $subject, true, 'normal'); } } } } if ($this['tabledata']['simplematching']["fleximport_expiration_date"]['column'] || in_array("fleximport_expiration_date", $this->fieldsToBeDynamicallyMapped())) { if ($data['fleximport_expiration_date']) { UserConfig::get($object->getId())->store("EXPIRATION_DATE", $data['fleximport_expiration_date']); } else { UserConfig::get($object->getId())->delete("EXPIRATION_DATE"); } } if ($output['found'] === false && $data['fleximport_welcome_message'] !== "none") { $user_language = getUserLanguagePath($object->getId()); setTempLanguage(false, $user_language); if ($data['fleximport_welcome_message'] && FleximportConfig::get($data['fleximport_welcome_message'])) { $message = FleximportConfig::get($data['fleximport_welcome_message']); foreach ($data as $field => $value) { $message = str_replace("{{" . $field . "}}", $value, $message); } foreach ($line as $field => $value) { if (!in_array($field, $data)) { $message = str_replace("{{" . $field . "}}", $value, $message); } } if (strpos($message, "\n") === false) { $subject = dgettext($user_language, "Anmeldung Stud.IP-System"); } else { $subject = strstr($message, "\n", true); $message = substr($message, strpos($message, "\n") + 1); } } else { $Zeit = date("H:i:s, d.m.Y", time()); $this->user_data = array('auth_user_md5.username' => $object['username'], 'auth_user_md5.perms' => $object['perms'], 'auth_user_md5.Vorname' => $object['vorname'], 'auth_user_md5.Nachname' => $object['nachname'], 'auth_user_md5.Email' => $object['email']); $password = $data['password']; //this is the not hashed password in cleartext include "locale/{$user_language}/LC_MAILS/create_mail.inc.php"; $message = $mailbody; } if ($message) { $mail = new StudipMail(); $mail->addRecipient($object['email'], $object->getFullName()); $mail->setSubject($subject); $mail->setBodyText($message); $mail->setBodyHtml(formatReady($message)); if (Config::get()->MAILQUEUE_ENABLE) { MailQueueEntry::add($mail); } else { $mail->send(); } } restoreLanguage(); } break; } //Datafields: $datafields = array(); switch ($classname) { case "Course": $datafields = Datafield::findBySQL("object_type = 'sem'"); break; case "User": $datafields = Datafield::findBySQL("object_type = 'user'"); break; case "CourseMember": $datafields = Datafield::findBySQL("object_type = 'usersemdata'"); break; } foreach ($datafields as $datafield) { $fieldname = $datafield['name']; if (isset($data[$fieldname])) { $entry = new DatafieldEntryModel(array($datafield->getId(), $object->getId(), "")); $entry['content'] = $data[$fieldname]; $entry->store(); } } if ($classname === "Course") { if ($this['tabledata']['simplematching']["fleximport_studyarea"]['column'] || in_array("fleximport_studyarea", $this->fieldsToBeDynamicallyMapped())) { //Studienbereiche: $remove = DBManager::get()->prepare("\n DELETE FROM seminar_sem_tree\n WHERE seminar_id = :seminar_id\n "); $remove->execute(array('seminar_id' => $object->getId())); if ($GLOBALS['SEM_CLASS'][$GLOBALS['SEM_TYPE'][$data['status']]['class']]['bereiche']) { foreach ($data['fleximport_studyarea'] as $sem_tree_id) { $insert = DBManager::get()->prepare("\n INSERT IGNORE INTO seminar_sem_tree\n SET sem_tree_id = :sem_tree_id,\n seminar_id = :seminar_id\n "); $insert->execute(array('sem_tree_id' => $sem_tree_id, 'seminar_id' => $object->getId())); } } } if ($this['tabledata']['simplematching']["fleximport_locked"]['column'] || in_array("fleximport_locked", $this->fieldsToBeDynamicallyMapped())) { //Lock or unlock course if ($data['fleximport_locked']) { CourseSet::addCourseToSet(CourseSet::getGlobalLockedAdmissionSetId(), $object->getId()); } elseif (in_array($data['fleximport_locked'], array("0", 0)) && $data['fleximport_locked'] !== "") { CourseSet::removeCourseFromSet(CourseSet::getGlobalLockedAdmissionSetId(), $object->getId()); } } $folder_exist = DBManager::get()->prepare("\n SELECT 1 FROM folder WHERE range_id = ?\n "); $folder_exist->execute(array($object->getId())); if (!$folder_exist->fetch()) { $insert_folder = DBManager::get()->prepare("\n INSERT IGNORE INTO folder\n SET folder_id = MD5(CONCAT(:seminar_id, 'allgemeine_dateien')),\n range_id = :seminar_id,\n user_id = :user_id,\n name = :name,\n description = :description,\n mkdate = UNIX_TIMESTAMP(),\n chdate = UNIX_TIMESTAMP()\n "); $insert_folder->execute(array('seminar_id' => $object->getId(), 'user_id' => $GLOBALS['user']->id, 'name' => _("Allgemeiner Dateiordner"), 'description' => _("Ablage für allgemeine Ordner und Dokumente der Veranstaltung"))); } } if ($plugin && !$object->isNew()) { $plugin->afterUpdate($object, $line); } return $output; }
/** * initialize a new user * * this method is invoked for one time, if a new user logs in ($this->is_new_user is true) * place special treatment of new users here * * @access private * @param * User the user object * @return bool */ function doNewUserInit($user) { // auto insertion of new users, according to $AUTO_INSERT_SEM[] (defined in local.inc) AutoInsert::instance()->saveUser($user->id, $user->perms); }
/** * Change an existing studip user according to the given parameters * * @access public * @param array structure: array('string table_name.field_name'=>'string value') * @return bool Change successful? */ function changeUser($newuser) { global $perm; // Do we have permission to do so? if (!$perm->have_perm("admin")) { $this->msg .= "error§" . _("Sie haben keine Berechtigung Accounts zu verändern.") . "§"; return FALSE; } if (!$perm->is_fak_admin() && $newuser['auth_user_md5.perms'] == "admin") { $this->msg .= "error§" . _("Sie haben keine Berechtigung, <em>Admin-Accounts</em> anzulegen.") . "§"; return FALSE; } if (!$perm->have_perm("root") && $newuser['auth_user_md5.perms'] == "root") { $this->msg .= "error§" . _("Sie haben keine Berechtigung, <em>Root-Accounts</em> anzulegen.") . "§"; return FALSE; } if (!$perm->have_perm("root")) { if (!$perm->is_fak_admin() && $this->user_data['auth_user_md5.perms'] == "admin") { $this->msg .= "error§" . _("Sie haben keine Berechtigung <em>Admin-Accounts</em> zu verändern.") . "§"; return FALSE; } if ($this->user_data['auth_user_md5.perms'] == "root") { $this->msg .= "error§" . _("Sie haben keine Berechtigung <em>Root-Accounts</em> zu verändern.") . "§"; return FALSE; } if ($perm->is_fak_admin() && $this->user_data['auth_user_md5.perms'] == "admin") { if (!$this->adminOK()) { $this->msg .= "error§" . _("Sie haben keine Berechtigung diesen Admin-Account zu verändern.") . "§"; return FALSE; } } } // active dozent? (ignore the studygroup guys) $status = studygroup_sem_types(); if (empty($status)) { $count = 0; } else { $query = "SELECT COUNT(*)\n FROM seminar_user AS su\n LEFT JOIN seminare AS s USING (Seminar_id)\n WHERE su.user_id = ?\n AND s.status NOT IN (?)\n AND su.status = 'dozent'\n AND (SELECT COUNT(*) FROM seminar_user su2 WHERE Seminar_id = su.Seminar_id AND su2.status = 'dozent') = 1\n GROUP BY user_id"; $statement = DBManager::get()->prepare($query); $statement->execute(array($this->user_data['auth_user_md5.user_id'], $status)); $count = $statement->fetchColumn(); } if ($count && isset($newuser['auth_user_md5.perms']) && $newuser['auth_user_md5.perms'] != "dozent") { $this->msg .= sprintf("error§" . _("Der Benutzer <em>%s</em> ist alleiniger Dozent in %s aktiven Veranstaltungen und kann daher nicht in einen anderen Status versetzt werden!") . "§", $this->user_data['auth_user_md5.username'], $count); return FALSE; } // active admin? if ($this->user_data['auth_user_md5.perms'] == 'admin' && $newuser['auth_user_md5.perms'] != 'admin') { // count number of institutes where the user is admin $query = "SELECT COUNT(*)\n FROM user_inst\n WHERE user_id = ? AND inst_perms = 'admin'\n GROUP BY Institut_id"; $statement = DBManager::get()->prepare($query); $statement->execute(array($this->user_data['auth_user_md5.user_id'])); // if there are institutes with admin-perms, add error-message and deny change if ($count = $statement->fetchColumn()) { $this->msg .= sprintf('error§' . _("Der Benutzer <em>%s</em> ist Admin in %s Einrichtungen und kann daher nicht in einen anderen Status versetzt werden!") . '§', $this->user_data['auth_user_md5.username'], $count); return false; } } // Is the username correct? if (isset($newuser['auth_user_md5.username'])) { if ($this->user_data['auth_user_md5.username'] != $newuser['auth_user_md5.username']) { if (!$this->validator->ValidateUsername($newuser['auth_user_md5.username'])) { $this->msg .= "error§" . _("Der gewählte Benutzername ist zu kurz oder enthält unzulässige Zeichen!") . "§"; return FALSE; } $check_uname = StudipAuthAbstract::CheckUsername($newuser['auth_user_md5.username']); if ($check_uname['found']) { $this->msg .= "error§" . _("Der Benutzername wird bereits von einem anderen Benutzer verwendet. Bitte wählen Sie einen anderen Benutzernamen!") . "§"; return false; } else { //$this->msg .= "info§" . $check_uname['error'] ."§"; } } else { unset($newuser['auth_user_md5.username']); } } // Can we reach the email? if (isset($newuser['auth_user_md5.Email'])) { if (!$this->checkMail($newuser['auth_user_md5.Email'])) { return FALSE; } } // Store changed values in internal array if allowed $old_perms = $this->user_data['auth_user_md5.perms']; $auth_plugin = $this->user_data['auth_user_md5.auth_plugin']; foreach ($newuser as $key => $value) { if (!StudipAuthAbstract::CheckField($key, $auth_plugin)) { $this->user_data[$key] = $value; } else { $this->msg .= "error§" . sprintf(_("Das Feld <em>%s</em> können Sie nicht ändern!"), $key) . "§"; return FALSE; } } if (!$this->storeToDatabase()) { $this->msg .= "info§" . _("Es wurden keine Veränderungen der Grunddaten vorgenommen.") . "§"; return false; } $this->msg .= "msg§" . sprintf(_("Benutzer \"%s\" verändert."), $this->user_data['auth_user_md5.username']) . "§"; if ($auth_plugin !== null) { // Automated entering new users, based on their status (perms) $result = AutoInsert::instance()->saveUser($this->user_data['auth_user_md5.user_id'], $newuser['auth_user_md5.perms']); foreach ($result['added'] as $item) { $this->msg .= "msg§" . sprintf(_("Das automatische Eintragen in die Veranstaltung <em>%s</em> wurde durchgeführt."), $item) . "§"; } foreach ($result['removed'] as $item) { $this->msg .= "msg§" . sprintf(_("Das automatische Austragen aus der Veranstaltung <em>%s</em> wurde durchgeführt."), $item) . "§"; } // include language-specific subject and mailbody $user_language = getUserLanguagePath($this->user_data['auth_user_md5.user_id']); $Zeit = date("H:i:s, d.m.Y", time()); include "locale/{$user_language}/LC_MAILS/change_mail.inc.php"; // send mail StudipMail::sendMessage($this->user_data['auth_user_md5.Email'], $subject, $mailbody); } // Upgrade to admin or root? if ($newuser['auth_user_md5.perms'] == "admin" || $newuser['auth_user_md5.perms'] == "root") { $this->re_sort_position_in_seminar_user(); // delete all seminar entries $query = "SELECT seminar_id FROM seminar_user WHERE user_id = ?"; $statement = DBManager::get()->prepare($query); $statement->execute(array($this->user_data['auth_user_md5.user_id'])); $seminar_ids = $statement->fetchAll(PDO::FETCH_COLUMN); $query = "DELETE FROM seminar_user WHERE user_id = ?"; $statement = DBManager::get()->prepare($query); $statement->execute(array($this->user_data['auth_user_md5.user_id'])); if (($db_ar = $statement->rowCount()) > 0) { $this->msg .= "info§" . sprintf(_("%s Einträge aus Veranstaltungen gelöscht."), $db_ar) . "§"; array_map('update_admission', $seminar_ids); } // delete all entries from waiting lists $query = "SELECT seminar_id FROM admission_seminar_user WHERE user_id = ?"; $statement = DBManager::get()->prepare($query); $statement->execute(array($this->user_data['auth_user_md5.user_id'])); $seminar_ids = $statement->fetchAll(PDO::FETCH_COLUMN); $query = "DELETE FROM admission_seminar_user WHERE user_id = ?"; $statement = DBManager::get()->prepare($query); $statement->execute(array($this->user_data['auth_user_md5.user_id'])); if (($db_ar = $statement->rowCount()) > 0) { $this->msg .= "info§" . sprintf(_("%s Einträge aus Wartelisten gelöscht."), $db_ar) . "§"; array_map('update_admission', $seminar_ids); } // delete 'Studiengaenge' $query = "DELETE FROM user_studiengang WHERE user_id = ?"; $statement = DBManager::get()->prepare($query); $statement->execute(array($this->user_data['auth_user_md5.user_id'])); if (($db_ar = $statement->rowCount()) > 0) { $this->msg .= "info§" . sprintf(_("%s Zuordnungen zu Studiengängen gelöscht."), $db_ar) . "§"; } // delete all private appointments of this user if ($db_ar = delete_range_of_dates($this->user_data['auth_user_md5.user_id'], FALSE) > 0) { $this->msg .= "info§" . sprintf(_("%s Einträge aus den Terminen gelöscht."), $db_ar) . "§"; } } if ($newuser['auth_user_md5.perms'] == "admin") { $this->logInstUserDel($this->user_data['auth_user_md5.user_id'], "inst_perms != 'admin'"); $query = "DELETE FROM user_inst WHERE user_id = ? AND inst_perms != 'admin'"; $statement = DBManager::get()->prepare($query); $statement->execute(array($this->user_data['auth_user_md5.user_id'])); if (($db_ar = $statement->rowCount()) > 0) { $this->msg .= "info§" . sprintf(_("%s Einträge aus MitarbeiterInnenlisten gelöscht."), $db_ar) . "§"; } } if ($newuser['auth_user_md5.perms'] == "root") { $this->logInstUserDel($this->user_data['auth_user_md5.user_id']); $query = "DELETE FROM user_inst WHERE user_id = ?"; $statement = DBManager::get()->prepare($query); $statement->execute(array($this->user_data['auth_user_md5.user_id'])); if (($db_ar = $statement->rowCount()) > 0) { $this->msg .= "info§" . sprintf(_("%s Einträge aus MitarbeiterInnenlisten gelöscht."), $db_ar) . "§"; } } return TRUE; }
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; }