Changeset 26626


Ignore:
Timestamp:
Jan 11, 2014, 3:50:26 PM (10 years ago)
Author:
mistic100
Message:

add 'allow_merge_accounts' parameter

Location:
extensions/oAuth
Files:
1 added
8 edited

Legend:

Unmodified
Added
Removed
  • extensions/oAuth/admin/config.php

    r26556 r26626  
    88    'display_register' => isset($_POST['display_register']),
    99    'display_menubar' => isset($_POST['display_menubar']),
     10    'allow_merge_accounts' => isset($_POST['allow_merge_accounts']),
    1011    'identification_icon' => $_POST['identification_icon'],
    1112    'menubar_icon' => $_POST['menubar_icon'],
  • extensions/oAuth/admin/template/config.tpl

    r26558 r26626  
    2020        <input type="checkbox" name="display_register" {if $display_register}checked="checked"{/if}>
    2121        <b>{'Display sign in buttons on the register page'|translate}</b>
     22      </label>
     23    </li>
     24
     25    <li>
     26      <label>
     27        <input type="checkbox" name="allow_merge_accounts" {if $allow_merge_accounts}checked="checked"{/if}>
     28        <b>{'Allow users to merge existing account with new <i>Social Connect</i> identity'|translate}</b>
    2229      </label>
    2330    </li>
  • extensions/oAuth/auth.php

    r26619 r26626  
    3333    {
    3434      header('HTTP/1.1 503 Service Unavailable');
     35      echo json_encode($response);
    3536      exit;
    3637    }
  • extensions/oAuth/include/public_events.inc.php

    r26619 r26626  
    5656function oauth_begin_register()
    5757{
    58   global $conf, $template, $hybridauth_conf, $page;
     58  global $conf, $template, $hybridauth_conf, $page, $user;
    5959 
    6060  if ($hybridauth_conf['enabled'] == 0)
     
    110110      $page['infos'][] = l10n('Your registration is almost done, please complete the registration form.');
    111111     
    112       // form submited
     112      // register form submited
    113113      if (isset($_POST['submit']))
    114114      {
     
    141141        unset($_POST['submit']);
    142142      }
     143      // login form submited
     144      else if (isset($_POST['login']) && $conf['oauth']['allow_merge_accounts'])
     145      {
     146        if ($conf['insensitive_case_logon'] == true)
     147        {
     148          $_POST['username'] = search_case_username($_POST['username']);
     149        }
     150       
     151        if ( pwg_login(false, $_POST['username'], $_POST['password'], false) )
     152        {
     153          pwg_unset_session_var('oauth_new_user');
     154         
     155          // update oauth field
     156          $query = '
     157UPDATE ' . USER_INFOS_TABLE . '
     158  SET oauth_id = "' . $oauth_id . '"
     159  WHERE user_id = ' . $user['id'] . '
     160;';
     161          pwg_query($query);
     162
     163          redirect('profile.php');
     164        }
     165        else
     166        {
     167          $page['errors'][] = l10n('Invalid password!');
     168        }
     169      }
    143170      else
    144171      {
     
    158185      // template
    159186      $template->assign('OAUTH_PATH', OAUTH_PATH);
    160       $template->set_prefilter('register', 'oauth_add_profile_prefilter');
    161       $template->set_prefilter('register', 'oauth_remove_password_fields_prefilter');
     187      if ($conf['oauth']['allow_merge_accounts'])
     188      {
     189        $template->assign('OAUTH_LOGIN_IN_REGISTER', true);
     190        $template->set_prefilter('register', 'oauth_add_login_in_register');
     191      }
     192      else
     193      {
     194        $template->set_prefilter('register', 'oauth_add_profile_prefilter');
     195        $template->set_prefilter('register', 'oauth_remove_password_fields_prefilter');
     196      }
    162197    }
    163198    catch (Exception $e)
     
    335370  return preg_replace($search, '$1 '.$add, $content);
    336371}
     372
     373function oauth_add_login_in_register($content)
     374{
     375  $search[0] = '<form method="post" action="{$F_ACTION}"';
     376  $replace[0] = file_get_contents(OAUTH_PATH . 'template/register.tpl') . $search[0];
     377 
     378  $search[1] = '{\'Enter your personnal informations\'|@translate}';
     379  $replace[1] = '{\'Create a new account\'|@translate}';
     380 
     381  return str_replace($search, $replace, $content);
     382}
  • extensions/oAuth/language/en_UK/plugin.lang.php

    r26608 r26626  
    2828$lang['Profile URL'] = 'Profile URL';
    2929$lang['Cancel'] = 'Cancel';
     30$lang['Associate with an existing account'] = 'Associate with an existing account';
     31$lang['Allow users to merge existing account with new <i>Social Connect</i> identity'] = 'Allow users to merge existing account with new <i>Social Connect</i> identity';
    3032
    3133?>
  • extensions/oAuth/language/fr_FR/plugin.lang.php

    r26609 r26626  
    2626$lang['Logged with'] = 'Connecté avec';
    2727$lang['Profile URL'] = 'URL du profil';
    28 
     28$lang['Associate with an existing account'] = 'Associer à un compte existant';
     29$lang['Allow users to merge existing account with new <i>Social Connect</i> identity'] = 'Autoriser les utilisateur à fusionner un compte existant avec leur identité <i>Social Connect</i>';
    2930$lang['Cancel'] = 'Annuler';
    3031$lang['Please enter your user ID'] = 'Veuillez entrer votre ID d\'utilisateur';
  • extensions/oAuth/main.inc.php

    r26619 r26626  
    6666function oauth_init()
    6767{
    68   global $conf, $page, $hybridauth_conf;
     68  global $conf, $page, $hybridauth_conf, $template;
    6969 
    7070  include_once(OAUTH_PATH . 'maintain.inc.php');
     
    9090 
    9191  // in case of registration aborded
    92   // DON'T WORK, because potentially executed by sub-scripts like Secureimage for Crypto Captcha
    93   // if ( script_basename() != 'register' and ($data=pwg_get_session_var('oauth_new_user')) !== null )
    94   // {
    95     // pwg_unset_session_var('oauth_new_user');
     92  if ( script_basename() == 'index' and ($oauth_id=pwg_get_session_var('oauth_new_user')) !== null )
     93  {
     94    pwg_unset_session_var('oauth_new_user');
    9695   
    97     // require_once(OAUTH_PATH . 'include/hybridauth/Hybrid/Auth.php');
    98    
    99     // try {
    100       // $hybridauth = new Hybrid_Auth($hybridauth_conf);
    101       // $adapter = $hybridauth->getAdapter($data[0]);
    102       // $adapter->logout();
    103     // }
    104     // catch (Exception $e) {
    105     // }
    106   // }
     96    if ($oauth_id[0] == 'Persona')
     97    {
     98      oauth_assign_template_vars(get_gallery_home_url());
     99      $template->block_footer_script(null, 'navigator.id.logout();');
     100    }
     101    else
     102    {
     103      require_once(OAUTH_PATH . 'include/hybridauth/Hybrid/Auth.php');
     104     
     105      try {
     106        $hybridauth = new Hybrid_Auth($hybridauth_conf);
     107        $adapter = $hybridauth->getAdapter($oauth_id[0]);
     108        $adapter->logout();
     109      }
     110      catch (Exception $e) {}
     111    }
     112  }
    107113}
  • extensions/oAuth/maintain.inc.php

    r26619 r26626  
    1111    'identification_icon' => '38px',
    1212    'menubar_icon' => '26px',
     13    'allow_merge_accounts' => true,
    1314    );
    1415   
     
    3031      $conf['oauth'] = serialize($this->default_conf);
    3132      conf_update_param('oauth', $conf['oauth']);
     33    }
     34    else
     35    {
     36      $old_conf = is_string($conf['oauth']) ? unserialize($conf['oauth']) : $conf['oauth'];
     37     
     38      if (!isset($old_conf['allow_merge_accounts']))
     39      {
     40        $old_conf['allow_merge_accounts'] = true;
     41       
     42        $conf['oauth'] = serialize($old_conf);
     43        conf_update_param('oauth', $conf['oauth']);
     44      }
    3245    }
    3346   
     
    5568    }
    5669   
    57     // add fields in hybridauth conf file
     70    // add 'total' and 'enabled' fields in hybridauth conf file
    5871    if (file_exists($this->file))
    5972    {
Note: See TracChangeset for help on using the changeset viewer.