remove old readme
[atutor.git] / docs / mods / _standard / social / set_prefs.php
1 <?php
2 /****************************************************************/
3 /* ATutor                                                                                                               */
4 /****************************************************************/
5 /* Copyright (c) 2002-2009                                                                              */
6 /* Inclusive Design Institute                                   */
7 /* http://atutor.ca                                                                                             */
8 /*                                                              */
9 /* This program is free software. You can redistribute it and/or*/
10 /* modify it under the terms of the GNU General Public License  */
11 /* as published by the Free Software Foundation.                                */
12 /****************************************************************/
13 // $Id$
14
15 define('AT_INCLUDE_PATH', '../../../include/');
16 $_user_location = 'public';
17 include(AT_INCLUDE_PATH.'vitals.inc.php');
18 include(AT_SOCIAL_INCLUDE.'classes/Application.class.php');
19
20 if (empty($_GET['st']) || empty($_GET['name']) || ! isset($_GET['value'])) {
21   header("HTTP/1.0 400 Bad Request", true);
22   echo "<html><body><h1>400 - Bad Request</h1></body></html>";
23 } else {
24   try {
25         $st = urldecode(base64_decode($_GET['st']));
26         $key = urldecode($_GET['name']);
27         $value = urldecode($_GET['value']);
28         $token = BasicSecurityToken::createFromToken($st, 15*60);       //TODO: Change 3600 to a constant
29         $app_id = $token->getAppId();
30 //      $viewer = $token->getViewerId();
31         debug($app_id,'appid');
32         debug($viewer, 'viewer');
33         debug($value, 'value');
34         debug($key,'key');
35         $app = new Application($app_id);
36
37         $result = $app->setApplicationSettings($_SESSION['member_id'], $key, $value);
38         if (!$result){
39                 echo "<html><body><h1>500 - SQL Error: </h1>" . mysql_error() . "</body></html>";
40         }
41
42   } catch (Exception $e) {
43         header("HTTP/1.0 400 Bad Request", true);
44         echo "<html><body><h1>400 - Bad Request</h1>" . $e->getMessage() . "</body></html>";
45   }
46 }
47 ?>