Advertisement
IzaacJ

Add permissions to UF UserProfile

Dec 7th, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.67 KB | None | 0 0
  1. // This code was added between the $schema and $form definitions. Also corrected typo on $cutomsFields to $customFields
  2.  
  3. foreach($schema->all() as $key => $cfs) {
  4.     // key = field name
  5.     // $cfs = field schema
  6.     if(isset($cfs['permission'])) {
  7.         $vperm = isset($cfs['permission']['view'])?$cfs['permission']['view']:'uri_user';
  8.         $eperm = isset($cfs['permission']['edit'])?$cfs['permission']['edit']:'uri_user';
  9.         if($customProfile->has($key)) {
  10.             if(!$authorizer->checkAccess($currentUser, $vperm, ['user' => $user])) {
  11.                 $customProfile->offsetUnset($key);
  12.                 $schema->offsetUnset($key);
  13.             }
  14.         }
  15.     }
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement