PluginProbe
ShiftController Employee Shift Scheduling / 4.9.26
ShiftController Employee Shift Scheduling v4.9.26
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
← All changes | sh4/app/command.php +9 -45 trunk4.9.26 View file →
@@ -20,10 +20,8 @@
20 20 }
21 21
22 22 class SH4_App_Command implements SH4_App_ICommand
23 23 {
24 - public $self, $crudFactory, $settings, $shiftTypesCommand, $calendarsCommand, $employeesCommand, $shiftsCommand;
25 -
26 24 public function __construct(
27 25 HC3_CrudFactory $crudFactory,
28 26 HC3_Settings $settings,
29 27 HC3_Hooks $hooks,
@@ -35,21 +33,22 @@
35 33 )
36 34 {
37 35 $this->crudFactory = $hooks->wrap( $crudFactory );
38 36 $this->settings = $hooks->wrap( $settings );
37 +
38 + $this->settings = $hooks->wrap( $settings );
39 39 $this->shiftTypesCommand = $hooks->wrap( $shiftTypesCommand );
40 40 $this->calendarsCommand = $hooks->wrap( $calendarsCommand );
41 41 $this->employeesCommand = $hooks->wrap( $employeesCommand );
42 42 $this->shiftsCommand = $hooks->wrap( $shiftsCommand );
43 - $this->self = $hooks->wrap( $this );
44 43 }
45 44
46 45 public function uninstall()
47 46 {
48 - // $this->shiftTypesCommand->deleteAll();
49 - // $this->calendarsCommand->deleteAll();
50 - // $this->employeesCommand->deleteAll();
51 - // $this->shiftsCommand->deleteAll();
47 + $this->shiftTypesCommand->deleteAll();
48 + $this->calendarsCommand->deleteAll();
49 + $this->employeesCommand->deleteAll();
50 + $this->shiftsCommand->deleteAll();
52 51 $this->settings->resetAll();
53 52 }
54 53
55 54 public function addManagerToCalendar( HC3_Users_Model $user, SH4_Calendars_Model $calendar )
@@ -58,16 +57,8 @@
58 57 $calendarId = $calendar->getId();
59 58 $settingName = 'calendar_' . $calendarId . '_manager';
60 59
61 60 $managersIds = $this->settings->get( $settingName, TRUE );
62 -
63 - $iis = array_keys( $managersIds );
64 - foreach( $iis as $ii ){
65 - if( ! is_numeric($managersIds[$ii]) ){
66 - unset( $managersIds[$ii] );
67 - }
68 - }
69 -
70 61 if( ! in_array($userId, $managersIds) ){
71 62 $managersIds[] = $userId;
72 63 }
73 64
@@ -92,16 +83,8 @@
92 83 $calendarId = $calendar->getId();
93 84 $settingName = 'calendar_' . $calendarId . '_viewer';
94 85
95 86 $managersIds = $this->settings->get( $settingName, TRUE );
96 -
97 - $iis = array_keys( $managersIds );
98 - foreach( $iis as $ii ){
99 - if( ! is_numeric($managersIds[$ii]) ){
100 - unset( $managersIds[$ii] );
101 - }
102 - }
103 -
104 87 if( ! in_array($userId, $managersIds) ){
105 88 $managersIds[] = $userId;
106 89 }
107 90
@@ -126,16 +109,8 @@
126 109 $calendarId = $calendar->getId();
127 110 $settingName = 'calendar_' . $calendarId . '_employee';
128 111
129 112 $employeesIds = $this->settings->get( $settingName, TRUE );
130 -
131 - $iis = array_keys( $employeesIds );
132 - foreach( $iis as $ii ){
133 - if( ! is_numeric($employeesIds[$ii]) ){
134 - unset( $employeesIds[$ii] );
135 - }
136 - }
137 -
138 113 if( ! in_array($employeeId, $employeesIds) ){
139 114 $employeesIds[] = $employeeId;
140 115 }
141 116
@@ -148,16 +123,8 @@
148 123 $calendarId = $calendar->getId();
149 124 $settingName = 'calendar_' . $calendarId . '_shifttype';
150 125
151 126 $shiftTypesIds = $this->settings->get( $settingName, TRUE );
152 -
153 - $iis = array_keys( $shiftTypesIds );
154 - foreach( $iis as $ii ){
155 - if( ! is_numeric($shiftTypesIds[$ii]) ){
156 - unset( $shiftTypesIds[$ii] );
157 - }
158 - }
159 -
160 127 if( ! in_array($shiftTypeId, $shiftTypesIds) ){
161 128 $shiftTypesIds[] = $shiftTypeId;
162 129 }
163 130
@@ -187,14 +154,16 @@
187 154
188 155 $this->settings->set( $settingName, $employeesIds );
189 156 }
190 157
191 - public function linkEmployeeToUserById( $employeeId, $userId )
158 + public function linkEmployeeToUser( SH4_Employees_Model $employee, HC3_Users_Model $user )
192 159 {
160 + $employeeId = $employee->getId();
193 161 if( ! $employeeId ){
194 162 return;
195 163 }
196 164
165 + $userId = $user->getId();
197 166 if( ! $userId ){
198 167 return;
199 168 }
200 169
@@ -201,13 +170,8 @@
201 170 $crud = $this->crudFactory->make('employee');
202 171
203 172 $values = array( 'user_id' => $userId );
204 173 $results = $crud->update( $employeeId, $values );
205 - }
206 -
207 - public function linkEmployeeToUser( SH4_Employees_Model $employee, HC3_Users_Model $user )
208 - {
209 - return $this->self->linkEmployeeToUserById( $employee->getId(), $user->getId() );
210 174 }
211 175
212 176 public function unlinkEmployeeFromUser( SH4_Employees_Model $employee )
213 177 {