Ignore:
Timestamp:
Jan 20, 2013, 9:41:55 PM (11 years ago)
Author:
mistic100
Message:

clean code

File:
1 edited

Legend:

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

    r20293 r20301  
    77function oauth_begin_identification()
    88{
    9   global $template, $conf, $page, $hybridauth_conf;
    10  
    11   if (isset($_GET['redirect']))
    12   {
    13     pwg_set_session_var('oauth_redirect', $_GET['redirect']);
    14   }
    15   else
    16   {
    17     pwg_unset_session_var('oauth_redirect');
    18   }
     9  global $template;
    1910 
    2011  // template icons
     
    2213  {
    2314    $template->assign(array(
    24       'OAUTH_URL' => get_root_url().OAUTH_PATH.'auth.php?provider=',
     15      'OAUTH_URL' => get_root_url() . OAUTH_PATH . 'auth.php?provider=',
    2516      'OAUTH_PATH' => OAUTH_PATH,
    26       'OAUTH_ABS_PATH' => realpath(OAUTH_PATH).'/',
     17      'OAUTH_ABS_PATH' => realpath(OAUTH_PATH) . '/',
    2718      'PROVIDERS' => get_activated_providers(),
    2819    ));
     
    5243    list($oauth_id) = pwg_db_fetch_row($result);
    5344    list($provider) = explode('---', $oauth_id);
    54     $_SESSION['page_errors'][] = 'You registered with a '.ucfirst($provider).' account, please login with the same account.';
     45    $_SESSION['page_errors'][] = sprintf(l10n('You registered with a %s account, please sign in with the same account.'), $provider);
    5546   
    5647    $redirect_to = get_root_url().'identification.php';
     
    6859{
    6960  global $conf, $template, $hybridauth_conf;
    70  
    71   if (!$conf['oauth']['display_register'])
    72   {
    73     return;
    74   }
    7561 
    7662  // comming from identification page
     
    135121      $template->set_prefilter('register', 'oauth_remove_password_fields_prefilter');
    136122    }
    137     catch( Exception $e ){
    138       die($e->getMessage());
     123    catch (Exception $e) {
     124      array_push($page['errors'], sprintf(l10n('An error occured, please contact the gallery owner. <i>Error code : %s</i>'), $e->getCode()));
    139125    }
    140126  }
    141   else
     127  // display login buttons
     128  else if ($conf['oauth']['display_register'])
    142129  {
    143130    // template icons
     
    145132    {
    146133      $template->assign(array(
    147         'OAUTH_URL' => get_root_url().OAUTH_PATH.'auth.php?provider=',
     134        'OAUTH_URL' => get_root_url() . OAUTH_PATH . 'auth.php?provider=',
    148135        'OAUTH_PATH' => OAUTH_PATH,
    149         'OAUTH_ABS_PATH' => realpath(OAUTH_PATH).'/',
     136        'OAUTH_ABS_PATH' => realpath(OAUTH_PATH) . '/',
    150137        'PROVIDERS' => get_activated_providers(),
    151138        ));
     
    189176   
    190177    $template->assign(array(
    191       'OAUTH_PROVIDER' => ucfirst($provider),
     178      'OAUTH_PROVIDER' => $provider,
    192179      'OAUTH_USERNAME' => $remote_user->displayName,
    193180      'OAUTH_URL' => $remote_user->profileURL,
     
    197184   
    198185    $template->set_prefilter('profile_content', 'oauth_add_profile_prefilter');
    199   }
    200   catch( Exception $e ){
    201     die($e->getMessage());
    202   }
    203  
    204  
    205   $template->set_prefilter('profile_content', 'oauth_remove_password_fields_prefilter');
     186    $template->set_prefilter('profile_content', 'oauth_remove_password_fields_prefilter');
     187  }
     188  catch (Exception $e) {
     189    array_push($page['errors'], sprintf(l10n('An error occured, please contact the gallery owner. <i>Error code : %s</i>'), $e->getCode()));
     190  }
    206191}
    207192
     
    236221    $adapter->logout();
    237222  }
    238   catch( Exception $e ){
    239     die($e->getMessage());
     223  catch (Exception $e) {
     224    $_SESSION['page_errors'][] = sprintf(l10n('An error occured, please contact the gallery owner. <i>Error code : %s</i>'), $e->getCode());
    240225  }
    241226}
     
    249234  global $template, $conf;
    250235 
    251   if (!$conf['oauth']['display_menubar'])
     236  $menu = &$menu_ref_arr[0]; 
     237 
     238  if ( !$conf['oauth']['display_menubar'] or $menu->get_block('mbIdentification') == null )
    252239  {
    253240    return;
    254241  }
    255242 
    256   $menu = &$menu_ref_arr[0]; 
    257  
    258   if ($menu->get_block('mbIdentification') == null)
    259   {
    260     return;
    261   }
    262  
    263243  if ($template->get_template_vars('OAUTH_URL') == null)
    264244  {
    265245    $template->assign(array(
    266       'OAUTH_URL' => get_root_url().OAUTH_PATH.'auth.php?provider=',
     246      'OAUTH_URL' => get_root_url() . OAUTH_PATH . 'auth.php?provider=',
    267247      'OAUTH_PATH' => OAUTH_PATH,
    268       'OAUTH_ABS_PATH' => realpath(OAUTH_PATH).'/',
     248      'OAUTH_ABS_PATH' => realpath(OAUTH_PATH) . '/',
    269249      'PROVIDERS' => get_activated_providers(),
    270250      ));
     
    283263{
    284264  $search = '</form>';
    285   $add = file_get_contents(OAUTH_PATH.'template/identification_page.tpl');
     265  $add = file_get_contents(OAUTH_PATH . 'template/identification_page.tpl');
    286266  return str_replace($search, $search.$add, $content);
    287267}
     
    310290{
    311291  $search = '{include file=$block->template|@get_extent:$id }';
    312   $add = file_get_contents(OAUTH_PATH.'template/identification_menubar.tpl');
     292  $add = file_get_contents(OAUTH_PATH . 'template/identification_menubar.tpl');
    313293  return str_replace($search, $search.$add, $content);
    314294}
Note: See TracChangeset for help on using the changeset viewer.