{
my $val = shift || 0;
- if ($val == 1 or $val eq "yes") {
+ if ($val eq '1' or $val eq "yes") {
return 1;
- } elsif ($val == 2 or $val eq "archived") {
+ } elsif ($val eq '2' or $val eq "archived") {
return 2;
} else {
return 0;
maxvolfiles => 0,
filenameid => 0,
pathid => 0,
+ nb => 0,
);
my %opt_ss =( # string with space
sub display_graph
{
my ($self) = @_;
-
+ $self->can_do('r_view_stat');
my $fields = $self->get_form(qw/age level status clients filesets
graph gtype type filter db_clients
limit db_filesets width height
sub move_media
{
my ($self, $in) = @_ ;
-
+ $self->can_do('r_media_mgnt');
my $media = $self->get_selected_media_location();
unless ($media) {
sub help_extern
{
my ($self) = @_ ;
+ $self->can_do('r_media_mgnt');
my $elt = $self->get_form(qw/db_pools db_mediatypes db_locations/) ;
$self->debug($elt);
sub help_extern_compute
{
my ($self) = @_;
+ $self->can_do('r_media_mgnt');
my $number = CGI::param('limit') || '' ;
unless ($number =~ /^(\d+)$/) {
sub help_intern
{
my ($self) = @_ ;
+ $self->can_do('r_media_mgnt');
my $param = $self->get_form(qw/db_locations db_pools db_mediatypes/) ;
$self->display($param, "help_intern.tpl");
sub help_intern_compute
{
my ($self) = @_;
+ $self->can_do('r_media_mgnt');
my $number = CGI::param('limit') || '' ;
unless ($number =~ /^(\d+)$/) {
sub display_media
{
my ($self, %arg) = @_ ;
+ $self->can_do('r_view_media');
my ($limit, $label) = $self->get_limit(%arg);
my ($where, %elt) = $self->get_param('pools',
sub display_groups
{
my ($self) = @_;
+ my $arg;
- my $arg = $self->get_form(qw/db_client_groups/) ;
+ if ($self->cant_do('r_group_mgnt')) {
+ $arg = $self->get_form(qw/db_client_groups filter/) ;
+ } else {
+ $arg = $self->get_form(qw/db_client_groups/) ;
+ }
if ($self->{dbh}->errstr) {
return $self->error("Can't use groups with bweb, read INSTALL to enable them");
return 1;
}
if (!$self->{loginname}) {
- return 0;
+ $self->error("Can't get your login name");
+ $self->display_end();
+ exit 0;
}
# already fill
if (defined $self->{security}) {
";
my $rows = $self->dbh_selectall_arrayref($query);
# do cache with this role
- if (!$rows) {
- return 0;
+ if (!$rows or !scalar(@$rows)) {
+ $self->error("Can't get $self->{loginname}'s roles");
+ $self->display_end();
+ exit 0;
}
foreach my $r (@$rows) {
$self->{security}->{$r->[1]}=1;
"Check security with your administrator";
return 1;
}
- $self->get_roles();
+ if (!$self->get_roles()) {
+ return 0;
+ }
if (!$self->{security}->{$action}) {
$self->{error} =
"$self->{loginname} sorry, but this action ($action) " .
if ($self->get_roles()) {
return $self->{security}->{use_acl};
} else {
- return 0;
+ return 1;
}
}
sub display_pool
{
my ($self, $poolname) = @_ ;
+ $self->can_do('r_view_media');
+
my $whereA = '';
my $whereW = '';
}, 'display_log.tpl');
}
+sub add_media
+{
+ my ($self) = @_ ;
+ $self->can_do('r_media_mgnt');
+ my $arg = $self->get_form('storage', 'pool', 'nb', 'media', 'offset');
+ my $b = $self->get_bconsole();
+
+ if (!$arg->{storage} || !$arg->{pool} || not defined $arg->{nb} || !$arg->{media} || !$arg->{offset}) {
+ CGI::param(offset => 0);
+ $arg = $self->get_form('db_pools');
+ $arg->{storage} = [ map { { name => $_ } }$b->list_storage()];
+ $self->display($arg, 'add_media.tpl');
+ return 1;
+ }
+
+ my $cmd;
+ if ($arg->{nb} > 0) {
+ $cmd = "add pool=\"$arg->{pool}\" storage=\"$arg->{storage}\"\n$arg->{nb}\n$arg->{media}\n$arg->{offset}\n";
+ } else {
+ $cmd = "add pool=\"$arg->{pool}\" storage=\"$arg->{storage}\"\n0\n$arg->{media}\n";
+ }
+ $b->connect();
+ $b->send($cmd);
+ $b->expect_it('*');
+
+ CGI::param('media', '');
+ CGI::param('re_media', $arg->{media});
+ $self->display_media();
+}
+
sub label_barcodes
{
my ($self) = @_ ;
sub director_show_sched
{
my ($self) = @_ ;
-
+ $self->can_do('r_view_job');
my $arg = $self->get_form('days');
my $b = $self->get_bconsole();