Xataface 2.0
Xataface Application Framework
actions/ajax_get_permissions.php
Go to the documentation of this file.
00001 <?php
00002 class dataface_actions_ajax_get_permissions {
00003 
00004         function handle($params){
00005         
00006                 session_write_close();
00007                 header('Connection:close');
00008                 
00009                 $app = Dataface_Application::getInstance();
00010                 $query = $app->getQuery();
00011                 
00012                 if ( @$query['--id'] ){
00013                         $table = Dataface_Table::loadTable($query['-table']);
00014                         $keys = array_keys($table->keys());
00015                         if ( count($keys) > 1 ){
00016                                 throw new Exception("Table has compound key so its permissions cannot be retrieved with the --id parameter.");
00017                         }
00018                         $query[$keys[0]] = '='.$query['--id'];
00019                         $record = df_get_record($query['-table'], $query);
00020                 } else {
00021                 
00022                         $record = $app->getRecord();
00023                 }
00024                 $perms = array();
00025                 if ( $record ) $perms = $record->getPermissions();
00026                 
00027                 header('Content-type: text/json; charset="'.$app->_conf['oe'].'"');
00028                 $out = json_encode($perms);
00029                 header('Content-Length: '.strlen($out));
00030                 echo $out;
00031                 flush();
00032         }
00033 }
 All Data Structures Namespaces Files Functions Variables Enumerations