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

prevent php8 warnings, fixes #2496

Closes #2496

Merge request studip/studip!1682
parent eb453097
No related branches found
No related tags found
No related merge requests found
...@@ -121,7 +121,7 @@ class LibraryDocument ...@@ -121,7 +121,7 @@ class LibraryDocument
{ {
if ($format == 'long') { if ($format == 'long') {
$long_title = ''; $long_title = '';
if ($this->csl_data['issued'] && $this->csl_data['author']) { if (isset($this->csl_data['issued'], $this->csl_data['author'])) {
$first_author_last_name = $this->csl_data['author'][0]['family']; $first_author_last_name = $this->csl_data['author'][0]['family'];
$year = $this->getIssueDate(true); $year = $this->getIssueDate(true);
if ($year) { if ($year) {
...@@ -129,11 +129,11 @@ class LibraryDocument ...@@ -129,11 +129,11 @@ class LibraryDocument
} else { } else {
$long_title = sprintf('%s - ', $first_author_last_name); $long_title = sprintf('%s - ', $first_author_last_name);
} }
} elseif ($this->csl_data['author']) { } elseif (isset($this->csl_data['author'])) {
$first_author_last_name = $this->csl_data['author'][0]['family']; $first_author_last_name = $this->csl_data['author'][0]['family'];
$long_title = sprintf('%s - ', $first_author_last_name); $long_title = sprintf('%s - ', $first_author_last_name);
} }
$long_title .= $this->csl_data['title']; $long_title .= $this->csl_data['title'] ?? '';
return $long_title; return $long_title;
} elseif ($format == 'long-comma') { } elseif ($format == 'long-comma') {
$data = []; $data = [];
...@@ -142,13 +142,13 @@ class LibraryDocument ...@@ -142,13 +142,13 @@ class LibraryDocument
if ($first_author_last_name) { if ($first_author_last_name) {
$data[] = $first_author_last_name; $data[] = $first_author_last_name;
} }
$data[] = $this->csl_data['title']; $data[] = $this->csl_data['title'] ?? '';
if ($year) { if ($year) {
$data[] = $year; $data[] = $year;
} }
return implode(', ', $data); return implode(', ', $data);
} else { } else {
return $this->csl_data['title'] ? $this->csl_data['title'] : ''; return $this->csl_data['title'] ?? '';
} }
} }
...@@ -158,7 +158,7 @@ class LibraryDocument ...@@ -158,7 +158,7 @@ class LibraryDocument
*/ */
public function getAuthorNames(): string public function getAuthorNames(): string
{ {
if (!$this->csl_data['author']) { if (empty($this->csl_data['author'])) {
return ''; return '';
} }
...@@ -411,22 +411,22 @@ class LibraryDocument ...@@ -411,22 +411,22 @@ class LibraryDocument
public function getSearchDescription() public function getSearchDescription()
{ {
$description = []; $description = [];
if ($this->search_params[LibrarySearch::AUTHOR]) { if (isset($this->search_params[LibrarySearch::AUTHOR])) {
$description[] = sprintf(_('Autor: „%s“'), $this->search_params[LibrarySearch::AUTHOR]); $description[] = sprintf(_('Autor: „%s“'), $this->search_params[LibrarySearch::AUTHOR]);
} }
if ($this->search_params[LibrarySearch::YEAR]) { if (isset($this->search_params[LibrarySearch::YEAR])) {
$description[] = sprintf(_('Jahr: „%s“'), $this->search_params[LibrarySearch::YEAR]); $description[] = sprintf(_('Jahr: „%s“'), $this->search_params[LibrarySearch::YEAR]);
} }
if ($this->search_params[LibrarySearch::TITLE]) { if (isset($this->search_params[LibrarySearch::TITLE])) {
$description[] = sprintf(_('Titel: „%s“'), $this->search_params[LibrarySearch::TITLE]); $description[] = sprintf(_('Titel: „%s“'), $this->search_params[LibrarySearch::TITLE]);
} }
if ($this->search_params[LibrarySearch::NUMBER]) { if (isset($this->search_params[LibrarySearch::NUMBER])) {
$description[] = sprintf(_('Nummer: „%s“'), $this->search_params[LibrarySearch::NUMBER]); $description[] = sprintf(_('Nummer: „%s“'), $this->search_params[LibrarySearch::NUMBER]);
} }
if ($this->search_params[LibrarySearch::PUBLICATION]) { if (isset($this->search_params[LibrarySearch::PUBLICATION])) {
$description[] = sprintf(_('Zeitschrift: „%s“'), $this->search_params[LibrarySearch::PUBLICATION]); $description[] = sprintf(_('Zeitschrift: „%s“'), $this->search_params[LibrarySearch::PUBLICATION]);
} }
if ($this->search_params[LibrarySearch::SIGNATURE]) { if (isset($this->search_params[LibrarySearch::SIGNATURE])) {
$description[] = sprintf(_('Signatur: „%s“'), $this->search_params[LibrarySearch::SIGNATURE]); $description[] = sprintf(_('Signatur: „%s“'), $this->search_params[LibrarySearch::SIGNATURE]);
} }
return $description; return $description;
......
...@@ -111,9 +111,11 @@ class FileManager ...@@ -111,9 +111,11 @@ class FileManager
return 'file-generic'; return 'file-generic';
} }
list($category, $type) = explode('/', $mime_type, 2); $chunks = explode('/', $mime_type, 2);
$category = $chunks[0];
$type = $chunks[1] ?? null;
switch($category) { switch ($category) {
case 'image': case 'image':
return 'file-pic'; return 'file-pic';
case 'audio': case 'audio':
......
...@@ -67,6 +67,7 @@ ...@@ -67,6 +67,7 @@
* @property UserInfo info has_one UserInfo * @property UserInfo info has_one UserInfo
* @property UserOnline online has_one UserOnline * @property UserOnline online has_one UserOnline
* @property Kategorie[]|SimpleORMapCollection $profile_categories has_many Kategorie * @property Kategorie[]|SimpleORMapCollection $profile_categories has_many Kategorie
* @property UserDomain[]|SimpleORMapCollection $domains
* *
* @property UserConfig config * @property UserConfig config
*/ */
......
...@@ -82,8 +82,13 @@ function get_visibility_by_state ($state, $user_id) { ...@@ -82,8 +82,13 @@ function get_visibility_by_state ($state, $user_id) {
return true; return true;
} }
$other_user = User::find($user_id);
if (!$other_user) {
return false;
}
$same_domain = UserDomain::checkUserVisibility( $same_domain = UserDomain::checkUserVisibility(
User::find($user_id)->domains, $other_user->domains,
User::findCurrent()->domains User::findCurrent()->domains
); );
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment