PluginProbe
ShiftController Employee Shift Scheduling / 4.9.85
ShiftController Employee Shift Scheduling v4.9.85
4.9.97 4.9.96 4.9.95 4.9.74 4.9.75 4.9.76 4.9.77 4.9.78 4.9.84 4.9.85 4.9.87 4.9.91 4.9.92 trunk 2.1.0 2.1.1 2.1.2 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.6 3.2.4 All 38 releases
shiftcontroller / sh4 / calendars / html / admin / view / permissions.php

permissions.php in ShiftController Employee Shift Scheduling 4.9.85, at sh4/calendars/html/admin/view/permissions.php

116 lines 3.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php if (! defined('ABSPATH')) exit; // Exit if accessed directly
2 #[AllowDynamicProperties]
3 class SH4_Calendars_Html_Admin_View_Permissions
4 {
5 public function __construct(
6 HC3_Hooks $hooks,
7 HC3_Ui $ui,
8 HC3_Ui_Layout1 $layout,
9
10 SH4_Calendars_Permissions $calendarsPermissions,
11 SH4_Calendars_Query $calendarsQuery,
12 SH4_Calendars_Presenter $calendarsPresenter
13 )
14 {
15 $this->self = $hooks->wrap($this);
16 $this->ui = $ui;
17 $this->layout = $layout;
18
19 $this->cp = $hooks->wrap( $calendarsPermissions );
20 $this->calendarsQuery = $hooks->wrap( $calendarsQuery );
21 $this->calendarsPresenter = $hooks->wrap( $calendarsPresenter );
22 $this->calendarsPermissions = $hooks->wrap( $calendarsPermissions );
23 }
24
25 public function render( $id )
26 {
27 $calendar = $this->calendarsQuery->findById($id);
28 $permissionsOptions = $this->calendarsPermissions->options();
29
30 $options = array();
31 foreach( $permissionsOptions as $o ){
32 $label = array_shift( $o );
33 $employeeOption = array_shift( $o );
34 $visitorOption = array_shift( $o );
35 $employee2Option = array_shift( $o );
36 // list( $label, $employeeOption, $visitorOption ) = $o;
37
38 $option = array();
39 $option[] = $label;
40 $option[] = $employeeOption ? $employeeOption[0] : NULL;
41 $option[] = $visitorOption ? $visitorOption[0] : NULL;
42 $option[] = $employee2Option ? $employee2Option[0] : NULL;
43
44 $options[] = $option;
45 }
46
47 $header = array(
48 'action' => NULL,
49 'employee' => '<div class="hc-align-center">' . '__Calendar Employees__' . '</div>',
50 'employee2' => '<div class="hc-align-center">' . '__Other Employees__' . '</div>',
51 'visitor' => '<div class="hc-align-center">' . '__Visitor__' . '</div>',
52 );
53
54 $rows = array();
55 foreach( $options as $k => $conf ){
56 list( $label, $kEmployee, $kVisitor, $kEmployee2 ) = $conf;
57
58 $row = array(
59 'action' => $label,
60 'employee' => $kEmployee ? $this->ui->makeInputCheckbox( $kEmployee, NULL, 1, $this->cp->get($calendar, $kEmployee) ) : NULL,
61 'visitor' => $kVisitor ? $this->ui->makeInputCheckbox( $kVisitor, NULL, 1, $this->cp->get($calendar, $kVisitor) ) : NULL,
62 'employee2' => $kEmployee2 ? $this->ui->makeInputCheckbox( $kEmployee2, NULL, 1, $this->cp->get($calendar, $kEmployee2) ) : NULL,
63 );
64
65 $keys = array_keys( $row );
66 foreach( $keys as $kk ){
67 if( 'action' === $kk ) continue;
68 if( isset($row[$kk]) ){
69 $row[$kk] = '<label class="hc-block hc-align-center">' . $row[$kk] . '</label>';
70 }
71 }
72
73 $rows[] = $row;
74 }
75
76 $out = $this->ui->makeTable( $header, $rows );
77
78 $buttons = $this->ui->makeInputSubmit( '__Save__')
79 ->tag('primary')
80 ;
81 $out = $this->ui->makeList( array($out, $buttons) );
82
83 $out = $this->ui->makeForm(
84 'admin/calendars/' . $id . '/prm',
85 $out
86 );
87
88 $this->layout
89 ->setContent( $out )
90 ->setBreadcrumb( $this->self->breadcrumb($calendar) )
91 ->setHeader( $this->self->header($calendar) )
92 ;
93
94 $out = $this->layout->render();
95 return $out;
96 }
97
98 public function header( SH4_Calendars_Model $model )
99 {
100 $out = '__Permissions__';
101 return $out;
102 }
103
104 public function breadcrumb( SH4_Calendars_Model $model )
105 {
106 $calendarId = $model->getId();
107 $calendarTitle = $this->calendarsPresenter->presentTitle( $model );
108
109 $return = array();
110 $return['admin'] = array( 'admin', '__Administration__' );
111 $return['calendars'] = array( 'admin/calendars', '__Calendars__' );
112 $return['calendars/edit'] = $calendarTitle;
113 return $return;
114 }
115 }
116