This topic is locked
[SOLVED]

 URL to View Page, Login Redirects

8/24/2011 3:37:06 PM
PHPRunner General questions
mcebula author

Hi, I created a link to the view pages of my app so people can embed the link in Word documents, emails or anywhere a link can go. People can click the link it will go straight to the view page so person can see the details (guest access).
I am able to get this to work on the view page, changing the record key field to a link so it's easy for users to copy the key value which has a link to same page built in (a link to itself). In visual editor for view page, change key field to hyperlink, add prefix of view page such as "ACTOR_view.php?editid1=" and select display field content = the record key field.
It all works perfect, I can click the link from any outside source it go straight to the view page if I have the normal default "menu approach" set for login (i.e. no redirects)
If I try to redirect to specific landing pages after login, clicking the link gets caught up in the redirect and link goes to the redirected landing page instead of directly to view page specificed in the link.
Simple after successful login redirect that forces all users to single place:

header("Location: BUSINESS_RULE_list.php");

exit();
Since I'm using static group permissions I've tried to get around it with something like this after login.
if ($_SESSION["GroupID"]=="Admin")

{

//admin group

header("location: BUSINESS_RULE_list.php");

}

elseif ($_SESSION["GroupID"]=="Analyst")

{

//analyst group

header("location: BUSINESS_RULE_list.php");

}

elseif ($_SESSION["GroupID"]=="Data Analyst")

{

//data analyst group

header("location: BUSINESS_RULE_list.php");

}

exit();
In the code above I thought maybe guest access would "fall through" and do nothing (go to menu?). For some reason it creates a new strange behavior for guest access. Logging in as a guest (or clicking a link) I can see the correct URL to the menu in browser address but it gets kind of "stuck" - displays a blank page and requires me to hit enter on the address to continue.
I can work around the problem by not doing redirects by I kind of like the idea of if I know who you are directing you some place, if not (guest) then displaying the menu.

Sergey Kornilov admin 8/24/2011

Try something like this:

if ($_SESSION["GroupID"]=="Admin")

{

//admin group

header("location: BUSINESS_RULE_list.php");

}

elseif ($_SESSION["GroupID"]=="Analyst")

{

//analyst group

header("location: BUSINESS_RULE_list.php");

}

elseif ($_SESSION["GroupID"]=="Data Analyst")

{

//data analyst group

header("location: BUSINESS_RULE_list.php");

}

else

{

header("location: menu.php");

}
exit();
mcebula author 8/25/2011

Thanks Sergey, that fixed the issue for guests logging in.
I still get the menu for any links to the view page from outside sources. Is there any trick that I can do to get a link to go directly to the destination page without having to go through the menu?
If I comment out all the redirect code in the after successful login event the link does go directly to the view page. It would be best if I could be able to do both redirect based on group and have links bypass the menu if possible.

Sergey Kornilov admin 8/26/2011

Mike,
try something like this:

if ($_SESSION["GroupID"]=="Admin")

{

//admin group

header("location: BUSINESS_RULE_list.php");

}

elseif ($_SESSION["GroupID"]=="Analyst")

{

//analyst group

header("location: BUSINESS_RULE_list.php");

}

elseif ($_SESSION["GroupID"]=="Data Analyst")

{

//data analyst group

header("location: BUSINESS_RULE_list.php");

}

else

{
if($_SESSION["MyURL"])

header("Location: ".$myurl);

else

header("Location: menu.php");
}
exit();
mcebula author 8/29/2011

Thanks Sergey. That works for logging in as guest (get the menu) and logging as in known user (they get landing page) but the links still go straight to menu which isn't the best (menu shows link came in as a guest too).
If you are already sitting on any page in the app, the link does work by going direct to view page but most times a user reading a document would not already be in the app.
If it is too hard I can back off and just give everyone the menu again.

mcebula author 9/29/2011

Sorry I'm back to this again. I was using the menu as a "work around" but I really don't like having the "pre menu" after login because my application has a horizontal menu so dumping the users to a specific page and letting them work with the normal menu makes more sense to me.
Here is my current code snippet after successful login. I'm now in v 6.0 beta now but same thing happens in 5.3 too. I've tried many different flavors of code snippets with no success.

if ($_SESSION["MyURL"])

header("Location: ".$MyURL);

elseif ($_SESSION["GroupID"]=="IDS")

header("Location: MESSAGE_list.php");

else

header("Location: BUSINESS_RULE_list.php");

exit();


Result is if link is clicked user is taken down the ELSE path (BUSINESS_RULE_list.php) when the application is not open in the browser. If you are in the application when the links is clicked it does work (goes to URL) but most use-cases users will not in the application when clicking links.
Any thoughts since I'm stumped.

C
cgphp 9/29/2011

When the "After successful login" event is performed, the $_SESSION['MyURL'] doesn't seem to exist. I can retrieve it only in the "Login page: before process" event.

mcebula author 9/30/2011

Interesting discovery Cristian thanks for checking that. Does that imply that it is a bug that myurl is not available in after successful login?
I tried to cut the myurl part from the after successful login event and tried to test it in login page: before process - result is the and app doesn't even come up (hangs trying to reach the login page).
Login page: before process event code test:

if ($_SESSION["MyURL"])

header("Location: ".$myurl);

exit();
C
cgphp 9/30/2011
if ($_SESSION["MyURL"])

header("Location: ".$_SESSION["MyURL"]);

exit();
mcebula author 9/30/2011

Thanks for the syntax correction. I tried that in 2 places.

  1. In After Successful Login:

if ($_SESSION["MyURL"])

header("Location: ".$_SESSION["MyURL"]);

elseif ($_SESSION["GroupID"]=="IDS")

header("Location: MESSAGE_list.php");

else

header("Location: BUSINESS_RULE_list.php");

exit();



Result = normal login works fine, direct link still goes to final else condition (business rule page) if the app is closed (does work if app is opened already in browser)
2) In Login Page: before process

if ($_SESSION["MyURL"])

header("Location: ".$_SESSION["MyURL"]);

exit():



Result = normal login hangs up on the login.php page (doesn't show page, hitting enter on address line does nothing). Direct link brings up business rule page.
I may to go with #1 and tell users the app must be open in order for links from documents to work. Not pretty but not sure what else I can do
<img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=61156&image=1&table=forumreplies' class='bbc_emoticon' alt=':(' /> <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=61156&image=2&table=forumreplies' class='bbc_emoticon' alt=':(' /> <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=61156&image=3&table=forumreplies' class='bbc_emoticon' alt=':(' />