[freeside-commits] freeside/FS/FS/TicketSystem RT_Internal.pm, 1.9, 1.10 RT_External.pm, 1.34, 1.35
Ivan,,,
ivan at wavetail.420.am
Wed Jul 8 04:12:47 PDT 2009
- Previous message: [freeside-commits] freeside/httemplate/search/elements cust_main_dayranges.html, NONE, 1.1
- Next message: [freeside-commits] freeside/httemplate/elements menu.html, 1.61, 1.62 header.html, 1.26, 1.27 popup_link.html, 1.8, 1.9 about_freeside.html, NONE, 1.1 about_rt.html, NONE, 1.1
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /home/cvs/cvsroot/freeside/FS/FS/TicketSystem
In directory wavetail.420.am:/tmp/cvs-serv14082/FS/FS/TicketSystem
Modified Files:
RT_Internal.pm RT_External.pm
Log Message:
borg RT menus, RT#1169
Index: RT_External.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/TicketSystem/RT_External.pm,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -d -r1.34 -r1.35
--- RT_External.pm 8 Feb 2008 15:00:51 -0000 1.34
+++ RT_External.pm 8 Jul 2009 11:12:45 -0000 1.35
@@ -349,5 +349,10 @@
$self->_retrieve_single_value($sql);
}
+sub access_right {
+ warn "WARNING: no access rights available w/ external RT";
+ 0;
+}
+
1;
Index: RT_Internal.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/TicketSystem/RT_Internal.pm,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- RT_Internal.pm 17 Dec 2007 19:59:12 -0000 1.9
+++ RT_Internal.pm 8 Jul 2009 11:12:45 -0000 1.10
@@ -1,13 +1,16 @@
package FS::TicketSystem::RT_Internal;
use strict;
-use vars qw( @ISA );
+use vars qw( @ISA $DEBUG );
use FS::UID qw(dbh);
use FS::CGI qw(popurl);
use FS::TicketSystem::RT_Libs;
+use RT::CurrentUser;
@ISA = qw( FS::TicketSystem::RT_Libs );
+$DEBUG = 1;
+
sub sql_num_customer_tickets {
"( select count(*) from tickets
join links on ( tickets.id = links.localbase )
@@ -25,5 +28,111 @@
}
}
+#mapping/genericize??
+#ShowConfigTab ModifySelf
+sub access_right {
+ my( $self, $session, $right ) = @_;
+
+ #return '' unless $conf->config('ticket_system');
+ return '' unless FS::Conf->new->config('ticket_system');
+
+ $self->_web_external_auth($session)
+ unless $session
+ && $session->{'CurrentUser'};
+
+ $session->{'CurrentUser'}->HasRight( Right => $right,
+ Object => $RT::System );
+}
+
+#shameless false laziness w/rt/html/autohandler to get logged into RT from afar
+sub _web_external_auth {
+ my( $self, $session ) = @_;
+
+ my $user = $FS::CurrentUser::CurrentUser->username;
+
+ $session->{'CurrentUser'} = RT::CurrentUser->new();
+
+ warn "loading RT user for $user\n"
+ if $DEBUG;
+
+ $session->{'CurrentUser'}->Load($user);
+
+ if ( ! $session->{'CurrentUser'}->Id() ) {
+
+ # Create users on-the-fly
+
+ warn "can't load RT user for $user; auto-creating\n"
+ if $DEBUG;
+
+ my $UserObj = RT::User->new( RT::CurrentUser->new('RT_System') );
+
+ my ( $val, $msg ) = $UserObj->Create(
+ %{ ref($RT::AutoCreate) ? $RT::AutoCreate : {} },
+ Name => $user,
+ Gecos => $user,
+ );
+
+ if ($val) {
+
+ # now get user specific information, to better create our user.
+ my $new_user_info
+ = RT::Interface::Web::WebExternalAutoInfo($user);
+
+ # set the attributes that have been defined.
+ # FIXME: this is a horrible kludge. I'm sure there's something cleaner
+ foreach my $attribute (
+ 'Name', 'Comments',
+ 'Signature', 'EmailAddress',
+ 'PagerEmailAddress', 'FreeformContactInfo',
+ 'Organization', 'Disabled',
+ 'Privileged', 'RealName',
+ 'NickName', 'Lang',
+ 'EmailEncoding', 'WebEncoding',
+ 'ExternalContactInfoId', 'ContactInfoSystem',
+ 'ExternalAuthId', 'Gecos',
+ 'HomePhone', 'WorkPhone',
+ 'MobilePhone', 'PagerPhone',
+ 'Address1', 'Address2',
+ 'City', 'State',
+ 'Zip', 'Country'
+ )
+ {
+ #uhh, wrong root
+ #$m->comp( '/Elements/Callback', %ARGS,
+ # _CallbackName => 'NewUser' );
+
+ my $method = "Set$attribute";
+ $UserObj->$method( $new_user_info->{$attribute} )
+ if ( defined $new_user_info->{$attribute} );
+ }
+ $session->{'CurrentUser'}->Load($user);
+ }
+ else {
+
+ # we failed to successfully create the user. abort abort abort.
+ delete $session->{'CurrentUser'};
+
+ die "can't auto-create RT user"; #an error message would be nice :/
+ #$m->abort() unless $RT::WebFallbackToInternalAuth;
+ #$m->comp( '/Elements/Login', %ARGS,
+ # Error => loc( 'Cannot create user: [_1]', $msg ) );
+ }
+ }
+
+ unless ( $session->{'CurrentUser'}->Id() ) {
+ delete $session->{'CurrentUser'};
+
+ die "can't auto-create RT user";
+ #$user = $orig_user;
+ #
+ #if ($RT::WebExternalOnly) {
+ # $m->comp( '/Elements/Login', %ARGS,
+ # Error => loc('You are not an authorized user') );
+ # $m->abort();
+ #}
+ }
+
+}
+
1;
- Previous message: [freeside-commits] freeside/httemplate/search/elements cust_main_dayranges.html, NONE, 1.1
- Next message: [freeside-commits] freeside/httemplate/elements menu.html, 1.61, 1.62 header.html, 1.26, 1.27 popup_link.html, 1.8, 1.9 about_freeside.html, NONE, 1.1 about_rt.html, NONE, 1.1
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the freeside-commits
mailing list