| Author |
Message |
denney
Novice


Joined: Dec 24, 2007 Posts: 28
|
Posted: Thu Jan 17, 2008 7:19 am Post subject: Prevent login with Gallery2? |
|
|
Is it possible to redirect the login page from an embedded Gallery2 (when accessing a protected item for example) to phpBB3's login page?
That way users can have the option to register and have the proper recover password link. |
|
| Back to top |
|
|
AdBot
|
| Post subject: Prevent login with Gallery2? |
|
|
|
|
|
| Back to top |
|
 |
jettyrat
Moderator


Joined: Nov 28, 2005 Posts: 1139
|
Posted: Thu Jan 17, 2008 11:18 am Post subject: Re: Prevent login with Gallery2? |
|
|
| From the GalleryEmbed.class file Quote: › /**
* Initialize Gallery; must be called before most GalleryEmbed methods can be used.
* This method should only be called once during the lifetime of the request.
*
* @param array $initParams (optional--required before calling handleRequest) (
* 'embedUri' => URI to access G2 via CMS application
* (example: /portal/index.php?module=gallery2)
* 'g2Uri' = URL path to G2
* (example: /gallery2/, see extended docs for special character '|')
* 'loginRedirect' => (optional) URI for redirect to CMS login view (example: /cms/index.php)
* 'embedSessionString' => (optional) To support cookieless browsing, pass in key=value for
* CMS session key and session id value to be added as query parameter in urls
* 'gallerySessionId' => (optional) To support cookieless browsing, pass in G2 session id
* (when cookies not in use, CMS must track this value between requests)
* 'activeUserId' => (optional) external user id of active user
* (empty string for anonymous/guest user)
* 'activeLanguage' => (optional) language code in use for this session
* 'fullInit' => (optional) call GalleryInitSecondPass
* (only use when not calling handleRequest)
* 'apiVersion' => (optional) array int major, int minor (check if your integration is
* compatible)
* )
* @return object GalleryStatus a status object
*/
I have not tried this, but try adding the loginRedirect option to the init array in g2helper.inc Example-Code: › function g2helper($db) {
global $user;
$user->add_lang('acp/gallery2');
$sql = 'SELECT fullPath, embedUri, g2Uri, activeAdminId FROM ' . GALLERY2_TABLE;
if (!$row = $db->sql_fetchrow($db->sql_query_limit($sql, 1))) {
msg_handler(E_G2_ERROR, $user->lang['OBTAIN_SETTINGS_FAILED'], __FILE__, __LINE__);
}
$this->_activeAdminId = $row['activeAdminId'];
$this->_init_array = array(
'embedUri' => $row['embedUri'],
'g2Uri' => $row['g2Uri'],
'loginRedirect' => '/phpBB3/ucp.php?mode=login',
'apiVersion' => array($this->_compatibleEmbedVersionMajor, $this->_compatibleEmbedVersionMinor)
);
if ($this->_activeAdminId == 0) {
msg_handler(E_G2_ERROR, $user->lang['G2_AUTHADMIN_FAILED'], __FILE__, __LINE__);
}
else {
require_once($row['fullPath']);
}
}
Set the loginRedirect path to your actual phpbb3 path.
That's probably worth adding to the integration - let me know how it works! |
|
| Back to top |
|
|
denney
Novice


Joined: Dec 24, 2007 Posts: 28
|
Posted: Thu Jan 17, 2008 12:03 pm Post subject: Re: Prevent login with Gallery2? |
|
|
That works great! 2 issues have come up though...
1. When using phpBB's login, you are redirected back to the index page and not the gallery page you were after! This is easily fixed by editing ucp.php and the following:
Find:
Code: › case 'login':
if ($user->data['is_registered'])
{
redirect(append_sid("{$phpbb_root_path}index.$phpEx"));
}
login_box(request_var('redirect', "index.$phpEx"));
break;
And replace with:
Code: › case 'login':
$referer = $_SERVER['HTTP_REFERER'];
if (empty($referer) || $referer == '')
{
$referer = "{$phpbb_root_path}index.$phpEx";
}
if ($user->data['is_registered'])
{
redirect(append_sid($referer));
}
login_box(request_var('redirect', $referer));
break;
2. If you use the above edit, it redirects you back to the page BEFORE the page you were after, making you have to click the link again.
The only way around this is to modify phpBB to accept a redirect parameter when showing the login box. That's easy but I don't know how easy it is to get this information from Gallery. |
|
| Back to top |
|
|
jettyrat
Moderator


Joined: Nov 28, 2005 Posts: 1139
|
Posted: Thu Jan 17, 2008 12:58 pm Post subject: Re: Prevent login with Gallery2? |
|
|
I don't know of a way to get that info from gallery. One would have to pass the desired gallery url along with the login request. I image that would require mods to the gallery code. Getting back to the calling page with the link on it seems close enough, doesn't it?
Isn't thisCode: › if (empty($referer) || $referer == '')
The same as Code: › if (empty($referer))
This is a better way to make the g2helper change, then it works for all integrations and doesn't have a hard coded path -Code: › 'loginRedirect' => dirname($row['embedUri']) . '/ucp.php?mode=login', |
|
| Back to top |
|
|
jettyrat
Moderator


Joined: Nov 28, 2005 Posts: 1139
|
Posted: Thu Jan 17, 2008 1:33 pm Post subject: Re: Prevent login with Gallery2? |
|
|
| This is nice, I think I will add it to the integration core. It also takes you back to the gallery if you login from a gallery page. My mod looks like this Code: › #
#-----[ OPEN ]------------------------------------------
#
ucp.php
#
#-----[ FIND ]------------------------------------------
#
if ($user->data['is_registered'])
{
redirect(append_sid("{$phpbb_root_path}index.$phpEx"));
}
login_box(request_var('redirect', "index.$phpEx"));
#
#-----[ REPLACE WITH ]------------------------------------------
#
$referer = (empty($_SERVER['HTTP_REFERER'])) ? "{$phpbb_root_path}index.$phpEx" : $_SERVER['HTTP_REFERER'];
if ($user->data['is_registered'])
{
redirect(append_sid($referer));
}
login_box(request_var('redirect', $referer)); |
|
| Back to top |
|
|
denney
Novice


Joined: Dec 24, 2007 Posts: 28
|
Posted: Thu Jan 17, 2008 1:44 pm Post subject: Re: Prevent login with Gallery2? |
|
|
I didn't try from a gallery page to another so it's good that works. I was trying it from a link in a forum post to the gallery. It ends up redirecting you back to the forum post instead of the gallery you clicked on.
Good to see it going into the integration though! |
|
| Back to top |
|
|
txll
Beginner


Joined: Jan 10, 2008 Posts: 3
|
Posted: Fri Jan 25, 2008 5:37 am Post subject: Re: Prevent login with Gallery2? |
|
|
Also you can do something like this:
Code: ›
#
#-----[ OPEN ]------------------------------------------
#
ucp.php
#
#-----[ FIND ]------------------------------------------
#
meta_refresh(3, append_sid("{$phpbb_root_path}index.$phpEx"));
$message = $message . '<br /><br />' . sprintf($user->lang['RETURN_INDEX'], '<a href="' . append_sid("{$phpbb_root_path}index.$phpEx") . '">', '</a> ');
#
#-----[ REPLACE WITH ]------------------------------------------
#
$referer = (empty($_SERVER['HTTP_REFERER'])) ? "{$phpbb_root_path}index.$phpEx" : $_SERVER['HTTP_REFERER'];
meta_refresh(3, append_sid($referer));
$message = $message . '<br /><br />' . sprintf($user->lang['RETURN_INDEX'], '<a href="' . append_sid($referer) . '">', '</a>
');
and when you logout while in gallery you will get back to the gallery rather than index of the forum. |
|
| Back to top |
|
|
jettyrat
Moderator


Joined: Nov 28, 2005 Posts: 1139
|
Posted: Fri Jan 25, 2008 11:26 am Post subject: Re: Prevent login with Gallery2? |
|
|
Nice...
I'm not sure why one would want to go back to the previous page since logging out usually means you are done, but I played with the code a little and noticed a couple things. The code always says 'return to index' even if it is going to return you to another page and it will return you to other phpbb pages instead of the index page.
I'm not sure of the usefulness of this, but I tweaked the code a bit so it gives alternate messages depending on if it is returning to gallery or phpbb and always returns to the phpbb index page if user is not in gallery.Code: › #
#-----[ OPEN ]------------------------------------------
#
ucp.php
#
#-----[ FIND ]------------------------------------------
#
meta_refresh(3, append_sid("{$phpbb_root_path}index.$phpEx"));
$message = $message . '<br /><br />' . sprintf($user->lang['RETURN_INDEX'], '<a href="' . append_sid("{$phpbb_root_path}index.$phpEx") . '">', '</a> ');
#
#-----[ REPLACE WITH ]------------------------------------------
#
if (!empty($_SERVER['HTTP_REFERER']) && strstr($_SERVER['HTTP_REFERER'], 'gallery2.php')) {
$referer = $_SERVER['HTTP_REFERER'];
$redirect = $user->lang['RETURN_PAGE'];
}
else {
$referer = "{$phpbb_root_path}index.$phpEx";
$redirect = $user->lang['RETURN_INDEX'];
}
meta_refresh(3, append_sid($referer));
$message = $message . '<br /><br />' . sprintf($redirect, '<a href="' . append_sid($referer) . '">', '</a> '); |
|
| Back to top |
|
|
jettyrat
Moderator


Joined: Nov 28, 2005 Posts: 1139
|
Posted: Fri Jan 25, 2008 2:58 pm Post subject: Re: Prevent login with Gallery2? |
|
|
| I'll go ahead and add both login and logout mods to the integration for completeness and similar behavior of each... |
|
| Back to top |
|
|
denney
Novice


Joined: Dec 24, 2007 Posts: 28
|
Posted: Wed Feb 13, 2008 3:27 am Post subject: Re: Prevent login with Gallery2? |
|
|
Is it possible to get the code for the new integration? Like a subversion repository or something?
It's been quite a while since the last release and there have been quite a few updates (according to this forum). |
|
| Back to top |
|
|
jettyrat
Moderator


Joined: Nov 28, 2005 Posts: 1139
|
Posted: Wed Feb 13, 2008 10:24 am Post subject: Re: Prevent login with Gallery2? |
|
|
Dari has the new code - released this week, but he is very busy with real work these days.
I've also submitted the mod to the phpbb mods database, but it is still pending validation at this point. Don't know if or when it will be approved... |
|
| Back to top |
|
|
denney
Novice


Joined: Dec 24, 2007 Posts: 28
|
Posted: Wed Feb 13, 2008 10:29 am Post subject: Re: Prevent login with Gallery2? |
|
|
Ahh... well that's great I guess.
Just a bummer it's not available anywhere.
Oh well, looking forward to seeing it soon. |
|
| Back to top |
|
|
jettyrat
Moderator


Joined: Nov 28, 2005 Posts: 1139
|
|
| Back to top |
|
|
denney
Novice


Joined: Dec 24, 2007 Posts: 28
|
Posted: Wed Feb 13, 2008 10:43 am Post subject: Re: Prevent login with Gallery2? |
|
|
Oh wonderful.... Thank you very much. It's much appreciated.
Keep up the great work guys!
Time to try and break this thing again.  |
|
| Back to top |
|
|
|
|
|
|
|