$groupq = " AND client_group_name IN ($arg->{jclient_groups}) ";
}
+my $filter = $bweb->get_client_filter();
+
my $gtype = CGI::param('gtype') || 'bars';
print CGI::header('image/png');
Client.Name AS clientname,
$jobt.Name AS jobname,
$jobt.JobBytes AS jobbytes
-FROM $jobt, FileSet, Client $groupf
+FROM $jobt, FileSet, Client $filter $groupf
WHERE $jobt.ClientId = Client.ClientId
AND $jobt.FileSetId = FileSet.FileSetId
AND $jobt.Type = 'B'
Client.Name AS clientname,
$jobt.Name AS jobname,
$jobt.JobFiles AS jobfiles
-FROM $jobt, FileSet, Client $groupf
+FROM $jobt, FileSet, Client $filter $groupf
WHERE $jobt.ClientId = Client.ClientId
AND $jobt.FileSetId = FileSet.FileSetId
AND $jobt.Type = 'B'
Job.Name AS jobname,
base64_decode_lstat(8,LStat) AS lstat
-FROM Job, FileSet, Filename, Path, File, Client
+FROM Job, FileSet, Filename, Path, File, Client $filter
WHERE Job.ClientId = Client.ClientId
AND Job.FileSetId = FileSet.FileSetId
AND Job.Type = 'B'
Job.Name AS jobname,
brestore_pathvisibility.size AS size
-FROM Job, Client, FileSet, Path, brestore_pathvisibility
+FROM Job, Client $filter, FileSet, Path, brestore_pathvisibility
WHERE Job.ClientId = Client.ClientId
AND Job.FileSetId = FileSet.FileSetId
AND Job.Type = 'B'
- $bweb->{sql}->{UNIX_TIMESTAMP}(StartTime)) + 0.01)
AS rate
-FROM $jobt, FileSet, Client $groupf
+FROM $jobt, FileSet, Client $filter $groupf
WHERE $jobt.ClientId = Client.ClientId
AND $jobt.FileSetId = FileSet.FileSetId
AND $jobt.Type = 'B'
$bweb->{sql}->{SEC_TO_INT}( $bweb->{sql}->{UNIX_TIMESTAMP}(EndTime)
- $bweb->{sql}->{UNIX_TIMESTAMP}(StartTime))
AS duration
-FROM $jobt, FileSet, Client $groupf
+FROM $jobt, FileSet, Client $filter $groupf
WHERE $jobt.ClientId = Client.ClientId
AND $jobt.FileSetId = FileSet.FileSetId
AND $jobt.Type = 'B'
SELECT
" . ($per_t?"":"UNIX_TIMESTAMP") . "($stime) AS A,
$t(JobBytes) AS nb
-FROM $jobt, FileSet, Client $groupf
+FROM $jobt, FileSet, Client $filter $groupf
WHERE $jobt.ClientId = Client.ClientId
AND $jobt.FileSetId = FileSet.FileSetId
AND $jobt.Type = 'B'
);
my $all = $dbh->selectall_arrayref($query) ;
- print STDERR Data::Dumper::Dumper($all);
+# print STDERR Data::Dumper::Dumper($all);
my ($ret) = make_tab_sum($all);
print $obj->plot([$ret->{date}, $ret->{nb}])->png;
sub display_clients
{
my ($self) = @_;
- my $where=' WHERE true '; # by default
+ my $where=''; # by default
my $arg = $self->get_form("client", "qre_client",
"jclient_groups", "qnotingroup");
- my ($filter, undef) = $self->get_param('username');
-
if ($arg->{qre_client}) {
$where = "WHERE Name $self->{sql}->{MATCH} $arg->{qre_client} ";
} elsif ($arg->{client}) {
$where = "WHERE Name = '$arg->{client}' ";
} elsif ($arg->{jclient_groups}) {
# $filter could already contains client_group_member
- $where = ($filter?'':"
+ $where = "
JOIN client_group_member USING (ClientId)
- JOIN client_group USING (client_group_id)") .
-
-" WHERE client_group_name IN ($arg->{jclient_groups}) ";
+ JOIN client_group USING (client_group_id)
+ WHERE client_group_name IN ($arg->{jclient_groups}) ";
} elsif ($arg->{qnotingroup}) {
$where = "
WHERE NOT EXISTS
FileRetention AS fileretention,
JobRetention AS jobretention
FROM Client " . $self->get_client_filter() .
-$where . $filter ;
+$where ;
my $all = $self->dbh_selectall_hashref($query, 'name') ;
}
if ($what{db_clients}) {
- my $filter=''; my $filter_where='';
- if ($what{username}) {
+ my $filter='';
+ if ($what{filter}) {
# get security filter only if asked
$filter = $self->get_client_filter();
- ($filter_where, undef) = $self->get_param('username');
}
my $query = "
SELECT Client.Name as clientname
- FROM Client $filter WHERE true $filter_where
+ FROM Client $filter
";
my $clients = $self->dbh_selectall_hashref($query, 'clientname');
}
if ($what{db_client_groups}) {
+ my $filter='';
+ if ($what{filter}) {
+ # get security filter only if asked
+ $filter = $self->get_client_group_filter();
+ }
+
my $query = "
SELECT client_group_name AS name
- FROM client_group
+ FROM client_group $filter
";
my $grps = $self->dbh_selectall_hashref($query, 'name');
}
if ($what{db_jobnames}) {
+ my $filter='';
+ if ($what{filter}) {
+ $filter = " JOIN Client USING (ClientId) " . $self->get_client_filter();
+ }
my $query = "
SELECT DISTINCT Job.Name AS jobname
- FROM Job
+ FROM Job $filter
";
my $jobnames = $self->dbh_selectall_hashref($query, 'jobname');
my ($self) = @_;
my $fields = $self->get_form(qw/age level status clients filesets
- graph gtype type
- db_clients limit db_filesets width height
+ graph gtype type filter db_clients
+ limit db_filesets width height
qclients qfilesets qjobnames db_jobnames/);
}
}
- # fill this only when security is enabled
- if ($elt{username} and $self->{info}->{enable_security}) {
- if ($self->{loginname} ne 'admin') {
- my $u = $self->dbh_quote($self->{loginname});
- $ret{username}=$self->{loginname};
- $limit .= "AND bweb_user.username = $u ";
- }
- }
-
return ($limit, %ret);
}
'jobtype',
'pools',
'jobid',
- 'username',
'status');
my $cgq='';
if (CGI::param('client_group')) {
}
my $filter = $self->get_client_filter();
- $cgq = ($filter)?$filter:$cgq;
-
my $query="
SELECT Job.JobId AS jobid,
Client.Name AS client,
JobErrors AS joberrors
- FROM Client $cgq,
+ FROM Client $filter $cgq,
Job LEFT JOIN Pool ON (Job.PoolId = Pool.PoolId)
LEFT JOIN FileSet ON (Job.FileSetId = FileSet.FileSetId)
WHERE Client.ClientId=Job.ClientId
# get security filter
my $filter = $self->get_client_filter();
- my ($filter_where, undef) = $self->get_param('username');
my $query="
SELECT DISTINCT Job.JobId AS jobid,
LEFT JOIN Pool ON (Job.PoolId = Pool.PoolId)
WHERE Client.ClientId=Job.ClientId
AND Job.JobId = $jobid
- $filter_where
";
my $row = $self->dbh_selectrow_hashref($query) ;
my ($where, undef) = $self->get_param('client_groups',
'level',
'pools');
-
+ my $filter = $self->get_client_group_filter();
my $query =
"
SELECT client_group_name AS client_group_name,
COALESCE(joberr.nbjobs,0) AS nbjoberr,
COALESCE(jobok.duration, '0:0:0') AS duration
-FROM client_group LEFT JOIN (
+FROM client_group $filter LEFT JOIN (
SELECT client_group_name AS client_group_name, COUNT(1) AS nbjobs,
SUM(JobFiles) AS jobfiles, SUM(JobBytes) AS jobbytes,
SUM(JobErrors) AS joberrors,
FROM client_group
WHERE client_group_name = $arg->{qclient_group});
+DELETE FROM bweb_client_group_acl
+ WHERE client_group_id IN
+ (SELECT client_group_id
+ FROM client_group
+ WHERE client_group_name = $arg->{qclient_group});
+
DELETE FROM client_group
WHERE client_group_name = $arg->{qclient_group};
";
{
my ($self) = @_;
if ($self->{info}->{enable_security}) {
+ my $u = $self->dbh_quote($self->{loginname});
return "
- JOIN client_group_member USING (ClientId)
- JOIN client_group USING (client_group_id)
- JOIN bweb_client_group_acl USING (client_group_id)
- JOIN bweb_user USING (userid) ";
+ JOIN (SELECT ClientId FROM client_group_member
+ JOIN client_group USING (client_group_id)
+ JOIN bweb_client_group_acl USING (client_group_id)
+ JOIN bweb_user USING (userid)
+ WHERE bweb_user.username = $u
+ ) AS filter USING (ClientId)";
+ } else {
+ return '';
+ }
+}
+
+#JOIN client_group USING (client_group_id)" . $b->get_client_group_filter()
+sub get_client_group_filter
+{
+ my ($self) = @_;
+ if ($self->{info}->{enable_security}) {
+ my $u = $self->dbh_quote($self->{loginname});
+ return "
+ JOIN (SELECT client_group_id
+ FROM bweb_client_group_acl
+ JOIN bweb_user USING (userid)
+ WHERE bweb_user.username = $u
+ ) AS filter USING (client_group_id)";
} else {
return '';
}
WHERE userid IN (
SELECT userid
FROM bweb_user
- WHERE username in ($username)
-)");
+ WHERE username in ($username))");
+ $self->dbh_do("
+DELETE FROM bweb_client_group_acl
+ WHERE userid IN (
+ SELECT userid
+ FROM bweb_user
+ WHERE username IN ($username))");
+
}
sub users_del
$self->{dbh}->begin_work();
{
$self->revoke_all($arg->{jusernames});
- $self->dbh_do("DELETE FROM bweb_user WHERE username IN ($arg->{jusernames})");
+ $self->dbh_do("
+DELETE FROM bweb_user WHERE username IN ($arg->{jusernames})");
}
$self->{dbh}->commit();
$self->can_do("user_mgnt");
# we don't quote username directly to check that it is conform
- my $arg = $self->get_form(qw/username qpasswd qcomment jrolenames qcreate qcopy_username/) ;
+ my $arg = $self->get_form(qw/username qpasswd qcomment jrolenames qcreate qcopy_username jclient_groups/) ;
if (not $arg->{qcreate}) {
- $arg = $self->get_form(qw/db_roles db_usernames/);
+ $arg = $self->get_form(qw/db_roles db_usernames db_client_groups/);
$self->display($arg, "display_user.tpl");
return 1;
}
} else {
$self->grant($arg->{jrolenames}, $u);
}
+
+ $self->dbh_do("
+INSERT INTO bweb_client_group_acl (client_group_id, userid)
+ SELECT client_group_id, userid
+ FROM client_group, bweb_user
+ WHERE client_group_name IN ($arg->{jclient_groups})
+ AND username = $u
+");
+
}
$self->{dbh}->commit();
my ($self) = @_;
$self->can_do("user_mgnt");
- my $arg = $self->get_form(qw/username db_usernames/);
+ my $arg = $self->get_form('username');
my $user = $self->dbh_quote($arg->{username});
my $userp = $self->dbh_selectrow_hashref("
if (!$userp) {
return $self->error("Can't find $user in catalog");
}
+ $arg = $self->get_form(qw/db_usernames db_client_groups/);
+ my $arg2 = $self->get_form(qw/filter db_client_groups/);
# rolename | userid
#------------+--------
username => $userp->{username},
comment => $userp->{comment},
passwd => $userp->{passwd},
+ db_client_groups => $arg->{db_client_groups},
+ client_group => $arg2->{db_client_groups},
db_roles => [ values %$role],
}, "display_user.tpl");
}
my $client = $self->dbh_quote($arg{clientname});
# get security filter
my $filter = $self->get_client_filter();
- my ($filter_where, undef) = $self->get_param('username');
+
my ($limit, $label) = $self->get_limit(%arg);
my $query = "
SELECT
FROM Job JOIN Client USING (ClientId) $filter
WHERE
Client.Name = $client
- $filter_where
$limit
GROUP BY Client.Name
";
if (!$arg->{client} and $arg->{jobid}) {
# get security filter
my $filter = $self->get_client_filter();
- my ($filter_where, undef) = $self->get_param('username');
my $query = "
SELECT Client.Name AS name
FROM Job INNER JOIN Client USING (ClientId) $filter
-WHERE Job.JobId = $arg->{jobid} $filter_where
+WHERE Job.JobId = $arg->{jobid}
";
my $row = $self->dbh_selectrow_hashref($query);
my ($self, $display_action) = @_;
# get security filter
my $filter = $self->get_client_filter();
- my ($filter_where, undef) = $self->get_param('username');
my $query = "
SELECT Job.JobId AS jobid,
FROM Job INNER JOIN Client USING (ClientId) $filter
WHERE
JobStatus IN ('C','R','B','e','D','F','S','m','M','s','j','c','d','t','p')
- $filter_where
";
my $all = $self->dbh_selectall_hashref($query, 'jobid') ;
# get security filter
$filter .= $self->get_client_filter();
- my ($filter_where, undef) = $self->get_param('username');
my $query = "
SELECT Job.Name as name, Client.Name as clientname
FROM Job INNER JOIN Client USING (ClientId) $filter
- WHERE JobId = $arg->{jobid} $filter_where
+ WHERE JobId = $arg->{jobid}
";
my $row = $self->dbh_selectrow_hashref($query);