use FS::Record qw( qsearch qsearchs dbh );
use FS::m2m_Common;
use FS::access_usergroup;
+use FS::agent;
@ISA = qw( FS::m2m_Common FS::Record );
sub agentnums_sql {
my $self = shift;
+
+ my @agentnums = $self->agentnums;
+ return ' 1 = 0 ' unless scalar(@agentnums);
+
'( '.
- join( ' OR ', map "agentnum = $_", $self->agentnums ).
+ join( ' OR ', map "agentnum = $_", @agentnums ).
' )';
}
$sth->fetchrow_arrayref->[0];
}
+=item agents
+
+Returns the list of agents this user can view (via group membership), as
+FS::agent objects.
+
+=cut
+
+sub agents {
+ my $self = shift;
+ qsearch({
+ 'table' => 'agent',
+ 'hashref' => { disabled=>'' },
+ 'extra_sql' => ' AND '. $self->agentnums_sql,
+ });
+}
=item access_right