From 60080354dcc904e01f4ee88793d0e132afca8227 Mon Sep 17 00:00:00 2001 From: Jan-Hendrik Willms Date: Thu, 14 Jul 2022 07:22:51 +0000 Subject: resurrect lost commit, fixes #1235 Closes #1235 Merge request studip/studip!806 --- app/controllers/course/archive.php | 46 -- lib/archiv.inc.php | 690 --------------------- .../Routes/Courseware/TaskFeedbackUpdate.php | 14 +- lib/classes/JsonApi/Schemas/User.php | 2 +- lib/classes/MvvPerm.php | 93 +-- lib/classes/SemBrowse.class.php | 10 +- lib/classes/StudipCacheFactory.class.php | 60 +- lib/classes/UserLookup.class.php | 20 +- lib/classes/UserManagement.class.php | 14 +- lib/classes/restapi/Router.php | 1 + lib/classes/restapi/UriTemplate.php | 2 +- lib/classes/restapi/UserPermissions.php | 6 +- lib/classes/searchtypes/RangeSearch.class.php | 24 +- lib/elearning/ConnectedLink.class.php | 4 +- lib/elearning/ELearningUtils.class.php | 28 +- lib/elearning/Ilias3ConnectedCMS.class.php | 39 +- lib/elearning/Ilias3ConnectedLink.class.php | 147 +++-- lib/elearning/Ilias3ConnectedPermissions.class.php | 62 +- lib/elearning/Ilias3ContentModule.class.php | 26 +- lib/elearning/Ilias4ConnectedCMS.class.php | 14 +- lib/elearning/Ilias4ConnectedLink.class.php | 6 +- lib/elearning/Ilias4Soap.class.php | 4 - lib/elearning/PmWikiConnectedCMS.class.php | 32 +- .../classes/EvaluationTreeEditView.class.php | 80 +-- .../classes/EvaluationTreeShowUser.class.php | 3 +- lib/evaluation/classes/HTMLempty.class.php | 2 +- lib/evaluation/evaluation_admin_overview.lib.php | 11 +- lib/evaluation/evaluation_admin_template.lib.php | 2 +- lib/export/export_linking_func.inc.php | 2 +- lib/export/export_studipdata_func.inc.php | 15 +- lib/export/export_xml_func.inc.php | 6 +- lib/export/export_xslt_vars.inc.php | 2 - lib/extern/elements/ExternElementContact.class.php | 2 +- .../ExternElementPersondetailsHeader.class.php | 94 +-- .../ExternElementPersondetailsLectures.class.php | 2 +- ...nElementPersondetailsLecturesTemplate.class.php | 2 +- .../ExternElementReplaceTextSemType.class.php | 15 +- .../ExternElementSelectInstitutes.class.php | 12 +- .../ExternElementSelectSubjectAreas.class.php | 2 +- .../main/ExternElementMainDownload.class.php | 12 +- .../ExternElementMainTemplateDownload.class.php | 8 +- lib/extern/lib/ExternConfig.class.php | 2 +- lib/extern/lib/ExternConfigDb.class.php | 47 +- lib/extern/lib/ExternEdit.class.php | 15 +- lib/extern/lib/ExternElementMain.class.php | 15 +- .../modules/ExternModuleLecturedetails.class.php | 14 +- .../modules/ExternModuleTemplateDownload.class.php | 22 +- .../ExternModuleTemplatePersondetails.class.php | 14 +- .../ExternModuleTemplateSemBrowse.class.php | 16 +- .../modules/views/persondetails_preview.inc.php | 38 +- lib/extern/views/ExternEditGeneric.class.php | 2 +- lib/extern/views/ExternEditModule.class.php | 2 +- lib/filesystem/FileArchiveManager.class.php | 1 - lib/filesystem/LibraryFile.class.php | 5 +- lib/filesystem/StandardFile.php | 17 +- lib/ilias_interface/ConnectedIlias.class.php | 6 - lib/ilias_interface/IliasSoap.class.php | 7 +- lib/models/ModuleManagementModel.php | 10 +- lib/models/User.class.php | 6 +- lib/phplib/Seminar_Register_Auth.class.php | 7 +- lib/wiki.inc.php | 19 +- phpstan.neon.dist | 5 +- templates/dates/seminar_export.php | 2 +- tests/functional/_bootstrap.php | 39 +- 64 files changed, 430 insertions(+), 1497 deletions(-) diff --git a/app/controllers/course/archive.php b/app/controllers/course/archive.php index 63a2594..1177fd8 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 2108eaf..b9e18ac 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 = ''; - $dump .= '' . "\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('' . "\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('
', 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('
', array_map('htmlReady', $tutors))); - } - - if ($seminar['status'] != '' && isset($SEM_TYPE[$seminar['status']])) { - $content = $SEM_TYPE[$seminar['status']]['name']; - $content .= ' ' . _('in der Kategorie') . ' '; - $content .= '' . $SEM_CLASS[$SEM_TYPE[$seminar['status']]['class']]['name'] . ''; - $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('
', 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('
', 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.= '
'; - $dump .= '

 ' . htmlReady($seminar['Name'], 1, 1) . '

'; - $dump .= '
%s%s
' . "\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 .= '
'; - $dump .= ''; - $dump .= ' ' . "\n"; - $dump .= '' . "\n"; - $dump .= '
'; - $dump .= '

 ' . htmlReady($scm->tab_name) . '

'; - $dump .= '

'. formatReady($scm->content, 1, 1) .'
' . "\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 .= '
'; - $dump .= ''; - $dump .= '' . "\n"; - - foreach ($file_refs as $file_ref) { - $dump .= sprintf( - '' . "\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 .= '
'; - $dump .= '

 ' . _('Dateien') . ':' . '

'; - $dump .= '
%s
%s (%u KB)
%s%s
' . "\n"; - } - } - - // Teilnehmer - if ($Modules['participants'] - && (Config::get()->AUTO_INSERT_SEM_PARTICIPANTS_VIEW_PERM || !in_array($sem_id, AutoInsert::getAllSeminars(true)))) - { - $dump .= '
'; - - $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 .= ''; - $dump .= '' . "\n"; - $dump .= ''; - $dump .= ''; - $dump .= '' . "\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( - '' . "\n", - $user['user_is_visible'] - ? htmlReady($user['fullname']) - : _('(unsichtbareR NutzerIn)'), - $postings, - $user_files_count - ); - } // eine Zeile zuende - - $dump.= '
'; - $dump .= '

 ' . get_title_for_status($key, count($users), $sem_type) . '

'; - $dump .= '
' . _('Name') . '' . _('Forenbeiträge') . '' . _('Dokumente') . '
%s%u%u
' . "\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 = '
'; - $dump .= ''; - $dump .= dumpDateTableHeader($title); - $dump .= dumpDateTableRows($data); - $dump .= '
' . "\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 = ''; - $dump .= '

 ' . htmlReady($title) . '

'; - $dump .= '' . "\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 .= ' '; - $dump .= ''; - $dump .= strftime('%d. %b. %Y, %H:%M', $row['date']); - $dump .= ' - ' . strftime('%H:%M', $row['end_time']); - $dump .= ' (' . $TERMIN_TYP[$row['date_typ']]['name'] . ')'; - $dump .= ''; - } else { - $dump .= ''; - } - - $dump .= ' '; - $dump .= htmlReady($row['th_title'], 1, 1); - if ($row['th_desc']) { - $dump .= '
'; - $dump .= formatReady($row['th_desc'], 1, 1); - } - $dump .= ' ' . "\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 4097818..f0330c7 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 14787ce..3e32665 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 ab50128..d7f3732 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 a6a672a..29dcd38 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)) . ''; } 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 5ce2985..5332e06 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 cef2b4a..61732ae 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 2dc1f59..17ce8a3 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 3d375cb..de663bd 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 e83dd2c..bfdf23f 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 eaaac44..af5bc36 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 181798f..ee7f969 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 2be5a12..80c61d1 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 .= "
\n"; + $output = "\n"; $output .= CSRFProtection::tokenTag(); $output .= "\n"; $output .= "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 .= "\n"; + $output = "\n"; $output .= CSRFProtection::tokenTag(); $output .= "\n"; $output .= "\n"; diff --git a/lib/elearning/ELearningUtils.class.php b/lib/elearning/ELearningUtils.class.php index ad49569..30c40c4 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 .= ''; 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())) . "

\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[] = "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())).""; // 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."). "
"; - $output["update"] .= "\n"; - $output["update"] .= CSRFProtection::tokenTag(); - $output["update"] .= "\n"; - $output["update"] .= "\n"; - $output["update"] .= Button::create(_('Aktualisieren'), 'update'); - $output["update"] .= ""; + } } return $connected_courses; diff --git a/lib/elearning/Ilias3ConnectedCMS.class.php b/lib/elearning/Ilias3ConnectedCMS.class.php index de8db3f..3e428ff 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())) . "
\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())) . "
\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 "" . Icon::create('decline', 'attention')->asImg(['class' => 'text-top', 'title' => _('Fehler')]) . " " . $messages["error"] . "

"; + } echo ""; echo "\n"; - } - - if ($this->config->getValue($args["main_module"], "showimage") - || $this->config->getValue($args["main_module"], "showcontact")) { - $out .= ""; - 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"] . "\n"; - } - - if ($this->config->getValue($args["main_module"], "showimage")) { - $out .= $this->config->getTag($this->name, "picturetd"); - if (file_exists($args["content"]["picture_url"])) { - $out .= "f("fullname"))) . "\""; - $out .= $this->config->getAttributes($this->name, "img") . ">"; - } - else - $out .= " "; - } - - 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"] . "\n"; - } - - $out .= "\n"; - } - - $out .= "
"; diff --git a/lib/elearning/Ilias3ConnectedLink.class.php b/lib/elearning/Ilias3ConnectedLink.class.php index 7565cfb..f50fd53 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 .= "
\n"; + $output = "\n"; $output .= CSRFProtection::tokenTag(); $output .= "\n"; $output .= "\n"; @@ -109,63 +107,62 @@ class Ilias3ConnectedLink extends ConnectedLink $output .= "cms_type]->content_module[$current_module]->getId()) . "\">\n"; $output .= "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 .= "
"; $output .= _("Mit Schreibrechten für alle Lehrenden/Tutoren und Tutorinnen dieser Veranstaltung") . "
"; $output .= ""; $output .= _("Mit Schreibrechten für alle Teilnehmenden dieser Veranstaltung") . "
"; $output .= Button::create(_('Hinzufügen'), 'add') . "
"; - } - else + } else { $output .= " " . Button::create(_('Hinzufügen'), 'add'); + } $output .= "
"; 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 dcb6615..9bf2fcd 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(), ".")."
"; + } +// if ($GLOBALS["debug"] == true) +// echo "P$proper_role A$active_role U" . $user_crs_role . " R" . implode($connected_cms[$this->cms_type]->user->getRoles(), ".")."
"; + } // 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 b1c913c..63857bf 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"] . "

" . _("Sie haben keine Leseberechtigung für dieses Modul.") . ""); + $this->allowed_operations = $connected_cms[$this->cms_type]->permissions->getOperationArray($operations); + $this->setDescription("" . _("Sie haben keine Leseberechtigung für dieses Modul.") . ""); return false; - break; case "missing_precondition": $this->allowed_operations = $connected_cms[$this->cms_type]->permissions->getOperationArray($operations ); - $this->setDescription($object_data["description"] . "

" . _("Sie haben zur Zeit noch keinen Zugriff auf deses Modul (fehlende Vorbedingungen).") . ""); + $this->setDescription("" . _("Sie haben zur Zeit noch keinen Zugriff auf deses Modul (fehlende Vorbedingungen).") . ""); break; case "no_object_access": $this->allowed_operations = $connected_cms[$this->cms_type]->permissions->getOperationArray($operations ); - $this->setDescription($object_data["description"] . "

" . _("Dieses Modul ist momentan offline oder durch Payment-Regeln gesperrt.") . ""); + $this->setDescription("" . _("Dieses Modul ist momentan offline oder durch Payment-Regeln gesperrt.") . ""); break; case "no_parent_access": $this->allowed_operations = $connected_cms[$this->cms_type]->permissions->getOperationArray($operations ); - $this->setDescription($object_data["description"] . "

" . _("Sie haben keinen Zugriff auf die übergeordneten Objekte dieses Moduls.") . ""); + $this->setDescription("" . _("Sie haben keinen Zugriff auf die übergeordneten Objekte dieses Moduls.") . ""); 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 b8f0ea3..f569756 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())) . "
\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())) . "
\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 a66bd8e..a2bdb14 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 7afd738..9172338 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 = ""; $param = [ diff --git a/lib/elearning/PmWikiConnectedCMS.class.php b/lib/elearning/PmWikiConnectedCMS.class.php index 3cd728e..7de0a78 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 bec740e..4cac715 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] .= "
" . _("Veränderungen wurden gespeichert."); return true; diff --git a/lib/evaluation/classes/EvaluationTreeShowUser.class.php b/lib/evaluation/classes/EvaluationTreeShowUser.class.php index f266ccd..7ae88f8 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 a3dfdae..4ca9545 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 09a6b0b..b552a5f 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 . "
" : $no_permission_msg; + ($eval->getStopdate() != $stopDate && + $eval->getTimespan() != $timeSpan)) { + $time_msg = $time_msg ? $time_msg . "
" : $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 596307d..26e5ae6 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 52ea828..d5f66aa 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 .= "
"; + $export_string = ""; $export_string .= CSRFProtection::tokenTag(); $export_string .= "
\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 .= "config->getAttributes($this->name, "headlinetd") . ">"; - $out .= $this->config->getTag($this->name, "font"); - $out .= $args["content"]["name"]; - $out .= "
\n\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 ccb30e8..e4f4b50 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 aa0d4b9..2b13f4f 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 0764049..72ace41 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 56aeb7b..2812686 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 c1309e5..d4a4bdc 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 a2e612f..0468b4b 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("/(<|>|\"||\"||\"||\"| $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 e439659..1f23a86 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 5e48fec..ea7d340 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 781325c..30a572a 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 ff803b8..9dbe2a3 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 .= "config->getValue("TableHeader", "table_width")) diff --git a/lib/extern/modules/ExternModuleTemplateDownload.class.php b/lib/extern/modules/ExternModuleTemplateDownload.class.php index 10a745d..ee4c82a 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 4f6fb52..288b0d5 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 da4d022..3ddfd3e 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 d60de08..71cd882 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 "$text_div_end\n
\n\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 = "
"; $subheadline_div_end = "
"; - } - else { + } else { $subheadline_div = ""; $subheadline_div_end = ""; } if ($margin = $module->config->getValue("List", "margin")) { $list_div = "
"; $list_div_end = "
"; - } - 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 .= "

"; + if ($j) { + $out .= "

"; + } $out .= "config->getAttributes("LinkIntern", "font") . ">"; - $out .= "config->getAttributes("LinkIntern", "a") . ">"; + $out .= "config->getAttributes("LinkIntern", "a") . ">"; $out .= $dat["name"] . "
\n"; $out .= "config->getAttributes("TableParagraphText", "font") . ">"; $out .= "
" . $dat["untertitel"] . "\n"; diff --git a/lib/extern/views/ExternEditGeneric.class.php b/lib/extern/views/ExternEditGeneric.class.php index f1ef317..111a847 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 .= "