| 1 |
<?php if (! defined('ABSPATH')) exit; // Exit if accessed directly |
| 2 |
class SH4_Notifications_Boot |
| 3 |
{ |
| 4 |
public function __construct( |
| 5 |
HC3_Router $router, |
| 6 |
HC3_Ui $ui, |
| 7 |
HC3_Acl $acl, |
| 8 |
HC3_Notificator $notificator, |
| 9 |
SH4_Notifications_Service $notificationsService, |
| 10 |
HC3_Hooks $hooks |
| 11 |
) |
| 12 |
{ |
| 13 |
$hooks |
| 14 |
->add( 'sh4/users/html/user/view/profile::menu::after', function( $ret ){ |
| 15 |
$ret['notifications'] = array( 'user/profile/notifications', '__Notifications__' ); |
| 16 |
return $ret; |
| 17 |
}) |
| 18 |
|
| 19 |
->add( 'sh4/schedule/html/view/miscoptions::options::after', array('SH4_Notifications_Html_Admin_View_TurnOnoff', 'render') ) |
| 20 |
|
| 21 |
->add( 'sh4/users/html/admin/view/index::listingcell::after', function( $return, $args ) use ( $notificator, $ui ){ |
| 22 |
$notes = array(); |
| 23 |
if( array_key_exists('notes', $return) ){ |
| 24 |
$notes[] = $return['notes']; |
| 25 |
} |
| 26 |
|
| 27 |
$thisView = array(); |
| 28 |
$user = $args[0]; |
| 29 |
$userId = $user->getId(); |
| 30 |
|
| 31 |
$actions = array(); |
| 32 |
if( ! $notificator->isOnForUser($user) ){ |
| 33 |
$thisNote = '__Notifications Turned Off__'; |
| 34 |
$thisView[] = $thisNote; |
| 35 |
$actions['user'] = array( 'admin/users/' . $userId . '/notifications/on', NULL, '__Turn On__' ); |
| 36 |
} |
| 37 |
else { |
| 38 |
$actions['user'] = array( 'admin/users/' . $userId . '/notifications/off', NULL, '__Turn Off Notifications__' ); |
| 39 |
} |
| 40 |
|
| 41 |
$actions = $ui->helperActionsFromArray( $actions ); |
| 42 |
if( $actions ){ |
| 43 |
$actions = $ui->makeListInline( $actions )->gutter(1)->separated(); |
| 44 |
$thisView[] = $actions; |
| 45 |
} |
| 46 |
|
| 47 |
if( $thisView ){ |
| 48 |
$thisView = $ui->makeList($thisView)->gutter(0); |
| 49 |
$notes[] = $thisView; |
| 50 |
} |
| 51 |
|
| 52 |
$notes = $ui->makeList( $notes ); |
| 53 |
|
| 54 |
$return['notes'] = $notes; |
| 55 |
return $return; |
| 56 |
}) |
| 57 |
; |
| 58 |
|
| 59 |
$router |
| 60 |
->register( 'get:admin/notifications/{id}', array('SH4_Notifications_Html_Admin_View_Index', 'render') ) |
| 61 |
|
| 62 |
->register( 'post:admin/notifications/{calendar}/{notification}/enable', array('SH4_Notifications_Html_Admin_Controller_Enable', 'execute') ) |
| 63 |
->register( 'post:admin/notifications/{calendar}/{notification}/disable', array('SH4_Notifications_Html_Admin_Controller_Disable', 'execute') ) |
| 64 |
|
| 65 |
->register( 'get:admin/notifications/{calendar}/{notification}', array('SH4_Notifications_Html_Admin_View_Edit', 'render') ) |
| 66 |
->register( 'post:admin/notifications/{calendar}/{notification}/reset', array('SH4_Notifications_Html_Admin_Controller_Edit', 'executeReset') ) |
| 67 |
->register( 'post:admin/notifications/{calendar}/{notification}', array('SH4_Notifications_Html_Admin_Controller_Edit', 'execute') ) |
| 68 |
|
| 69 |
->register( 'get:user/profile/notifications', array('SH4_Notifications_Html_User_View_Profile_Notifications', 'render') ) |
| 70 |
->register( 'post:user/profile/notifications', array('SH4_Notifications_Html_User_Controller_Profile_Notifications', 'execute') ) |
| 71 |
|
| 72 |
->register( 'post:admin/users/{user}/notifications/on', array('SH4_Notifications_Html_Admin_Users_Controller_Notifications', 'executeOn') ) |
| 73 |
->register( 'post:admin/users/{user}/notifications/off', array('SH4_Notifications_Html_Admin_Users_Controller_Notifications', 'executeOff') ) |
| 74 |
|
| 75 |
->register( 'post:admin/notifications/turnonoff', array('SH4_Notifications_Html_Admin_Controller_Turnonoff', 'execute') ) |
| 76 |
; |
| 77 |
|
| 78 |
$notificationsService |
| 79 |
->register( 'sh4/shifts/command::publish', 'email_manager_publish', 'SH4_Notifications_Email_Manager_Publish', TRUE ) |
| 80 |
->register( 'sh4/shifts/command::publish', 'email_employee_publish', 'SH4_Notifications_Email_Employee_Publish', TRUE ) |
| 81 |
|
| 82 |
->register( 'sh4/shifts/command::draft', 'email_manager_draft', 'SH4_Notifications_Email_Manager_Draft', FALSE ) |
| 83 |
->register( 'sh4/shifts/command::draft', 'email_employee_draft', 'SH4_Notifications_Email_Employee_Draft', FALSE ) |
| 84 |
|
| 85 |
->register( 'sh4/shifts/command::unpublish', 'email_manager_unpublish', 'SH4_Notifications_Email_Manager_Unpublish', FALSE ) |
| 86 |
->register( 'sh4/shifts/command::unpublish', 'email_employee_unpublish', 'SH4_Notifications_Email_Employee_Unpublish', TRUE ) |
| 87 |
|
| 88 |
->register( 'sh4/shifts/command::reschedule', 'email_manager_reschedule', 'SH4_Notifications_Email_Manager_Reschedule', TRUE ) |
| 89 |
->register( 'sh4/shifts/command::reschedule', 'email_employee_reschedule', 'SH4_Notifications_Email_Employee_Reschedule', TRUE ) |
| 90 |
|
| 91 |
->register( 'sh4/shifts/command::delete', 'email_manager_delete', 'SH4_Notifications_Email_Manager_Delete', TRUE ) |
| 92 |
->register( 'sh4/shifts/command::delete', 'email_employee_delete', 'SH4_Notifications_Email_Employee_Delete', TRUE ) |
| 93 |
|
| 94 |
->register( 'sh4/shifts/command::changecalendar', 'email_manager_changecalendar', 'SH4_Notifications_Email_Manager_ChangeCalendar', TRUE ) |
| 95 |
->register( 'sh4/shifts/command::changecalendar', 'email_employee_changecalendar', 'SH4_Notifications_Email_Employee_ChangeCalendar', TRUE ) |
| 96 |
; |
| 97 |
|
| 98 |
$acl |
| 99 |
->register( 'get:user/profile/notifications', array('SH4_App_Acl', 'checkUserProfile') ) |
| 100 |
; |
| 101 |
} |
| 102 |
} |