From: shane <sh...@lo...> - 2002-03-13 21:03:05
|
I'm trying to determine where the "appropriate" place is to determine a user's current section, and I'm getting confused: in the current slash series: If I look at $user->{currentSection}, it is set when header() is called. the line is: $user->{currentSection} = $section || ''; where section was passed to header(). in the devel slash series: there's the SlashSectionHost call that will hard-wire the section because of the URL. It sets $new_cfg->{defaultsection} = $section; and Anchor.pm still has $user->{currentSection} = $section || ''; where section was *passed* to header(). Which leads me to think that getting $user->{currentSection} is *always* up to the perl script running at the time to get the section set correctly. So I cannot do the following: sub main { my $constants = getCurrentStatic(); my $slashdb = getCurrentDB(); my $user = getCurrentUser(); and expect that $user->{currentSection}, at this point in time, is correct. Only after calling header() in the script will $user->{currentSection} be correct. Am I understanding this correctly? Or what did I miss? What I am looking for is the correct way to obtain what section a user is in (so as to display the correct section-related data in a calendar for them). I had always thought this was easy - check the $form data for $form->{section}, look it up with $slashdb->getSection(), check the return for validity and you're set. But with the new Apache directive (which is very cool, btw) it would seem to me that $user->{currentSection} should immediately be populated with that section that the user's in, if they're in a section.sitename.blah And it also seems that any script that needs to know the current section (ie index.pl) would have to do something like my $section; if ($form->{section}) { $section = $slashdb->getSection($form->{section}); } else { $section->{section} = $constants->{defaultsection}; } instead of my $section; if ($form->{section}) { $section = $slashdb->getSection($form->{section}); } else { $section->{section} = 'index'; $section->{issue} = 1; } while other scripts just do: header("$constants->{sitename}", $form->{section}); and don't bother to lookup what's being passed to them via the form. I couldn't test the devel setup with the newer Apache directive, I've got no box that I can run slash>2.2.5 on at this time. (though I did try something like http://apache.slashdot.org/?section=features and it listed as it should) so I think I'm missing something... please help! Shane |