Plugin Directory

Changeset 2214469


Ignore:
Timestamp:
12/18/2019 05:43:27 PM (6 years ago)
Author:
hitcode
Message:

4.5.5

Location:
shiftcontroller/trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • shiftcontroller/trunk/readme.txt

    r2212879 r2214469  
    6060
    6161== Changelog ==
     62
     63= 4.5.5 =
     64* BUG: Employees could see shifts from other calendars that they are not allowed to participate in.
    6265
    6366= 4.5.4 =
  • shiftcontroller/trunk/sh4/app/query.php

    r2107416 r2214469  
    88    public function findManagersForCalendar( SH4_Calendars_Model $calendar );
    99    public function findCalendarsManagedByUser( HC3_Users_Model $user );
     10    public function findCalendarsViewedByUser( HC3_Users_Model $user );
    1011
    1112    public function findEmployeesForCalendar( SH4_Calendars_Model $calendar );
  • shiftcontroller/trunk/sh4/schedule/html/view/common.php

    r2170467 r2214469  
    111111                ->gutter(1)
    112112                ;
    113 
    114113        }
    115114
     
    132131        $currentUserId = $currentUser->getId();
    133132
     133        $meEmployeeId = NULL;
     134        $meEmployeeCalendars = array();
     135
    134136        $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        }
    136141
    137142        $myManagedCalendars = array();
     
    188193        // is other employee
    189194            if( $meEmployeeId != $shiftEmployeeId ){
     195
     196                if( ! isset($meEmployeeCalendars[$shiftCalendarId]) ){
     197                    unset( $return[$id] );
     198                    continue;
     199                }
     200
    190201                if( $shift->isOpen() ){
    191202                    $permName = $shift->isPublished() ? 'employee_view_open_publish' : 'employee_view_open_draft';
     
    194205                    $permName = $shift->isPublished() ? 'employee_view_others_publish' : 'employee_view_others_draft';
    195206                }
     207
    196208                $perm = $this->calendarsPermissions->get( $shiftCalendar, $permName );
    197209                if( ! $perm ){
     
    323335        }
    324336
     337        $calendarsForEmployee = array();
    325338        if( $employee ){
    326             $thisReturn = $this->appQuery->findCalendarsForEmployee( $employee );
    327             $allowed = $allowed + $thisReturn;
     339            $calendarsForEmployee = $this->appQuery->findCalendarsForEmployee( $employee );
     340            $allowed = $allowed + $calendarsForEmployee;
    328341        }
    329342
    330343        foreach( $return as $calendar ){
     344            $calendarId = $calendar->getId();
     345
    331346            $permNames = array();
    332347            $permNames[] = 'visitor_view_others_publish';
    333348            $permNames[] = 'visitor_view_others_draft';
     349
    334350            if( $currentUserId ){
     351                if( ! isset($calendarsForEmployee[$currentUserId]) ){
     352                    continue;
     353                }
    335354                $permNames[] = 'employee_view_others_publish';
    336355                $permNames[] = 'employee_view_others_draft';
     
    341360                $perm = $this->calendarsPermissions->get( $calendar, $permName );
    342361                if( $perm ){
    343                     $calendarId = $calendar->getId();
    344362                    $allowed[ $calendarId ] = $calendar;
    345363                    break;
     
    350368        $ids = array_keys( $return );
    351369        foreach( $ids as $id ){
    352             if( ! array_key_exists($id, $allowed) ){
     370            // if( ! array_key_exists($id, $allowed) ){
     371            if( ! isset($allowed[$id]) ){
    353372                unset( $return[$id] );
    354373            }
  • shiftcontroller/trunk/sh4/shifts/acl.php

    r1986586 r2214469  
    22interface SH4_Shifts_IAcl
    33{
     4    public function checkView( $shiftId );
    45    public function checkCreate( $shiftId );
    56    public function checkCreateDraft( $shiftId );
     
    265266        return $return;
    266267    }
     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    }
    267346}
  • shiftcontroller/trunk/sh4/shifts/boot.php

    r1986586 r2214469  
    4545            ->register( 'get:shifts/{id}/time', array('SH4_Shifts_Acl', 'checkChangeTime') )
    4646            ->register( 'post:shifts/{id}/time/{start}/{end}', array('SH4_Shifts_Acl', 'checkChangeTime') )
     47
     48            ->register( 'get:shifts/{id}', array('SH4_Shifts_Acl', 'checkView') )
    4749            ;
    4850    }
  • shiftcontroller/trunk/shiftcontroller4.php

    r2212879 r2214469  
    44 * Plugin URI: http://www.shiftcontroller.com/
    55 * Description: Staff scheduling plugin
    6  * Version: 4.5.4
     6 * Version: 4.5.5
    77 * Author: hitcode.com
    88 * Author URI: http://www.shiftcontroller.com/
     
    1111*/
    1212
    13 define( 'SH4_VERSION', 454 );
     13define( 'SH4_VERSION', 455 );
    1414
    1515if (! defined('ABSPATH')) exit; // Exit if accessed directly
Note: See TracChangeset for help on using the changeset viewer.