Xataface  2.0alpha2
Xataface Application Framework
 All Data Structures Namespaces Files Functions Variables Groups Pages
ajax_set_preference.php
Go to the documentation of this file.
1 <?php
3  function handle(&$params){
5  $record =& $app->getRecord();
6  $out = array();
7  if ( !isset($_POST['--name']) ){
8  $out['error'] = 'No name specified';
9  $this->respond($out);
10  exit;
11  }
12 
13  if ( !isset($_POST['--value']) ){
14  $out['error'] = 'No value specified';
15  $this->respond($out);
16  exit;
17  }
18 
19  if ( isset($_POST['--record_id']) ){
20  $recordid = $_POST['--record_id'];
21  } else {
22  $recordid = $recordd->getId();
23  }
24 
25  import('Dataface/PreferencesTool.php');
27 
28  $pt->savePreference($recordid, $_POST['--name'], $_POST['--value']);
29  $out['message'] = 'Successfully saved preference '.$_POST['--name'].' to '.$_POST['--value'].' for '.$recordid;
30  $this->respond($out);
31 
32  }
33 
34  function respond($out){
35  import('Services/JSON.php');
36  $json = new Services_JSON;
37 
38  header('Content-type: application/json');
39  echo $json->encode($out);
40  exit;
41 
42  }
43 }