Example #1
0
 public function isAuthorised($permissonSet, $permissionKey)
 {
     if ($permissonSet) {
         $userPermissions = explode('|', $permissonSet);
         $permissionSetController = new PermissionSetController();
         $permissions = $permissionSetController->getPermissionsStdObj();
         foreach ($userPermissions as $key => $value) {
             if ($permissions->{$value} == $permissionKey) {
                 return true;
             }
         }
     }
     return FALSE;
 }
Example #2
0
 public function editUser()
 {
     $restaurantId = parent::readCookie('cri');
     $requestData = $this->request->data;
     $userRoleController = new UserRoleController();
     $userRoles = $userRoleController->getUserRole();
     $permissionSetController = new PermissionSetController();
     $permission = $permissionSetController->getPermissionSet();
     if ($this->request->is('post') and isset($requestData['edit'])) {
         $stdUser = new \stdClass();
         foreach ($requestData as $key => $value) {
             $stdUser->{$key} = $value;
         }
         $this->set(['userInfo' => $stdUser, 'roles' => $userRoles, 'permissions' => $permission]);
     } elseif ($this->request->is('post') and isset($requestData['save'])) {
         $user_permission = $requestData['permi'];
         Log::debug('permission from form' . $user_permission);
         $data = explode(',', $user_permission);
         $saparator = '|';
         $userPermission = implode($saparator, $data);
         $userUploadDto = new DownloadDTO\UserDownloadDto($requestData['uid'], $requestData['userName'], $requestData['password'], ACTIVE, $requestData['userRole'], $restaurantId, $userPermission);
         Log::debug('User Permission :-' . $userPermission);
         $insertResult = $this->getTbaleObj()->insert($userUploadDto);
         if ($insertResult) {
             $newUser = $this->getTbaleObj()->getNewUser($userUploadDto->userId);
             $this->makeSyncEntry($userUploadDto->userId, json_encode($newUser), UPDATE_OPERATION, $restaurantId);
             $this->redirect('manage/users');
         } else {
             $this->set([MESSAGE => DTO\ErrorDto::prepareMessage(133), COLOR => ERROR_COLOR, 'permissions' => $permission, 'roles' => $userRoles]);
         }
     }
 }