Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 19 additions & 17 deletions lib/Controller/PageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,18 @@ class PageController extends Controller
/**
* Constructor
*
* @param IRequest $request The request.
* @param IInitialState $initialState Nextcloud initial-state service.
* @param IDashboardManager $dashboardManager Dashboard widget manager.
* @param IUserSession $userSession Current user session.
* @param IGroupManager $groupManager Group membership lookup.
* @param AdminSettingsService $adminSettings MyDash admin settings.
* @param DashboardService $dashboardService Dashboard service (active
* resolver — REQ-DASH-018).
* @param AdminTemplateService $templateService Template service (primary
* group resolver —
* REQ-TMPL-012).
* @param IRequest $request The request.
* @param IInitialState $initialState Nextcloud initial-state service.
* @param IDashboardManager $dashboardManager Dashboard widget manager.
* @param IUserSession $userSession Current user session.
* @param IGroupManager $groupManager Group membership lookup.
* @param AdminSettingsService $adminSettings MyDash admin settings.
* @param DashboardService $dashboardService Dashboard service (active
* resolver —
* REQ-DASH-018).
* @param AdminTemplateService $templateService Template service (primary
* group resolver —
* REQ-TMPL-012).
*/
public function __construct(
IRequest $request,
Expand Down Expand Up @@ -88,18 +89,19 @@ public function index(): TemplateResponse
// Load all widget scripts so legacy widgets can register their callbacks.
$widgets = $this->loadWidgetScripts();

$user = $this->userSession->getUser();
$isAdmin = false;
$userId = null;
$user = $this->userSession->getUser();
$isAdmin = false;
$userId = null;
if ($user !== null) {
$userId = $user->getUID();
$isAdmin = $this->groupManager->isAdmin(userId: $userId);
}

// Resolve the primary group via the canonical REQ-TMPL-012 authority.
$primaryGroup = ($userId !== null)
? $this->templateService->resolvePrimaryGroup(userId: $userId)
: Dashboard::DEFAULT_GROUP_ID;
$primaryGroup = Dashboard::DEFAULT_GROUP_ID;
if ($userId !== null) {
$primaryGroup = $this->templateService->resolvePrimaryGroup(userId: $userId);
}

$primaryGroupName = $primaryGroup;
if ($primaryGroup !== 'default'
Expand Down
12 changes: 6 additions & 6 deletions lib/Controller/ResponseHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,12 @@ public static function forbidden(
* exception is recorded in the server log; the client only ever sees
* the generic `$message` (defaulting to "Operation failed").
*
* @param \Exception $exception The exception.
* @param int $statusCode The HTTP status code.
* @param LoggerInterface|null $logger When provided, the exception is
* logged at ERROR level before
* the response is returned.
* @param string $message Generic client-facing message.
* @param \Exception $exception The exception.
* @param int $statusCode The HTTP status code.
* @param LoggerInterface|null $logger When provided, the exception is
* logged at ERROR level before
* the response is returned.
* @param string $message Generic client-facing message.
*
* @return JSONResponse The error response.
*/
Expand Down
Loading