Skip to content
Snippets Groups Projects
Commit 930bebba authored by David Siegfried's avatar David Siegfried Committed by Jan-Hendrik Willms
Browse files

prevent php-warnings, closes #2256

Closes #2256

Merge request studip/studip!1486
parent 4292f9fd
No related branches found
No related tags found
No related merge requests found
...@@ -242,8 +242,8 @@ class Course_LtiController extends StudipController ...@@ -242,8 +242,8 @@ class Course_LtiController extends StudipController
]); ]);
foreach ($custom_parameters as $param) { foreach ($custom_parameters as $param) {
list($key, $value) = explode('=', $param, 2); if (strpos($param, '=') !== false) {
if (isset($value)) { list($key, $value) = explode('=', $param, 2);
$lti_link->addCustomParameter(trim($key), trim($value)); $lti_link->addCustomParameter(trim($key), trim($value));
} }
} }
...@@ -291,13 +291,12 @@ class Course_LtiController extends StudipController ...@@ -291,13 +291,12 @@ class Course_LtiController extends StudipController
$lti_data->description = Studip\Markup::purifyHtml(Studip\Markup::markAsHtml($item['text'])); $lti_data->description = Studip\Markup::purifyHtml(Studip\Markup::markAsHtml($item['text']));
$lti_data->tool_id = $tool_id; $lti_data->tool_id = $tool_id;
$lti_data->launch_url = (string) $item['url']; $lti_data->launch_url = (string) $item['url'];
$custom_parameters = '';
$options = []; $options = [];
if (is_array($item['custom'])) { if (is_array($item['custom'])) {
$custom_parameters = '';
foreach ($item['custom'] as $key => $value) { foreach ($item['custom'] as $key => $value) {
$custom_parameters .= $key . '=' . $value . "\n"; $custom_parameters .= $key . '=' . $value . "\n";
} }
$options['custom_parameters'] = $custom_parameters; $options['custom_parameters'] = $custom_parameters;
} }
...@@ -352,8 +351,8 @@ class Course_LtiController extends StudipController ...@@ -352,8 +351,8 @@ class Course_LtiController extends StudipController
]); ]);
foreach ($custom_parameters as $param) { foreach ($custom_parameters as $param) {
list($key, $value) = explode('=', $param, 2); if (strpos($param, '=') !== false) {
if (isset($value)) { list($key, $value) = explode('=', $param, 2);
$lti_link->addCustomParameter(trim($key), trim($value)); $lti_link->addCustomParameter(trim($key), trim($value));
} }
} }
......
...@@ -103,8 +103,13 @@ class Course_ScmController extends AuthenticatedController ...@@ -103,8 +103,13 @@ class Course_ScmController extends AuthenticatedController
)->includeTicket('studip_ticket'); )->includeTicket('studip_ticket');
} }
$this->set_title($this->scm->tab_name ?: _('Informationen')); if (isset($this->scm)) {
Navigation::activateItem('/course/scm/' . $this->scm->id); $this->set_title($this->scm->tab_name);
Navigation::activateItem('/course/scm/' . $this->scm->id);
} else {
$this->set_title(_('Informationen'));
Navigation::activateItem('/course/scm');
}
} }
/** /**
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
<? if($create_perm) : ?> <? if($create_perm) : ?>
<nav> <nav>
<a href="<?= $controller->link_for('course/feedback/create_form/' . $range_id . '/' . $range_type) ?>" <a href="<?= $controller->link_for('course/feedback/create_form/' . $range_id . '/' . $range_type) ?>"
title="<?= _('Neues Feedback-Element') ?>" class="feedback-add" data-id="<?= $feedback ? $feedback->id : '' ?>" title="<?= _('Neues Feedback-Element') ?>"
data-dialog=""> data-dialog="">
<?= Icon::create('add'); ?> <?= Icon::create('add'); ?>
</a> </a>
......
<form class="default" action="<?= $controller->link_for('course/lti/save/' . $lti_data->position) ?>" method="post"> <form class="default" action="<?= $controller->link_for('course/lti/save', isset($lti_data) ? $lti_data->position : '') ?>" method="post">
<?= CSRFProtection::tokenTag() ?> <?= CSRFProtection::tokenTag() ?>
<fieldset> <fieldset>
<legend> <legend>
...@@ -9,12 +9,12 @@ ...@@ -9,12 +9,12 @@
<span class="required"> <span class="required">
<?= _('Titel') ?> <?= _('Titel') ?>
</span> </span>
<input type="text" name="title" value="<?= htmlReady($lti_data->title) ?>" required> <input type="text" name="title" value="<?= htmlReady(isset($lti_data) ? $lti_data->title : '') ?>" required>
</label> </label>
<label> <label>
<?= _('Beschreibung') ?> <?= _('Beschreibung') ?>
<textarea name="description" class="add_toolbar wysiwyg"><?= wysiwygReady($lti_data->description) ?></textarea> <textarea name="description" class="add_toolbar wysiwyg"><?= wysiwygReady(isset($lti_data) ? $lti_data->description : '') ?></textarea>
</label> </label>
<label> <label>
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
<? endif ?> <? endif ?>
<?= $lti_data->tool_id == $tool->id ? 'selected' : '' ?>><?= htmlReady($tool->name) ?></option> <?= $lti_data->tool_id == $tool->id ? 'selected' : '' ?>><?= htmlReady($tool->name) ?></option>
<? endforeach ?> <? endforeach ?>
<option value="0" <?= $lti_data && $lti_data->tool_id == 0 ? 'selected' : '' ?>><?= _('Zugangsdaten selbst eingeben...') ?></option> <option value="0" <?= isset($lti_data) && $lti_data->tool_id == 0 ? 'selected' : '' ?>><?= _('Zugangsdaten selbst eingeben...') ?></option>
</select> </select>
</label> </label>
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
<label> <label>
<?= _('URL der Anwendung (optional)') ?> <?= _('URL der Anwendung (optional)') ?>
<?= tooltipIcon(_('Sie können direkt auf eine URL in der Anwendung verlinken.')) ?> <?= tooltipIcon(_('Sie können direkt auf eine URL in der Anwendung verlinken.')) ?>
<input type="text" name="custom_url" value="<?= htmlReady($lti_data->launch_url) ?>"> <input type="text" name="custom_url" value="<?= htmlReady(isset($lti_data) ? $lti_data->launch_url : '') ?>">
</label> </label>
</div> </div>
...@@ -43,36 +43,36 @@ ...@@ -43,36 +43,36 @@
<label> <label>
<?= _('URL der Anwendung') ?> <?= _('URL der Anwendung') ?>
<?= tooltipIcon(_('Die Betreiber dieses Tools müssen Ihnen eine URL und Zugangsdaten (Consumer-Key und Consumer-Secret) mitteilen.')) ?> <?= tooltipIcon(_('Die Betreiber dieses Tools müssen Ihnen eine URL und Zugangsdaten (Consumer-Key und Consumer-Secret) mitteilen.')) ?>
<input type="text" name="launch_url" value="<?= htmlReady($lti_data->launch_url) ?>"> <input type="text" name="launch_url" value="<?= htmlReady(isset($lti_data) ? $lti_data->launch_url : '') ?>">
</label> </label>
<label> <label>
<?= _('Consumer-Key des LTI-Tools') ?> <?= _('Consumer-Key des LTI-Tools') ?>
<input type="text" name="consumer_key" value="<?= htmlReady($lti_data->options['consumer_key']) ?>"> <input type="text" name="consumer_key" value="<?= htmlReady(isset($lti_data) ? $lti_data->options['consumer_key'] : '') ?>">
</label> </label>
<label> <label>
<?= _('Consumer-Secret des LTI-Tools') ?> <?= _('Consumer-Secret des LTI-Tools') ?>
<input type="text" name="consumer_secret" value="<?= htmlReady($lti_data->options['consumer_secret']) ?>"> <input type="text" name="consumer_secret" value="<?= htmlReady(isset($lti_data) ? $lti_data->options['consumer_secret'] : '') ?>">
</label> </label>
<label> <label>
<?= _('OAuth Signatur Methode des LTI-Tools') ?> <?= _('OAuth Signatur Methode des LTI-Tools') ?>
<select name="oauth_signature_method"> <select name="oauth_signature_method">
<option value="sha1">HMAC-SHA1</option> <option value="sha1">HMAC-SHA1</option>
<option value="sha256" <?=$lti_data->options['oauth_signature_method'] === 'sha256' ? 'selected' : '' ?>>HMAC-SHA256</option> <option value="sha256" <?= isset($lti_data) && $lti_data->options['oauth_signature_method'] === 'sha256' ? 'selected' : '' ?>>HMAC-SHA256</option>
</select> </select>
</label> </label>
<label> <label>
<input type="checkbox" name="send_lis_person" value="1" <?= $lti_data->options['send_lis_person'] ? ' checked' : '' ?>> <input type="checkbox" name="send_lis_person" value="1" <?= isset($lti_data) && $lti_data->options['send_lis_person'] ? ' checked' : '' ?>>
<?= _('Nutzerdaten an LTI-Tool senden') ?> <?= _('Nutzerdaten an LTI-Tool senden') ?>
<?= tooltipIcon(_('Nutzerdaten dürfen nur an das externe Tool gesendet werden, wenn es keine Datenschutzbedenken gibt. Mit Setzen des Hakens bestätigen Sie, dass die Übermittlung der Daten zulässig ist.')) ?> <?= tooltipIcon(_('Nutzerdaten dürfen nur an das externe Tool gesendet werden, wenn es keine Datenschutzbedenken gibt. Mit Setzen des Hakens bestätigen Sie, dass die Übermittlung der Daten zulässig ist.')) ?>
</label> </label>
</div> </div>
<label> <label>
<input type="checkbox" name="document_target" value="iframe" <?= $lti_data->options['document_target'] == 'iframe' ? ' checked' : '' ?>> <input type="checkbox" name="document_target" value="iframe" <?= isset($lti_data) && $lti_data->options['document_target'] == 'iframe' ? ' checked' : '' ?>>
<?= _('Anzeige im IFRAME auf der Seite') ?> <?= _('Anzeige im IFRAME auf der Seite') ?>
<?= tooltipIcon(_('Normalerweise wird das externe Tool in einem neuen Fenster angezeigt. Aktivieren Sie diese Option, wenn die Anzeige stattdessen in einem IFRAME erfolgen soll.')) ?> <?= tooltipIcon(_('Normalerweise wird das externe Tool in einem neuen Fenster angezeigt. Aktivieren Sie diese Option, wenn die Anzeige stattdessen in einem IFRAME erfolgen soll.')) ?>
</label> </label>
...@@ -80,7 +80,7 @@ ...@@ -80,7 +80,7 @@
<label> <label>
<?= _('Zusätzliche LTI-Parameter') ?> <?= _('Zusätzliche LTI-Parameter') ?>
<?= tooltipIcon(_('Ein Wert pro Zeile, Beispiel: Review:Chapter=1.2.56')) ?> <?= tooltipIcon(_('Ein Wert pro Zeile, Beispiel: Review:Chapter=1.2.56')) ?>
<textarea name="custom_parameters"><?= htmlReady($lti_data->options['custom_parameters']) ?></textarea> <textarea name="custom_parameters"><?= htmlReady(isset($lti_data) && $lti_data->options['custom_parameters']) ?></textarea>
</label> </label>
</fieldset> </fieldset>
...@@ -92,7 +92,7 @@ ...@@ -92,7 +92,7 @@
<script> <script>
$('.config_tool').change(function() { $('.config_tool').change(function() {
var url = $(this).find(':selected').data('url'); let url = $(this).find(':selected').data('url');
if ($(this).val() == 0) { if ($(this).val() == 0) {
$('.config_launch_url').show(); $('.config_launch_url').show();
......
...@@ -2,14 +2,14 @@ ...@@ -2,14 +2,14 @@
<header> <header>
<h1> <h1>
<?= Icon::create('infopage', Icon::ROLE_INACTIVE)->asImg(['class' => 'text-top']) ?> <?= Icon::create('infopage', Icon::ROLE_INACTIVE)->asImg(['class' => 'text-top']) ?>
<?= htmlReady($scm->tab_name) ?> <?= htmlReady(isset($scm) ? $scm->tab_name : '') ?>
</h1> </h1>
<nav> <nav>
<span> <span>
<? if ($scm->user): ?> <? if (isset($scm) && $scm->user): ?>
<?= sprintf(_('Zuletzt geändert von %s am %s'), ObjectdisplayHelper::link($scm->user), strftime('%x, %X', $scm->chdate)) ?> <?= sprintf(_('Zuletzt geändert von %s am %s'), ObjectdisplayHelper::link($scm->user), strftime('%x, %X', $scm->chdate)) ?>
<? else: ?> <? else: ?>
<?= $scm->chdate ? sprintf(_('Zuletzt geändert am %s'), strftime('%x, %X', $scm->chdate)) : '' ?> <?= isset($scm) && $scm->chdate ? sprintf(_('Zuletzt geändert am %s'), strftime('%x, %X', $scm->chdate)) : '' ?>
<? endif; ?> <? endif; ?>
</span> </span>
<? if ($priviledged): ?> <? if ($priviledged): ?>
...@@ -30,6 +30,6 @@ ...@@ -30,6 +30,6 @@
</nav> </nav>
</header> </header>
<section> <section>
<?= ((string) $scm->content) ? formatReady($scm->content) : MessageBox::info(_('In diesem Bereich wurden noch keine Inhalte erstellt.')) ?> <?= (isset($scm) && (string) $scm->content) ? formatReady($scm->content) : MessageBox::info(_('In diesem Bereich wurden noch keine Inhalte erstellt.')) ?>
</section> </section>
</article> </article>
...@@ -22,7 +22,7 @@ class ForumActivity ...@@ -22,7 +22,7 @@ class ForumActivity
*/ */
public static function newEntry($event, $topic_id, $post) public static function newEntry($event, $topic_id, $post)
{ {
$verb = $post['depth'] === 3 ? 'answered' : 'created'; $verb = isset($post['depth']) && $post['depth'] === 3 ? 'answered' : 'created';
if ($verb === 'created') { if ($verb === 'created') {
if (isset($post['depth']) && (int)$post['depth'] === 1) { if (isset($post['depth']) && (int)$post['depth'] === 1) {
...@@ -41,7 +41,7 @@ class ForumActivity ...@@ -41,7 +41,7 @@ class ForumActivity
* Post activity for updating a forum post * Post activity for updating a forum post
* @param string $event * @param string $event
* @param string $topic_id * @param string $topic_id
* @param string $post * @param array $post
*/ */
public static function updateEntry($event, $topic_id, $post) public static function updateEntry($event, $topic_id, $post)
{ {
...@@ -69,7 +69,7 @@ class ForumActivity ...@@ -69,7 +69,7 @@ class ForumActivity
* Post activity for deleting a forum post * Post activity for deleting a forum post
* $param string $event * $param string $event
* @param string $topic_id * @param string $topic_id
* @param string $post * @param array $post
*/ */
public static function deleteEntry($event, $topic_id, $post) public static function deleteEntry($event, $topic_id, $post)
{ {
......
...@@ -187,7 +187,7 @@ class LtiLink ...@@ -187,7 +187,7 @@ class LtiLink
/** /**
* Add a list of additional launch parameters to this LTI launch request. * Add a list of additional launch parameters to this LTI launch request.
* *
* @param string $params list of launch parameters * @param array $params list of launch parameters
*/ */
public function addLaunchParameters($params) public function addLaunchParameters($params)
{ {
...@@ -217,7 +217,7 @@ class LtiLink ...@@ -217,7 +217,7 @@ class LtiLink
/** /**
* Add a list of custom launch parameters to this LTI launch request. * Add a list of custom launch parameters to this LTI launch request.
* *
* @param string $params list of custom parameters * @param array $params list of custom parameters
*/ */
public function addCustomParameters($params) public function addCustomParameters($params)
{ {
...@@ -244,7 +244,7 @@ class LtiLink ...@@ -244,7 +244,7 @@ class LtiLink
/** /**
* Add a list of substitution variables to this LTI launch request. * Add a list of substitution variables to this LTI launch request.
* *
* @param string $variables list of substitution variables * @param array $variables list of substitution variables
*/ */
public function addVariables($variables) public function addVariables($variables)
{ {
...@@ -292,8 +292,15 @@ class LtiLink ...@@ -292,8 +292,15 @@ class LtiLink
*/ */
public function getLaunchSignature($launch_params) public function getLaunchSignature($launch_params)
{ {
list($launch_url, $fragment) = explode('#', $this->launch_url); $launch_url = $this->launch_url;
list($launch_url, $query) = explode('?', $launch_url);
if (strpos($launch_url, '#') !== false) {
$launch_url = explode('#', $launch_url)[0];
}
if (strpos($launch_url, '?') !== false) {
list($launch_url, $query) = explode('?', $launch_url);
}
if (isset($query)) { if (isset($query)) {
parse_str($query, $query_params); parse_str($query, $query_params);
......
...@@ -34,7 +34,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ...@@ -34,7 +34,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
require '../lib/bootstrap.php'; require '../lib/bootstrap.php';
page_open(["sess" => "Seminar_Session", "auth" => "Seminar_Default_Auth", "perm" => "Seminar_Perm", "user" => "Seminar_User"]); page_open(["sess" => "Seminar_Session", "auth" => "Seminar_Default_Auth", "perm" => "Seminar_Perm", "user" => "Seminar_User"]);
$auth->login_if(Request::get('again') && ($auth->auth["uid"] == "nobody")); $GLOBALS['auth']->login_if(Request::get('again') && $GLOBALS['user']->id === 'nobody');
include ('lib/seminar_open.php'); // initialise Stud.IP-Session include ('lib/seminar_open.php'); // initialise Stud.IP-Session
...@@ -77,7 +77,7 @@ if (in_array(Request::get('view'), words('listnew listall export'))) { ...@@ -77,7 +77,7 @@ if (in_array(Request::get('view'), words('listnew listall export'))) {
if (Request::option('wiki_comments') === 'none') { // don't show comments if (Request::option('wiki_comments') === 'none') { // don't show comments
$show_wiki_comments = 'none'; $show_wiki_comments = 'none';
} else if ($user->cfg->WIKI_COMMENTS_ENABLE) { // show all comments } else if ($GLOBALS['user']->cfg->WIKI_COMMENTS_ENABLE) { // show all comments
$show_wiki_comments = 'all'; $show_wiki_comments = 'all';
} else { // show comments as icons } else { // show comments as icons
$show_wiki_comments = 'icon'; $show_wiki_comments = 'icon';
...@@ -145,10 +145,10 @@ if ($view === 'listall') { ...@@ -145,10 +145,10 @@ if ($view === 'listall') {
} }
// set lock // set lock
setWikiLock(null, $user->id, Context::getId(), $keyword); setWikiLock(null, $GLOBALS['user']->id, Context::getId(), $keyword);
// show form // show form
wikiEdit($keyword, $wikiData, $user->id); wikiEdit($keyword, $wikiData, $GLOBALS['user']->id);
} else if ($view === 'editnew') { } else if ($view === 'editnew') {
// //
...@@ -161,7 +161,7 @@ if ($view === 'listall') { ...@@ -161,7 +161,7 @@ if ($view === 'listall') {
$ancestor = null; $ancestor = null;
} }
$edit_perms = CourseConfig::get($range_id)->WIKI_COURSE_EDIT_RESTRICTED ? 'tutor' : 'autor'; $edit_perms = CourseConfig::get($range_id)->WIKI_COURSE_EDIT_RESTRICTED ? 'tutor' : 'autor';
if (!$perm->have_studip_perm($edit_perms, $range_id)) { if (!$GLOBALS['perm']->have_studip_perm($edit_perms, $range_id)) {
throw new AccessDeniedException(_('Sie haben keine Berechtigung, in dieser Veranstaltung Seiten zu editieren!')); throw new AccessDeniedException(_('Sie haben keine Berechtigung, in dieser Veranstaltung Seiten zu editieren!'));
} }
...@@ -181,10 +181,10 @@ if ($view === 'listall') { ...@@ -181,10 +181,10 @@ if ($view === 'listall') {
} }
// set lock // set lock
setWikiLock(null, $user->id, Context::getId(), $keyword); setWikiLock(null, $GLOBALS['user']->id, Context::getId(), $keyword);
//show form //show form
wikiEdit($keyword, $wikiData, $user->id, Request::get('lastpage'), $ancestor); wikiEdit($keyword, $wikiData, $GLOBALS['user']->id, Request::get('lastpage'), $ancestor);
} else { } else {
// Default action: Display WikiPage (+ logic for submission) // Default action: Display WikiPage (+ logic for submission)
...@@ -202,9 +202,10 @@ if ($view === 'listall') { ...@@ -202,9 +202,10 @@ if ($view === 'listall') {
if (Request::get('ancestor')) { if (Request::get('ancestor')) {
$ancestor = Request::get('ancestor'); $ancestor = Request::get('ancestor');
} else { } else {
$ancestor = WikiPage::findLatestPage(Context::getId(), $keyword)->ancestor ?: null; $latest_page = WikiPage::findLatestPage(Context::getId(), $keyword);
$ancestor = $latest_page ? $latest_page->ancestor : null;
} }
submitWikiPage($keyword, $version, Studip\Markup::purifyHtml(Request::get('body')), $user->id, Context::getId(), $ancestor); submitWikiPage($keyword, $version, Studip\Markup::purifyHtml(Request::get('body')), $GLOBALS['user']->id, Context::getId(), $ancestor);
$version = ''; // $version="" means: get latest $version = ''; // $version="" means: get latest
} else if ($cmd === 'abortedit') { // Editieren abgebrochen } else if ($cmd === 'abortedit') { // Editieren abgebrochen
...@@ -213,7 +214,7 @@ if ($view === 'listall') { ...@@ -213,7 +214,7 @@ if ($view === 'listall') {
// //
// kill lock (set when starting to edit) // kill lock (set when starting to edit)
releasePageLocks($keyword, $user->id); releasePageLocks($keyword, $GLOBALS['user']->id);
// if editing new page was aborted, display last page again // if editing new page was aborted, display last page again
$keyword = Request::get('lastpage', $keyword); $keyword = Request::get('lastpage', $keyword);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment