diff --git a/app/controllers/course/archive.php b/app/controllers/course/archive.php index 63a25944eb2e1624336b115f67b2943e44302009..1177fd8774597469917e44abfb1383092d5b980c 100644 --- a/app/controllers/course/archive.php +++ b/app/controllers/course/archive.php @@ -187,51 +187,5 @@ class Course_ArchiveController extends AuthenticatedController } } - /* - // enable the following code when archive.inc.php is replaced - - //get all courses: - $courses = Course::findMany($courseIds); - - //now create ArchivedCourse objects out of the Course objects: - - foreach ($courses as $course) { - in_archiv($course->id); - } - $archivedCourse = new ArchivedCourse(); - $archivedCourse->id = $course->id; - $archivedCourse->name = $course->name; - $archivedCourse->untertitel = $course->untertitel; - $archivedCourse->beschreibung = $course->beschreibung; - $archivedCourse->start_time = $course->start_time; - $archivedCourse->semester = $course->end_semester; //TODO: maybe start_semester is better - $archivedCourse->heimat_inst_id = $course->home_institut->id; - $archivedCourse->institute = $course->institutes; - - //get "dozenten": - $archivedCourse->dozenten = $course->members->filter( - function ($member) { - return $member['status'] === "dozent"; - } - ); - - $archivedCourse->fakultaet = $course->home_institut->faculty; - - - //dump is an HTML table with the seminar data - $archivedCourse->dump = $this->createArchivedCourseHTMLTable($course); - - //TODO: - //$archivedCourse->archiv_file_id = - //$archivedCourse->archiv_protected_file_id = - $archivedCourse->mkdate = time(); - //$archivedCourse->forumdump = - //$archivedCourse->wikidump = - $archivedCourse->studienbereiche = $course->study_areas; - $archivedCourse->veranstaltungsnummer = $course->veranstaltungsnummer; - $archivedCourse->members = $course->members; - $archivedCourse->home_institut = $course->home_institut; - } - */ } } diff --git a/lib/archiv.inc.php b/lib/archiv.inc.php index 2108eaf28fd476c263a89ce5ca5fa711126b3160..b9e18ac8e6fea11764c4d9222ae33b6cdf36b21d 100644 --- a/lib/archiv.inc.php +++ b/lib/archiv.inc.php @@ -23,10 +23,6 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -require_once 'lib/dates.inc.php'; -require_once 'lib/wiki.inc.php'; // getAllWikiPages for dump -require_once 'lib/user_visible.inc.php'; - /** * This function returns the last activity in the course. * @@ -86,689 +82,3 @@ function lastActivity ($sem_id) return $timestamp; } - -// Liefert den dump des Seminars -function dump_sem($sem_id, $print_view = false) -{ - global $TERMIN_TYP, $SEM_TYPE, $SEM_CLASS, $_fullname_sql, $AUTO_INSERT_SEM; - - - $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([$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 Lehrenden? - $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, Vorname"; - $statement = DBManager::get()->prepare($query); - $statement->execute([$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, Vorname"; - $statement = DBManager::get()->prepare($query); - $statement->execute([$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([$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) ?: []; - $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([$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([$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([$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); - - $num_files = 0; - $course_top_folder = Folder::findTopFolder($sem_id); - if ($course_top_folder) { - $course_top_folder = $course_top_folder->getTypedFolder(); - } - - $user_id = $print_view === true ? $GLOBALS['user']->id : $print_view; - - $readable_files_user_id = $user_id; - - if ($Modules['documents']) { - //Get the amount of readable files for a user with status autor in the course: - - $autor = CourseMember::findOneBySql( - "seminar_id = :course_id AND status = 'autor'", - [ - 'course_id' => $sem_id - ] - ); - if ($autor) { - $readable_files_user_id = $autor->user_id; - $num_files = FileManager::countFilesInFolder($course_top_folder, true, null, $autor->user_id); - } else { - $dozent = CourseMember::findOneBySql( - "seminar_id = :course_id AND status = 'dozent'", - [ - 'course_id' => $sem_id - ] - ); - $readable_files_user_id = $dozent->user_id; - $num_files = FileManager::countFilesInFolder($course_top_folder, true, null, $dozent->user_id); - } - } - - $dumpRow(_('Dokumente') . ':', $num_files ? $num_files : 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"; - } - } - } - - // Dateien anzeigen - if ($Modules['documents']) { - - if ($course_top_folder) { - list($file_refs, $folders) = array_values( - FileManager::getFolderFilesRecursive( - $course_top_folder, - $readable_files_user_id, - true - ) - ); - - $link_text = _('Hinweis: Diese Datei wurde nicht archiviert, da sie lediglich verlinkt wurde.'); - - - if ($file_refs) { - $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 ($file_refs as $file_ref) { - $dump .= sprintf( - '<tr><td width="100%%"><b>%s</b><br>%s (%u KB)</td><td>%s</td><td>%s</td></tr>' . "\n", - htmlReady($file_ref->name), - htmlReady($file_ref->description), - round($file_ref->file->size / 1024), - htmlReady($file_ref->owner->nachname), - date('d.m.Y', $file_ref->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>'; - - $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([$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) { - //Count the files the user owns in the course: - - $user_files_count = FileManager::countFilesInFolder( - $course_top_folder, - true, - $user['user_id'] - ); - - // 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, - $user_files_count - ); - } // eine Zeile zuende - - $dump.= '</table>' . "\n"; - } - } // eine Gruppe zuende - } - - return $dump; -} // end function dump_sem($sem_id) - - -/** - * Returns the regular dates for one seminar. - * @param $sem_id the id of the seminar - * @return the HTML for the schedule table - */ -function dumpRegularDatesSchedule($sem_id) -{ - $presence_type_clause = getPresenceTypeClause(); - $query = "SELECT termine.*, themen.title AS th_title, themen.description AS th_desc - FROM termine - LEFT JOIN themen_termine USING (termin_id) - LEFT JOIN themen USING (issue_id) - WHERE range_id = ? AND date_typ IN {$presence_type_clause} - ORDER BY date"; - $statement = DBManager::get()->prepare($query); - $statement->execute([$sem_id]); - $data = $statement->fetchAll(PDO::FETCH_ASSOC); - - return dumpScheduleTable($data, _('Ablaufplan')); -} - -/** - * Returns the extra dates for one seminar - * @param $sem_id the id of the seminar - * @return the HTML for the schedule table for the extra dates - */ -function dumpExtraDatesSchedule($sem_id) -{ - $presence_type_clause = getPresenceTypeClause(); - $query = "SELECT termine.*, themen.title AS th_title, themen.description AS th_desc - FROM termine - LEFT JOIN themen_termine USING (termin_id) - LEFT JOIN themen USING (issue_id) - WHERE range_id = ? AND date_typ NOT IN {$presence_type_clause} - ORDER BY date"; - $statement = DBManager::get()->prepare($query); - $statement->execute([$sem_id]); - $data = $statement->fetchAll(PDO::FETCH_ASSOC); - - return dumpScheduleTable($data, _('zusätzliche Termine')); -} - -/** - * Returns the schedule table for one query as HTML. - * The query has to start like this: - * SELECT termine.*, themen.title as th_title, themen.description as th_desc FROM termine LEFT JOIN themen_termine USING (termin_id) LEFT JOIN themen USING (issue_id) - * @param $data the result of an query for date entries - * @param $title the title for the table header - * @return the HTML for the schedule table - */ -function dumpScheduleTable($data, $title) -{ - if (count($data) > 0) { - $dump = '<br>'; - $dump .= '<table width="100%" border="1" cellpadding="2" cellspacing="0">'; - $dump .= dumpDateTableHeader($title); - $dump .= dumpDateTableRows($data); - $dump .= '</table>' . "\n"; - } - - return $dump; -} - -/** - * Returns the first row (the header row) for the tables listing dates. - * @param $title title to show in first table row - * @return the HTML for the first table row - */ -function dumpDateTableHeader($title) -{ - $dump = '<tr><td colspan="2" align="left" class="table_header_bold">'; - $dump .= '<h2 class="table_header_bold"> ' . htmlReady($title) . '</h2>'; - $dump .= '</td></tr>' . "\n"; - - return $dump; -} - -/** - * Returns the HTML table rows for the date entries in $data. - * The query has to start like this: - * SELECT termine.*, themen.title as th_title, themen.description as th_desc FROM termine LEFT JOIN themen_termine USING (termin_id) LEFT JOIN themen USING (issue_id) - * @param $data the result of an query for date entries - * @return the HTML for the table rows - */ -function dumpDateTableRows($data) -{ - global $TERMIN_TYP; - - $dump = ''; - $lastTerminId = NULL; - - foreach ($data as $row) { - $currentTerminId = $row['termin_id']; - if ($lastTerminId != $currentTerminId) { - $dump .= '<tr align="center"> '; - $dump .= '<td width="25%" align="left" valign="top">'; - $dump .= strftime('%d. %b. %Y, %H:%M', $row['date']); - $dump .= ' - ' . strftime('%H:%M', $row['end_time']); - $dump .= ' (' . $TERMIN_TYP[$row['date_typ']]['name'] . ')'; - $dump .= '</td>'; - } else { - $dump .= '<tr><td width="25%"></td>'; - } - - $dump .= '<td width="75%" align="left"> '; - $dump .= htmlReady($row['th_title'], 1, 1); - if ($row['th_desc']) { - $dump .= '<br/>'; - $dump .= formatReady($row['th_desc'], 1, 1); - } - $dump .= ' </td></tr>' . "\n"; - - $lastTerminId = $currentTerminId; - } - - return $dump; -} - - -/////// die beiden Funktionen um das Forum zu exportieren - -//Funktion zum archivieren eines Seminars, sollte in der Regel vor dem Loeschen ausgfuehrt werden. -function in_archiv ($sem_id) -{ - global $SEM_CLASS,$SEM_TYPE, $ARCHIV_PATH, $TMP_PATH, $_fullname_sql; - - NotificationCenter::postNotification('CourseWillArchive', $sem_id); - - //Besorgen der Grunddaten des Seminars - $query = "SELECT Seminar_id, Name, Untertitel, Beschreibung, - start_time, Institut_id, status - FROM seminare - WHERE Seminar_id = ?"; - $statement = DBManager::get()->prepare($query); - $statement->execute([$sem_id]); - $row = $statement->fetch(PDO::FETCH_ASSOC); - - $seminar_id = $row['Seminar_id']; - $name = $row['Name']; - $untertitel = $row['Untertitel']; - $beschreibung = $row['Beschreibung']; - $start_time = $row['start_time']; - $heimat_inst_id = $row['Institut_id']; - - //Besorgen von einzelnen Daten zu dem Seminar - $all_semester = Semester::findAllVisible(false); - foreach ($all_semester as $sem) { - if (($start_time >= $sem['beginn']) && ($start_time <= $sem['ende'])) { - $semester_tmp = $sem['name']; - } - } - - //Studienbereiche - if ($SEM_CLASS[$SEM_TYPE[$row['status']]['class']]['bereiche']) { - $sem_path = get_sem_tree_path($seminar_id); - if (is_array($sem_path)) { - $studienbereiche = join(', ', $sem_path); - } - } - - // das Heimatinstitut als erstes - $query = "SELECT Name FROM Institute WHERE Institut_id = ?"; - $statement = DBManager::get()->prepare($query); - $statement->execute([$heimat_inst_id]); - $institute = $statement->fetchColumn(); - - // jetzt den Rest - $query = "SELECT Name - FROM Institute - LEFT JOIN seminar_inst USING (institut_id) - WHERE seminar_id = ? AND Institute.Institut_id != ?"; - $statement = DBManager::get()->prepare($query); - $statement->execute([$seminar_id, $heimat_inst_id]); - while ($temp = $statement->fetchColumn()) { - $institute .= ', ' . $temp; - } - - $query = "SELECT GROUP_CONCAT({$_fullname_sql['full']} SEPARATOR ', ') - FROM seminar_user - LEFT JOIN auth_user_md5 USING (user_id) - LEFT JOIN user_info USING (user_id) - WHERE seminar_id = ? AND seminar_user.status = 'dozent'"; - $statement = DBManager::get()->prepare($query); - $statement->execute([$seminar_id]); - $dozenten = $statement->fetchColumn(); - - $query = "SELECT fakultaets_id - FROM seminare - LEFT JOIN Institute USING (Institut_id) - WHERE Seminar_id = ?"; - $statement = DBManager::get()->prepare($query); - $statement->execute([$seminar_id]); - $fakultaet_id = $statement->fetchColumn(); - - $query = "SELECT GROUP_CONCAT(DISTINCT c.Name SEPARATOR ' | ') - 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([$seminar_id]); - $fakultaet = $statement->fetchColumn(); - - setTempLanguage(); // use DEFAULT_LANGUAGE for archiv-dumps - - //Dump holen - $dump = dump_sem($sem_id, 'nobody'); - - //Forumdump holen - foreach (PluginEngine::getPlugins('ForumModule', $sem_id) as $plugin) { - $forumdump .= $plugin->getDump($sem_id); - } - - // Wikidump holen - $wikidump = getAllWikiPages($sem_id, $name, FALSE); - - restoreLanguage(); - - //OK, naechster Schritt: Kopieren der Personendaten aus seminar_user in archiv_user - $query = "INSERT IGNORE INTO archiv_user (seminar_id, user_id, status) - SELECT Seminar_id, user_id, status FROM seminar_user WHERE Seminar_id = ?"; - $statement = DBManager::get()->prepare($query); - $statement->execute([$seminar_id]); - - // Eventuelle Vertretungen in der Veranstaltung haben weiterhin Zugriff mit Lehrendenrechten - if (Config::get()->DEPUTIES_ENABLE) { - $deputies = Deputy::findDeputies($seminar_id)->pluck('user_id'); - // Eintragen ins Archiv mit Zugriffsberechtigung "dozent" - $query = "INSERT IGNORE INTO archiv_user SET seminar_id = ?, user_id = ?, status = 'dozent'"; - $statement = DBManager::get()->prepare($query); - foreach ($deputies as $deputy) { - $statement->execute([$seminar_id, $deputy]); - } - } - - - //Archive files: - - - //Get the top folder of the course: - $top_folder = Folder::findTopFolder($sem_id); - if($top_folder) { - $top_folder = $top_folder->getTypedFolder(); - } - - //Collect all subfolders and files which are directly below the top folder: - - $readable_items = []; //files and folders which are readable for all course participants - $protected_archive_items = []; //all files and folders of the course - - foreach($top_folder->getSubfolders() as $subfolder) { - $protected_archive_items[] = $subfolder; - if($subfolder instanceof StandardFolder) { - //StandardFolder instances inside a course are always readable - //for everyone. For other folder types we can't be sure - //about that so that these folder types aren't included - //in the standard file archive. - $readable_items[] = $subfolder; - } - } - - foreach($top_folder->getFiles() as $file_ref) { - $protected_archive_items[] = $file_ref; - if($file_ref->terms_of_use) { - if($file_ref->terms_of_use->download_condition == 0) { - //only Files which are downloadable by everyone in the course - //can be added to the standard file archive. - $readable_items[] = $file_ref; - } - } - } - - - //Create the standard file archive if there are files and folders which - //are readable (or downloadable) for everyone in the course: - - $archive_file_id = ''; - - if (!empty($readable_items)) { - //list of readable items isn't empty - - //create name for the archive ZIP file: - $archive_file_id = md5('archive_' . $sem_id); - - $archive_path = $ARCHIV_PATH . '/' . $archive_file_id; - - FileArchiveManager::createArchive( - $readable_items, - 'nobody', - $archive_path, - false, //don't do individual permission checks - true, //keep hierarchy - true //skip check for user permissions - ); - - if(!file_exists($archive_path)) { - //empty archive or error during archive creation: - $archive_file_id = ''; //no archive - } - - } - - - //Create the protected file archive which contains all files of the course. - - $archive_protected_files_zip_id = md5('protected_archive_' . $sem_id); - - $archive_protected_files_path = $ARCHIV_PATH . '/' . $archive_protected_files_zip_id; - - FileArchiveManager::createArchive( - $protected_archive_items, - null, - $archive_protected_files_path, - false //no permission checks - ); - - if(!file_exists($archive_protected_files_path)) { - //empty archive or error during archive creation: - $archive_protected_files_zip_id = ''; //no protected files archive - } - - - //We're done with archiving: Store a new archived course in the database: - $query = "INSERT INTO archiv - (seminar_id, name, untertitel, beschreibung, start_time, - semester, heimat_inst_id, institute, dozenten, fakultaet, - dump, archiv_file_id,archiv_protected_file_id, forumdump, wikidump, studienbereiche, - mkdate) - VALUES - (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, UNIX_TIMESTAMP())"; - $statement = DBManager::get()->prepare($query); - $success = $statement->execute([ - $seminar_id, - $name ?: '', - $untertitel ?: '', - $beschreibung ?: '', - $start_time, - $semester_tmp ?: '', - $heimat_inst_id, - $institute ?: '', - $dozenten ?: '', - $fakultaet ?: '', - $dump ?: '', - $archive_file_id ?: '', - $archive_protected_files_zip_id ?: '', - $forumdump ?: '', - $wikidump ?: '', - $studienbereiche ?: '', - ]); - if ($success) { - NotificationCenter::postNotification('CourseDidArchive', $seminar_id); - } -} diff --git a/lib/classes/JsonApi/Routes/Courseware/TaskFeedbackUpdate.php b/lib/classes/JsonApi/Routes/Courseware/TaskFeedbackUpdate.php index 4097818212815bd2c056955a25585be61414ff93..f0330c7a471d6016d1148eb2c145e5e77bead840 100755 --- a/lib/classes/JsonApi/Routes/Courseware/TaskFeedbackUpdate.php +++ b/lib/classes/JsonApi/Routes/Courseware/TaskFeedbackUpdate.php @@ -62,23 +62,21 @@ class TaskFeedbackUpdate extends JsonApiController } $resource->store(); - if ($struct->range_type === 'courses') { - $data = [ + if ($resource->getStructuralElement()->range_type === 'courses') { + Activity::create([ 'provider' => 'Studip\Activity\CoursewareProvider', 'context' => 'course', - 'context_id' => $task->seminar_id, + 'context_id' => $resource->getStructuralElement()->range_id, 'content' => self::arrayGet($json, 'data.attributes.content', ''), 'actor_type' => 'user', 'actor_id' => $user->id, 'verb' => 'answered', - 'object_id' => $task->structural_element_id, + 'object_id' => $resource->task->structural_element_id, 'object_type' => 'courseware', 'mkdate' => time() - ]; - - $activity = Activity::create($data); + ]); } return $resource; } -} \ No newline at end of file +} diff --git a/lib/classes/JsonApi/Schemas/User.php b/lib/classes/JsonApi/Schemas/User.php index 14787ce6d8e200882df10452ceb2e0fc6f2a7564..3e326652ed924268f190825fd353cbca0324a2c1 100644 --- a/lib/classes/JsonApi/Schemas/User.php +++ b/lib/classes/JsonApi/Schemas/User.php @@ -253,7 +253,7 @@ class User extends SchemaProvider self::RELATIONSHIP_LINKS => [ Link::RELATED => $this->getRelationshipRelatedLink($user, self::REL_COURSE_MEMBERSHIPS), ], - self::RELATIONSHIP_DATA => $resource->course_memberships, + self::RELATIONSHIP_DATA => $user->course_memberships, ]; return $relationships; diff --git a/lib/classes/MvvPerm.php b/lib/classes/MvvPerm.php index ab5012890d07aa76874abc4a9b738b347b99153a..d7f3732cf745f9381a462577eb64cf21ee62df4f 100644 --- a/lib/classes/MvvPerm.php +++ b/lib/classes/MvvPerm.php @@ -31,13 +31,13 @@ class MvvPerm { * of the designated field. */ const PERM_CREATE = 7; - + /** * Permission to read, write/create and delete the value * of the designated field. Possibly the admin have permission to * particular functions. */ - const PERM_ADMIN = 15; + const PERM_ADMIN = 15; private static $privileges; @@ -47,21 +47,21 @@ class MvvPerm { /** * The actual mvv object. - * + * * @var object */ private $mvv_object; /** - * to distinguish config files between different languages - * + * to distinguish config files between different languages + * * @var string */ private $variant; /** * Creates a new perm object for given mvv object. - * + * * @param ModuleManagementModel $mvv_object */ public function __construct(ModuleManagementModel $mvv_object) @@ -71,7 +71,7 @@ class MvvPerm { /** * Returns a new perm object for given mvv object. - * + * * @param ModuleManagementModel|string $mvv_object Class name or instance of * mvv object. * @return MvvPerm A new perm object. @@ -105,11 +105,11 @@ class MvvPerm { /** * Intercepts static calls to retrieve permission from configuration. - * + * * Allowed calls are: - * + * * MvvPerm::getFieldPermFIELD($mvv_object, $user_id, $institut_id) - * + * * @see MvvPerm:getFieldPerm() * FIELD is the name of the table field. * $mvv_object: Class name or instance of mvv object. @@ -117,9 +117,9 @@ class MvvPerm { * $institut_id: The id of an institute or an array of institute ids the * user has a mvv related role. * Last two arguments are optional. - * + * * MvvPerm::havePermPERM($mvv_object, $status, $user_id, $institut_id) - * + * * @see MvvPerm::havePerm() * PERM is the constant defining the permission (MvvPerm::PERM_ADMIN, * MvvPerm::PERM_CREATE, MvvPerm::PERM_READ, MvvPerm::PERM_WRITE) @@ -130,9 +130,9 @@ class MvvPerm { * $institut_id: The id of an institute or an array of institute ids the * user has a mvv related role. * Last three arguments are optional - * + * * MvvPerm::haveFieldPermFIELD($mvv_object, $perm, $user_id, $institut_id) - * + * * @see MvvPerm::haveFieldPerm() * FIELD is the name of the table field. * $mvv_object: Class name or instance of mvv object. @@ -143,7 +143,7 @@ class MvvPerm { * $institut_id: The id of an institute or an array of institute ids the * user has a mvv related role. * Last three arguments are optional. - * + * * @param type $name * @param type $arguments * @return type @@ -183,11 +183,11 @@ class MvvPerm { /** * Intercepts instance methods to retrieve permission from configuration. - * + * * Allowed calls are: - * + * * havePermPERM($status, $user_id, $institut_id) - * + * * @see MvvPerm::havePerm() * PERM is the constant defining the permission (MvvPerm::PERM_ADMIN, * MvvPerm::PERM_CREATE, MvvPerm::PERM_READ, MvvPerm::PERM_WRITE) @@ -197,19 +197,19 @@ class MvvPerm { * $institut_id: The id of an institute or an array of institute ids the * user has a mvv related role. * All three arguments are optional - * + * * getFieldPermFIELD($user_id, $institut_id) - * + * * @see MvvPerm::getFieldPerm() * FIELD is the name of the table field. * $user_id: The id of an user. Id of current user as default. * $institut_id: The id of an institute or an array of institute ids the * user has a mvv related role. * All two arguments are optional. - * - * + * + * * haveFieldPermFIELD($perm, $user_id, $institut_id) - * + * * @see MvvPerm::haveFieldPerm() * FIELD is the name of the table field. * $perm: The constant defining the permission (MvvPerm::PERM_ADMIN, @@ -219,10 +219,10 @@ class MvvPerm { * $institut_id: The id of an institute or an array of institute ids the * user has a mvv related role. * All three arguments are optional. - * - * + * + * * @param string $name - * @param array $arguments + * @param array $arguments * @return mixed * @throws InvalidArgumentException If called with unknown permission. * @throws BadMethodCallException If called with unknown method to @@ -262,7 +262,7 @@ class MvvPerm { * Sets the variant of an mvv object. The variant means that a different * configuration file is used to retrieve the permissions. It is used to * determines permissions for different languages of a descriptor. - * + * * @param string $variant The suffix (part after las underscore) of the * file name of a config file. * @return $this Returns this instance for method chaining. @@ -367,15 +367,15 @@ class MvvPerm { * Accepts the id of the user, an institute id and the status of this object * as optional arguments. Returns whether the user has the given permission * to this object. - * - * The status of this object is defined in the configuration file - * + * + * The status of this object is defined in the configuration file + * * @param int $perm The permission to check against. * @param string $status The status of the object defined in config. * @param string $user_id The id of the user. * @param string|array $institut_id The id of an institute or an array of * institute ids the user has a mvv related role. - * @return bool + * @return bool */ public final function havePerm($perm, $status = null, $user_id = null, $institut_id = null) @@ -389,7 +389,7 @@ class MvvPerm { * Returns whether the given user has at least the given permission to this * object with the actual status. The user_id is optional. Default is the * id of the current user. - * + * * @param int $perm The permission to check against. * @param type $user_id The id of an user. * @return bool True if the permission is granted. @@ -405,9 +405,9 @@ class MvvPerm { /** * Returns whether the actual user has at least the given permission to * the datafield entry. - * + * * @param $datafield_id The id of a datafield. - * @param int $perm + * @param int $perm * @return bool True if permission is granted. */ public function haveDfEntryPerm($datafield_id, $perm) @@ -497,9 +497,9 @@ class MvvPerm { /** * Returns true if the user have at least the given permission status. - * + * * @param string $field The name of the table field. - * @param int $perm The optional (default PERM_WRITE) permission status. + * @param int $perm The optional (default PERM_WRITE) permission status. * @param string $user_id Optional. The ID of the user. If not set the ID of * the current user. * @param string|array $institut_id Optional. The id of an institute or an array of @@ -515,7 +515,7 @@ class MvvPerm { /** * Returns 'readonly' if the given user has no access to the given field. - * + * * @param string $field The name of the table field. * @param int $perm Optional. The permission. Defaults to MvvPerm:PERM_WRITE. * @param string $user_id Optional. The ID of the user. If not set the ID of @@ -532,10 +532,10 @@ class MvvPerm { } /** - * - * + * + * * @param type $user_id - * @return + * @return */ public static function getRoles($user_id) { @@ -543,7 +543,7 @@ class MvvPerm { $assigned = RolePersistence::getAssignedRoles($user_id); foreach (RolePersistence::getAssignedRoles($user_id) as $role_id => $role) { if (substr_compare($role->rolename, 'MVV', 1, 3, true)) { - self::$roles[$user_id][] = $role; + self::$roles[$user_id][] = $role; } } } @@ -560,13 +560,14 @@ class MvvPerm { self::$privileges = unserialize($cache->read(MVV::CACHE_KEY . '/privileges')); } - if (self::$privileges[$mvv_table] === null) { + if (self::$privileges[$mvv_table] === null) { $config_dir = $GLOBALS['STUDIP_BASE_PATH'] . '/config/mvvconfig'; if ($config_dir) { $config_file = $config_dir . '/' . $mvv_table . '.php'; if (filetype($config_file) === 'file') { - include $config_file; - self::$privileges[$mvv_table] = $privileges; + // TODO: This should be refactored in a way that $config_file returns an array + include $config_file; // Defines $privileges + self::$privileges[$mvv_table] = $privileges ?? []; } $cache = StudipCacheFactory::getCache(); $cache->write(MVV::CACHE_KEY . '/privileges', serialize(self::$privileges)); @@ -607,10 +608,10 @@ class MvvPerm { if (self::$user_role_institutes[$user_id] === null) { $institutes = []; foreach ($roles as $role) { - + // don't check system roles or roles not related to MVV if (stripos($role->rolename, 'MVV') !== 0) continue; - + if ($GLOBALS['perm']->have_perm('root', $user_id)) { $institutes = []; break; diff --git a/lib/classes/SemBrowse.class.php b/lib/classes/SemBrowse.class.php index a6a672a60289be0b9cb94a6bdbbd7c404ee5cb4e..29dcd387845123b7423db06f4e3e0e4616cc4655 100644 --- a/lib/classes/SemBrowse.class.php +++ b/lib/classes/SemBrowse.class.php @@ -934,12 +934,10 @@ class SemBrowse { . htmlReady(mb_substr($seminar_obj->description, 0, 100)) . '</div>'; } else { - $temp_turnus_string = $seminar_obj->getDatesExport( - [ - 'short' => true, - 'shrink' => true, - 'semester_id' => $current_semester_id - ]); + $temp_turnus_string = $seminar_obj->getDatesExport([ + 'short' => true, + 'shrink' => true, + ]); //Shorten, if string too long (add link for details.php) if (mb_strlen($temp_turnus_string) > 70) { $temp_turnus_string = htmlReady(mb_substr($temp_turnus_string, 0, mb_strpos(mb_substr($temp_turnus_string, 70, mb_strlen($temp_turnus_string)), ',') + 71)); diff --git a/lib/classes/StudipCacheFactory.class.php b/lib/classes/StudipCacheFactory.class.php index 5ce2985e2781c4fc90e68e5993d3f64c3b6633ef..5332e067881afbc65988b6f98217f1128c9c44b1 100644 --- a/lib/classes/StudipCacheFactory.class.php +++ b/lib/classes/StudipCacheFactory.class.php @@ -66,49 +66,6 @@ class StudipCacheFactory self::$cache = NULL; } - - /** - * Configure the file, class and arguments used for instantiation of the - * StudipCache instance. After sending this method, the previously used cache - * instance is voided and a new instance will be created on demand. - * - * @param string the absolute path to the implementing class - * @param string the name of the class - * @param array an array of custom arguments - * - * @return void - */ - public static function configure($file, $class, $arguments) - { - # TODO encoding for strings... but probably the caller should care.. - $arguments = json_encode($arguments); - - // strip leading STUDIP_BASE_PATH from file path - $file = studip_relative_path($file); - - self::unconfigure(); - - $cfg = self::getConfig(); - - $cfg->create('cache_class', [ - 'comment' => 'Pfad der Datei, die die StudipCache-Klasse enthält', - 'value' => $class] - ); - $cfg->create('cache_class_file', [ - 'comment' => 'Klassenname des zu verwendenden StudipCaches', - 'value' => $file] - ); - $cfg->create('cache_init_args', [ - 'comment' => 'JSON-kodiertes Array von Argumenten für die Instanziierung der StudipCache-Klasse', - 'value' => $arguments] - ); - - $cfg->store('cache_class', $class); - $cfg->store('cache_class_file', $file); - $cfg->store('cache_init_args', $arguments); - } - - /** * Resets the configuration and voids the cache instance. * @@ -119,7 +76,6 @@ class StudipCacheFactory self::$cache = NULL; } - /** * Returns a cache instance. * @@ -187,7 +143,7 @@ class StudipCacheFactory $cache_class = $cacheConfig['type'] ?: null; # default class - if (is_null($cache_class)) { + if ($cache_class === null) { $version = new DBSchemaVersion(); if ($version->get(1) < 224) { // db cache is not yet available, use StudipMemoryCache @@ -197,18 +153,8 @@ class StudipCacheFactory return self::DEFAULT_CACHE_CLASS; } - # already loaded - if (class_exists($cache_class)) { - return $cache_class; - } - - $loaded = false; - if (file_exists($cache_class_file) || file_exists($GLOBALS['STUDIP_BASE_PATH'] . '/' . $cache_class_file)) { - $loaded = include $cache_class_file; - } - if ($loaded === FALSE || !class_exists($cache_class)) { - # TODO (mlunzena) a more specific exception would be welcome here - throw new Exception("Could not find class: '$cache_class'"); + if (!class_exists($cache_class)) { + throw new UnexpectedValueException("Could not find class: '$cache_class'"); } return $cache_class; diff --git a/lib/classes/UserLookup.class.php b/lib/classes/UserLookup.class.php index cef2b4aa5a7bd8f0ef19dbb5c82c2545e0453ef9..61732ae36a89f6767aea3d510e9bc0ad4ace0465 100644 --- a/lib/classes/UserLookup.class.php +++ b/lib/classes/UserLookup.class.php @@ -231,20 +231,20 @@ class UserLookup throw new Exception('[UserLookup] Unknown type "' . $type . '"'); } - if (self::USE_CACHE) { - $cache = StudipCacheFactory::getCache(); - $cache_key = "UserLookup/{$type}/values"; - $cached_values = $cache->read($cache_key); - if ($cached_values) { - return unserialize($cached_values); - } + if (!self::USE_CACHE) { + return call_user_func(self::$types[$type]['values']); + } + + $cache = StudipCacheFactory::getCache(); + $cache_key = "UserLookup/{$type}/values"; + $cached_values = $cache->read($cache_key); + if ($cached_values) { + return unserialize($cached_values); } $values = call_user_func(self::$types[$type]['values']); - if (self::USE_CACHE) { - $cache->write($cache_key, serialize($values), self::CACHE_DURATION); - } + $cache->write($cache_key, serialize($values), self::CACHE_DURATION); return $values; } diff --git a/lib/classes/UserManagement.class.php b/lib/classes/UserManagement.class.php index 2dc1f59e63371f9b809d4d5f559213d06fe7d3a7..17ce8a3cbae66ba331138217e8b4cbc1cd97bd4b 100644 --- a/lib/classes/UserManagement.class.php +++ b/lib/classes/UserManagement.class.php @@ -539,10 +539,12 @@ class UserManagement // include language-specific subject and mailbody $user_language = getUserLanguagePath($this->user_data['auth_user_md5.user_id']); $Zeit = strftime('%x, %X'); - include "locale/{$user_language}/LC_MAILS/change_mail.inc.php"; + + // TODO: This should be refactored so that the included file returns an array + include "locale/{$user_language}/LC_MAILS/change_mail.inc.php"; // Defines $subject and $mailbody // send mail - StudipMail::sendMessage($this->user_data['auth_user_md5.Email'], $subject, $mailbody); + StudipMail::sendMessage($this->user_data['auth_user_md5.Email'], $subject ?? '', $mailbody ?? ''); } // Upgrade to admin or root? if (in_array($newuser['auth_user_md5.perms'], ['admin', 'root'])) { @@ -999,7 +1001,7 @@ class UserManagement $this->user_data['auth_user_md5.user_id'] ]); if ($statement->rowCount() > 0) { - $msg .= 'info§' . _('Benutzername anonymisiert.') . '§'; + $this->msg .= 'info§' . _('Benutzername anonymisiert.') . '§'; } NotificationCenter::postNotification('UserDataDidRemove', $this->user_data['auth_user_md5.user_id'], 'names'); } @@ -1036,10 +1038,12 @@ class UserManagement if ($this->checkMail($this->user_data['auth_user_md5.Email'])) { // include language-specific subject and mailbody $Zeit = strftime('%x, %X'); - include "locale/$user_language/LC_MAILS/delete_mail.inc.php"; + + // TODO: This should be refactored so that the included file returns an array + include "locale/$user_language/LC_MAILS/delete_mail.inc.php"; // Defines $subject and $mailbody // send mail - StudipMail::sendMessage($this->user_data['auth_user_md5.Email'], $subject, $mailbody); + StudipMail::sendMessage($this->user_data['auth_user_md5.Email'], $subject ?? '', $mailbody ?? ''); } // Remove plugin associations/activations diff --git a/lib/classes/restapi/Router.php b/lib/classes/restapi/Router.php index 3d375cba4ed10ce71bb41330be2a72e036f422fa..de663bdabca676fc20333a806b7b0f298c89d8f1 100644 --- a/lib/classes/restapi/Router.php +++ b/lib/classes/restapi/Router.php @@ -582,6 +582,7 @@ class Router $route['uri_template'] = new UriTemplate($uri_template, $route['conditions']); } + $prmtrs = null; // Will be filled by a successful match() if ($route['uri_template']->match($uri, $prmtrs)) { if (!$this->permissions->check($uri_template, $method)) { throw new RouterException(403, "Route not activated"); diff --git a/lib/classes/restapi/UriTemplate.php b/lib/classes/restapi/UriTemplate.php index e83dd2c1eb04f10678190f2d00276b80738d5be1..bfdf23f398f91bee265fb25cac99bc22f5b8a214 100644 --- a/lib/classes/restapi/UriTemplate.php +++ b/lib/classes/restapi/UriTemplate.php @@ -31,7 +31,7 @@ class UriTemplate * be stored in the parameters array. * * @param String $uri The uri to test - * @param Array $parameters Stores evaluated parameters on match (optional) + * @param array $parameters Stores evaluated parameters on match (optional) * * @return bool Returns true if the uri matches the template */ diff --git a/lib/classes/restapi/UserPermissions.php b/lib/classes/restapi/UserPermissions.php index eaaac440f778051b7185d110ee0f2bd3be04ee91..af5bc3673e513061c9d31b9ae298a598854ade9b 100644 --- a/lib/classes/restapi/UserPermissions.php +++ b/lib/classes/restapi/UserPermissions.php @@ -114,11 +114,11 @@ class UserPermissions chdate = UNIX_TIMESTAMP()"; $statement = DBManager::get()->prepare($query); $statement->bindValue(':user_id', $this->user_id); - $statement->bindParam(':consumer_id', $consumer_id); - $statement->bindParam(':granted', $granted); foreach ($this->permissions as $consumer_id => $granted) { - $granted = (int)!empty($granted); + $statement->bindValue(':consumer_id', $consumer_id); + $statement->bindValue(':granted', (int) !empty($granted)); + $result = $result && $statement->execute(); } diff --git a/lib/classes/searchtypes/RangeSearch.class.php b/lib/classes/searchtypes/RangeSearch.class.php index 181798ffb465d66cfa1924501fb66067a6885d64..ee7f969815e0754008d79cfec4a7c7cb917f2fa3 100644 --- a/lib/classes/searchtypes/RangeSearch.class.php +++ b/lib/classes/searchtypes/RangeSearch.class.php @@ -7,31 +7,9 @@ class RangeSearch extends SQLSearch { public $search; - public $search_settings; - /** - * - * @param string $search The search type. - * - * @param Array $search_settings Settings for the selected seach type. - * Depending on the search type different settings are possible - * which can change the output or the display of the output - * of the search. The array must be an associative array - * with the setting as array key. - * The following settings are implemented: - * Search type 'room': - * - display_seats: If set to true, the seats will be displayed - * after the name of the room. - * - * @return void - */ - public function __construct($parameter_name = 'range_id') + public function __construct() { - if (is_array($search_settings)) { - $this->search_settings = $search_settings; - } - - $this->avatarLike = $this->search = $search; $this->sql = $this->getSQL(); } diff --git a/lib/elearning/ConnectedLink.class.php b/lib/elearning/ConnectedLink.class.php index 2be5a1259dd8359c1dff924e085a2fe473335e1d..80c61d1e027617c3b8723c63322d5ae0726aa120 100644 --- a/lib/elearning/ConnectedLink.class.php +++ b/lib/elearning/ConnectedLink.class.php @@ -47,7 +47,7 @@ class ConnectedLink { global $connected_cms, $cms_select, $current_module; - $output .= "<form method=\"POST\" action=\"" . URLHelper::getLink() . "\">\n"; + $output = "<form method=\"POST\" action=\"" . URLHelper::getLink() . "\">\n"; $output .= CSRFProtection::tokenTag(); $output .= "<input type=\"HIDDEN\" name=\"view\" value=\"" . Request::option('view') . "\">\n"; $output .= "<input type=\"HIDDEN\" name=\"ref_id\" value=\"" . htmlReady($connected_cms[$this->cms_type]->content_module[$current_module]->getId()) . "\">\n"; @@ -84,7 +84,7 @@ class ConnectedLink { global $connected_cms, $view, $search_key, $cms_select, $current_module; - $output .= "<form method=\"POST\" action=\"" . URLHelper::getLink() . "\">\n"; + $output = "<form method=\"POST\" action=\"" . URLHelper::getLink() . "\">\n"; $output .= CSRFProtection::tokenTag(); $output .= "<input type=\"HIDDEN\" name=\"view\" value=\"" . htmlReady($view) . "\">\n"; $output .= "<input type=\"HIDDEN\" name=\"search_key\" value=\"" . htmlReady($search_key) . "\">\n"; diff --git a/lib/elearning/ELearningUtils.class.php b/lib/elearning/ELearningUtils.class.php index ad49569d013c17db510ea1cd8d9bfd672365ce7c..30c40c401a2e898d5faeac921f3ae40044a98fd8 100644 --- a/lib/elearning/ELearningUtils.class.php +++ b/lib/elearning/ELearningUtils.class.php @@ -225,8 +225,6 @@ class ELearningUtils $template->set_attribute('is_connected', 1); } $template->set_attribute('my_account_cms', $my_account_cms); - $template->set_attribute('search_key', $search_key); - $template->set_attribute('view', $view); $template->set_attribute('message', $message); return $template->render(); } @@ -318,7 +316,6 @@ class ELearningUtils } } } elseif (!$is_verified) { - $output .= '<font size="-1">'; if (Request::submitted('start')) { $messages["info"] = sprintf(_("Sie versuchen zum erstem Mal ein Lernmodul des angebundenen Systems %s zu starten. Bevor Sie das Modul nutzen können, muss Ihrem Stud.IP-Benutzeraccount ein Account im angebundenen System zugeordnet werden."), htmlReady($connected_cms[$new_account_cms]->getName())) . "<br><br>\n\n"; } @@ -464,7 +461,7 @@ class ELearningUtils * * creates output of ilias courses linked to the chosen seminar. also updates object-connections. * - * @return boolean successful + * @return array */ public static function getIliasCourses($sem_id) { @@ -475,15 +472,20 @@ class ELearningUtils FROM object_contentmodules WHERE module_type = 'crs' AND object_id = " . $db->quote($sem_id)) ->fetchAll(PDO::FETCH_ASSOC); - foreach ($rs as $row) $courses[$row['system_type']] = $row['module_id']; + foreach ($rs as $row) { + $courses[$row['system_type']] = $row['module_id']; + } + + $connected_courses = [ + 'courses' => [], + ]; if (is_array($courses)) - foreach($courses as $system_type => $crs_id) + foreach ($courses as $system_type => $crs_id) if (self::isCMSActive($system_type)) { self::loadClass($system_type); $connected_courses['courses'][$system_type] = [ 'url' => URLHelper::getLink($connected_cms[$system_type]->link->cms_link . '?client_id=' . $connected_cms[$system_type]->getClientId() . '&cms_select=' . $system_type . '&ref_id=' . $crs_id . '&type=crs&target=start'), 'cms_name' => $connected_cms[$system_type]->getName()]; - $course_output[] = "<a href=\"" . URLHelper::getLink($connected_cms[$system_type]->link->cms_link . "?" . "client_id=" . $connected_cms[$system_type]->getClientId() . "&cms_select=" . $system_type . "&ref_id=" . $crs_id . "&type=crs&target=start") . "\" target=\"_blank\" rel=\"noopener noreferrer\">".sprintf(_("Kurs in %s"), htmlReady($connected_cms[$system_type]->getName()))."</a>"; // gegebenenfalls zugeordnete Module aktualisieren if (Request::option('update')) { if ((method_exists($connected_cms[$system_type], "updateConnections"))) { @@ -496,17 +498,11 @@ class ELearningUtils } if ($connected_courses['courses']) { - if (count($connected_courses['courses']) > 1) + if (count($connected_courses['courses']) > 1) { $connected_courses['text'] = _("Diese Veranstaltung ist mit folgenden Ilias-Kursen verknüpft. Hier gelangen Sie direkt in den jeweiligen Kurs: "); - else + } else { $connected_courses['text'] = _("Diese Veranstaltung ist mit einem Ilias-Kurs verknüpft. Hier gelangen Sie direkt in den Kurs: "); - $output["update"] .= _("Hier können Sie die Zuordnungen zu den verknüpften Kursen aktualisieren."). "<br>"; - $output["update"] .= "<form method=\"POST\" action=\"" . URLHelper::getLink() . "#anker\">\n"; - $output["update"] .= CSRFProtection::tokenTag(); - $output["update"] .= "<input type=\"HIDDEN\" name=\"view\" value=\"" . htmlReady($view) . "\">\n"; - $output["update"] .= "<input type=\"HIDDEN\" name=\"cms_select\" value=\"" . htmlReady($cms_select) . "\">\n"; - $output["update"] .= Button::create(_('Aktualisieren'), 'update'); - $output["update"] .= "</form>"; + } } return $connected_courses; diff --git a/lib/elearning/Ilias3ConnectedCMS.class.php b/lib/elearning/Ilias3ConnectedCMS.class.php index de8db3fb714785f0eb7835dfe1a71417aa00b28e..3e428ff2b729360723407f6e22a7152ef0e9e90e 100644 --- a/lib/elearning/Ilias3ConnectedCMS.class.php +++ b/lib/elearning/Ilias3ConnectedCMS.class.php @@ -67,12 +67,9 @@ class Ilias3ConnectedCMS extends ConnectedCMS * get preferences * * shows additional settings. - * @access public */ - function getPreferences() + public function getPreferences() { - global $connected_cms; - $role_template_name = Request::get('role_template_name'); $cat_name = Request::get('cat_name'); $style_setting = Request::option('style_setting'); @@ -80,48 +77,46 @@ class Ilias3ConnectedCMS extends ConnectedCMS $this->soap_client->setCachingStatus(false); - if ($cat_name != "") - { + $messages = ['error' => '']; + + if ($cat_name) { $cat = $this->soap_client->getReferenceByTitle( trim( $cat_name ), "cat"); - if ($cat == false) + if (!$cat) { $messages["error"] .= sprintf(_("Das Objekt mit dem Namen \"%s\" wurde im System %s nicht gefunden."), htmlReady($cat_name), htmlReady($this->getName())) . "<br>\n"; - if ($cat != "") - { + } else { ELearningUtils::setConfigValue("category_id", $cat, $this->cms_type); $this->main_category_node_id = $cat; } } - if ($role_template_name != "") - { + if ($role_template_name) { $role_template = $this->soap_client->getObjectByTitle( trim( $role_template_name ), "rolt" ); - if ($role_template == false) + if (!$role_template) { $messages["error"] .= sprintf(_("Das Rollen-Template mit dem Namen \"%s\" wurde im System %s nicht gefunden."), htmlReady($role_template_name), htmlReady($this->getName())) . "<br>\n"; - if (is_array($role_template)) - { + } elseif (is_array($role_template)) { ELearningUtils::setConfigValue("user_role_template_id", $role_template["obj_id"], $this->cms_type); ELearningUtils::setConfigValue("user_role_template_name", $role_template["title"], $this->cms_type); $this->user_role_template_id = $role_template["obj_id"]; } } - if (Request::submitted('submit')) - { + if (Request::submitted('submit')) { ELearningUtils::setConfigValue("user_style", $style_setting, $this->cms_type); ELearningUtils::setConfigValue("user_skin", $style_setting, $this->cms_type); ELearningUtils::setConfigValue("encrypt_passwords", $encrypt_passwords, $this->cms_type); - } - else - { - if (ELearningUtils::getConfigValue("user_style", $this->cms_type) != "") + } else { + if (ELearningUtils::getConfigValue("user_style", $this->cms_type)) { $style_setting = ELearningUtils::getConfigValue("user_style", $this->cms_type); - if (ELearningUtils::getConfigValue("encrypt_passwords", $this->cms_type) != "") + } + if (ELearningUtils::getConfigValue("encrypt_passwords", $this->cms_type)) { $encrypt_passwords = ELearningUtils::getConfigValue("encrypt_passwords", $this->cms_type); + } } - if ($messages["error"] != "") + if ($messages['error']) { echo "<b>" . Icon::create('decline', 'attention')->asImg(['class' => 'text-top', 'title' => _('Fehler')]) . " " . $messages["error"] . "</b><br><br>"; + } echo "<table>"; echo "<tr valign=\"top\"><td width=30% align=\"left\"><font size=\"-1\">"; diff --git a/lib/elearning/Ilias3ConnectedLink.class.php b/lib/elearning/Ilias3ConnectedLink.class.php index 7565cfb7bfef54533fad953bd428b34780f53091..f50fd533eb8a4233881ef65a51763f934bb874b0 100644 --- a/lib/elearning/Ilias3ConnectedLink.class.php +++ b/lib/elearning/Ilias3ConnectedLink.class.php @@ -36,53 +36,52 @@ class Ilias3ConnectedLink extends ConnectedLink * get user module links * * returns content module links for user - * @access public * @return string html-code */ - function getUserModuleLinks() + public function getUserModuleLinks() { - global $connected_cms, $view, $search_key, $cms_select, $current_module; + global $connected_cms, $current_module; - if ($connected_cms[$this->cms_type]->isAuthNecessary() AND (! $connected_cms[$this->cms_type]->user->isConnected())) - { - $output .= $this->getNewAccountLink(); - } - else - { - if (! $connected_cms[$this->cms_type]->content_module[$current_module]->isDummy() ) - { - if ($connected_cms[$this->cms_type]->content_module[$current_module]->isAllowed(OPERATION_READ)) - { + $output = ''; - $output .= LinkButton::create(_('Starten'), URLHelper::getURL($this->cms_link . "?" - . "client_id=" . $connected_cms[$this->cms_type]->getClientId() - . "&cms_select=" . $this->cms_type -// . "&sess_id=" . $connected_cms[$this->cms_type]->user->getSessionId() - . "&ref_id=" . $connected_cms[$this->cms_type]->content_module[$current_module]->getId() - . "&type=" . $connected_cms[$this->cms_type]->content_module[$current_module]->getModuleType() - . $auth_data - . "&target=start"), [ - 'target' => '_blank', - 'rel' => 'noopener noreferrer', - ]); - $output .= " "; - } - if ($connected_cms[$this->cms_type]->content_module[$current_module]->isAllowed(OPERATION_WRITE)) - { - $output .= LinkButton::create(_('Bearbeiten'), URLHelper::getURL($this->cms_link . "?" - . "client_id=" . $connected_cms[$this->cms_type]->getClientId() - . "&cms_select=" . $this->cms_type -// . "&sess_id=" . $connected_cms[$this->cms_type]->user->getSessionId() - . "&ref_id=" . $connected_cms[$this->cms_type]->content_module[$current_module]->getId() - . "&type=" . $connected_cms[$this->cms_type]->content_module[$current_module]->getModuleType() - . $auth_data - . "&target=edit"), [ - 'target' => '_blank', - 'rel' => 'noopener noreferrer', - ]); - $output .= " "; - - } + if ($connected_cms[$this->cms_type]->isAuthNecessary() && !$connected_cms[$this->cms_type]->user->isConnected()) { + $output .= $this->getNewAccountLink(); + } elseif (!$connected_cms[$this->cms_type]->content_module[$current_module]->isDummy()) { + if ($connected_cms[$this->cms_type]->content_module[$current_module]->isAllowed(OPERATION_READ)) { + $output .= LinkButton::create( + _('Starten'), + URLHelper::getURL($this->cms_link, [ + 'client_id' => $connected_cms[$this->cms_type]->getClientId(), + 'cms_select' => $this->cms_type, + // 'sess_id' => $connected_cms[$this->cms_type]->user->getSessionId(), + 'ref_id' => $connected_cms[$this->cms_type]->content_module[$current_module]->getId(), + 'type' => $connected_cms[$this->cms_type]->content_module[$current_module]->getModuleType(), + 'target' => 'start', + ]), + [ + 'target' => '_blank', + 'rel' => 'noopener noreferrer', + ] + ); + $output .= " "; + } + if ($connected_cms[$this->cms_type]->content_module[$current_module]->isAllowed(OPERATION_WRITE)) { + $output .= LinkButton::create( + _('Bearbeiten'), + URLHelper::getURL($this->cms_link, [ + 'client_id' => $connected_cms[$this->cms_type]->getClientId(), + 'cms_select' => $this->cms_type, + // 'sess_id' => $connected_cms[$this->cms_type]->user->getSessionId(), + 'ref_id' => $connected_cms[$this->cms_type]->content_module[$current_module]->getId(), + 'type' => $connected_cms[$this->cms_type]->content_module[$current_module]->getModuleType(), + 'target' => 'edit', + ]), + [ + 'target' => '_blank', + 'rel' => 'noopener noreferrer', + ] + ); + $output .= " "; } } @@ -93,14 +92,13 @@ class Ilias3ConnectedLink extends ConnectedLink * get admin module links * * returns links add or remove a module from course - * @access public * @return string returns html-code */ - function getAdminModuleLinks() + public function getAdminModuleLinks() { global $connected_cms, $view, $search_key, $cms_select, $current_module; - $output .= "<form method=\"POST\" action=\"" . URLHelper::getLink() . "\">\n"; + $output = "<form method=\"POST\" action=\"" . URLHelper::getLink() . "\">\n"; $output .= CSRFProtection::tokenTag(); $output .= "<input type=\"HIDDEN\" name=\"view\" value=\"" . htmlReady($view) . "\">\n"; $output .= "<input type=\"HIDDEN\" name=\"search_key\" value=\"" . htmlReady($search_key) . "\">\n"; @@ -109,63 +107,62 @@ class Ilias3ConnectedLink extends ConnectedLink $output .= "<input type=\"HIDDEN\" name=\"module_id\" value=\"" . htmlReady($connected_cms[$this->cms_type]->content_module[$current_module]->getId()) . "\">\n"; $output .= "<input type=\"HIDDEN\" name=\"module_system_type\" value=\"" . htmlReady($this->cms_type) . "\">\n"; - if ($connected_cms[$this->cms_type]->content_module[$current_module]->isConnected()) + if ($connected_cms[$this->cms_type]->content_module[$current_module]->isConnected()) { $output .= " " . Button::create(_('Entfernen'), 'remove'); - elseif ($connected_cms[$this->cms_type]->content_module[$current_module]->isAllowed(OPERATION_WRITE)) - { + } elseif ($connected_cms[$this->cms_type]->content_module[$current_module]->isAllowed(OPERATION_WRITE)) { $output .= "<div align=\"left\"><input type=\"CHECKBOX\" value=\"1\" name=\"write_permission\" style=\"vertical-align:middle\">"; $output .= _("Mit Schreibrechten für alle Lehrenden/Tutoren und Tutorinnen dieser Veranstaltung") . "<br>"; $output .= "<input type=\"CHECKBOX\" value=\"1\" style=\"vertical-align:middle\" name=\"write_permission_autor\">"; $output .= _("Mit Schreibrechten für alle Teilnehmenden dieser Veranstaltung") . "</div>"; $output .= Button::create(_('Hinzufügen'), 'add') . "<br>"; - } - else + } else { $output .= " " . Button::create(_('Hinzufügen'), 'add'); + } $output .= "</form>"; return $output; -// $output .= parent::getAdminModuleLinks(); } /** * get new module link * * returns link to create a new module if allowed - * @access public - * @return string returns html-code or false + * @return string|false returns html-code or false */ - function getNewModuleLink() + public function getNewModuleLink() { global $connected_cms, $auth; $output = "\n"; -// echo "NML."; - if ((Request::get("module_type_" . $this->cms_type) != "")) - { -// echo "TYPE."; - if ($connected_cms[$this->cms_type]->user->category == "") - { -// echo "NoCat."; + if (Request::get("module_type_" . $this->cms_type)) { + if (!$connected_cms[$this->cms_type]->user->category) { $connected_cms[$this->cms_type]->user->newUserCategory(); - if ($connected_cms[$this->cms_type]->user->category == false) + if ($connected_cms[$this->cms_type]->user->category == false) { return $output; + } } - $output = " " . LinkButton::create(_('Neu anlegen'), URLHelper::getURL($this->cms_link . "?" - . "client_id=" . $connected_cms[$this->cms_type]->getClientId() - . "&cms_select=" . $this->cms_type -// . "&sess_id=" . $connected_cms[$this->cms_type]->user->getSessionId() - . "&ref_id=" . $connected_cms[$this->cms_type]->user->category - . $auth_data - . "&type=" . Request::option("module_type_" . $this->cms_type) . "&target=new"), [ + $output = " "; + $output .= LinkButton::create( + _('Neu anlegen'), + URLHelper::getURL($this->cms_link, [ + 'client_id' => $connected_cms[$this->cms_type]->getClientId(), + 'cms_select' => $this->cms_type, +// 'sess_id' => $connected_cms[$this->cms_type]->user->getSessionId(), + 'ref_id' => $connected_cms[$this->cms_type]->user->category, + 'type' => Request::option("module_type_" . $this->cms_type), + 'target' => 'new', + ]), + [ 'target' => '_blank', 'rel' => 'noopener noreferrer', - ]); -// echo $output . "."; + ] + ); } - $user_crs_role = $connected_cms[$this->cms_type]->crs_roles[$auth->auth["perm"]]; - if ($user_crs_role=="admin") + $user_crs_role = $connected_cms[$this->cms_type]->crs_roles[$auth->auth['perm']]; + if ($user_crs_role === 'admin') { return $output; - else - return false; + } + + return false; } /** diff --git a/lib/elearning/Ilias3ConnectedPermissions.class.php b/lib/elearning/Ilias3ConnectedPermissions.class.php index dcb661574f9b69ef0f97f269c880d8b3a2d3f78a..9bf2fcd6d41409ae9e83c0291101a9c2842e7931 100644 --- a/lib/elearning/Ilias3ConnectedPermissions.class.php +++ b/lib/elearning/Ilias3ConnectedPermissions.class.php @@ -84,43 +84,45 @@ class Ilias3ConnectedPermissions extends ConnectedPermissions * @param string $course_id course-id * @return boolean returns false on error */ - function checkUserPermissions($course_id = "") + function checkUserPermissions($course_id) { global $connected_cms, $messages; - if ($course_id == "") + if (!$course_id) { return false; - if ($connected_cms[$this->cms_type]->user->getId() == "") + } + if (!$connected_cms[$this->cms_type]->user->getId()) { return false; + } // get course role folder and local roles $local_roles = $connected_cms[$this->cms_type]->soap_client->getLocalRoles($course_id); $active_role = ""; $proper_role = ""; - $user_crs_role = $connected_cms[$this->cms_type]->crs_roles[$perm->get_studip_perm(Context::getId())]; - if (is_array($local_roles)) - foreach ($local_roles as $key => $role_data) - // check only if local role is il_crs_member, -tutor or -admin - if (! (mb_strpos($role_data["title"], "_crs_") === false)) - { - if ( in_array( $role_data["obj_id"], $connected_cms[$this->cms_type]->user->getRoles() ) ) + $user_crs_role = $connected_cms[$this->cms_type]->crs_roles[$GLOBALS['perm']->get_studip_perm(Context::getId())]; + if (is_array($local_roles)) { + foreach ($local_roles as $key => $role_data) { // check only if local role is il_crs_member, -tutor or -admin + if (mb_strpos($role_data["title"], "_crs_") !== false) { + if (in_array($role_data["obj_id"], $connected_cms[$this->cms_type]->user->getRoles())) { $active_role = $role_data["obj_id"]; - if ( mb_strpos( $role_data["title"], $user_crs_role) > 0 ) + } + if (mb_strpos($role_data["title"], $user_crs_role) > 0) { $proper_role = $role_data["obj_id"]; + } } - // if ($GLOBALS["debug"] == true) - // echo "P$proper_role A$active_role U" . $user_crs_role . " R" . implode($connected_cms[$this->cms_type]->user->getRoles(), ".")."<br>"; + } +// if ($GLOBALS["debug"] == true) +// echo "P$proper_role A$active_role U" . $user_crs_role . " R" . implode($connected_cms[$this->cms_type]->user->getRoles(), ".")."<br>"; + } // is user already course-member? otherwise add member with proper role $is_member = $connected_cms[$this->cms_type]->soap_client->isMember( $connected_cms[$this->cms_type]->user->getId(), $course_id); - if (! $is_member) - { + if (!$is_member) { $member_data["usr_id"] = $connected_cms[$this->cms_type]->user->getId(); $member_data["ref_id"] = $course_id; $member_data["status"] = CRS_NO_NOTIFICATION; $type = ""; - switch ($user_crs_role) - { + switch ($user_crs_role) { case "admin": $member_data["role"] = CRS_ADMIN_ROLE; $type = "Admin"; @@ -237,22 +239,20 @@ class Ilias3ConnectedPermissions extends ConnectedPermissions * get operation-ids * * returns an array of operation-ids - * @access public - * @param string $operation operation - * @return array operation-ids + * @param array $operation operation + * @return array|false operation-ids */ - function getOperationArray($operation) + public function getOperationArray($operation) { - if (is_array($operation)) - { - foreach ($operation as $key => $operation_name) - { - $ops_array[] = $this->operations[$operation_name]; - } - } - else + if (!is_array($operation)) { return false; - return $ops_array; + } + + return array_map( + function ($operation_name) { + return $this->operations[$operation_name]; + }, + $operation + ); } } -?> diff --git a/lib/elearning/Ilias3ContentModule.class.php b/lib/elearning/Ilias3ContentModule.class.php index b1c913ce3cf67f03168fdd58c5773d6db56337b3..63857bfc94d34978a9c7cea4fe8d058e404b8772 100644 --- a/lib/elearning/Ilias3ContentModule.class.php +++ b/lib/elearning/Ilias3ContentModule.class.php @@ -86,43 +86,37 @@ class Ilias3ContentModule extends ContentModule { global $connected_cms; - switch ($access_info) - { + switch ($access_info) { case "granted": - $this->allowed_operations = $connected_cms[$this->cms_type]->permissions->getOperationArray($operations ); + $this->allowed_operations = $connected_cms[$this->cms_type]->permissions->getOperationArray($operations); break; case "no_permission": - $this->allowed_operations = $connected_cms[$this->cms_type]->permissions->getOperationArray($operations ); - $this->setDescription($object_data["description"] . "<br><br><i>" . _("Sie haben keine Leseberechtigung für dieses Modul.") . "</i>"); + $this->allowed_operations = $connected_cms[$this->cms_type]->permissions->getOperationArray($operations); + $this->setDescription("<i>" . _("Sie haben keine Leseberechtigung für dieses Modul.") . "</i>"); return false; - break; case "missing_precondition": $this->allowed_operations = $connected_cms[$this->cms_type]->permissions->getOperationArray($operations ); - $this->setDescription($object_data["description"] . "<br><br><i>" . _("Sie haben zur Zeit noch keinen Zugriff auf deses Modul (fehlende Vorbedingungen).") . "</i>"); + $this->setDescription("<i>" . _("Sie haben zur Zeit noch keinen Zugriff auf deses Modul (fehlende Vorbedingungen).") . "</i>"); break; case "no_object_access": $this->allowed_operations = $connected_cms[$this->cms_type]->permissions->getOperationArray($operations ); - $this->setDescription($object_data["description"] . "<br><br><i>" . _("Dieses Modul ist momentan offline oder durch Payment-Regeln gesperrt.") . "</i>"); + $this->setDescription("<i>" . _("Dieses Modul ist momentan offline oder durch Payment-Regeln gesperrt.") . "</i>"); break; case "no_parent_access": $this->allowed_operations = $connected_cms[$this->cms_type]->permissions->getOperationArray($operations ); - $this->setDescription($object_data["description"] . "<br><br><i>" . _("Sie haben keinen Zugriff auf die übergeordneten Objekte dieses Moduls.") . "</i>"); + $this->setDescription("<i>" . _("Sie haben keinen Zugriff auf die übergeordneten Objekte dieses Moduls.") . "</i>"); return false; - break; case "object_deleted": $this->createDummyForErrormessage("deleted"); return false; - break; } - if ($connected_cms[$this->cms_type]->isAuthNecessary() AND ($connected_cms[$this->cms_type]->user->isConnected())) - { + if ($connected_cms[$this->cms_type]->isAuthNecessary() && $connected_cms[$this->cms_type]->user->isConnected()) { // If User has no permission, don't show module data - if ((! $this->isAllowed(OPERATION_VISIBLE) ) AND (! $this->isDummy()) AND ($connected_cms[$this->cms_type]->user->isConnected())) + if (!$this->isAllowed(OPERATION_VISIBLE) && !$this->isDummy() && $connected_cms[$this->cms_type]->user->isConnected()) { $this->createDummyForErrormessage("no permission"); + } } -// echo "PERM".implode($this->allowed_operations,"-"); - return true; } diff --git a/lib/elearning/Ilias4ConnectedCMS.class.php b/lib/elearning/Ilias4ConnectedCMS.class.php index b8f0ea3ab14f32e0bb89cea880862a9a2a7cd091..f569756516baf5e4202e611fd7297f55f3368207 100644 --- a/lib/elearning/Ilias4ConnectedCMS.class.php +++ b/lib/elearning/Ilias4ConnectedCMS.class.php @@ -191,23 +191,25 @@ class Ilias4ConnectedCMS extends Ilias3ConnectedCMS $this->soap_client->setCachingStatus(false); - if ($cat_name != "") { + $messages = ['error' => '']; + + if ($cat_name) { $cat = $this->soap_client->getReferenceByTitle( trim( $cat_name ), "cat"); - if ($cat == false) { - $messages["error"] .= sprintf(_("Das Objekt mit dem Namen \"%s\" wurde im System %s nicht gefunden."), htmlReady($cat_name), htmlReady($this->getName())) . "<br>\n"; - } elseif ($cat != "") { + if (!$cat) { + $messages["error"] .= sprintf(_('Das Objekt mit dem Namen "%s" wurde im System %s nicht gefunden.'), htmlReady($cat_name), htmlReady($this->getName())) . "<br>\n"; + } else { ELearningUtils::setConfigValue("category_id", $cat, $this->cms_type); $this->main_category_node_id = $cat; } } if (($this->main_category_node_id != false) AND (ELearningUtils::getConfigValue("user_category_id", $this->cms_type) == "")) { - $object_data["title"] = sprintf(_("User-Daten")); + $object_data["title"] = _("User-Daten"); $object_data["description"] = _("Hier befinden sich die persönlichen Ordner der Stud.IP-User."); $object_data["type"] = "cat"; $object_data["owner"] = $this->user->getId(); $user_cat = $connected_cms[$this->cms_type]->soap_client->addObject($object_data, $connected_cms[$this->cms_type]->main_category_node_id); - if ($user_cat != false) { + if ($user_cat) { $this->user_category_node_id = $user_cat; ELearningUtils::setConfigValue("user_category_id", $user_cat, $this->cms_type); } else { diff --git a/lib/elearning/Ilias4ConnectedLink.class.php b/lib/elearning/Ilias4ConnectedLink.class.php index a66bd8e0a5c0997ad09c270597e92f109939a3b7..a2bdb14123d91b72388ab4135cd45676533fef8e 100644 --- a/lib/elearning/Ilias4ConnectedLink.class.php +++ b/lib/elearning/Ilias4ConnectedLink.class.php @@ -69,7 +69,10 @@ class Ilias4ConnectedLink extends Ilias3ConnectedLink { global $connected_cms, $view, $search_key, $cms_select, $current_module; - if (! $connected_cms[$this->cms_type]->content_module[$current_module]->isDummy()) { + $output = ''; + + $result = false; + if (!$connected_cms[$this->cms_type]->content_module[$current_module]->isDummy()) { $result = $connected_cms[$this->cms_type]->soap_client->getPath($connected_cms[$this->cms_type]->content_module[$current_module]->getId()); } if ($result) { @@ -119,4 +122,3 @@ class Ilias4ConnectedLink extends Ilias3ConnectedLink return $output; } } -?> diff --git a/lib/elearning/Ilias4Soap.class.php b/lib/elearning/Ilias4Soap.class.php index 7afd7380a29df0bb4ddf5721329ace3d05b854f3..91723386fb037217b30a9cbd33601603bb40ba17 100644 --- a/lib/elearning/Ilias4Soap.class.php +++ b/lib/elearning/Ilias4Soap.class.php @@ -106,10 +106,6 @@ class Ilias4Soap extends Ilias3Soap */ function copyObject($source_id, $target_id) { - $type = $object_data["type"]; - $title = $object_data["title"]; - $description = $object_data["description"]; - $xml = "<Settings source_id=\"$source_id\" target_id=\"$target_id\" default_action=\"COPY\"/>"; $param = [ diff --git a/lib/elearning/PmWikiConnectedCMS.class.php b/lib/elearning/PmWikiConnectedCMS.class.php index 3cd728e64714ab73d855cf87853f823f3c59b59d..7de0a788e73a5acad1a06677e933db463b38751f 100644 --- a/lib/elearning/PmWikiConnectedCMS.class.php +++ b/lib/elearning/PmWikiConnectedCMS.class.php @@ -58,29 +58,27 @@ class PmWikiConnectedCMS extends ConnectedCMS * search for content modules * * returns found content modules - * @access public * @param string $key keyword * @return array list of content modules */ - - function searchContentModules($key) + public function searchContentModules($key) { - $fields_found = $this->client->call("search_content_modules", $args = [ - $GLOBALS['ELEARNING_INTERFACE_MODULES'][$this->cms_type]['soap_data']['api-key'], - $key]); + $fields_found = $this->client->call("search_content_modules", [ + $GLOBALS['ELEARNING_INTERFACE_MODULES'][$this->cms_type]['soap_data']['api-key'], + $key + ]); $result = []; - - foreach($fields_found as $field) - { - - $result[$field['field_id']] = [ 'ref_id' => $field['field_id'], - 'type' => $field['field_type'], - 'obj_id' => $field_id, - 'create_date' => $field['create_date'], - 'last_update' => $field['change_date'], - 'title' => $field['field_title'], - 'description' => $field['field_description']]; + foreach ($fields_found as $field) { + $result[$field['field_id']] = [ + 'ref_id' => $field['field_id'], + 'type' => $field['field_type'], + 'obj_id' => null, + 'create_date' => $field['create_date'], + 'last_update' => $field['change_date'], + 'title' => $field['field_title'], + 'description' => $field['field_description'], + ]; } return $result; } diff --git a/lib/evaluation/classes/EvaluationTreeEditView.class.php b/lib/evaluation/classes/EvaluationTreeEditView.class.php index bec740e5030eef9e507d6486dc9a2d0d08fff9f3..4cac71571c1db3432b951a5593d4dab558908d21 100644 --- a/lib/evaluation/classes/EvaluationTreeEditView.class.php +++ b/lib/evaluation/classes/EvaluationTreeEditView.class.php @@ -840,77 +840,28 @@ class EvaluationTreeEditView * @param string $item_id the current item * @return string the item details (html) */ - function createTreeItemDetails($item_id) + private function createTreeItemDetails($item_id) { - $mode = $this->getInstance($item_id); switch ($mode) { - case ROOT_BLOCK: - $eval = new Evaluation ($this->evalID, NULL, EVAL_LOAD_FIRST_CHILDREN); - $hasKids = ($eval->getNumberChildren() == 0) - ? NO - : YES; - $isLastKid = YES; - break; + $eval = new Evaluation($this->evalID, NULL, EVAL_LOAD_FIRST_CHILDREN); + $hasKids = $eval->getNumberChildren() == 0 ? NO : YES; break; - case ARRANGMENT_BLOCK: - $group = &$this->tree->getGroupObject($item_id); - $hasKids = ($group->getNumberChildren() == 0) - ? NO - : YES; - - $par = $this->getInstance($group->getParentID()); - - if ($par == ROOT_BLOCK) - $parent = new Evaluation ($group->getParentID(), NULL, EVAL_LOAD_FIRST_CHILDREN); - else - $parent =& $this->tree->getGroupObject($group->getParentID()); - - $isLastKid = ($parent->getNumberChildren() - == $group->getPosition() + 1) - ? YES - : NO; + $group = $this->tree->getGroupObject($item_id); + $hasKids = $group->getNumberChildren() == 0 ? NO : YES; break; - - case QUESTION_BLOCK: - - $hasKids = NO; - - $group =& $this->tree->getGroupObject($item_id); - $par = $this->getInstance($group->getParentID()); - - if ($par == ROOT_BLOCK) $parent = new Evaluation ($group->getParentID(), NULL, EVAL_LOAD_FIRST_CHILDREN); - else $parent = &$this->tree->getGroupObject($group->getParentID); - $isLastKid = ($parent->getNumberChildren() - == $group->getPosition() + 1) - ? YES - : NO; - break; - default: $hasKids = NO; - $isLastKid = NO; break; } - if (!$hasKids || (!$this->itemID == $item_id)) - $level_output = $this->createLevelOutputTD("forumleer.gif") . $level_output; - else - $level_output = $this->createLevelOutputTD("forumstrich.gif") . $level_output;# - - - if ($item_id != $this->startItemID) { - $parent_id = $item_id; - - while (($this->tree->tree_data[$parent_id]['parent_id'] != $this->tree->tree_data[$this->startItemID]['parent_id']) && - ($this->tree->tree_data[$parent_id]['parent_id'] != $start_itemID) && - ($this->tree->tree_data[$parent_id]['parent_id'] != ROOT_BLOCK)) { - - $parent_id = $this->tree->tree_data[$parent_id]['parent_id']; - } + if (!$hasKids || $this->itemID != $item_id) { + $level_output = $this->createLevelOutputTD(); + } else { + $level_output = $this->createLevelOutputTD("forumstrich.gif"); } $table = new HTML ("table"); @@ -920,8 +871,6 @@ class EvaluationTreeEditView $table->addAttr("width", "100%"); $tr = new HTML ("tr"); - - if ($level_output) ; $tr->addHTMLContent($level_output); $td = new HTML ("td"); @@ -1794,13 +1743,10 @@ class EvaluationTreeEditView $this->swapPosition($this->itemID, $questionID, $oldposition, "down"); - if ($oldposition == $numberchild - 1) - $this->msg[$this->itemID] = "msg§" - . sprintf(_("Die Frage wurde von Position %s an die erste Stelle verschoben.") - , $oldposition + 1); - else - $this->msg[$this->itemID] = "msg§" - . sprintf(_("Die Frage wurde von Position %s nach oben verschoben."), $oldposition + 1); + $this->msg[$this->itemID] = "msg§" . sprintf( + _("Die Frage wurde von Position %s nach unten verschoben."), + $oldposition + 1 + ); $this->msg[$this->itemID] .= "<br>" . _("Veränderungen wurden gespeichert."); return true; diff --git a/lib/evaluation/classes/EvaluationTreeShowUser.class.php b/lib/evaluation/classes/EvaluationTreeShowUser.class.php index f266ccd9565984cb76042d63288c879dbad46225..7ae88f8bef1401ff1191decfad01aaa04b026836 100644 --- a/lib/evaluation/classes/EvaluationTreeShowUser.class.php +++ b/lib/evaluation/classes/EvaluationTreeShowUser.class.php @@ -315,7 +315,6 @@ class EvaluationTreeShowUser */ public function getQuestionContent($question, $group) { - $type = $question->isMultipleChoice() ? "checkbox" : "radio"; $answerBorder = "1px dotted #909090"; $residualBorder = "1px dotted #909090"; @@ -328,6 +327,8 @@ class EvaluationTreeShowUser ? "background-image:url(" . Assets::image_path("steelgroup1.gif") . "); border-left:3px solid red; border-right:3px solid red;" : ""; + $html = ''; + /* Skala (one row question) ---------------------------------------- */ if ($question->getType() == EVALQUESTION_TYPE_LIKERT || $question->getType() == EVALQUESTION_TYPE_POL) { diff --git a/lib/evaluation/classes/HTMLempty.class.php b/lib/evaluation/classes/HTMLempty.class.php index a3dfdae99cc1678f070c894d09bdb9aea1849b19..4ca95456e9303c03ae7dd9b06c707f082f4b0d6a 100644 --- a/lib/evaluation/classes/HTMLempty.class.php +++ b/lib/evaluation/classes/HTMLempty.class.php @@ -159,7 +159,7 @@ class HTMLempty */ public function printContent($indent = 0) { - echo $this->createContent($str); + echo $this->createContent($indent); } /** diff --git a/lib/evaluation/evaluation_admin_overview.lib.php b/lib/evaluation/evaluation_admin_overview.lib.php index 09a6b0bf6a966e1f2fe163e85afc5fb6ee91bea8..b552a5fe163b632a72bf315904f8af0524e92b59 100644 --- a/lib/evaluation/evaluation_admin_overview.lib.php +++ b/lib/evaluation/evaluation_admin_overview.lib.php @@ -849,10 +849,10 @@ class EvalOverview /* -------------------------------------- end: errorcheck while loading */ /* Check for permissions in all ranges of the evaluation -------------- */ + $no_permission_msg = ''; if (!$eval->isTemplate() && ($GLOBALS['user']->id != $eval->getAuthorID())) { $no_permisson = (int)EvaluationObjectDB::getEvalUserRangesWithNoPermission($eval); - $no_permission_msg = ''; if ($no_permisson > 0) { if ($no_permisson === 1) { $no_permission_msg .= sprintf(_("Die Evaluation %s ist einem Bereich zugeordnet, für den Sie keine Veränderungsrechte besitzen."), $evalName); @@ -1094,8 +1094,10 @@ class EvalOverview case "save2": case "save": + $eval = new Evaluation($evalID, NULL, EVAL_LOAD_ALL_CHILDREN); $update_message = sprintf(_("Die Evaluation %s wurde mit den Veränderungen gespeichert."), $evalName); + $time_msg = ''; /* Timesettings ---------------------------------------------------- */ if (Request::option("startMode")) { switch (Request::option("startMode")) { @@ -1131,14 +1133,15 @@ class EvalOverview } if ($no_permission_msg && - ($eval->getStopdate != $stopDate && - $eval->getTimespan != $timeSpan)) { - $time_msg = ($time_msg) ? $time_msg . "<br>" : $no_permission_msg; + ($eval->getStopdate() != $stopDate && + $eval->getTimespan() != $timeSpan)) { + $time_msg = $time_msg ? $time_msg . "<br>" : $no_permission_msg; $time_msg .= _("Die Einstellungen zur Endzeit wurden nicht verändert."); } } /* ----------------------------------------------- end: timesettings */ + $message = ''; /* link eval to ranges --------------------------------------------- */ $link_range_Array = Request::optionArray("link_range"); diff --git a/lib/evaluation/evaluation_admin_template.lib.php b/lib/evaluation/evaluation_admin_template.lib.php index 596307dcc497bcbd5a8a5c229fd01903d427c548..26e5ae693c3ab749f51b1209d414bf57d0ae8aff 100644 --- a/lib/evaluation/evaluation_admin_template.lib.php +++ b/lib/evaluation/evaluation_admin_template.lib.php @@ -964,7 +964,7 @@ class EvalTemplateGUI } if (empty($rangeID)) { - $rangeID = get_Username($user->id); + $rangeID = get_Username($GLOBALS['user']->id); } $actions = new ActionsWidget(); diff --git a/lib/export/export_linking_func.inc.php b/lib/export/export_linking_func.inc.php index 52ea828fd0540547d3cf4c85d72530fb6f767cd1..d5f66aa3e34ffda6d8f97c46fa71a4f5238e9b65 100644 --- a/lib/export/export_linking_func.inc.php +++ b/lib/export/export_linking_func.inc.php @@ -87,7 +87,7 @@ function export_form_sidebar($range_id, $ex_type = "", $filename = "", $format = global $output_formats, $xslt_filename; $filename = $xslt_filename; require_once ("lib/export/export_xslt_vars.inc.php"); - $export_string .= "<form class=\"default\" action=\"" . URLHelper::getLink('export.php') . "\" method=\"post\">"; + $export_string = "<form class=\"default\" action=\"" . URLHelper::getLink('export.php') . "\" method=\"post\">"; $export_string .= CSRFProtection::tokenTag(); $export_string .= "<select name=\"format\">"; foreach ($output_formats as $key => $val) diff --git a/lib/export/export_studipdata_func.inc.php b/lib/export/export_studipdata_func.inc.php index 32f61efad276a82fa30a38e66b01bc4c2b134fbd..b645e1e2f23c7417e59d83a3efd35025c50f6c72 100644 --- a/lib/export/export_studipdata_func.inc.php +++ b/lib/export/export_studipdata_func.inc.php @@ -395,7 +395,7 @@ function export_sem($inst_id, $ex_sem_id = 'all') $statement->execute($parameters); $data = $statement->fetchAll(PDO::FETCH_ASSOC); - $data_object .= xml_open_tag($xml_groupnames_lecture['group']); + $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']])) { @@ -412,16 +412,6 @@ function export_sem($inst_id, $ex_sem_id = 'all') $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; @@ -540,9 +530,6 @@ function export_sem($inst_id, $ex_sem_id = 'all') $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']); } diff --git a/lib/export/export_xml_func.inc.php b/lib/export/export_xml_func.inc.php index 7b266c6edd35bbf4c8fe2ba82f8191b8ef4beb9e..f294b67c91bff414cc9b67bd3e83cd7234ad7d5c 100644 --- a/lib/export/export_xml_func.inc.php +++ b/lib/export/export_xml_func.inc.php @@ -74,8 +74,12 @@ global $SOFTWARE_VERSION, $ex_type, $ex_sem, $range_name, $range_id; */ function xml_open_tag($tag_name, $tag_key = "") { - if ($tag_key != "") + $xml_tag_string = ''; + + if ($tag_key) { $xml_tag_string .= " key=\"" . xml_escape ($tag_key ) ."\"" ; + } + $xml_tag_string = "<" . $tag_name . $xml_tag_string . ">\n"; return $xml_tag_string; } diff --git a/lib/export/export_xslt_vars.inc.php b/lib/export/export_xslt_vars.inc.php index 7b74a9eb63160a6f0d933cb831dbfcab09bdaf07..4d044011a6c00aabc517e89a7f5ea4c1fed6b429 100644 --- a/lib/export/export_xslt_vars.inc.php +++ b/lib/export/export_xslt_vars.inc.php @@ -188,5 +188,3 @@ $xslt_files["csv-veranstaltung-2"]["desc"] = _("Modul zur Ausgabe von Veranstalt $xslt_files["csv-veranstaltung-2"]["file"] = "csv-v-2.xsl"; $xslt_files["csv-veranstaltung-2"]["csv"] = true; $xslt_files["csv-veranstaltung-2"]["veranstaltung"] = true; - -?> diff --git a/lib/extern/elements/ExternElementContact.class.php b/lib/extern/elements/ExternElementContact.class.php index eb6b1aaab3036c723e69e19ddfebfb9ec9da27e6..996addd2b6c3e1d334d3fc4c69609a2c6f91b27d 100644 --- a/lib/extern/elements/ExternElementContact.class.php +++ b/lib/extern/elements/ExternElementContact.class.php @@ -127,7 +127,7 @@ class ExternElementContact extends ExternElement { $info = _("Zusatz zur Adresse der Einrichtung, z.B. Universitätsname."); $table .= $edit_form->editTextfieldGeneric("adradd", $title, $info, 35, 100); - $content_table .= $edit_form->editContentTable($headline, $table); + $content_table = $edit_form->editContentTable($headline, $table); $content_table .= $edit_form->editBlankContent(); $attributes = ["table_width", "table_align", diff --git a/lib/extern/elements/ExternElementPersondetailsHeader.class.php b/lib/extern/elements/ExternElementPersondetailsHeader.class.php index 8104498a83672461a5d83f0ad93dd2cd970c038e..32595253e6e6cb0276ce7bd8bc54949bbe63518a 100644 --- a/lib/extern/elements/ExternElementPersondetailsHeader.class.php +++ b/lib/extern/elements/ExternElementPersondetailsHeader.class.php @@ -150,97 +150,9 @@ class ExternElementPersondetailsHeader extends ExternElement { return $element_headline . $out; } - function toString ($args = null) { - if (!$args["main_module"]) - $args["main_module"] = "Main"; - - $pic_max_width = $this->config->getValue($this->name, "img_width"); - $pic_max_height = $this->config->getValue($this->name, "img_height"); - - // fit size of image - if ($pic_max_width && $pic_max_height) { - $pic_size = @getimagesize("user/" - . $db->f("user_id") . ".jpg"); - - if ($pic_size[0] > $pic_max_width || $pic_size[1] > $pic_max_height) { - $fak_width = $pic_size[0] / $pic_max_width; - $fak_height = $pic_size[1] / $pic_max_height; - if ($fak_width > $fak_height) { - $pic_width = (int) ($pic_size[0] / $fak_width); - $pic_height = (int) ($pic_size[1] / $fak_width); - } - else { - $pic_height = (int) ($pic_size[1] / $fak_height); - $pic_width = (int) ($pic_size[0] / $fak_height); - } - } - else { - $pic_width = $pic_size[0]; - $pic_height = $pic_size[1]; - } - $pic_max_width = $pic_width; - $pic_max_height = $pic_height; - } - /* else { - $pic_max_width = ""; - $pic_max_height = ""; - }*/ - - $this->config->config[$this->name]["img_width"] = $pic_max_width; - $this->config->config[$this->name]["img_height"] = $pic_max_height; - - if ($this->config->getValue($args["main_module"], "showcontact") - && $this->config->getValue($args["main_module"], "showimage")) - $colspan = " colspan=\"2\""; - else - $colspan = ""; - - $out = "\n<tr><td width=\"100%\">\n"; - $out .= $this->config->getTag($this->name, "table") . "\n"; - - // display name as headline - if (!$this->config->getValue($this->name, 'hidename')) { - $out .= $this->config->getTag($this->name, "tr"); - $out .= "<td$colspan width=\"100%\""; - $out .= $this->config->getAttributes($this->name, "headlinetd") . ">"; - $out .= $this->config->getTag($this->name, "font"); - $out .= $args["content"]["name"]; - $out .= "</font></td></tr>\n"; - } - - if ($this->config->getValue($args["main_module"], "showimage") - || $this->config->getValue($args["main_module"], "showcontact")) { - $out .= "<tr>"; - if ($this->config->getValue($args["main_module"], "showcontact") - && ($this->config->getValue($args["main_module"], "showimage") == "right" - || !$this->config->getValue($args["main_module"], "showimage"))) { - $out .= $this->config->getTag($this->name, "contacttd"); - $args["content"]["contact"] . "</td>\n"; - } - - if ($this->config->getValue($args["main_module"], "showimage")) { - $out .= $this->config->getTag($this->name, "picturetd"); - if (file_exists($args["content"]["picture_url"])) { - $out .= "<img src=\"{$args['content']['picture_url']}\" "; - $out .= "alt=\"Picture " . htmlReady(trim($db->f("fullname"))) . "\""; - $out .= $this->config->getAttributes($this->name, "img") . "></td>"; - } - else - $out .= " </td>"; - } - - if ($this->config->getValue($args["main_module"], "showcontact") - && $this->config->getValue($args["main_module"], "showimage") == "left") { - $out .= $this->config->getTag("PersondetailsHeader", "contacttd"); - $out .= $args["content"]["contact"] . "</td>\n"; - } - - $out .= "</tr>\n"; - } - - $out .= "</table>\n</td></tr>\n"; - - return $out; + function toString ($args = null) + { + return ''; } function checkValue ($attribute, $value) { diff --git a/lib/extern/elements/ExternElementPersondetailsLectures.class.php b/lib/extern/elements/ExternElementPersondetailsLectures.class.php index ccb30e876a2741200711ed21f87b5859ccd037db..e4f4b50095dd3a9cd3bb7a98b7e8787c57e9668f 100644 --- a/lib/extern/elements/ExternElementPersondetailsLectures.class.php +++ b/lib/extern/elements/ExternElementPersondetailsLectures.class.php @@ -159,7 +159,7 @@ class ExternElementPersondetailsLectures extends ExternElement { } $table .= $edit_form->editCheckboxGeneric("semclass", $title, $info, $class_values, $class_names); - $content_table .= $edit_form->editContentTable($headline, $table); + $content_table = $edit_form->editContentTable($headline, $table); $content_table .= $edit_form->editBlankContent(); $submit = $edit_form->editSubmit($this->config->getName(), diff --git a/lib/extern/elements/ExternElementPersondetailsLecturesTemplate.class.php b/lib/extern/elements/ExternElementPersondetailsLecturesTemplate.class.php index aa0d4b97b5ee2aa0c93a4ae92ba13e152199526f..2b13f4f2434af48ab6256d0a76565234e79e2632 100644 --- a/lib/extern/elements/ExternElementPersondetailsLecturesTemplate.class.php +++ b/lib/extern/elements/ExternElementPersondetailsLecturesTemplate.class.php @@ -151,7 +151,7 @@ class ExternElementPersondetailsLecturesTemplate extends ExternElementPersondeta } $table .= $edit_form->editCheckboxGeneric("semclass", $title, $info, $class_values, $class_names); - $content_table .= $edit_form->editContentTable($headline, $table); + $content_table = $edit_form->editContentTable($headline, $table); $content_table .= $edit_form->editBlankContent(); $submit = $edit_form->editSubmit($this->config->getName(), diff --git a/lib/extern/elements/ExternElementReplaceTextSemType.class.php b/lib/extern/elements/ExternElementReplaceTextSemType.class.php index 0764049b108a772918010ac5e5fd4d2f3799b9ed..72ace415fc47497b2515882ea065bd2a3956e35c 100644 --- a/lib/extern/elements/ExternElementReplaceTextSemType.class.php +++ b/lib/extern/elements/ExternElementReplaceTextSemType.class.php @@ -85,9 +85,8 @@ class ExternElementReplaceTextSemType extends ExternElement { return $config; } - function toStringEdit ($post_vars = "", $faulty_values = "", - $edit_form = "", $anker = "") { - + function toStringEdit ($post_vars = "", $faulty_values = "", $edit_form = "", $anker = "") + { global $SEM_TYPE; $order = $this->config->getValue($this->name, "order"); @@ -96,19 +95,19 @@ class ExternElementReplaceTextSemType extends ExternElement { $this->config->store(); } - if ($faulty_values == '') + if (!$faulty_values) $faulty_values = []; - $out = ''; - $table = ''; - if ($edit_form == '') + + if (!$edit_form) { $edit_form = new ExternEditHtml($this->config, $post_vars, $faulty_values, $anker); + } $edit_form->setElementName($this->getName()); $element_headline = $this->getEditFormHeadline($edit_form); $table = $edit_form->editSemTypes(); - $content_table .= $edit_form->editContentTable($headline, $table); + $content_table = $edit_form->editContentTable('', $table); $content_table .= $edit_form->editBlankContent(); $submit = $edit_form->editSubmit($this->config->getName(), diff --git a/lib/extern/elements/ExternElementSelectInstitutes.class.php b/lib/extern/elements/ExternElementSelectInstitutes.class.php index 56aeb7bd4c7272dbd816debf40b7e5e8132efa59..28126864b5160dfeb0a9d96bd1000c1be6a5d262 100644 --- a/lib/extern/elements/ExternElementSelectInstitutes.class.php +++ b/lib/extern/elements/ExternElementSelectInstitutes.class.php @@ -65,14 +65,12 @@ class ExternElementSelectInstitutes extends ExternElement { return $config; } - public function toStringEdit ($post_vars = '', $faulty_values = '', $edit_form = '', $anker = '') { - - if ($faulty_values == '') { + public function toStringEdit ($post_vars = '', $faulty_values = '', $edit_form = '', $anker = '') + { + if (!$faulty_values) { $faulty_values = []; } - $out = ''; - $table = ''; - if ($edit_form == '') { + if (!$edit_form) { $edit_form = new ExternEditHtml($this->config, $post_vars, $faulty_values, $anker); } @@ -81,7 +79,7 @@ class ExternElementSelectInstitutes extends ExternElement { $table = $edit_form->editSelectInstitutes(); - $content_table .= $edit_form->editContentTable($headline, $table); + $content_table = $edit_form->editContentTable('', $table); $content_table .= $edit_form->editBlankContent(); $submit = $edit_form->editSubmit($this->config->getName(), $this->config->getId(), $this->getName()); diff --git a/lib/extern/elements/ExternElementSelectSubjectAreas.class.php b/lib/extern/elements/ExternElementSelectSubjectAreas.class.php index c1309e5d23a6cef951ab66821685bd2df12a525f..d4a4bdc9df713361d0345008ca8b387c433b1091 100644 --- a/lib/extern/elements/ExternElementSelectSubjectAreas.class.php +++ b/lib/extern/elements/ExternElementSelectSubjectAreas.class.php @@ -98,7 +98,7 @@ class ExternElementSelectSubjectAreas extends ExternElement { $names = ''; $table .= $edit_form->editCheckboxGeneric('reverseselection', $title, $info, $values, $names); - $content_table .= $edit_form->editContentTable($headline, $table); + $content_table = $edit_form->editContentTable('', $table); $content_table .= $edit_form->editBlankContent(); $submit = $edit_form->editSubmit($this->config->getName(), diff --git a/lib/extern/elements/main/ExternElementMainDownload.class.php b/lib/extern/elements/main/ExternElementMainDownload.class.php index a2e612f2073ee51bf0f83ee600e2e68b5f6dea05..0468b4b1893b75997a8b48abc3742b2a90015b76 100644 --- a/lib/extern/elements/main/ExternElementMainDownload.class.php +++ b/lib/extern/elements/main/ExternElementMainDownload.class.php @@ -216,7 +216,7 @@ class ExternElementMainDownload extends ExternElementMain { $icon_titles[$i], $icon_infos[$i] . $info_add, 50, 200); } } - + $content_table .= $edit_form->editContentTable($headline, $table); $content_table .= $edit_form->editBlankContent(); @@ -242,12 +242,14 @@ class ExternElementMainDownload extends ExternElementMain { case "iconrtf" : case "iconzip" : case "icondefault" : - return ($value[$i] != "" - && (preg_match("/(<|>|\"|<script|<php)/i", $value[$i]) - || !preg_match("/^[^.\/\\\].*\.(png|jpg|jpeg|gif)$/i", $value[$i]))); + return $value + && ( + preg_match("/(<|>|\"|<script|<php)/i", $value) + || !preg_match("/^[^.\/\\\].*\.(png|jpg|jpeg|gif)$/i", $value) + ); } - return FALSE; + return false; } } diff --git a/lib/extern/elements/main/ExternElementMainTemplateDownload.class.php b/lib/extern/elements/main/ExternElementMainTemplateDownload.class.php index ec74391de0f9d420d7bca712f47098a7216999c1..879284ede2e194c3692491389b28fefe3eb277f0 100644 --- a/lib/extern/elements/main/ExternElementMainTemplateDownload.class.php +++ b/lib/extern/elements/main/ExternElementMainTemplateDownload.class.php @@ -206,9 +206,11 @@ class ExternElementMainTemplateDownload extends ExternElementMain { case "iconrtf" : case "iconzip" : case "icondefault" : - return ($value[$i] != "" - && (preg_match("/(<|>|\"|<script|<php)/i", $value[$i]) - || !preg_match("/^[^.\/\\\].*\.(png|jpg|jpeg|gif)$/i", $value[$i]))); + return $value + && ( + preg_match("/(<|>|\"|<script|<php)/i", $value) + || !preg_match("/^[^.\/\\\].*\.(png|jpg|jpeg|gif)$/i", $value) + ); } return FALSE; diff --git a/lib/extern/lib/ExternConfig.class.php b/lib/extern/lib/ExternConfig.class.php index 3fa92ab864dab22bf7bf7d79b7404bd8383399e5..226dbe7db7b856919741b2027d70235abb27711c 100644 --- a/lib/extern/lib/ExternConfig.class.php +++ b/lib/extern/lib/ExternConfig.class.php @@ -567,7 +567,7 @@ class ExternConfig "sri" => $sri, "sri_structure" => $sri_structure, "link_sri" => $link_sri, "level" => $level, "link_br" => $link_br]; } else { - $info = ["module_type" => $module_type, "module_name" => $module_name, + $info = ["module_type" => $module_type, "module_name" => $module, "name" =>$res['name'], "make_date" => $make, "change_date" => $change, "sri" => $sri, "link_sri" => $link_sri, "level" => $level]; diff --git a/lib/extern/lib/ExternConfigDb.class.php b/lib/extern/lib/ExternConfigDb.class.php index e439659bc9c4fdc2c250aaeef94a059ad941cf06..1f23a8613858fcb4a6688a385e21b968d20dc2a9 100644 --- a/lib/extern/lib/ExternConfigDb.class.php +++ b/lib/extern/lib/ExternConfigDb.class.php @@ -37,19 +37,10 @@ // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // +---------------------------------------------------------------------------+ -class ExternConfigDb extends ExternConfig { - - /** - * - */ - function __construct ($range_id, $module_name, $config_id = '') { - parent::__construct ($range_id, $module_name, $config_id); - } - - /** - * - */ - function store () { +class ExternConfigDb extends ExternConfig +{ + public function store () + { parent::store(); $serialized_config = json_encode($this->config); @@ -67,10 +58,8 @@ class ExternConfigDb extends ExternConfig { } - /** - * - */ - function parse () { + public function parse () + { $query = "SELECT config FROM extern_config WHERE config_id = ?"; $parameters = [$this->id]; $statement = DBManager::get()->prepare($query); @@ -83,20 +72,24 @@ class ExternConfigDb extends ExternConfig { } } - function insertConfiguration () { + public function insertConfiguration () + { if (!parent::insertConfiguration()) { return false; } - $serialized_config = json_encode($config_obj->config); + $serialized_config = json_encode($this->config); $time = time(); - $query = "INSERT INTO extern_config VALUES (?,?,?,?,0,?,?,?)"; + $query = "INSERT INTO extern_config VALUES (?, ?, ?, ?, 0, ?, ?, ?)"; $statement = DBManager::get()->prepare($query); - $statement->execute([$this->id, $this->range_id, $this->module_type, - $this->config_name, $serialized_config, $time, $time - ]); - if (!$statement->rowCount()) { - return FALSE; - } - return TRUE; + $statement->execute([ + $this->id, + $this->range_id, + $this->module_type, + $this->config_name, + $serialized_config, + $time, + $time + ]); + return $statement->rowCount() > 0; } } diff --git a/lib/extern/lib/ExternEdit.class.php b/lib/extern/lib/ExternEdit.class.php index 5e48fec4bc1c650825d0cf99108cac877d888aeb..ea7d340d80f14a70c9a7b1fe506d689095dafb41 100644 --- a/lib/extern/lib/ExternEdit.class.php +++ b/lib/extern/lib/ExternEdit.class.php @@ -97,12 +97,15 @@ class ExternEdit { return htmlReady($this->config->getValue($this->element_name, $attribute)); } - function getEditFormContent ($attributes, $tag_headlines = NULL) { + function getEditFormContent ($attributes, $tag_headlines = NULL) + { $previous_tag = ''; + $out = ''; + foreach ($attributes as $attribute) { $attribute_part = explode('_', $attribute); - + if (!$attribute_part[2] && $attribute_part[1]) { $edit_function = 'edit' . $attribute_part[1]; @@ -128,9 +131,9 @@ class ExternEdit { $previous_tag = $attribute_part[0]; } $table .= $this->$edit_function($attribute); - + } elseif ($attribute_part[2] && $tag_headlines["{$attribute_part[0]}_{$attribute_part[2]}"]) { - + $attribute_name = $attribute_part[0] . '_' . $attribute_part[2]; $edit_function = 'edit' . $attribute_part[1]; if ($attribute_name != $previous_tag) { @@ -146,9 +149,9 @@ class ExternEdit { } $table .= $this->$edit_function($attribute); } - + } - + $out .= $this->editContentTable($headline, $table); return $out; diff --git a/lib/extern/lib/ExternElementMain.class.php b/lib/extern/lib/ExternElementMain.class.php index 781325c3e4d24ac65cb2cdc7f3dc46ab969c4b5f..30a572af01cef22ccf2792caa8d68252460f3e1f 100644 --- a/lib/extern/lib/ExternElementMain.class.php +++ b/lib/extern/lib/ExternElementMain.class.php @@ -82,16 +82,11 @@ class ExternElementMain extends ExternElement { */ function getDefaultConfig () {} - /** - * - */ - function toStringEdit ($post_vars = "", $faulty_values = "", - $edit_form = "", $anker = "") { - - $out = ''; - $table = ''; - if ($edit_form == '') + public function toStringEdit ($post_vars = "", $faulty_values = "", $edit_form = "", $anker = "") + { + if (!$edit_form) { $edit_form = new ExternEdit($this->config, $post_vars, $faulty_values, $anker); + } $edit_form->setElementName($this->getName()); $element_headline = $edit_form->editElementHeadline($this->real_name, @@ -103,7 +98,7 @@ class ExternElementMain extends ExternElement { $edit_function = $this->edit_function; $table = $edit_form->$edit_function($this->field_names); - $content_table = $edit_form->editContentTable($tag_headline, $table); + $content_table = $edit_form->editContentTable('', $table); $submit = $edit_form->editSubmit($this->config->getName(), $this->config->getId(), $this->getName()); $out = $edit_form->editContent($content_table, $submit); diff --git a/lib/extern/modules/ExternModuleLecturedetails.class.php b/lib/extern/modules/ExternModuleLecturedetails.class.php index ff803b84e0e488867ba1339a6079187afa4e7d75..9dbe2a328c9f68063314eb64fb97ef34fad756ce 100644 --- a/lib/extern/modules/ExternModuleLecturedetails.class.php +++ b/lib/extern/modules/ExternModuleLecturedetails.class.php @@ -305,9 +305,7 @@ class ExternModuleLecturedetails extends ExternModule { setlocale(LC_TIME, $this->config->getValue("Main", "timelocale")); - $order = $this->config->getValue("Main", "order"); $visible = $this->config->getValue("Main", "visible"); - $aliases = $this->config->getValue("Main", "aliases"); $j = -1; $data["name"] = $data_sem["name"]; @@ -328,12 +326,12 @@ class ExternModuleLecturedetails extends ExternModule { if ($visible[++$j]) { $aliases_sem_type = $this->config->getValue("ReplaceTextSemType", - "class_{$SEM_TYPE[$data_sem['semtype']]['class']}"); + "class_{$GLOBALS['SEM_TYPE'][$data_sem['semtype']]['class']}"); if ($aliases_sem_type[$sem_types_position[$data_sem['semtype']] - 1]) $data["status"] = $aliases_sem_type[$sem_types_position[$data_sem['semtype']] - 1]; else { - $data["status"] = htmlReady($SEM_TYPE[$data_sem['semtype']]["name"] - ." (". $SEM_CLASS[$SEM_TYPE[$data_sem['semtype']]["class"]]["name"].")"); + $data["status"] = htmlReady($GLOBALS['SEM_TYPE'][$data_sem['semtype']]["name"] + ." (". $GLOBALS['SEM_CLASS'][$GLOBALS['SEM_TYPE'][$data_sem['semtype']]["class"]]["name"].")"); } } @@ -391,12 +389,14 @@ class ExternModuleLecturedetails extends ExternModule { } - // private - function toStringMainTable ($data, $preview) { + private function toStringMainTable ($data, $preview) + { $order = $this->config->getValue("Main", "order"); $visible = $this->config->getValue("Main", "visible"); $aliases = $this->config->getValue("Main", "aliases"); + $out = ''; + if ($this->config->getValue("Main", "studiplink")) { $out .= "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\""; if ($studiplink_width = $this->config->getValue("TableHeader", "table_width")) diff --git a/lib/extern/modules/ExternModuleTemplateDownload.class.php b/lib/extern/modules/ExternModuleTemplateDownload.class.php index 10a745d17eb41ddebd20d91b78033202e444804f..ee4c82afd4037627dbe82d9db0002fe147d4ad3f 100644 --- a/lib/extern/modules/ExternModuleTemplateDownload.class.php +++ b/lib/extern/modules/ExternModuleTemplateDownload.class.php @@ -136,16 +136,11 @@ class ExternModuleTemplateDownload extends ExternModule { } function getContent ($args = NULL, $raw = FALSE) { - $error_message = ""; if (!$args) { $args = []; } $content = []; - // check for valid range_id - if(!$this->checkRangeId($this->config->range_id)) { - $error_message = $GLOBALS['EXTERN_ERROR_MESSAGE']; - } // if $args['seminar_id'] is given, check for free access if ($args['seminar_id']) { $seminar_id = $args['seminar_id']; @@ -156,9 +151,6 @@ class ExternModuleTemplateDownload extends ExternModule { $statement = DBManager::get()->prepare($query); $statement->execute($params); $row = $statement->fetchColumn(); - if ($row !== false && $row == 0 ) { - $error_message = $GLOBALS['EXTERN_ERROR_MESSAGE']; - } } else { $seminar_id = $this->config->range_id; } @@ -288,15 +280,17 @@ class ExternModuleTemplateDownload extends ExternModule { } - function printoutPreview () { - if (!$language = $this->config->getValue("Main", "language")) - $language = "de_DE"; + public function printoutPreview () + { + $language = $this->config->getValue("Main", "language") ?: 'de_DE'; init_i18n($language); - echo $this->elements['TemplateGeneric']->toString(['content' => $this->getContent($args), 'subpart' => 'DOWNLOAD', 'hide_markers' => FALSE]); + echo $this->elements['TemplateGeneric']->toString([ + 'content' => $this->getContent(), + 'subpart' => 'DOWNLOAD', + 'hide_markers' => false, + ]); } } - -?> diff --git a/lib/extern/modules/ExternModuleTemplatePersondetails.class.php b/lib/extern/modules/ExternModuleTemplatePersondetails.class.php index 4f6fb52b9f19c2988f1c90a500f5f0caf92e897b..288b0d5ec748e7532c88ebf80245f7f60b056de8 100644 --- a/lib/extern/modules/ExternModuleTemplatePersondetails.class.php +++ b/lib/extern/modules/ExternModuleTemplatePersondetails.class.php @@ -257,9 +257,7 @@ class ExternModuleTemplatePersondetails extends ExternModule { $global_view = true; $selected_item_ids = $this->config->getValue('SelectInstitutes', 'institutesselected'); // at least one institute has to be selected in the configuration - if (!is_array($selected_item_ids)) { - // default to always show user for now - } else if ($this->config->getValue('Main', 'onlylecturers')) { + if (is_array($selected_item_ids)) { // is user lecturer ? $current_semester = get_sem_num(time()); $stm = DBManager::get()->prepare(sprintf( @@ -287,7 +285,7 @@ class ExternModuleTemplatePersondetails extends ExternModule { get_ext_vis_query())); $stm->execute([$username]); // user is not a lecturer - if (!$row = $stm->fetch()) { + if (!$stm->fetch()) { return []; } } else { @@ -303,14 +301,12 @@ class ExternModuleTemplatePersondetails extends ExternModule { implode("','", $selected_item_ids), get_ext_vis_query())); $stm->execute([$username]); // user is not dozent at an institute that is in the list of accepted institutes - if (!$row = $stm->fetch()) { + if (!$stm->fetch()) { return []; } } } - $row = false; - // Mitarbeiter/in am Institut $stm_inst = DBManager::get()->prepare( "SELECT i.Institut_id " @@ -346,7 +342,7 @@ class ExternModuleTemplatePersondetails extends ExternModule { . "LEFT JOIN auth_user_md5 aum USING(user_id) " . "WHERE s.Seminar_id = ? " . "AND si.institut_id != ? AND ui.inst_perms = 'dozent' AND aum.username = ? AND " . get_ext_vis_query()); - $stm_inst->execute([$sem_id, $intituts_id, $username]); + $stm_inst->execute([$sem_id, $instituts_id, $username]); if ($row = $stm_inst->fetch(PDO::FETCH_ASSOC)) { $instituts_id = $row['institut_id']; } @@ -435,8 +431,6 @@ class ExternModuleTemplatePersondetails extends ExternModule { $this->user_id = $row['user_id']; - $this->user_perm = $visibilities['perms']; - $content['__GLOBAL__']['STUDIP-EDIT-HREF'] = "{$GLOBALS['ABSOLUTE_URI_STUDIP']}dispatch.php/settings/account?username=$username&login=yes"; $content['PERSONDETAILS']['FULLNAME'] = ExternModule::ExtHtmlReady($row['fullname']); diff --git a/lib/extern/modules/ExternModuleTemplateSemBrowse.class.php b/lib/extern/modules/ExternModuleTemplateSemBrowse.class.php index da4d0226ce39330274763197cee3c03666a6a38c..3ddfd3ee2fb87003fc6e6ecdf70b1ced223f116a 100644 --- a/lib/extern/modules/ExternModuleTemplateSemBrowse.class.php +++ b/lib/extern/modules/ExternModuleTemplateSemBrowse.class.php @@ -1113,20 +1113,6 @@ class ExternModuleTemplateSemBrowse extends ExternModule { $sem_types_query = ''; } - // participated institutes (or show only courses located at this faculty) - /* - $sem_inst_query = ''; - if (!$this->config->getValue('Main', 'allseminars')) { - $tree = TreeAbstract::GetInstance('StudipRangeTree'); - $kidskids = $tree->getKidsKids($this->sem_browse_data['start_item_id']); - $institute_ids = array($tree->tree_data[$this->sem_browse_data['start_item_id']]['studip_object_id']); - foreach ($kidskids as $kid) { - $institute_ids[] = $tree->tree_data[$kid]['studip_object_id']; - } - $sem_inst_query = " AND seminare.Institut_id IN ('" . join("','", $institute_ids) . "')"; - } - */ - if (!$nameformat = $this->config->getValue('Main', 'nameformat')) { $nameformat = 'full_rev'; } @@ -1138,7 +1124,7 @@ class ExternModuleTemplateSemBrowse extends ExternModule { LEFT JOIN auth_user_md5 USING (user_id) LEFT JOIN user_info USING (user_id) $add_query - WHERE seminare.Seminar_id IN('" . join("','", array_keys($this->sem_browse_data['search_result'])) . "') $sem_types_query $sem_inst_query $sem_tree_query $limit_sql"; + WHERE seminare.Seminar_id IN('" . join("','", array_keys($this->sem_browse_data['search_result'])) . "') $sem_types_query $sem_tree_query $limit_sql"; $db = new DB_Seminar($query); if (!$db->num_rows()) { return [[], []]; diff --git a/lib/extern/modules/views/persondetails_preview.inc.php b/lib/extern/modules/views/persondetails_preview.inc.php index d60de0849728810ed88c89504ebdba91ae2c2781..71cd88266b5f98dd775a52f462febb28989aa480 100644 --- a/lib/extern/modules/views/persondetails_preview.inc.php +++ b/lib/extern/modules/views/persondetails_preview.inc.php @@ -264,9 +264,8 @@ function kategorien (&$module, $data, $alias_content, $text_div, $text_div_end) echo "</font>$text_div_end</td></tr>\n</table>\n</td></tr>\n"; } -function lehre (&$module, $data, $alias_content, $text_div, $text_div_end) { - global $attr_text_td; - +function lehre (&$module, $data, $alias_content, $text_div, $text_div_end) +{ $all_semester = Semester::findAllVisible(false); // old hard coded $SEMESTER-array starts with index 1 array_unshift($all_semester, 0); @@ -274,25 +273,23 @@ function lehre (&$module, $data, $alias_content, $text_div, $text_div_end) { if ($margin = $module->config->getValue("TableParagraphSubHeadline", "margin")) { $subheadline_div = "<div style=\"margin-left:$margin;\">"; $subheadline_div_end = "</div>"; - } - else { + } else { $subheadline_div = ""; $subheadline_div_end = ""; } if ($margin = $module->config->getValue("List", "margin")) { $list_div = "<div style=\"margin-left:$margin;\">"; $list_div_end = "</div>"; - } - else { + } else { $list_div = ""; $list_div_end = ""; } // sem-types in class 1 (Lehre) foreach ($GLOBALS["SEM_TYPE"] as $key => $type) { - if ($type["class"] == 1) + if ($type["class"] == 1) { $types[] = $key; + } } - $types = implode("','", $types); $switch_time = mktime(0, 0, 0, date("m"), @@ -302,25 +299,30 @@ function lehre (&$module, $data, $alias_content, $text_div, $text_div_end) { switch ($module->config->getValue("PersondetailsLectures", "semstart")) { case "previous" : - if (isset($all_semester[$current_sem - 1])) + if (isset($all_semester[$current_sem - 1])) { $current_sem--; + } break; case "next" : - if (isset($all_semester[$current_sem + 1])) + if (isset($all_semester[$current_sem + 1])) { $current_sem++; + } break; case "current" : break; default : - if (isset($all_semester[$module->config->getValue("PersondetailsLectures", "semstart")])) + if (isset($all_semester[$module->config->getValue("PersondetailsLectures", "semstart")])) { $current_sem = $module->config->getValue("PersondetailsLectures", "semstart"); + } } $last_sem = $current_sem + $module->config->getValue("PersondetailsLectures", "semrange") - 1; - if ($last_sem < $current_sem) + if ($last_sem < $current_sem) { $last_sem = $current_sem; - if (!isset($all_semester[$last_sem])) - $last_sem = sizeof($all_semester) - 1; + } + if (!isset($all_semester[$last_sem])) { + $last_sem = count($all_semester) - 1; + } $out = ""; for (;$current_sem <= $last_sem; $last_sem--) { @@ -361,9 +363,11 @@ function lehre (&$module, $data, $alias_content, $text_div, $text_div_end) { $out .= $text_div; $j = 0; foreach ($data as $dat) { - if ($j) $out .= "<br><br>"; + if ($j) { + $out .= "<br><br>"; + } $out .= "<font" . $module->config->getAttributes("LinkIntern", "font") . ">"; - $out .= "<a href=\"$lnk\"" . $module->config->getAttributes("LinkIntern", "a") . ">"; + $out .= "<a href=\"\"" . $module->config->getAttributes("LinkIntern", "a") . ">"; $out .= $dat["name"] . "</a></font>\n"; $out .= "<font" . $module->config->getAttributes("TableParagraphText", "font") . ">"; $out .= "<br>" . $dat["untertitel"] . "</font>\n"; diff --git a/lib/extern/views/ExternEditGeneric.class.php b/lib/extern/views/ExternEditGeneric.class.php index f1ef317811861d8ea6b2e1ef50cff2a2b6366d7a..111a847adb9b151891a37c0281977772fbc0b5b4 100644 --- a/lib/extern/views/ExternEditGeneric.class.php +++ b/lib/extern/views/ExternEditGeneric.class.php @@ -111,7 +111,7 @@ class ExternEditGeneric extends ExternEdit { $invalidClass = $this->faulty_values[$form_name][0] ? "class=\"invalid\" " : ""; - $out .= "<label $invalidClass>$title\n"; + $out = "<label $invalidClass>$title\n"; $out .= tooltipIcon($info); $out .= "<input type=\"text\" name=\"$form_name\" size=\"$size\""; $out .= " maxlength=\"$maxlength\" value=\"$value\">"; diff --git a/lib/extern/views/ExternEditModule.class.php b/lib/extern/views/ExternEditModule.class.php index 7d71de1b38e10f27cb8b05bf43a2a94945cd069b..2a576611f28880da0bfd3730c137e8c855a3b1db 100644 --- a/lib/extern/views/ExternEditModule.class.php +++ b/lib/extern/views/ExternEditModule.class.php @@ -176,7 +176,7 @@ class ExternEditModule extends ExternEditHtml { $out .= " checked=\"checked\""; $out .= ">" . _("Pixel") . " \n"; $out .= tooltipIcon($info); - $out .= "$error_sign</td></tr>\n"; + $out .= "</td></tr>\n"; } $out .= "</table>\n"; diff --git a/lib/filesystem/FileArchiveManager.class.php b/lib/filesystem/FileArchiveManager.class.php index 90b1da784c36f805940d07501899df931f509aa8..36ea988d8b4df27cac09cbf1d53dc9db6aab4bae 100644 --- a/lib/filesystem/FileArchiveManager.class.php +++ b/lib/filesystem/FileArchiveManager.class.php @@ -657,7 +657,6 @@ class FileArchiveManager return self::createArchive( self::getFolderChildren($folder), $archive_file_path, - $archive_file_name, $do_user_permission_checks, $keep_hierarchy ); diff --git a/lib/filesystem/LibraryFile.class.php b/lib/filesystem/LibraryFile.class.php index 736919b4dc359aeef26fc05e158e13f143d6a21d..0c2bcb68b89323b0a7ff9448f0800ae48cb1bc13 100644 --- a/lib/filesystem/LibraryFile.class.php +++ b/lib/filesystem/LibraryFile.class.php @@ -246,10 +246,7 @@ class LibraryFile extends StandardFile _('Datei löschen'), Icon::create('trash', Icon::ROLE_CLICKABLE, ['size' => 20]), [ - 'formaction' => URLHelper::getURL( - sprintf('dispatch.php/file/delete/%s', $this->fileref->id), - $flat_view ? ['from_flat_view' => 1] : [] - ), + 'formaction' => URLHelper::getURL("dispatch.php/file/delete/{$this->fileref->id}"), 'data-confirm' => sprintf(_('Soll die Datei "%s" wirklich gelöscht werden?'), $this->fileref->name), ] ); diff --git a/lib/filesystem/StandardFile.php b/lib/filesystem/StandardFile.php index 5c9b5e8b76ea4c8812319c4084d4951a3231cd2b..19f80e462f36227b017c238de051a7d5866320a3 100644 --- a/lib/filesystem/StandardFile.php +++ b/lib/filesystem/StandardFile.php @@ -237,21 +237,6 @@ class StandardFile implements FileType, ArrayAccess, StandardFileInterface ['data-dialog' => ''], 'file-display-info' ); - if ($current_action === 'flat') { - if (Navigation::hasItem('/course/files') && Navigation::getItem('/course/files')->isActive()) { - $actionMenu->addLink( - URLHelper::getURL('dispatch.php/course/files/index/' . $this->fileref->folder_id), - _('Ordner öffnen'), - Icon::create('folder-empty', Icon::ROLE_CLICKABLE, ['size' => 20]) - ); - } elseif (Navigation::hasItem('/files_dashboard/files') && Navigation::getItem('/files_dashboard/files')->isActive()) { - $actionMenu->addLink( - URLHelper::getURL('dispatch.php/files/index/' . $this->fileref->folder_id), - _('Ordner öffnen'), - Icon::create('folder-empty', Icon::ROLE_CLICKABLE, ['size' => 20]) - ); - } - } if ($this->isEditable($GLOBALS['user']->id)) { $actionMenu->addLink( URLHelper::getURL('dispatch.php/file/edit/' . $this->fileref->id), @@ -330,7 +315,7 @@ class StandardFile implements FileType, ArrayAccess, StandardFileInterface _('Datei löschen'), Icon::create('trash', Icon::ROLE_CLICKABLE, ['size' => 20]), [ - 'formaction' => URLHelper::getURL("dispatch.php/file/delete/{$this->fileref->id}", $flat_view ? ['from_flat_view' => 1] : []), + 'formaction' => URLHelper::getURL("dispatch.php/file/delete/{$this->fileref->id}"), 'data-confirm' => sprintf(_('Soll die Datei "%s" wirklich gelöscht werden?'), $this->fileref->name), ] ); diff --git a/lib/ilias_interface/ConnectedIlias.class.php b/lib/ilias_interface/ConnectedIlias.class.php index ca01700e6ac3d608901a2317132b7963e43f03fe..86e0efa083e3232ef4cdc53ccebf8d28ab064207 100644 --- a/lib/ilias_interface/ConnectedIlias.class.php +++ b/lib/ilias_interface/ConnectedIlias.class.php @@ -738,14 +738,12 @@ class ConnectedIlias $found = []; $added = 0; $deleted = 0; - $messages["info"] .= "<b>".sprintf(_("Aktualisierung der Zuordnungen zum System \"%s\":"), $this->getName()) . "</b><br>"; foreach($result as $ref_id => $data) { if (($data['accessInfo'] == 'granted') || ($this->ilias_interface_config['show_offline'] && $data['offline'])) { $this->course_modules[$ref_id] = new IliasModule($ref_id, $data, $this->index, $this->ilias_int_version); } $check->execute([Context::getId(), $ref_id, $this->index, $data["type"]]); if (!$check->fetch()) { - $messages["info"] .= sprintf(_("Zuordnung zur Lerneinheit \"%s\" wurde hinzugefügt."), ($data["title"])) . "<br>"; IliasObjectConnections::setConnection(Context::getId(), $ref_id, $data["type"], $this->index); $added++; } @@ -756,10 +754,6 @@ class ConnectedIlias while ($row = $to_delete->fetch(PDO::FETCH_ASSOC)) { IliasObjectConnections::unsetConnection(Context::getId(), $row["module_id"], $row["module_type"], $this->index); $deleted++; - $messages["info"] .= sprintf(_("Zuordnung zu \"%s\" wurde entfernt."), $row["module_id"] . '_' . $row["module_type"]) . "<br>"; - } - if (($added + $deleted) < 1) { - $messages["info"] .= _("Die Zuordnungen sind bereits auf dem aktuellen Stand.") . "<br>"; } return true; } diff --git a/lib/ilias_interface/IliasSoap.class.php b/lib/ilias_interface/IliasSoap.class.php index 5066d28a4d4d69957adf42d86b0bd8d5d39bd264..231b8e90f33c98d18304bcaeff6e2a4e3b7536b5 100644 --- a/lib/ilias_interface/IliasSoap.class.php +++ b/lib/ilias_interface/IliasSoap.class.php @@ -1065,15 +1065,12 @@ class IliasSoap extends StudipSoapClient function copyObject($source_id, $target_id) { $this->clearCache(); - $type = $object_data["type"]; - $title = $object_data["title"]; - $description = $object_data["description"]; $xml = "<Settings source_id=\"$source_id\" target_id=\"$target_id\" default_action=\"COPY\"/>"; $param = [ - 'sid' => $this->getSID(), - 'xml' => $xml + 'sid' => $this->getSID(), + 'xml' => $xml ]; return $this->call('copyObject', $param); } diff --git a/lib/models/ModuleManagementModel.php b/lib/models/ModuleManagementModel.php index db565b94de51bbbe92bbb54207622376d889af3f..39b7d75e229ffd3d551758fd5cf5f62e3051f784 100644 --- a/lib/models/ModuleManagementModel.php +++ b/lib/models/ModuleManagementModel.php @@ -302,7 +302,7 @@ abstract class ModuleManagementModel extends SimpleORMap implements ModuleManage /** * Logs all changes of this object. * - * @param type $action new, update or delete + * @param string $action new, update or delete * @return boolean Return true if logging was successful. */ protected function logChanges ($action = null) { @@ -462,14 +462,16 @@ abstract class ModuleManagementModel extends SimpleORMap implements ModuleManage if ($action == 'update') { foreach ($this->content as $name => $value) { - if ($name == 'author_id' || $name == 'editor_id' || $name == 'mkdate' || $name == 'chdate' ) continue; + if ($name == 'author_id' || $name == 'editor_id' || $name == 'mkdate' || $name == 'chdate' ) { + continue; + } if ($this->isFieldDirty($name)) { $info = ($num_index == 3) ? $debuginfo.';'.$value : $value; - StudipLog::log($logging, $aff, $coaff, $this->db_table.'.'.$name, $info, $editor_id); + StudipLog::log($logging, $aff, $coaff, $this->db_table.'.'.$name, $info); } } } else { - StudipLog::log($logging, $aff, $coaff, $this->db_table, $debuginfo, $editor_id); + StudipLog::log($logging, $aff, $coaff, $this->db_table, $debuginfo); } return true; diff --git a/lib/models/User.class.php b/lib/models/User.class.php index eb86a1e1433bd6e064b6b5d2624f34d4b4b1ed7d..2f768c3d710d07fef7c9b3b70df695085d336a05 100644 --- a/lib/models/User.class.php +++ b/lib/models/User.class.php @@ -1001,9 +1001,11 @@ class User extends AuthUserMd5 implements Range, PrivacyObject if($lang == '') { $lang = 'de'; } - include_once("locale/$lang/LC_MAILS/change_self_mail.inc.php"); - $mail = StudipMail::sendMessage($email, $subject, $mailbody); + // TODO: This should be refactored so that the included file returns an array + include "locale/$lang/LC_MAILS/change_self_mail.inc.php"; // Defines $subject and $mailbody + + $mail = StudipMail::sendMessage($email, $subject ?? '', $mailbody ?? ''); if (!$mail) { return true; diff --git a/lib/phplib/Seminar_Register_Auth.class.php b/lib/phplib/Seminar_Register_Auth.class.php index e2d43fbc09dbd0662e82d96306cdca35059fdf1e..f4b0fd9b43e7fac4de4f957f8ab482ddce079d10 100644 --- a/lib/phplib/Seminar_Register_Auth.class.php +++ b/lib/phplib/Seminar_Register_Auth.class.php @@ -219,12 +219,13 @@ class Seminar_Register_Auth extends Seminar_Auth $lang_path = getUserLanguagePath($user->id); // include language-specific subject and mailbody - include_once "locale/{$lang_path}/LC_MAILS/register_mail.inc.php"; + // TODO: This should be refactored so that the included file returns an array + include "locale/{$lang_path}/LC_MAILS/register_mail.inc.php"; // Defines $subject and $mailbody // send the mail - $mail->setSubject($subject) + $mail->setSubject($subject ?? '') ->addRecipient($to) - ->setBodyText($mailbody) + ->setBodyText($mailbody ?? '') ->send(); } diff --git a/lib/wiki.inc.php b/lib/wiki.inc.php index 4e9e6098b6ef0a62d90d8eca3344c31de35477b4..d1a0dbe719d22311888fa44c1197cdd6764a7e5b 100644 --- a/lib/wiki.inc.php +++ b/lib/wiki.inc.php @@ -13,7 +13,7 @@ use Studip\Button, Studip\LinkButton; * @param int Version number. If empty, latest version is returned. * **/ -function getWikiPage($keyword, $version) +function getWikiPage($keyword, $version = null) { $page = null; if ($version) { @@ -686,10 +686,10 @@ function listPages($mode, $sortby = NULL) /** * List all versions of a wiki page * -* @param string WikiPage name -* @param sortby string Different sortings of entries. +* @param string $keyword WikiPage name +* @param string|null $sortby Different sortings of entries. **/ -function listPageVersions($keyword, $sortby = NULL) +function listPageVersions($keyword, $sortby = null) { $selfurl = '?view=pageversions'; $sort = "ORDER by version DESC"; // default sort order for versions" @@ -724,13 +724,10 @@ function listPageVersions($keyword, $sortby = NULL) $pages = WikiPage::findBySQL("range_id = ? AND keyword = ? ".$sort, [Context::getId(), $keyword]); - if (count($pages) === 0) { - #PageLayout::postInfo($nopages); - } else { + if (count($pages) > 0) { $template = $GLOBALS['template_factory']->open('wiki/pageversions.php'); $template->keyword = $keyword; $template->url = $selfurl; - $template->titlesortlink = $titlesortlink; $template->versionsortlink = $versionsortlink; $template->changesortlink = $changesortlink; $template->pages = $pages; @@ -738,11 +735,11 @@ function listPageVersions($keyword, $sortby = NULL) echo $template->render(); } - $wikiData = getWikiPage($keyword, $version); + $wikiData = getWikiPage($keyword); - getShowPageInfobox($keyword, $wikiData->isLatestVersion(),TRUE); + getShowPageInfobox($keyword, $wikiData->isLatestVersion()); - showPageFrameEnd([]); + showPageFrameEnd(); } diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 59276839be6b4275bfa26162e071ba0b856c7b86..588535a28f938fcffecae22109c8f3f46a88cb74 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -5,12 +5,15 @@ parameters: # - app/routes - lib # - tests + scanFiles: + - composer/phpxmlrpc/phpxmlrpc/lib/xmlrpc.inc scanDirectories: - app/controllers - lib - vendor excludePaths: - lib/classes/ZipArchiveLegacyTrait.php + - lib/elearning/studip_referrer.php - lib/soap/StudipSoapClient_PHP5.class.php tmpDir: .caches earlyTerminatingMethodCalls: @@ -20,4 +23,4 @@ parameters: errorFormat: junit ignoreErrors: - - '#Undefined variable#' + # - '#Undefined variable#' diff --git a/templates/dates/seminar_export.php b/templates/dates/seminar_export.php index ae6fd1b1cf98794eb3d2244f3309b3456e819f92..d7ad311b21c30dd39429f79d84153f2157eafc4b 100644 --- a/templates/dates/seminar_export.php +++ b/templates/dates/seminar_export.php @@ -57,7 +57,7 @@ if (!empty($dates['regular']['turnus_data']) || !empty($dates['irregular'])) : $rooms = array_merge(getPlainRooms($irregular_rooms, false), array_keys($freetext_rooms)); if (is_array($irregular) && sizeof($irregular)) : - if (isset($shrink) && !$shrink && sizeof($irregular < 20)) : + if (isset($shrink) && !$shrink && sizeof($irregular) < 20) : foreach ($irregular as $date) : echo $date['tostring']; diff --git a/tests/functional/_bootstrap.php b/tests/functional/_bootstrap.php index 2ffdd75e623bcc64c1d3f8bcb943b1ac051d0318..4a71787b14144346eb4d4fcae404d0608fe6d21f 100644 --- a/tests/functional/_bootstrap.php +++ b/tests/functional/_bootstrap.php @@ -48,32 +48,8 @@ StudipMail::setDefaultTransporter(new debug_message_class()); require_once 'vendor/flexi/lib/flexi.php'; $GLOBALS['template_factory'] = new Flexi_TemplateFactory(dirname(dirname(__DIR__)) . '/templates'); -// create "fake" cache class -if (!class_exists('StudipArrayCache')) { - class StudipArrayCache implements StudipCache { - public $data = []; - - function expire($key) - { - unset($this->data); - } - - function flush() - { - $this->data = []; - } - - function read($key) - { - return $this->data[$key]; - } - - function write($name, $content, $expire = 43200) - { - return ($this->data[$name] = $content); - } - } -} +// Disable caching to fallback to memory cache +$GLOBALS['CACHING_ENABLE'] = false; // SimpleORMapFake if (!class_exists('StudipTestHelper')) { @@ -81,13 +57,6 @@ if (!class_exists('StudipTestHelper')) { { static function set_up_tables($tables) { - // first step, set fake cache - $testconfig = new Config(['cache_class' => 'StudipArrayCache']); - Config::set($testconfig); - StudipCacheFactory::setConfig($testconfig); - - $GLOBALS['CACHING_ENABLE'] = true; - $cache = StudipCacheFactory::getCache(false); // second step, expire table scheme @@ -120,10 +89,6 @@ if (!class_exists('StudipTestHelper')) { static function tear_down_tables() { SimpleORMap::expireTableScheme(); - Config::set(null); - - StudipCacheFactory::setConfig(null); - $GLOBALS['CACHING_ENABLE'] = false; } } }