Changeset 20301
- Timestamp:
- Jan 20, 2013, 9:41:55 PM (11 years ago)
- Location:
- extensions/oAuth
- Files:
-
- 4 added
- 1 deleted
- 11 edited
- 1 copied
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
extensions/oAuth/admin/config.php
r20293 r20301 30 30 } 31 31 32 if ( $id == 'Wordpress' and $data['enabled'] and !@$providers['OpenID']['enabled'])32 if ( ($id=='Wordpress' or $id=='Flickr') and $data['enabled'] and !@$providers['OpenID']['enabled'] ) 33 33 { 34 array_push($page['errors'], sprintf(l10n('OpenID must be enabled in order to use %s authenti fication'), $id));34 array_push($page['errors'], sprintf(l10n('OpenID must be enabled in order to use %s authentication'), $id)); 35 35 $error = true; 36 36 } … … 55 55 $content.= ";\n?>"; 56 56 file_put_contents(OAUTH_CONFIG, $content); 57 58 // plugin config 59 $conf['oauth'] = array( 60 'display_register' => isset($_POST['display_register']), 61 'display_menubar' => isset($_POST['display_menubar']), 62 ); 63 64 conf_update_param('oauth', serialize($conf['oauth'])); 65 array_push($page['infos'], l10n('Information data registered in database')); 57 66 } 58 59 // plugin config60 $conf['oauth'] = array(61 'display_register' => isset($_POST['display_register']),62 'display_menubar' => isset($_POST['display_menubar']),63 );64 65 conf_update_param('oauth', serialize($conf['oauth']));66 array_push($page['infos'], l10n('Information data registered in database'));67 67 } 68 68 -
extensions/oAuth/admin/template/config.tpl
r20293 r20301 36 36 37 37 <div class="titrePage"> 38 <h2> oAuth</h2>38 <h2>OAuth</h2> 39 39 </div> 40 40 … … 125 125 <li>{'Put your website domain in the %s fields. It should match with the current hostname: <em>%s</em>'|@translate|sprintf:'<b>Redirect Domain</b>':$SERVERNAME}</li> 126 126 {elseif $p=='Facebook'} 127 <li>{'Select <em>Website with facebook authenti fication</em> as application type'|@translate}</li>127 <li>{'Select <em>Website with facebook authentication</em> as application type'|@translate}</li> 128 128 <li>{'Put your website domain in the %s fields. It should match with the current hostname: <em>%s</em>'|@translate|sprintf:'<b>Site Url</b>, <b>App Domains</b>':$SERVERNAME}</li> 129 129 {elseif $p=='LinkedIn'} -
extensions/oAuth/auth.php
r20293 r20301 9 9 10 10 try { 11 // inputs 11 12 if ( $provider == 'OpenID' and !isset($_GET['openid_identifier']) ) 12 13 { 13 throw new Exception('Invalid OpenID!' );14 throw new Exception('Invalid OpenID!', 1003); 14 15 } 15 16 16 // inputs17 17 if ( 18 18 !array_key_exists($provider, $hybridauth_conf['providers']) 19 19 or !$hybridauth_conf['providers'][$provider]['enabled'] 20 20 ) { 21 throw new Exception('Hacking attempt!' );21 throw new Exception('Hacking attempt!', 1002); 22 22 } 23 24 25 23 26 24 $hybridauth = new Hybrid_Auth($hybridauth_conf); … … 29 27 if ($hybridauth->isConnectedWith($provider)) 30 28 { 31 $template->assign('AUTH_DONE', true);32 33 29 $adapter = $hybridauth->getAdapter($provider); 34 30 $remote_user = $adapter->getUserProfile(); … … 69 65 else if (isset($_GET['init_auth'])) 70 66 { 71 $params = array('hauth_return_to', get_absolute_root_url() .OAUTH_PATH.'auth.php?provider='.$provider.'&auth_done=1');67 $params = array('hauth_return_to', get_absolute_root_url() . OAUTH_PATH . 'auth.php?provider='.$provider.'&auth_done=1'); 72 68 if ($provider == 'OpenID') 73 69 { … … 83 79 $template->assign('LOADING', '&openid_identifier='.@$_GET['openid_identifier'].'&init_auth=1'); 84 80 } 85 } 86 catch( Exception $e ){ 87 $template->assign('ERROR', $e->getMessage()); 81 } 82 /* 83 library errors : 84 0 : Unspecified error 85 1 : Hybriauth configuration error 86 2 : Provider not properly configured 87 3 : Unknown or disabled provider 88 4 : Missing provider application credentials 89 5 : Authentication aborded 90 other errors : 91 1002 : Invalid provider 92 1003 : Missing openid_identifier 93 */ 94 catch (Exception $e) { 95 switch ($e->getCode()) { 96 case 5: 97 $template->assign('ERROR', l10n('Authentication canceled')); break; 98 default: 99 $template->assign('ERROR', sprintf(l10n('An error occured, please contact the gallery owner. <i>Error code : %s</i>'), $e->getCode())); 100 } 88 101 } 89 102 … … 96 109 'OAUTH_PATH' => OAUTH_PATH, 97 110 'PROVIDER' => $provider, 98 'SELF_URL' => OAUTH_PATH .'auth.php?provider='.$provider,111 'SELF_URL' => OAUTH_PATH . 'auth.php?provider='.$provider, 99 112 )); 100 113 101 $template->set_filename('index', realpath(OAUTH_PATH .'template/auth.tpl'));114 $template->set_filename('index', realpath(OAUTH_PATH . 'template/auth.tpl')); 102 115 $template->pparse('index'); 103 116 ?> -
extensions/oAuth/include/providers_stats.inc.php
r20293 r20301 10 10 'scope' => 'email', 11 11 ), 12 12 13 'Google' => array( 13 14 'label' => 'Google', … … 30 31 'new_app_link' => 'https://www.linkedin.com/secure/developer', 31 32 'userguide_section' => 'http://hybridauth.sourceforge.net/userguide/IDProvider_info_LinkedIn.html', 32 ),33 'OpenID' => array(34 'label' => 'OpenID',35 'provider_name' => 'OpenID',36 'new_app_link' => null,37 'userguide_section' => 'http://hybridauth.sourceforge.net/userguide/IDProvider_info_OpenID.html',38 33 ), 39 34 'Tumblr' => array( … … 62 57 'userguide_section' => 'http://hybridauth.sourceforge.net/userguide/IDProvider_info_Yahoo.html', 63 58 ), 59 'OpenID' => array( 60 'label' => 'OpenID', 61 'provider_name' => 'OpenID', 62 'new_app_link' => null, 63 'userguide_section' => 'http://hybridauth.sourceforge.net/userguide/IDProvider_info_OpenID.html', 64 ), 65 'Flickr' => array( 66 'label' => 'Flickr', 67 'provider_name' => 'Flickr', 68 'new_app_link' => null, 69 'userguide_section' => 'http://hybridauth.sourceforge.net/userguide/IDProvider_info_OpenID.html', 70 ), 64 71 'Wordpress' => array( 65 72 'label' => 'Wordpress', -
extensions/oAuth/include/public_events.inc.php
r20293 r20301 7 7 function oauth_begin_identification() 8 8 { 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; 19 10 20 11 // template icons … … 22 13 { 23 14 $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=', 25 16 'OAUTH_PATH' => OAUTH_PATH, 26 'OAUTH_ABS_PATH' => realpath(OAUTH_PATH) .'/',17 'OAUTH_ABS_PATH' => realpath(OAUTH_PATH) . '/', 27 18 'PROVIDERS' => get_activated_providers(), 28 19 )); … … 52 43 list($oauth_id) = pwg_db_fetch_row($result); 53 44 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); 55 46 56 47 $redirect_to = get_root_url().'identification.php'; … … 68 59 { 69 60 global $conf, $template, $hybridauth_conf; 70 71 if (!$conf['oauth']['display_register'])72 {73 return;74 }75 61 76 62 // comming from identification page … … 135 121 $template->set_prefilter('register', 'oauth_remove_password_fields_prefilter'); 136 122 } 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())); 139 125 } 140 126 } 141 else 127 // display login buttons 128 else if ($conf['oauth']['display_register']) 142 129 { 143 130 // template icons … … 145 132 { 146 133 $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=', 148 135 'OAUTH_PATH' => OAUTH_PATH, 149 'OAUTH_ABS_PATH' => realpath(OAUTH_PATH) .'/',136 'OAUTH_ABS_PATH' => realpath(OAUTH_PATH) . '/', 150 137 'PROVIDERS' => get_activated_providers(), 151 138 )); … … 189 176 190 177 $template->assign(array( 191 'OAUTH_PROVIDER' => ucfirst($provider),178 'OAUTH_PROVIDER' => $provider, 192 179 'OAUTH_USERNAME' => $remote_user->displayName, 193 180 'OAUTH_URL' => $remote_user->profileURL, … … 197 184 198 185 $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 } 206 191 } 207 192 … … 236 221 $adapter->logout(); 237 222 } 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()); 240 225 } 241 226 } … … 249 234 global $template, $conf; 250 235 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 ) 252 239 { 253 240 return; 254 241 } 255 242 256 $menu = &$menu_ref_arr[0];257 258 if ($menu->get_block('mbIdentification') == null)259 {260 return;261 }262 263 243 if ($template->get_template_vars('OAUTH_URL') == null) 264 244 { 265 245 $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=', 267 247 'OAUTH_PATH' => OAUTH_PATH, 268 'OAUTH_ABS_PATH' => realpath(OAUTH_PATH) .'/',248 'OAUTH_ABS_PATH' => realpath(OAUTH_PATH) . '/', 269 249 'PROVIDERS' => get_activated_providers(), 270 250 )); … … 283 263 { 284 264 $search = '</form>'; 285 $add = file_get_contents(OAUTH_PATH .'template/identification_page.tpl');265 $add = file_get_contents(OAUTH_PATH . 'template/identification_page.tpl'); 286 266 return str_replace($search, $search.$add, $content); 287 267 } … … 310 290 { 311 291 $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'); 313 293 return str_replace($search, $search.$add, $content); 314 294 } -
extensions/oAuth/language/en_UK/description.txt
r20293 r20301 1 Provides various ways to sign in your gallery (Twitter, Facebook, Google, etc.) -
extensions/oAuth/language/fr_FR/description.txt
r20293 r20301 1 Fournit diverses manières de se connecter à la galerie (Twitter, Facebook, Google, etc.) -
extensions/oAuth/main.inc.php
r20293 r20301 1 1 <?php 2 2 /* 3 Plugin Name: oauth3 Plugin Name: OAuth 4 4 Version: auto 5 Description: This is not a plugin. It's a oauth for future plugins.5 Description: Provides various ways to sign in your gallery (Twitter, Facebook, Google, etc.) 6 6 Plugin URI: auto 7 7 Author: Mistic … … 41 41 add_event_handler('get_admin_plugin_menu_links', 'oauth_admin_plugin_menu_links'); 42 42 43 include_once(OAUTH_PATH . 'include/admin_events.inc.php'); 43 function oauth_admin_plugin_menu_links($menu) 44 { 45 array_push($menu, array( 46 'NAME' => l10n('OAuth'), 47 'URL' => OAUTH_ADMIN, 48 )); 49 return $menu; 50 } 44 51 } 45 52 else if (!empty($hybridauth_conf) and function_exists('curl_init')) … … 87 94 if (defined('IN_ADMIN')) 88 95 { 89 $_SESSION['page_infos'][] = ' oAuth updated to version '. OAUTH_VERSION;96 $_SESSION['page_infos'][] = 'OAuth updated to version '. OAUTH_VERSION; 90 97 } 91 98 } … … 101 108 if (empty($hybridauth_conf)) 102 109 { 103 array_push($page['errors'], l10n(' oAuth: You need to configure the credentials'));110 array_push($page['errors'], l10n('OAuth: You need to configure the credentials')); 104 111 } 105 112 if (!function_exists('curl_init')) 106 113 { 107 array_push($page['errors'], l10n(' oAuth: cURL extension is needed'));114 array_push($page['errors'], l10n('OAuth: cURL extension is needed')); 108 115 } 109 116 } -
extensions/oAuth/template/auth.tpl
r20293 r20301 4 4 <meta http-equiv="Content-Type" content="text/html; charset={$CONTENT_ENCODING}"> 5 5 <title>{'Sign in with %s'|@translate|sprintf:$PROVIDER} | {$GALLERY_TITLE}</title> 6 7 {combine_script id="jquery" load="footer"}8 9 {get_combined_css}10 {get_combined_scripts load='header'}11 {if not empty($head_elements)}12 {foreach from=$head_elements item=elt}{$elt}13 {/foreach}14 {/if}15 6 </head> 16 7 17 8 <body> 9 10 <div style="text-align:center;margin-top:20px;"> 11 {if $ERROR} 12 <img id="loader" src="{$OAUTH_PATH}template/images/alert.png"> 13 <h3>{'Error...'|@translate}</h3> 14 {$ERROR}<br> 15 <a href="#" id="close">{'Close'|@translate}</a> 18 16 19 {if $LOADING} 20 <img src="{$OAUTH_PATH}template/ajax-loader-big.gif"> 21 <script type="text/javascript"> 22 setTimeout('window.location.href = "{$SELF_URL}{$LOADING}";', 500); 17 <script type="text/javascript"> 18 document.getElementById('close').onclick = function() {ldelim} window.self.close(); }; 23 19 </script> 24 20 25 {elseif $AUTH_DONE} 26 <script language="javascript"> 27 if (window.opener) {ldelim} 28 window.opener.parent.redirect('{$REDIRECT_TO}'); 29 } 21 {elseif $LOADING} 22 <img id="loader" src="{$OAUTH_PATH}template/images/ajax-loader-big.gif"> 23 <h3>{'Loading...'|@translate}</h3> 24 {'Contacting <b>%s</b>. Please wait.'|@translate|sprintf:$PROVIDER} 25 26 <script type="text/javascript"> 27 setTimeout('window.location.href = "{$SELF_URL}{$LOADING}";', 200); 28 </script> 29 30 {elseif $REDIRECT_TO} 31 <script type="text/javascript"> 32 if (window.opener) window.opener.parent.redirect('{$REDIRECT_TO}'); 30 33 window.self.close(); 31 34 </script> 32 {elseif $ERROR}33 {$ERROR}<br>34 <a href="#" id="close">{'Close'|@translate}</a>35 35 {/if} 36 </div> 36 37 37 38 {footer_script}{literal}39 $("a#close").click(function() {40 window.self.close();41 });42 {/literal}{/footer_script}43 44 45 46 {get_combined_scripts load='footer'}47 {if isset($footer_elements)}48 {foreach from=$footer_elements item=v}{$v}49 {/foreach}50 {/if}51 38 </body> 52 39 </html> -
extensions/oAuth/template/identification_common.tpl
r20293 r20301 29 29 } 30 30 31 // open authenti fication popup31 // open authentication popup 32 32 function open_auth(url) {ldelim} 33 33 window.open( … … 43 43 44 44 switch(idp) {ldelim} 45 case 'OpenID': case 'Wordpress': 45 case 'OpenID': case 'Wordpress': case 'Flickr': 46 46 switch(idp) {ldelim} 47 case 'OpenID': $("#openid_label").html('{'Please enter your OpenID URL'|@translate}'); break; 48 case 'Wordpress': $("#openid_label").html('{'Please enter your Wordpress username'|@translate}'); break; 47 case 'OpenID': 48 $("#openid_label").html('{'Please enter your OpenID URL'|@translate}'); break; 49 case 'Wordpress': case 'Flickr': 50 $("#openid_label").html('{'Please enter your username'|@translate}'); break; 49 51 } 50 52 … … 82 84 switch(idp) {ldelim} 83 85 case 'Wordpress': oi = "http://" + oi + ".wordpress.com"; break; 86 case 'Flickr': oi = "http://www.flickr.com/photos/" + oi + "/"; break; 84 87 } 85 88 -
extensions/oAuth/template/profile.tpl
r20293 r20301 24 24 <img src="{$OAUTH_AVATAR}" class="avatar"> 25 25 {else} 26 <img src="{$ROOT_URL}{$OAUTH_PATH}template/ avatar-default.png" class="avatar">26 <img src="{$ROOT_URL}{$OAUTH_PATH}template/images/avatar-default.png" class="avatar"> 27 27 {/if} 28 28
Note: See TracChangeset
for help on using the changeset viewer.