remove old readme
[atutor.git] / mods / _standard / social / lib / OAuth / authorize.php
1 <?php
2 /***********************************************************************/
3 /* ATutor                                                                                                                          */
4 /***********************************************************************/
5 /* Copyright (c) 2002-2010                                             */
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 $_user_location = 'public';
15
16 define('AT_INCLUDE_PATH', '../../../../../include/');
17 require(AT_INCLUDE_PATH.'vitals.inc.php');
18 require_once('OAuth.php');
19 //require_once('../Shindig/ATutorOAuthDataStore.php');
20
21 // log user in.
22 if (!isset($_SESSION['member_id'])){
23         header('Location: ../../../../../login.php?p='.urlencode($_SERVER['REQUEST_URI']));
24         exit;
25
26
27 try {
28         $request = OAuthRequest::from_request();
29         $token = $request->get_parameter('oauth_token');
30         $callback = $request->get_parameter('oauth_callback');
31         if (! $token) {
32                 echo 'Bad Request - missing oauth_token';
33                 return;
34         }
35         //oauth customized header template
36         $savant->assign('page_title', 'Authentication Page');
37         $savant->assign('lang_code', $_SESSION['lang']);
38         $savant->assign('lang_charset', $myLang->getCharacterSet());
39         $savant->assign('base_path', $_base_path);
40         $savant->assign('base_tmpl_path', $_SERVER['HTTP_HOST']);
41         $savant->assign('theme', $_SESSION['prefs']['PREF_THEME']);
42         $savant->assign('current_date', AT_date(_AT('announcement_date_format')));
43         $savant->assign('just_social', $_config['just_social']);
44         $savant->display('social/oauth/header.tmpl.php');
45
46         //authorize template
47         $savant->assign('token', $token);
48         $savant->assign('callback', $callback);
49         $savant->display('social/oauth/authorize.tmpl.php');
50
51         //oauth customized footer template
52         $savant->display('social/oauth/footer.tmpl.php');
53 } catch (OAuthException $e) {
54   echo $e->getMessage();
55   exit;
56 } catch (Exception $e) {
57   echo $e->getMessage();
58   exit;
59 }
60 ?>