select last product on login

The release 1.6 is going to be unsupported by Community. Because our effort moves ahead. However there are still valuable informations for you.
Locked
jbarchibald
TestLink user
Posts: 9
Joined: Wed Nov 09, 2005 6:06 pm
Location: Salt Lake City, Utah

select last product on login

Post by jbarchibald »

Here at the bank, we manage over 50 different products.
so we needed the ability for each user to be returned to thier last selected product upon log in. having to change this each time was a pain..

Here is how I resolved the issue.
I added a new column to the user table called lastProduct, of type int.

then added a new function to the users.inc.php:
/** Function updatethe last product selected by the user */
// 20051109 - jba created
function userUpdateLastProduct($userID, $lastProduct)
{
$sql = \"UPDATE user \" .
\"SET lastProduct=\" . $lastProduct;
$sql .= \" WHERE id=\" . $userID;
$result = do_mysql_query($sql);

// MHT 200507 - update session data if admin modify yourself
if (($userID == $_SESSION[\'userID\']) && $result)
setUserSession($login, $userID, $rightsID, $email, $locale, $lastProduct);

return $result ? \'ok\' : mysql_error();
}


I then modified the navBar.php to include the following:

$updateMainPage=0;
if (isset($_GET[\'product\']))
{
$updateMainPage=1;
userUpdateLastProduct($_SESSION[\'userID\'], $_GET[\'product\']);

}

So I\'m basically calling the function and updating the user table every time a new prodect is selected.

then modified the existLogin function in users.inc.php to include my new column, as well as the setUserSession function.

Last I modified the call to set user session in doAuthorize.php to include my new column.

setUserSession($userInfo[\'login\'], $userInfo[\'id\'],
$userInfo[\'rightsid\'], $userInfo[\'email\'],
$userInfo[\'locale\'], $userInfo[\'lastProduct\']);


and viola,, upon login the user is taken directly to the last product they selected before logging out.

there may have been a more elegant way.. and I must add.. with your awsome code structure it was pretty easy to make this change..

Jason
Jason B. Archibald
havlatm
Member of TestLink Community
Posts: 940
Joined: Mon Oct 31, 2005 1:24 am
Location: Czech

Post by havlatm »

A better solution is to use cookies. It\'s not too much work and no changes in DB. But unfortunatelly nobody implement it in 1.6. I think that this request is in our BTS. Just add it if not.
Now we only bug fixing, so no chance to add it now.

Martin
fman
Member of TestLink Community
Posts: 3110
Joined: Tue Nov 15, 2005 7:19 am

This Post is an Issue in Mantis

Post by fman »

Please, don\'t use this forum as Bug Tracking System
You have reported the same bug in mantis, and IMHO mantis is the right place

regards

francisco
Locked