From 235ce5716edc2f7cbe80fdccf26eac7269587839 Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Mon, 08 Jun 2026 04:38:18 +0000
Subject: [PATCH] =FavouritesManager.php and FavouritesRoutes.php fixes. Moving all logic to FavouritesManager.php. Still some left to do
---
inc/managers/CRUDManager.php | 30 ++++++++++++++++++++++--------
1 files changed, 22 insertions(+), 8 deletions(-)
diff --git a/inc/managers/CRUDManager.php b/inc/managers/CRUDManager.php
index 7ad84df..1fedd00 100644
--- a/inc/managers/CRUDManager.php
+++ b/inc/managers/CRUDManager.php
@@ -1,6 +1,7 @@
<?php
namespace JVBase\managers;
+use JVBase\base\Site;
use JVBase\registrar\Registrar;
use JVBase\ui\CRUDSkeleton;
@@ -63,19 +64,27 @@
// Fields and sections
$this->skeleton->setFields($this->registrar->getFields());
- foreach ($this->registrar->getSections() as $config) {
- $this->skeleton->addSection($config['id'], $config);
- }
+ $sections = $this->registrar->getSections();
+ if (count($sections) > 1) {
+ foreach ($sections as $config) {
+ $this->skeleton->addSection($config['slug'], $config);
+ }
+ }
// Taxonomies
$this->initTaxonomies();
// Statuses
- if ($this->registrar && $this->registrar->hasFeature('is_calendar')) {
+ if ($this->registrar->hasFeature('is_calendar')) {
$this->skeleton->setCalendar();
}
- $this->skeleton->setDefaultStatus();
+ if ($this->registrar->getType() === 'post') {
+ $this->skeleton->setDefaultStatus();
+ } else {
+ $this->skeleton->setStatuses([]);
+ }
+
// Views
$this->skeleton
@@ -94,7 +103,7 @@
$this->skeleton->addCapabilities(['view', 'edit', 'create', 'delete']);
$plural = strtolower($this->registrar->getPlural() ?? $this->content . 's');
- $canPublish = jvbUserIsVerified() && user_can($this->user_id, "publish_{$plural}");
+ $canPublish = $this->userIsVerified() && user_can($this->user_id, "publish_{$plural}");
$this->skeleton->userCanPublish($canPublish);
// Bulk actions
@@ -117,6 +126,11 @@
add_filter('jvbAdditionalActions', [$this, 'createItem']);
}
+ protected function userIsVerified():bool {
+ $membership = Site::membership();
+
+ return !($membership && $membership->has('member_verified')) || current_user_can('skip_moderation');
+ }
/**
* Setup uploader configuration
*/
@@ -154,7 +168,7 @@
* Initialize taxonomies from WordPress config
*/
protected function initTaxonomies(): void {
- $this->taxonomies = $this->registrar->registrar->taxonomies;
+ $this->taxonomies = ($this->registrar->getType() === 'post') ? $this->registrar->registrar->taxonomies : [];
}
/**
@@ -173,7 +187,7 @@
protected function addDateRanges():array
{
- return $this->cache->remember(
+ return $this->cache->user()->remember(
'dateRanges',
function() {
$postType = jvbCheckBase($this->content);
--
Gitblit v1.10.0