| 1 |
<?php if (! defined('ABSPATH')) exit; // Exit if accessed directly |
| 2 |
#[AllowDynamicProperties] |
| 3 |
class SH4_Calendars_Html_Admin_Controller_Managers |
| 4 |
{ |
| 5 |
public function __construct( |
| 6 |
HC3_Hooks $hooks, |
| 7 |
HC3_Users_Query $usersQuery, |
| 8 |
SH4_Calendars_Query $calendarsQuery, |
| 9 |
SH4_App_Command $appCommand |
| 10 |
) |
| 11 |
{ |
| 12 |
$this->calendarsQuery = $hooks->wrap($calendarsQuery); |
| 13 |
$this->usersQuery = $hooks->wrap($usersQuery); |
| 14 |
$this->appCommand = $hooks->wrap($appCommand); |
| 15 |
} |
| 16 |
|
| 17 |
public function add( $calendarId, $userId ) |
| 18 |
{ |
| 19 |
$calendar = $this->calendarsQuery->findById( $calendarId ); |
| 20 |
$user = $this->usersQuery->findById( $userId ); |
| 21 |
|
| 22 |
$this->appCommand->addManagerToCalendar( $user, $calendar ); |
| 23 |
|
| 24 |
$return = array( 'admin/calendars/' . $calendarId . '/managers', '__Manager Added To Calendar__' ); |
| 25 |
return $return; |
| 26 |
} |
| 27 |
|
| 28 |
public function remove( $calendarId, $userId ) |
| 29 |
{ |
| 30 |
$calendar = $this->calendarsQuery->findById( $calendarId ); |
| 31 |
$user = $this->usersQuery->findById( $userId ); |
| 32 |
|
| 33 |
$this->appCommand->removeManagerFromCalendar( $user, $calendar ); |
| 34 |
|
| 35 |
$return = array( '-referrer-', '__Manager Removed From Calendar__' ); |
| 36 |
return $return; |
| 37 |
} |
| 38 |
|
| 39 |
public function addViewer( $calendarId, $userId ) |
| 40 |
{ |
| 41 |
$calendar = $this->calendarsQuery->findById( $calendarId ); |
| 42 |
$user = $this->usersQuery->findById( $userId ); |
| 43 |
|
| 44 |
$this->appCommand->addViewerToCalendar( $user, $calendar ); |
| 45 |
|
| 46 |
$return = array( 'admin/calendars/' . $calendarId . '/managers', '__Viewer Added To Calendar__' ); |
| 47 |
return $return; |
| 48 |
} |
| 49 |
|
| 50 |
public function removeViewer( $calendarId, $userId ) |
| 51 |
{ |
| 52 |
$calendar = $this->calendarsQuery->findById( $calendarId ); |
| 53 |
$user = $this->usersQuery->findById( $userId ); |
| 54 |
|
| 55 |
$this->appCommand->removeViewerFromCalendar( $user, $calendar ); |
| 56 |
|
| 57 |
$return = array( '-referrer-', '__Viewer Removed From Calendar__' ); |
| 58 |
return $return; |
| 59 |
} |
| 60 |
} |