Ignore:
Timestamp:
Jan 10, 2014, 9:51:32 PM (10 years ago)
Author:
mistic100
Message:

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/oAuth/include/functions.inc.php

    r26556 r26604  
    2323}
    2424
    25 function get_activated_providers()
     25function oauth_assign_template_vars($u_redirect=null)
    2626{
    27   global $hybridauth_conf;
     27  global $template, $conf, $hybridauth_conf;
    2828 
    29   return array_filter($hybridauth_conf['providers'], create_function('$p', 'return $p["enabled"];'));
    30 }
    31 
    32 function oauth_assign_template_vars()
    33 {
    34   global $template, $conf;
     29  $conf['oauth']['include_common_template'] = true;
    3530 
    36   if ($template->get_template_vars('OAUTH_URL') == null)
     31  if ($template->get_template_vars('OAUTH') == null)
    3732  {
     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      ));
    3838    $template->assign(array(
    39       'oauth' => $conf['oauth'],
    40       'OAUTH_URL' => get_root_url() . OAUTH_PATH . 'auth.php?provider=',
    4139      'OAUTH_PATH' => OAUTH_PATH,
    4240      'OAUTH_ABS_PATH' => realpath(OAUTH_PATH) . '/',
    43       'PROVIDERS' => get_activated_providers(),
    4441      'ABS_ROOT_URL' => rtrim(get_gallery_home_url(), '/') . '/',
    4542      ));
    4643  }
     44 
     45  if (isset($u_redirect))
     46  {
     47    $template->append('OAUTH', compact('u_redirect'), true);
     48  }
    4749}
     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 TracChangeset for help on using the changeset viewer.