source: extensions/oAuth/include/functions.inc.php @ 26604

Last change on this file since 26604 was 26604, checked in by mistic100, 10 years ago

clean templating + allow to use Steam/Wordpress/Flickr without displaying OpenID

File size: 1.6 KB
Line 
1<?php
2defined('OAUTH_PATH') or die('Hacking attempt!');
3
4function load_hybridauth_conf()
5{
6  global $hybridauth_conf, $conf;
7 
8  if (file_exists(PHPWG_ROOT_PATH.OAUTH_CONFIG))
9  {
10    $hybridauth_conf = include(PHPWG_ROOT_PATH.OAUTH_CONFIG);
11    $hybridauth_conf['base_url'] = OAUTH_PUBLIC;
12    if (!empty($conf['oauth_debug_file']))
13    {
14      $hybridauth_conf['debug_mode'] = true;
15      $hybridauth_conf['debug_file'] = $conf['oauth_debug_file'];
16    }
17    return true;
18  }
19  else
20  {
21    return false;
22  }
23}
24
25function oauth_assign_template_vars($u_redirect=null)
26{
27  global $template, $conf, $hybridauth_conf;
28 
29  $conf['oauth']['include_common_template'] = true;
30 
31  if ($template->get_template_vars('OAUTH') == null)
32  {
33    $template->assign('OAUTH', array(
34      'conf' => $conf['oauth'],
35      'u_login' => get_root_url() . OAUTH_PATH . 'auth.php?provider=',
36      'providers' => $hybridauth_conf['providers'],
37      ));
38    $template->assign(array(
39      'OAUTH_PATH' => OAUTH_PATH,
40      'OAUTH_ABS_PATH' => realpath(OAUTH_PATH) . '/',
41      'ABS_ROOT_URL' => rtrim(get_gallery_home_url(), '/') . '/',
42      ));
43  }
44 
45  if (isset($u_redirect))
46  {
47    $template->append('OAUTH', compact('u_redirect'), true);
48  }
49}
50
51function get_oauth_id($user_id)
52{
53  global $conf;
54 
55  $query = '
56SELECT oauth_id FROM ' . USERS_TABLE . '
57  WHERE ' . $conf['user_fields']['id'] . ' = ' . $user_id . '
58  AND oauth_id != ""
59;';
60  $result = pwg_query($query);
61 
62  if (!pwg_db_num_rows($result))
63  {
64    return null;
65  }
66  else
67  {
68    list($oauth_id) = pwg_db_fetch_row($result);
69    return $oauth_id;
70  }
71}
Note: See TracBrowser for help on using the repository browser.