From 3d6e9f573c39cadc3af2f3eff89eee2c4af68b34 Mon Sep 17 00:00:00 2001 From: Jan-Hendrik Willms Date: Mon, 3 Jul 2023 08:15:36 +0000 Subject: fix errors and warnings, fixes #2803 Closes #2803 Merge request studip/studip!1890 --- app/controllers/admin/user.php | 9 +++---- app/controllers/course/messenger.php | 4 ++- app/controllers/jsupdater.php | 3 ++- app/controllers/profile.php | 36 ++++++++++++++++++++----- app/views/admin/user/new.php | 6 ++--- app/views/course/ilias_interface/add_object.php | 2 +- app/views/my_ilias_accounts/add_object.php | 4 +-- lib/classes/ProfileModel.php | 5 +++- lib/functions.php | 13 ++++----- lib/models/UserDomain.php | 10 ++++--- lib/user_visible.inc.php | 5 ++-- 11 files changed, 64 insertions(+), 33 deletions(-) diff --git a/app/controllers/admin/user.php b/app/controllers/admin/user.php index 8932f48..33d56a5 100644 --- a/app/controllers/admin/user.php +++ b/app/controllers/admin/user.php @@ -891,16 +891,14 @@ class Admin_UserController extends AuthenticatedController } if ($GLOBALS['perm']->have_perm('root')) { - $sql - = "SELECT Institut_id, Name, 1 AS is_fak + $sql = "SELECT Institut_id, Name, 1 AS is_fak FROM Institute WHERE Institut_id=fakultaets_id ORDER BY Name"; $faks = DBManager::get()->query($sql)->fetchAll(PDO::FETCH_ASSOC); $domains = UserDomain::getUserDomains(); } else { - $sql - = "SELECT a.Institut_id, Name, b.Institut_id = b.fakultaets_id AS is_fak + $sql = "SELECT a.Institut_id, Name, b.Institut_id = b.fakultaets_id AS is_fak FROM user_inst a LEFT JOIN Institute b USING (Institut_id) WHERE a.user_id = ? AND a.inst_perms = 'admin' @@ -911,8 +909,7 @@ class Admin_UserController extends AuthenticatedController $domains = UserDomain::getUserDomainsForUser(User::findCurrent()->id); } - $query - = "SELECT Institut_id, Name + $query = "SELECT Institut_id, Name FROM Institute WHERE fakultaets_id = ? AND institut_id != fakultaets_id ORDER BY Name"; diff --git a/app/controllers/course/messenger.php b/app/controllers/course/messenger.php index 8acd24b..ca0ec3c 100644 --- a/app/controllers/course/messenger.php +++ b/app/controllers/course/messenger.php @@ -12,7 +12,9 @@ class Course_MessengerController extends AuthenticatedController public function course_action($thread_id = null) { - PageLayout::setTitle(Context::get()->getFullname() . ' - ' . _('Blubber')); + if (Context::get()) { + PageLayout::setTitle(Context::get()->getFullname() . ' - ' . _('Blubber')); + } if (Navigation::hasItem('/course/blubber')) { Navigation::activateItem('/course/blubber'); diff --git a/app/controllers/jsupdater.php b/app/controllers/jsupdater.php index d0cd721..0d657fe 100644 --- a/app/controllers/jsupdater.php +++ b/app/controllers/jsupdater.php @@ -262,6 +262,7 @@ class JsupdaterController extends AuthenticatedController private function getCoursewareClipboardUpdates($pageInfo) { - return count(\Courseware\Clipboard::findUsersClipboards($GLOBALS["user"])) != $pageInfo['coursewareclipboard']['counter']; + $counter = $pageInfo['coursewareclipboard']['counter'] ?? 0; + return \Courseware\Clipboard::countByUser_id($GLOBALS['user']->id) != $counter; } } diff --git a/app/controllers/profile.php b/app/controllers/profile.php index 74e0b43..a177617 100644 --- a/app/controllers/profile.php +++ b/app/controllers/profile.php @@ -28,19 +28,41 @@ class ProfileController extends AuthenticatedController URLHelper::addLinkParam('username', Request::username('username')); PageLayout::setHelpKeyword('Basis.Homepage'); - $this->user = User::findCurrent(); // current logged in user - $this->perm = $GLOBALS['perm']; // perms of current logged in user - $this->current_user = User::findByUsername(Request::username('username', $this->user->username)); // current selected user + // current logged in user + $this->user = User::findCurrent(); + // perms of current logged in user + $this->perm = $GLOBALS['perm']; + // current selected user + $this->current_user = User::findByUsername(Request::username( + 'username', + $this->user ? $this->user->username : null + )); // get additional informations to selected user - $this->profile = new ProfileModel($this->current_user->user_id, $this->user->user_id); + $this->profile = new ProfileModel( + $this->current_user ? $this->current_user->id : null, + $this->user ? $this->user->id : null + ); // set the page title depending on user selection - if ($this->current_user['user_id'] == $this->user->id && !$this->current_user['locked']) { + if ( + $this->user + && $this->current_user->id === $this->user->id + && !$this->current_user->locked + ) { PageLayout::setTitle(_('Mein Profil')); UserConfig::get($this->user->id)->store('PROFILE_LAST_VISIT', time()); - } elseif ($this->current_user['user_id'] && ($this->perm->have_perm('root') || (!$this->current_user['locked'] && get_visibility_by_id($this->current_user['user_id'])))) { + } elseif ( + $this->current_user->id + && ( + $this->perm->have_perm('root') + || ( + !$this->current_user->locked + && get_visibility_by_id($this->current_user->id) + ) + ) + ) { PageLayout::setTitle(_('Profil von') . ' ' . $this->current_user->getFullname()); - object_add_view($this->current_user->user_id); + object_add_view($this->current_user->id); } else { PageLayout::setTitle(_('Profil')); $action = 'not_available'; diff --git a/app/views/admin/user/new.php b/app/views/admin/user/new.php index 49fd9ed..8ceb12f 100644 --- a/app/views/admin/user/new.php +++ b/app/views/admin/user/new.php @@ -171,16 +171,16 @@ use Studip\Button, Studip\LinkButton; - + - + - + diff --git a/app/views/course/ilias_interface/add_object.php b/app/views/course/ilias_interface/add_object.php index 356a82d..8550337 100644 --- a/app/views/course/ilias_interface/add_object.php +++ b/app/views/course/ilias_interface/add_object.php @@ -122,7 +122,7 @@