[interchange-cvs] interchange - heins modified lib/Vend/Dispatch.pm

interchange-cvs at icdevgroup.org interchange-cvs at icdevgroup.org
Thu Aug 2 11:15:53 EDT 2007


User:      heins
Date:      2007-08-02 15:15:52 GMT
Modified:  lib/Vend Dispatch.pm
Log:
* Add SpecialSub configurability for admin_init. Added at point just
  after initialization of embedded perl, so catalog subroutines can
  handle it and they will be assured of having a proper setup of
  @{$Session}{qw/ superuser admin username groups /}.

* This allows you to simplify access based on groups or usernames, by
  changing configuration. For instance, consider this:

SpecialSub  admin_init  admin_functions
Sub admin_functions <<EOR
sub {
    if(! $Session->{username} eq 'foundation') {
        $Variable->{MV_MENU_DIRECTORY} = 'include/foundation/menus';
    }
}
EOR
u

Revision  Changes    Path
1.83      +14 -2     interchange/lib/Vend/Dispatch.pm


rev 1.83, prev_rev 1.82
Index: Dispatch.pm
===================================================================
RCS file: /var/cvs/interchange/lib/Vend/Dispatch.pm,v
retrieving revision 1.82
retrieving revision 1.83
diff -u -r1.82 -r1.83
--- Dispatch.pm	6 Jul 2007 00:35:18 -0000	1.82
+++ Dispatch.pm	2 Aug 2007 15:15:52 -0000	1.83
@@ -1,6 +1,6 @@
 # Vend::Dispatch - Handle Interchange page requests
 #
-# $Id: Dispatch.pm,v 1.82 2007/07/06 00:35:18 kwalsh Exp $
+# $Id: Dispatch.pm,v 1.83 2007/08/02 15:15:52 mheins Exp $
 #
 # Copyright (C) 2002-2006 Interchange Development Group
 # Copyright (C) 2002 Mike Heins <mike at perusion.net>
@@ -26,7 +26,7 @@
 package Vend::Dispatch;
 
 use vars qw($VERSION);
-$VERSION = substr(q$Revision: 1.82 $, 10);
+$VERSION = substr(q$Revision: 1.83 $, 10);
 
 use POSIX qw(strftime);
 use Vend::Util;
@@ -1400,6 +1400,18 @@
 
 	$Vend::Calc_initialized = 0;
 	$CGI::values{mv_session_id} = $Vend::Session->{id} = $Vend::SessionID;
+
+	if($Vend::admin and my $subname = $Vend::Cfg->{SpecialSub}{admin_init}) {
+		my $sub = $Vend::Cfg->{Sub}{$subname} || $Global::GlobalSub->{$subname};
+		eval {
+			$sub->();
+		};
+
+		if($@) {
+			::logError("Error running %s subroutine %s: %s", 'admin_init', $subname, $@);
+		}
+	}
+
 	if(my $vspace = $CGI::values{mv_values_space}) {
 		$::Values = $Vend::Session->{values_repository}{$vspace} ||= {};
 		$Vend::ValuesSpace = $vspace;








More information about the interchange-cvs mailing list