$bweb->help_extern_compute();
} elsif ($action eq 'extern') {
- print "TODO : Eject ", join(",", CGI::param('media'));
+ $bweb->eject_media();
$bweb->move_media();
+} elsif ($action eq 'move_email') {
+ $bweb->move_email();
+
} elsif ($action eq 'change_location') {
$bweb->change_location();
if ($? == 0) {
my $content = $self->get_slot($src);
- print "content = $content<br/> $src => $dst<br/>";
+ print "$content ($src) => $dst<br/>";
$self->{slot}->[$src] = 'empty';
$self->set_slot($dst, $content);
return 1;
my $nb = $self->dbh_do($query);
- print "$nb media updated";
+ print "$nb media updated, you may have to update your autochanger.";
+
+ $self->display_media();
}
sub change_location
sub eject_media
{
my ($self) = @_;
- my $arg = $self->get_form('jmedias', 'slots', 'ach');
+ my $arg = $self->get_form('jmedias');
unless ($arg->{jmedias}) {
return $self->error("Can't get media selection");
}
- my $a = $self->ach_get($arg->{ach});
- unless ($a) {
- return 0;
- }
-
my $query = "
SELECT Media.VolumeName AS volumename,
Storage.Name AS storage,
my $all = $self->dbh_selectall_hashref($query, 'volumename');
- $a->status();
-
foreach my $vol (values %$all) {
+ my $a = $self->ach_get($vol->{location});
+ unless ($a) {
+ $self->error("Can't find autochanger $vol->{location}");
+ next;
+ }
+
+ unless ($a->{have_status}) {
+ $a->status();
+ $a->{have_status} = 1;
+ }
+
print "eject $vol->{volumename} from $vol->{storage} : ";
if ($a->send_to_io($vol->{slot})) {
print "ok</br>";
}
}
+sub move_email
+{
+ my ($self) = @_;
+
+ my ($to, $subject, $content) = (CGI::param('email'),
+ CGI::param('subject'),
+ CGI::param('content'));
+ $to =~ s/[^\w\d\.\@<>,]//;
+ $subject =~ s/[^\w\d\.\[\]]/ /;
+
+ open(MAIL, "|mail -s '$subject' '$to'") ;
+ print MAIL $content;
+ close(MAIL);
+
+ print "Mail sent";
+}
+
sub restore
{
my ($self) = @_;
- <TMPL_VAR VolumeName> (<TMPL_VAR location>)
</TMPL_LOOP>
-When it's finish, could you update media location ? (you can use <a
-href="<TMPL_VAR url>">
-this link</a>).
+When it's finish, could you update media location ?
+(you can use this link : <TMPL_VAR url>).
Thanks
</textarea>
</td></tr></table>
-<input class='formulaire' type='submit' name='action' value='email_move'>
+<input class='formulaire' type='submit' name='action' value='move_email'>
</form>
<br>
<a href="<TMPL_VAR url>"><img alt='update now' src='/bweb/update.png'>Update now</a>