Changeset 26619


Ignore:
Timestamp:
Jan 11, 2014, 2:11:21 PM (7 years ago)
Author:
mistic100
Message:

move "oauth_id" field to user + display 16px icon on users list

Location:
extensions/oAuth
Files:
1 added
5 edited

Legend:

Unmodified
Added
Removed
  • extensions/oAuth/auth.php

    r26608 r26619  
    2222  if ($provider == 'Persona')
    2323  {
    24     if (!verify_ephemeral_key(@$_POST['key']) | empty($_POST['assertion']))
     24    if (!verify_ephemeral_key(@$_POST['key']) || empty($_POST['assertion']))
    2525    {
    2626      header('HTTP/1.1 403 Forbidden');
     
    6363    // check is already registered
    6464    $query = '
    65 SELECT id FROM ' . USERS_TABLE . '
     65SELECT user_id FROM ' . USER_INFOS_TABLE . '
    6666  WHERE oauth_id = "' . implode('---', $oauth_id) . '"
    6767;';
  • extensions/oAuth/include/functions.inc.php

    r26608 r26619  
    6262function get_oauth_id($user_id)
    6363{
    64   global $conf;
    65  
    6664  $query = '
    67 SELECT oauth_id FROM ' . USERS_TABLE . '
    68   WHERE ' . $conf['user_fields']['id'] . ' = ' . $user_id . '
     65SELECT oauth_id FROM ' . USER_INFOS_TABLE . '
     66  WHERE user_id = ' . $user_id . '
    6967  AND oauth_id != ""
    7068;';
  • extensions/oAuth/include/public_events.inc.php

    r26608 r26619  
    2828 
    2929  $query = '
    30 SELECT oauth_id FROM ' . USERS_TABLE . '
     30SELECT oauth_id
     31  FROM ' . USER_INFOS_TABLE . ' AS i
     32    INNER JOIN ' . USERS_TABLE . ' AS u
     33    ON i.user_id = u.' . $conf['user_fields']['id'] . '
    3134  WHERE ' . $conf['user_fields']['username'] . ' = "' . pwg_db_real_escape_string($username) . '"
    3235  AND oauth_id != ""
     
    125128          // update oauth field
    126129          $query = '
    127 UPDATE ' . USERS_TABLE . '
     130UPDATE ' . USER_INFOS_TABLE . '
    128131  SET oauth_id = "' . $oauth_id . '"
    129   WHERE ' . $conf['user_fields']['id'] . ' = ' . $user_id . '
     132  WHERE user_id = ' . $user_id . '
    130133;';
    131134          pwg_query($query);
  • extensions/oAuth/main.inc.php

    r26605 r26619  
    3030}
    3131
    32 // force getuserdata() to retrieve 'oauth_id' field
    33 $conf['user_fields']['oauth_id'] = 'oauth_id';
    34 
    3532
    3633add_event_handler('init', 'oauth_init');
     
    3936{
    4037  add_event_handler('get_admin_plugin_menu_links', 'oauth_admin_plugin_menu_links');
     38 
     39  add_event_handler('user_list_columns', 'oauth_user_list_columns');
     40  add_event_handler('after_render_user_list', 'oauth_user_list_render');
     41 
     42  add_event_handler('loc_begin_admin_page', 'oauth_user_list');
     43 
     44  include_once(OAUTH_PATH . 'include/admin_events.inc.php');
    4145}
    4246else if (!empty($hybridauth_conf) and function_exists('curl_init'))
     
    101105    // }
    102106  // }
    103  
    104   // pwg_unset_session_var('persona_logout');
    105107}
    106 
    107 function oauth_admin_plugin_menu_links($menu)
    108 {
    109   $menu[] = array(
    110     'NAME' => 'Social Connect',
    111     'URL' => OAUTH_ADMIN,
    112     );
    113   return $menu;
    114 }
  • extensions/oAuth/maintain.inc.php

    r26604 r26619  
    3232    }
    3333   
     34    $result = pwg_query('SHOW COLUMNS FROM `' . USER_INFOS_TABLE . '` LIKE "oauth_id";');
     35    if (!pwg_db_num_rows($result))
     36    {
     37      pwg_query('ALTER TABLE `' . USER_INFOS_TABLE . '` ADD `oauth_id` VARCHAR(255) DEFAULT NULL;');
     38    }
     39   
     40    // move field from users table to user_infos
    3441    $result = pwg_query('SHOW COLUMNS FROM `' . USERS_TABLE . '` LIKE "oauth_id";');
    35     if (!pwg_db_num_rows($result))
    36     {     
    37       pwg_query('ALTER TABLE `' . USERS_TABLE . '` ADD `oauth_id` VARCHAR(255) DEFAULT NULL;');
     42    if (pwg_db_num_rows($result))
     43    {
     44      $query = '
     45UPDATE `' . USER_INFOS_TABLE . '` AS i
     46  SET oauth_id = (
     47    SELECT oauth_id
     48      FROM `' . USERS_TABLE . '` AS u
     49      WHERE u.'.$conf['user_fields']['id'].' = i.user_id
     50    )
     51;';
     52      pwg_query($query);
     53     
     54      pwg_query('ALTER TABLE `' . USERS_TABLE . '` DROP `oauth_id`;');
    3855    }
    3956   
     
    7693    conf_delete_param('oauth');
    7794
    78     pwg_query('ALTER TABLE `'. USERS_TABLE .'` DROP `oauth_id`;');
     95    pwg_query('ALTER TABLE `'. USER_INFOS_TABLE .'` DROP `oauth_id`;');
    7996   
    8097    @unlink($this->file);
Note: See TracChangeset for help on using the changeset viewer.