Subversion Repositories php_users

Rev

Rev 16 | Rev 18 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 16 Rev 17
Line 326... Line 326...
326
            $this->configuration['tables']['permissions']['table'],
326
            $this->configuration['tables']['permissions']['table'],
327
            $this->configuration['tables']['permissions']['id']
327
            $this->configuration['tables']['permissions']['id']
328
            );
328
            );
329
            $this->doSQL($query, true );
329
            $this->doSQL($query, true );
330
      } // setUsersPermissions
330
      } // setUsersPermissions
-
 
331
      
-
 
332
      public function getARecord( $whereFields, $fieldList = null ) {
-
 
333
         $id = isset( $whereFields['id'] ) ? $whereFields['id'] : null;
-
 
334
         $result = parent::getARecord( $whereFields, $fieldList );
-
 
335
         if ( $result && isset( $id ) ) {
-
 
336
            $result['permissions'] = $this->getPermissions( $id );
-
 
337
         }
-
 
338
         return $result;
-
 
339
      }
-
 
340
      
-
 
341
      public function getPermissions ( $id ) {
-
 
342
         $query = ( 
-
 
343
            $id == -1 ?
-
 
344
               "select name permission,default_value value from _permissions" :
-
 
345
               "select permission,value from _view_users_permissions where users_id = $id"
-
 
346
         );
-
 
347
         $results = $this->doSQL( $query );
-
 
348
         $values = $results->fetch_all(MYSQLI_ASSOC);
-
 
349
         return array_column( $values, 'value', 'permission' );
-
 
350
      }
-
 
351
       
-
 
352
      public function getFullPermissions( $id ) {
-
 
353
         $query = (
-
 
354
            $id == -1 ?
-
 
355
               "select _permission_id permission_id, _permissions.name permission, description, _permissions_categories.name category, default_value value from _permissions join _permissions_categories using (_permission_category_id)" :
-
 
356
               "select permission_id,permission,description,category,value from _view_users_permissions where users_id = $id order by category,description"
-
 
357
         );
-
 
358
         $results = $this->doSQL( $query );
-
 
359
         return $results->fetch_all(MYSQLI_ASSOC);
-
 
360
      }
-
 
361
      
-
 
362
      public function updatePermissions ( $userID,$newData ) {
-
 
363
         $query = '';
-
 
364
         foreach ( $newData as $key => $value ) {
-
 
365
            $query = "insert into _permissions ( _user_id,_permission_id,value) select $userID, _permission_id, $value from _permissions where name = 'key' on duplicate key update value = $value";
-
 
366
            $this->doSQL( $query, true );
331
         
367
         }
-
 
368
      } // update
332
 
369
 
333
}
370
}
334
 
371
 
335
?>
372
?>