From: ivan Date: Mon, 29 Mar 2010 00:50:28 +0000 (+0000) Subject: add user_custnum to 1.9 for employee commissioning, RT#6991 X-Git-Tag: freeside_1_9_2^5~3 X-Git-Url: http://git.freeside.biz/gitweb/?a=commitdiff_plain;h=3c64b5db7af79557f231f0f41bd821b58c63bc95;p=freeside.git add user_custnum to 1.9 for employee commissioning, RT#6991 --- diff --git a/FS/FS/access_user.pm b/FS/FS/access_user.pm index 8cc8b64fc..1bf6e9387 100644 --- a/FS/FS/access_user.pm +++ b/FS/FS/access_user.pm @@ -10,6 +10,7 @@ use FS::option_Common; use FS::access_user_pref; use FS::access_usergroup; use FS::agent; +use FS::cust_main; @ISA = qw( FS::m2m_Common FS::option_Common FS::Record ); #@ISA = qw( FS::m2m_Common FS::option_Common ); @@ -220,6 +221,9 @@ sub replace { $dbh->rollback or die $dbh->errstr if $oldAutoCommit; return $error; } + } elsif ( $old->disabled && !$new->disabled + && $new->_password =~ /changeme/i ) { + return "Must change password when enabling this account"; } my $error = $new->SUPER::replace($old, @_); @@ -254,6 +258,7 @@ sub check { || $self->ut_text('_password') || $self->ut_text('last') || $self->ut_text('first') + || $self->ut_foreign_keyn('user_custnum', 'cust_main', 'custnum') || $self->ut_enum('disabled', [ '', 'Y' ] ) ; return $error if $error; @@ -272,6 +277,18 @@ sub name { $self->get('last'). ', '. $self->first; } +=item user_cust_main + +Returns the FS::cust_main object (see L), if any, for this +user. + +=cut + +sub user_cust_main { + my $self = shift; + qsearchs( 'cust_main', { 'custnum' => $self->user_custnum } ); +} + =item access_usergroup Returns links to the the groups this user is a part of, as FS::access_usergroup