Conditional login page

General discussion of Mantis.

Moderators: Developer, Contributor

Post Reply
keimpe
Posts: 5
Joined: 16 Feb 2011, 22:59

Conditional login page

Post by keimpe »

How do I make a conditional default page?

I want to make the following function:
When a user logsin and there is new news the next page is main_page.php
When a user logsin and there is news he has already read the next page is my_view_page.php

What code do I have to add?

maybe the user also goes to the main_page.php when he selects an other project with news he hasn't read
cas
Posts: 1622
Joined: 11 Mar 2006, 16:08
Contact:

Re: Conditional login page

Post by cas »

You could make that change in login_page.php
there you will find the following code (line 31)

Code: Select all

if ( auth_is_user_authenticated() && !current_user_is_anonymous() ) {
	print_header_redirect( config_get( 'default_home_page' ) );
} 
Within the above condition you would need to put your logic.
The 'default_home_page' is nprmally defined in config_inc.php so you that makes life easy :mrgreen:
keimpe
Posts: 5
Joined: 16 Feb 2011, 22:59

Re: Conditional login page

Post by keimpe »

Hi cas,

Thanks, but I don't know a lot about php.
I grabed some lines from main_page.php and put them together.
But when I put in the lines I get a lot of errors, mainly from the _api's.
How does it work? Why can the require_once be called from the main_page.php but not from the login_page.php?
Can you make this work?

require_once( 'core.php' );
require_once( 'current_user_api.php' );
require_once( 'news_api.php' );
require_once( 'string_api.php' );
news_ensure_enabled();
access_ensure_project_level( VIEWER );


$rows = news_get_rows( helper_get_current_project() );
$t_count = count( $rows );
if ( $t_count > 0 )
{
extract( $rows[$t_count], EXTR_PREFIX_ALL, 'v' );
if ( VS_PRIVATE == $v_view_state &&
access_has_project_level( config_get( 'private_news_threshold' ), $v_project_id ) )

{ $v_date_posted = date( config_get( 'complete_date_format' ), $v_date_posted );
if (current_user_get_field( 'last_visit' ) < $v_date_posted)
{ $g_default_home_page = 'main_page.php';}
}
}
Post Reply