From 3baf3d2545ba6ece6b74a64c0def59bd0774cf54 Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Wed, 10 Jun 2026 16:34:12 +0000
Subject: [PATCH] =Laid the groundwork for an improved DashboardManager.php setup. Have to put it aside so I can get the dang Northeh done though.
---
JVBase.php | 39 +++++++++++++++++++++++++++++----------
1 files changed, 29 insertions(+), 10 deletions(-)
diff --git a/JVBase.php b/JVBase.php
index cf531ec..ea4f09c 100644
--- a/JVBase.php
+++ b/JVBase.php
@@ -3,13 +3,15 @@
use JVBase\blocks\CustomBlocks;
use JVBase\base\Site;
+use JVBase\managers\ApprovalManager;
use JVBase\managers\EmailManager;
use JVBase\managers\ErrorHandler;
+use JVBase\managers\FavouritesManager;
use JVBase\managers\InvitationsManager;
use JVBase\managers\LoginManager;
use JVBase\managers\MagicLinkManager;
use JVBase\managers\queue\Queue;
-use JVBase\managers\DashboardManager;
+use JVBase\managers\Dashboard\DashboardManager;
use JVBase\managers\DirectoryManager;
use JVBase\managers\ReferralManager;
use JVBase\managers\RoleManager;
@@ -130,9 +132,6 @@
$this->routes['referral'] = new ReferralRoutes();
}
- if (Site::has('dashboard')) {
- $this->managers['dash'] = new DashboardManager();
- }
if (Site::hasIntegration('square')) {
$this->routes['square'] = new IntegrationsSquareRoutes();
@@ -149,6 +148,9 @@
$this->managers['notifications'] = new NotificationManager();
$this->routes['notifications'] = new NotificationsRoutes();
}
+ if (!empty(Registrar::withFeature('approve_new'))) {
+ $this->managers['approvals'] = new ApprovalManager();
+ }
if (Site::has('feed_block') || Site::has('dashboard')) {
$this->routes['term'] = new TermRoutes();
}
@@ -168,6 +170,7 @@
}
if (Site::has('favourites')) {
+ $this->managers['favourites'] = new FavouritesManager();
$this->routes['favourites'] = new FavouritesRoutes();
}
@@ -177,13 +180,13 @@
if ($membership && $membership->has('invitable')) {
$this->managers['invitations'] = new InvitationsManager();
}
- if (!empty(Registrar::getFeatured('has_responses'))) {
+ if (!empty(Registrar::withFeature('has_responses'))) {
$this->routes['comments'] = new ResponseRoutes();
}
- if (!empty(Registrar::getFeatured('karma'))) {
+ if (!empty(Registrar::withFeature('karma'))) {
$this->routes['vote'] = new VoteRoutes();
}
- if (!empty(Registrar::getFeatured('karma'))
+ if (!empty(Registrar::withFeature('karma'))
|| ($membership && $membership->has('member_verified')) ||
($membership && $membership->has('term_approval'))) {
$this->routes['approvals'] = new ApprovalRoutes();
@@ -192,6 +195,11 @@
$this->routes['invites'] = new Invitations();
}
+
+ if (Site::has('dashboard')) {
+ $this->managers['dash'] = new DashboardManager();
+ }
+
$this->setupIntegrations();
add_action('wp_footer', [$this, 'additionalActions']);
@@ -213,6 +221,11 @@
return array_merge(array_keys($this->content), array_keys($this->taxonomies));
}
+ public function favourites(): FavouritesManager|false
+ {
+ return $this->managers['favourites'] ?? false;
+ }
+
public function dashboard(): DashboardManager|false
{
return $this->managers['dash'] ?? false;
@@ -296,8 +309,9 @@
public function userCanConnect(string $service, int $userID): bool
{
- $allowed = JVB_USER[jvbUserRole($userID)]['integrations'] ?? [];
- return user_can($userID, 'manage_options') || in_array($service, $allowed);
+ $role = jvbUserRole($userID);
+ $registrar = Registrar::getInstance($role);
+ return user_can($userID, 'manage_options') || $registrar->hasIntegration($service);
}
public function getAvailableServices(bool $keys = true): array
@@ -358,7 +372,7 @@
if (!empty ($buttons)) {
?>
- <section class="additional-actions">
+ <section class="main-actions">
<div class="buttons col">
<?= implode($buttons); ?>
</div>
@@ -388,4 +402,9 @@
{
return $this->managers['terms'];
}
+
+ public function approvals ():ApprovalManager|false
+ {
+ return $this->managers['approvals']??false;
+ }
}
--
Gitblit v1.10.0