b4acae34a3
WordPress administrators (manage_options) now implicitly hold every studio-admin capability via a user_has_cap filter, so the site owner runs the studio without being assigned the separate us_studio_admin role. The grant persists nothing and is removed on deactivation. The us_studio_admin role still exists for non-administrator staff and does NOT confer any core WordPress admin powers. Also re-gate the studio-wide "Scheduler" dashboard off manage_options onto a new view_all_lessons capability (added to the studio-admin cap set), so a us_studio_admin user can see it too — previously it was administrator-only. - RoleManager: STUDIO_ADMIN_CAPS constant, CAP_VIEW_ALL_LESSONS, grantStudioCapsToAdministrators() user_has_cap filter - AdminMenu + LessonController: Scheduler gated on view_all_lessons - Docs: user-roles.md cap matrix + administrator note; lesson-booking.md - Tests: administrators receive studio caps; non-admins do not Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
90 lines
2.9 KiB
PHP
90 lines
2.9 KiB
PHP
<?php
|
|
declare(strict_types=1);
|
|
|
|
namespace Unsupervised\Schedular;
|
|
|
|
use Unsupervised\Schedular\Availability\AvailabilityController;
|
|
use Unsupervised\Schedular\Availability\AvailabilityRepository;
|
|
use Unsupervised\Schedular\Auth\RoleManager;
|
|
use Unsupervised\Schedular\Booking\BookingRepository;
|
|
use Unsupervised\Schedular\Booking\LessonController;
|
|
use Unsupervised\Schedular\Offering\OfferingController;
|
|
use Unsupervised\Schedular\Offering\OfferingRepository;
|
|
use Unsupervised\Schedular\Registration\QuestionController;
|
|
use Unsupervised\Schedular\Registration\QuestionRepository;
|
|
|
|
class AdminMenu {
|
|
|
|
private AvailabilityController $availabilityController;
|
|
private LessonController $lessonController;
|
|
private OfferingController $offeringController;
|
|
private QuestionController $questionController;
|
|
|
|
public function __construct( AvailabilityRepository $availability, BookingRepository $bookings, OfferingRepository $offerings, QuestionRepository $questions ) {
|
|
$this->availabilityController = new AvailabilityController( $availability );
|
|
$this->lessonController = new LessonController( $bookings );
|
|
$this->offeringController = new OfferingController( $offerings );
|
|
$this->questionController = new QuestionController( $questions, $offerings );
|
|
}
|
|
|
|
public function register(): void {
|
|
add_action( 'admin_menu', [ $this, 'addPages' ] );
|
|
}
|
|
|
|
public function addPages(): void {
|
|
// Studio-wide dashboard: all upcoming lessons across instructors.
|
|
add_menu_page(
|
|
__( 'Scheduler', 'unsupervised-schedular' ),
|
|
__( 'Scheduler', 'unsupervised-schedular' ),
|
|
RoleManager::CAP_VIEW_ALL_LESSONS,
|
|
'us-scheduler',
|
|
[ $this->lessonController, 'renderAdminDashboard' ],
|
|
'dashicons-calendar-alt',
|
|
30
|
|
);
|
|
|
|
// Instructor: manage their own availability.
|
|
add_menu_page(
|
|
__( 'My Availability', 'unsupervised-schedular' ),
|
|
__( 'My Availability', 'unsupervised-schedular' ),
|
|
RoleManager::CAP_MANAGE_AVAILABILITY,
|
|
'us-availability',
|
|
[ $this->availabilityController, 'renderPage' ],
|
|
'dashicons-clock',
|
|
31
|
|
);
|
|
|
|
// Studio admin / instructor: manage offerings.
|
|
add_menu_page(
|
|
__( 'Offerings', 'unsupervised-schedular' ),
|
|
__( 'Offerings', 'unsupervised-schedular' ),
|
|
RoleManager::CAP_MANAGE_OFFERINGS,
|
|
'us-offerings',
|
|
[ $this->offeringController, 'renderPage' ],
|
|
'dashicons-tag',
|
|
33
|
|
);
|
|
|
|
// Studio admin / instructor: manage per-offering intake questions.
|
|
add_submenu_page(
|
|
'us-offerings',
|
|
__( 'Questions', 'unsupervised-schedular' ),
|
|
__( 'Questions', 'unsupervised-schedular' ),
|
|
RoleManager::CAP_MANAGE_QUESTIONS,
|
|
'us-questions',
|
|
[ $this->questionController, 'renderPage' ]
|
|
);
|
|
|
|
// Instructor: view their upcoming lessons.
|
|
add_menu_page(
|
|
__( 'My Lessons', 'unsupervised-schedular' ),
|
|
__( 'My Lessons', 'unsupervised-schedular' ),
|
|
RoleManager::CAP_VIEW_LESSONS,
|
|
'us-my-lessons',
|
|
[ $this->lessonController, 'renderInstructorLessons' ],
|
|
'dashicons-welcome-learn-more',
|
|
32
|
|
);
|
|
}
|
|
}
|