Xataface  2.0alpha2
Xataface Application Framework
 All Data Structures Namespaces Files Functions Variables Groups Pages
ajax_get_permissions.php
Go to the documentation of this file.
1 <?php
3 
4  function handle($params){
5 
6  session_write_close();
7  header('Connection:close');
8 
10  $query = $app->getQuery();
11 
12  if ( @$query['--id'] ){
13  $table = Dataface_Table::loadTable($query['-table']);
14  $keys = array_keys($table->keys());
15  if ( count($keys) > 1 ){
16  throw new Exception("Table has compound key so its permissions cannot be retrieved with the --id parameter.");
17  }
18  $query[$keys[0]] = '='.$query['--id'];
19  $record = df_get_record($query['-table'], $query);
20  } else {
21 
22  $record = $app->getRecord();
23  }
24  $perms = array();
25  if ( $record ) $perms = $record->getPermissions();
26 
27  header('Content-type: application/json; charset="'.$app->_conf['oe'].'"');
28  $out = json_encode($perms);
29  header('Content-Length: '.strlen($out));
30  echo $out;
31  flush();
32  }
33 }