summaryrefslogtreecommitdiffstats
path: root/apps/user_status/lib
diff options
context:
space:
mode:
authorPytal <24800714+Pytal@users.noreply.github.com>2021-10-18 23:03:58 -0700
committerGitHub <noreply@github.com>2021-10-18 23:03:58 -0700
commitf7b3d521f866a949f457f31f8f8480aebd3c9934 (patch)
tree0c4a6cd0e03b85c37b75f8baebc77aee17f0eae0 /apps/user_status/lib
parent7cebde242c9f45d46f45bdd3b2a186bccd12434b (diff)
parent3be9d3ca8fca4fb743a4d2f2ffe44a45fa9ffa6e (diff)
downloadnextcloud-server-f7b3d521f866a949f457f31f8f8480aebd3c9934.tar.gz
nextcloud-server-f7b3d521f866a949f457f31f8f8480aebd3c9934.zip
Merge pull request #28751 from nextcloud/feat/28139/profile-page
Diffstat (limited to 'apps/user_status/lib')
-rw-r--r--apps/user_status/lib/Listener/BeforeTemplateRenderedListener.php32
1 files changed, 30 insertions, 2 deletions
diff --git a/apps/user_status/lib/Listener/BeforeTemplateRenderedListener.php b/apps/user_status/lib/Listener/BeforeTemplateRenderedListener.php
index 86e151affdf..24090188170 100644
--- a/apps/user_status/lib/Listener/BeforeTemplateRenderedListener.php
+++ b/apps/user_status/lib/Listener/BeforeTemplateRenderedListener.php
@@ -24,17 +24,27 @@ declare(strict_types=1);
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
+
namespace OCA\UserStatus\Listener;
use OCA\UserStatus\AppInfo\Application;
use OCA\UserStatus\Service\JSDataService;
+use OCP\Accounts\IAccountManager;
use OCP\AppFramework\Http\Events\BeforeTemplateRenderedEvent;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\EventDispatcher\Event;
use OCP\EventDispatcher\IEventListener;
use OCP\IInitialStateService;
+use OCP\IUserSession;
class BeforeTemplateRenderedListener implements IEventListener {
+ use \OC\Profile\TProfileHelper;
+
+ /** @var IAccountManager */
+ private $accountManager;
+
+ /** @var IUserSession */
+ private $userSession;
/** @var IInitialStateService */
private $initialState;
@@ -45,11 +55,19 @@ class BeforeTemplateRenderedListener implements IEventListener {
/**
* BeforeTemplateRenderedListener constructor.
*
+ * @param IAccountManager $accountManager
+ * @param IUserSession $userSession
* @param IInitialStateService $initialState
* @param JSDataService $jsDataService
*/
- public function __construct(IInitialStateService $initialState,
- JSDataService $jsDataService) {
+ public function __construct(
+ IAccountManager $accountManager,
+ IUserSession $userSession,
+ IInitialStateService $initialState,
+ JSDataService $jsDataService
+ ) {
+ $this->accountManager = $accountManager;
+ $this->userSession = $userSession;
$this->initialState = $initialState;
$this->jsDataService = $jsDataService;
}
@@ -58,6 +76,12 @@ class BeforeTemplateRenderedListener implements IEventListener {
* @inheritDoc
*/
public function handle(Event $event): void {
+ $user = $this->userSession->getUser();
+ if ($user === null) {
+ return;
+ }
+ $account = $this->accountManager->getAccount($user);
+
if (!($event instanceof BeforeTemplateRenderedEvent)) {
// Unrelated
return;
@@ -71,6 +95,10 @@ class BeforeTemplateRenderedListener implements IEventListener {
return $this->jsDataService;
});
+ $this->initialState->provideLazyInitialState(Application::APP_ID, 'profileEnabled', function () use ($account) {
+ return ['profileEnabled' => $this->isProfileEnabled($account)];
+ });
+
\OCP\Util::addScript('user_status', 'user-status-menu');
\OCP\Util::addStyle('user_status', 'user-status-menu');
}