Changeset 2214469
- Timestamp:
- 12/18/2019 05:43:27 PM (6 years ago)
- Location:
- shiftcontroller/trunk
- Files:
-
- 6 edited
-
readme.txt (modified) (1 diff)
-
sh4/app/query.php (modified) (1 diff)
-
sh4/schedule/html/view/common.php (modified) (7 diffs)
-
sh4/shifts/acl.php (modified) (2 diffs)
-
sh4/shifts/boot.php (modified) (1 diff)
-
shiftcontroller4.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
shiftcontroller/trunk/readme.txt
r2212879 r2214469 60 60 61 61 == Changelog == 62 63 = 4.5.5 = 64 * BUG: Employees could see shifts from other calendars that they are not allowed to participate in. 62 65 63 66 = 4.5.4 = -
shiftcontroller/trunk/sh4/app/query.php
r2107416 r2214469 8 8 public function findManagersForCalendar( SH4_Calendars_Model $calendar ); 9 9 public function findCalendarsManagedByUser( HC3_Users_Model $user ); 10 public function findCalendarsViewedByUser( HC3_Users_Model $user ); 10 11 11 12 public function findEmployeesForCalendar( SH4_Calendars_Model $calendar ); -
shiftcontroller/trunk/sh4/schedule/html/view/common.php
r2170467 r2214469 111 111 ->gutter(1) 112 112 ; 113 114 113 } 115 114 … … 132 131 $currentUserId = $currentUser->getId(); 133 132 133 $meEmployeeId = NULL; 134 $meEmployeeCalendars = array(); 135 134 136 $meEmployee = $this->appQuery->findEmployeeByUser( $currentUser ); 135 $meEmployeeId = $meEmployee ? $meEmployee->getId() : NULL; 137 if( $meEmployee ){ 138 $meEmployeeId = $meEmployee->getId(); 139 $meEmployeeCalendars = $this->appQuery->findCalendarsForEmployee( $meEmployee ); 140 } 136 141 137 142 $myManagedCalendars = array(); … … 188 193 // is other employee 189 194 if( $meEmployeeId != $shiftEmployeeId ){ 195 196 if( ! isset($meEmployeeCalendars[$shiftCalendarId]) ){ 197 unset( $return[$id] ); 198 continue; 199 } 200 190 201 if( $shift->isOpen() ){ 191 202 $permName = $shift->isPublished() ? 'employee_view_open_publish' : 'employee_view_open_draft'; … … 194 205 $permName = $shift->isPublished() ? 'employee_view_others_publish' : 'employee_view_others_draft'; 195 206 } 207 196 208 $perm = $this->calendarsPermissions->get( $shiftCalendar, $permName ); 197 209 if( ! $perm ){ … … 323 335 } 324 336 337 $calendarsForEmployee = array(); 325 338 if( $employee ){ 326 $ thisReturn= $this->appQuery->findCalendarsForEmployee( $employee );327 $allowed = $allowed + $ thisReturn;339 $calendarsForEmployee = $this->appQuery->findCalendarsForEmployee( $employee ); 340 $allowed = $allowed + $calendarsForEmployee; 328 341 } 329 342 330 343 foreach( $return as $calendar ){ 344 $calendarId = $calendar->getId(); 345 331 346 $permNames = array(); 332 347 $permNames[] = 'visitor_view_others_publish'; 333 348 $permNames[] = 'visitor_view_others_draft'; 349 334 350 if( $currentUserId ){ 351 if( ! isset($calendarsForEmployee[$currentUserId]) ){ 352 continue; 353 } 335 354 $permNames[] = 'employee_view_others_publish'; 336 355 $permNames[] = 'employee_view_others_draft'; … … 341 360 $perm = $this->calendarsPermissions->get( $calendar, $permName ); 342 361 if( $perm ){ 343 $calendarId = $calendar->getId();344 362 $allowed[ $calendarId ] = $calendar; 345 363 break; … … 350 368 $ids = array_keys( $return ); 351 369 foreach( $ids as $id ){ 352 if( ! array_key_exists($id, $allowed) ){ 370 // if( ! array_key_exists($id, $allowed) ){ 371 if( ! isset($allowed[$id]) ){ 353 372 unset( $return[$id] ); 354 373 } -
shiftcontroller/trunk/sh4/shifts/acl.php
r1986586 r2214469 2 2 interface SH4_Shifts_IAcl 3 3 { 4 public function checkView( $shiftId ); 4 5 public function checkCreate( $shiftId ); 5 6 public function checkCreateDraft( $shiftId ); … … 265 266 return $return; 266 267 } 268 269 public function checkView( $shiftId ) 270 { 271 $return = FALSE; 272 273 $shift = $this->shiftsQuery->findById( $shiftId ); 274 $calendar = $shift->getCalendar(); 275 $calendarId = $calendar->getId(); 276 277 $currentUser = $this->auth->getCurrentUser(); 278 if( ! $currentUser ){ 279 if( $shift->isOpen() ){ 280 $permName = $shift->isPublished() ? 'visitor_view_open_publish' : 'visitor_view_open_draft'; 281 } 282 else { 283 $permName = $shift->isPublished() ? 'visitor_view_others_publish' : 'visitor_view_others_draft'; 284 } 285 286 $perm = $this->calendarsPermissions->get( $calendar, $permName ); 287 if( $perm ){ 288 $return = TRUE; 289 } 290 291 return $return; 292 } 293 294 if( $this->permission->isAdmin($currentUser) ){ 295 $return = TRUE; 296 return $return; 297 } 298 299 $calendarsAsManager = $this->appQuery->findCalendarsManagedByUser( $currentUser ); 300 if( isset($calendarsAsManager[$calendarId]) ){ 301 $return = TRUE; 302 return $return; 303 } 304 305 $calendarsAsViewer = $this->appQuery->findCalendarsViewedByUser( $currentUser ); 306 if( isset($calendarsAsViewer[$calendarId]) ){ 307 $return = TRUE; 308 return $return; 309 } 310 311 $meEmployee = $this->appQuery->findEmployeeByUser( $currentUser ); 312 313 if( ! $meEmployee ){ 314 return $return; 315 } 316 317 $employeeCalendars = $this->appQuery->findCalendarsForEmployee( $meEmployee ); 318 if( ! isset($employeeCalendars[$calendarId]) ){ 319 return $return; 320 } 321 322 $shiftEmployee = $shift->getEmployee(); 323 $shiftEmployeeId = $shiftEmployee->getId(); 324 325 $meEmployeeId = $meEmployee->getId(); 326 327 if( $meEmployeeId == $shiftEmployeeId ){ 328 $return = TRUE; 329 return $return; 330 } 331 332 if( $shift->isOpen() ){ 333 $permName = $shift->isPublished() ? 'employee_view_open_publish' : 'employee_view_open_draft'; 334 } 335 else { 336 $permName = $shift->isPublished() ? 'employee_view_others_publish' : 'employee_view_others_draft'; 337 } 338 $perm = $this->calendarsPermissions->get( $calendar, $permName ); 339 340 if( $perm ){ 341 $return = TRUE; 342 } 343 344 return $return; 345 } 267 346 } -
shiftcontroller/trunk/sh4/shifts/boot.php
r1986586 r2214469 45 45 ->register( 'get:shifts/{id}/time', array('SH4_Shifts_Acl', 'checkChangeTime') ) 46 46 ->register( 'post:shifts/{id}/time/{start}/{end}', array('SH4_Shifts_Acl', 'checkChangeTime') ) 47 48 ->register( 'get:shifts/{id}', array('SH4_Shifts_Acl', 'checkView') ) 47 49 ; 48 50 } -
shiftcontroller/trunk/shiftcontroller4.php
r2212879 r2214469 4 4 * Plugin URI: http://www.shiftcontroller.com/ 5 5 * Description: Staff scheduling plugin 6 * Version: 4.5. 46 * Version: 4.5.5 7 7 * Author: hitcode.com 8 8 * Author URI: http://www.shiftcontroller.com/ … … 11 11 */ 12 12 13 define( 'SH4_VERSION', 45 4);13 define( 'SH4_VERSION', 455 ); 14 14 15 15 if (! defined('ABSPATH')) exit; // Exit if accessed directly
Note: See TracChangeset
for help on using the changeset viewer.