Xataface 2.0
Xataface Application Framework
actions/ajax_set_preference.php
Go to the documentation of this file.
00001 <?php
00002 class dataface_actions_ajax_set_preference {
00003         function handle(&$params){
00004                 $app =& Dataface_Application::getInstance();
00005                 $record =& $app->getRecord();
00006                 $out = array();
00007                 if ( !isset($_POST['--name']) ){
00008                         $out['error'] = 'No name specified';
00009                         $this->respond($out);
00010                         exit;
00011                 }
00012                 
00013                 if ( !isset($_POST['--value']) ){
00014                         $out['error'] = 'No value specified';
00015                         $this->respond($out);
00016                         exit;
00017                 }
00018                 
00019                 if ( isset($_POST['--record_id']) ){
00020                         $recordid = $_POST['--record_id'];
00021                 } else {
00022                         $recordid = $recordd->getId();
00023                 }
00024                 
00025                 import('Dataface/PreferencesTool.php');
00026                 $pt =& Dataface_PreferencesTool::getInstance();
00027                 
00028                 $pt->savePreference($recordid, $_POST['--name'], $_POST['--value']);
00029                 $out['message'] = 'Successfully saved preference '.$_POST['--name'].' to '.$_POST['--value'].' for '.$recordid;
00030                 $this->respond($out);
00031                 
00032         }
00033         
00034         function respond($out){
00035                 import('Services/JSON.php');
00036                 $json = new Services_JSON;
00037                 
00038                 header('Content-type: text/json');
00039                 echo $json->encode($out);
00040                 exit;
00041                 
00042         }
00043 }
 All Data Structures Namespaces Files Functions Variables Enumerations