Skip to content
Snippets Groups Projects
Commit fef7d936 authored by David Siegfried's avatar David Siegfried
Browse files

prevent php-warnings, closes #2303

Closes #2303

Merge request studip/studip!1522
parent d8e47379
No related branches found
No related tags found
No related merge requests found
...@@ -25,11 +25,10 @@ class Siteinfo { ...@@ -25,11 +25,10 @@ class Siteinfo {
$this->db = DBManager::get(); $this->db = DBManager::get();
} }
function get_detail_content($id) { function get_detail_content($id) {
global $perm;
//first we define some fallbacks //first we define some fallbacks
if ($id == 0) { if ((int)$id === 0) {
//users with root priveleges get a hint whether what to do... //users with root priveleges get a hint whether what to do...
if ($perm->have_perm('root')) { if ($GLOBALS['perm']->have_perm('root')) {
if ($this->rubrics_empty) { if ($this->rubrics_empty) {
return _("Benutzen Sie den Link »neue Rubrik anlegen« in der Infobox, um eine Rubrik anzulegen."); return _("Benutzen Sie den Link »neue Rubrik anlegen« in der Infobox, um eine Rubrik anzulegen.");
} else { } else {
...@@ -63,8 +62,7 @@ class Siteinfo { ...@@ -63,8 +62,7 @@ class Siteinfo {
function get_detail_content_processed($id) { function get_detail_content_processed($id) {
//applying Schnellformatierungen and Siteinfo-specific markup to the content //applying Schnellformatierungen and Siteinfo-specific markup to the content
$content = $this->get_detail_content($id); $content = $this->get_detail_content($id);
$output = $this->sme->siteinfoDirectives(formatReady(language_filter($content))); return $this->sme->siteinfoDirectives(formatReady(language_filter($content)));
return $output;
} }
function get_all_details() { function get_all_details() {
...@@ -107,8 +105,8 @@ class Siteinfo { ...@@ -107,8 +105,8 @@ class Siteinfo {
if ($result->rowCount() > 0) { if ($result->rowCount() > 0) {
return $rows[0]; return $rows[0];
} else { } else {
$this->rubrics_empty = TRUE; $this->rubrics_empty = true;
return NULL; return null;
} }
} }
...@@ -134,6 +132,8 @@ class Siteinfo { ...@@ -134,6 +132,8 @@ class Siteinfo {
function save($type, $input) { function save($type, $input) {
//distinguish the subject and the action (modification/insertion) //distinguish the subject and the action (modification/insertion)
$rubric = '';
$detail = '';
switch ($type) { switch ($type) {
case 'update_detail': case 'update_detail':
$query = "UPDATE siteinfo_details $query = "UPDATE siteinfo_details
...@@ -186,8 +186,9 @@ class Siteinfo { ...@@ -186,8 +186,9 @@ class Siteinfo {
return [$rubric, $detail]; return [$rubric, $detail];
} }
function delete($type,$id) { public function delete($type, $id)
if($type=="rubric") { {
if ($type === 'rubric') {
$query = "DELETE FROM siteinfo_details WHERE rubric_id = ?"; $query = "DELETE FROM siteinfo_details WHERE rubric_id = ?";
$statement = DBManager::get()->prepare($query); $statement = DBManager::get()->prepare($query);
$statement->execute([$id]); $statement->execute([$id]);
...@@ -269,7 +270,7 @@ class SiteinfoMarkupEngine { ...@@ -269,7 +270,7 @@ class SiteinfoMarkupEngine {
$statement->execute([$input]); $statement->execute([$input]);
$temp = $statement->fetchAll(PDO::FETCH_ASSOC); $temp = $statement->fetchAll(PDO::FETCH_ASSOC);
if (count($temp) == 1) { if (count($temp) === 1) {
$user = reset($temp); $user = reset($temp);
$template->username = $user['username']; $template->username = $user['username'];
$template->fullname = $user['fullname']; $template->fullname = $user['fullname'];
...@@ -290,7 +291,7 @@ class SiteinfoMarkupEngine { ...@@ -290,7 +291,7 @@ class SiteinfoMarkupEngine {
$statement->execute([$input]); $statement->execute([$input]);
$temp = $statement->fetchAll(PDO::FETCH_ASSOC); $temp = $statement->fetchAll(PDO::FETCH_ASSOC);
if (count($temp) == 1) { if (count($temp) === 1) {
$user = reset($temp); $user = reset($temp);
$template->username = $user['username']; $template->username = $user['username'];
$template->fullname = $user['fullname']; $template->fullname = $user['fullname'];
...@@ -355,8 +356,7 @@ class SiteinfoMarkupEngine { ...@@ -355,8 +356,7 @@ class SiteinfoMarkupEngine {
$remotefile = file_get_contents('https://develop.studip.de/studip/extern.php?module=Persons&config_id=8d1dafc3afca2bce6125d57d4119b631&range_id=4498a5bc62d7974d0a0ac3e97aca5296', false, get_default_http_stream_context('https://develop.studip.de')); $remotefile = file_get_contents('https://develop.studip.de/studip/extern.php?module=Persons&config_id=8d1dafc3afca2bce6125d57d4119b631&range_id=4498a5bc62d7974d0a0ac3e97aca5296', false, get_default_http_stream_context('https://develop.studip.de'));
$cache->write('coregroup', $remotefile); $cache->write('coregroup', $remotefile);
} }
$out = str_replace(['class="normal"','align="left"'], ["",""], $remotefile); return str_replace(['class="normal"', 'align="left"'], ['', ''], $remotefile);
return $out;
} }
function toplist($item) { function toplist($item) {
...@@ -365,6 +365,7 @@ class SiteinfoMarkupEngine { ...@@ -365,6 +365,7 @@ class SiteinfoMarkupEngine {
return $found_in_cache; return $found_in_cache;
} }
$template = $this->template_factory->open('toplist'); $template = $this->template_factory->open('toplist');
$sql = '';
switch ($item) { switch ($item) {
case "mostparticipants": case "mostparticipants":
$template->heading = _("die meisten Teilnehmenden"); $template->heading = _("die meisten Teilnehmenden");
...@@ -424,7 +425,7 @@ class SiteinfoMarkupEngine { ...@@ -424,7 +425,7 @@ class SiteinfoMarkupEngine {
// sort the seminars by the number of combined postings // sort the seminars by the number of combined postings
usort($seminars, function($a, $b) { usort($seminars, function($a, $b) {
if ($a['count'] == $b['count']) { if ($a['count'] === $b['count']) {
return 0; return 0;
} }
return ($a['count'] > $b['count']) ? -1 : 1; return ($a['count'] > $b['count']) ? -1 : 1;
...@@ -520,7 +521,7 @@ class SiteinfoMarkupEngine { ...@@ -520,7 +521,7 @@ class SiteinfoMarkupEngine {
"detail" => _("von Stud.IP verwaltete Ressourcen wie Räume oder Geräte"), "detail" => _("von Stud.IP verwaltete Ressourcen wie Räume oder Geräte"),
"constraint" => Config::get()->RESOURCES_ENABLE]; "constraint" => Config::get()->RESOURCES_ENABLE];
if ($key == 'posting') { if ($key === 'posting') {
$count = 0; $count = 0;
// sum up number of postings for all availabe ForumModules // sum up number of postings for all availabe ForumModules
...@@ -547,10 +548,10 @@ class SiteinfoMarkupEngine { ...@@ -547,10 +548,10 @@ class SiteinfoMarkupEngine {
$template->detail = $indicator[$key]['detail']; $template->detail = $indicator[$key]['detail'];
} }
} else { } else {
return ""; return '';
} }
} else { } else {
return ""; return '';
} }
} }
$ret = $template->render(); $ret = $template->render();
...@@ -563,7 +564,7 @@ class SiteinfoMarkupEngine { ...@@ -563,7 +564,7 @@ class SiteinfoMarkupEngine {
} }
function termsOfUse() { function termsOfUse() {
return @file_get_contents($GLOBALS['STUDIP_BASE_PATH'] . '/locale/' . ($GLOBALS['_language_path'] ?: 'de') . '/LC_HELP/pages/nutzung.html'); return @file_get_contents($GLOBALS['STUDIP_BASE_PATH'] . '/locale/' . ($GLOBALS['_language_path'] ?? 'de') . '/LC_HELP/pages/nutzung.html');
} }
function style($style, $styled) { function style($style, $styled) {
...@@ -583,7 +584,7 @@ function language_filter($input) { ...@@ -583,7 +584,7 @@ function language_filter($input) {
function stripforeignlanguage($language, $text) { function stripforeignlanguage($language, $text) {
list($primary, $sub) = explode('_',$_SESSION['_language']); list($primary, $sub) = explode('_',$_SESSION['_language']);
if (($language==$primary) || ($language==$_SESSION['_language'])) { if ($language === $primary || $language === $_SESSION['_language']) {
return str_replace('\"', '"', $text); return str_replace('\"', '"', $text);
} else { } else {
return ''; return '';
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment