mirror of
https://github.com/ZoneMinder/zoneminder.git
synced 2026-02-05 03:51:11 -05:00
Add Objects for Tag, Event_Tag and add functions to Event to load them.
This commit is contained in:
committed by
Charlie Root
parent
9fa7925f53
commit
cd616214eb
@@ -33,6 +33,8 @@ require ZoneMinder::Object;
|
||||
require ZoneMinder::Storage;
|
||||
require ZoneMinder::Frame;
|
||||
require ZoneMinder::Monitor;
|
||||
require ZoneMinder::Event_Tag;
|
||||
require ZoneMinder::Tag;
|
||||
require Date::Manip;
|
||||
require File::Find;
|
||||
require File::Path;
|
||||
@@ -945,6 +947,31 @@ FROM `Frames` WHERE `EventId`=?';
|
||||
});
|
||||
} # end sub Close
|
||||
|
||||
sub Event_Tags {
|
||||
my $self = shift;
|
||||
$$self{Event_Tags} = shift if @_;
|
||||
if (!$$self{Event_Tags}) {
|
||||
$$self{Event_Tags} = [ ZoneMinder::Event_Tag->find(EventId=>$$self{Id}) ];
|
||||
}
|
||||
return wantarray ? @{$$self{Event_Tags}} : $$self{Event_Tags};
|
||||
}
|
||||
|
||||
sub Tags {
|
||||
my $self = shift;
|
||||
$$self{Tags} = shift if @_;
|
||||
|
||||
if (!$$self{Tags}) {
|
||||
$$self{Tags} = [ map { $_->Tag() } $self->Event_Tags() ];
|
||||
}
|
||||
return wantarray ? @{$$self{Tags}} : $$self{Tags};
|
||||
}
|
||||
|
||||
sub tags {
|
||||
my $self = shift;
|
||||
my @tags = map { $_->Name() } $self->Tags();
|
||||
return wantarray ? @tags : \@tags;
|
||||
}
|
||||
|
||||
1;
|
||||
__END__
|
||||
|
||||
|
||||
85
scripts/ZoneMinder/lib/ZoneMinder/Event_Tag.pm
Normal file
85
scripts/ZoneMinder/lib/ZoneMinder/Event_Tag.pm
Normal file
@@ -0,0 +1,85 @@
|
||||
# ==========================================================================
|
||||
#
|
||||
# ZoneMinder Tag Module
|
||||
# Copyright (C) 2022 ZoneMinder Inc
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
#
|
||||
# ==========================================================================
|
||||
#
|
||||
# This module contains the common definitions and functions used by the rest
|
||||
# of the ZoneMinder scripts
|
||||
#
|
||||
package ZoneMinder::Event_Tag;
|
||||
|
||||
use 5.006;
|
||||
use strict;
|
||||
use warnings;
|
||||
use Time::HiRes qw(usleep);
|
||||
|
||||
require ZoneMinder::Base;
|
||||
require ZoneMinder::Object;
|
||||
require ZoneMinder::Event;
|
||||
require ZoneMinder::Tag;
|
||||
use ZoneMinder::Logger qw(:all);
|
||||
|
||||
use parent qw(ZoneMinder::Object);
|
||||
|
||||
use vars qw/ $table %fields @identified_by %defaults $debug /;
|
||||
$table = 'Events_Tags';
|
||||
@identified_by = ('TagId','EventId');
|
||||
%fields = map { $_ => $_ } qw(
|
||||
TagId
|
||||
EventId
|
||||
AssignedDate
|
||||
AssignedBy
|
||||
);
|
||||
|
||||
%defaults = (
|
||||
);
|
||||
|
||||
sub Event {
|
||||
return new ZoneMinder::Event($_[0]{EventId});
|
||||
}
|
||||
|
||||
sub Tag {
|
||||
return new ZoneMinder::Tag($_[0]{TagId});
|
||||
}
|
||||
|
||||
1;
|
||||
__END__
|
||||
|
||||
=head1 NAME
|
||||
|
||||
ZoneMinder::Event_Tag - Perl Class for Event Tags
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
use ZoneMinder::Event_Tag;
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
Isaac Connor, E<lt>isaac@zoneminder.comE<gt>
|
||||
|
||||
=head1 COPYRIGHT AND LICENSE
|
||||
|
||||
Copyright (C) 2022 ZoneMinder Inc
|
||||
|
||||
This library is free software; you can redistribute it and/or modify
|
||||
it under the same terms as Perl itself, either Perl version 5.8.3 or,
|
||||
at your option, any later version of Perl 5 you may have available.
|
||||
|
||||
|
||||
=cut
|
||||
80
scripts/ZoneMinder/lib/ZoneMinder/Tag.pm
Normal file
80
scripts/ZoneMinder/lib/ZoneMinder/Tag.pm
Normal file
@@ -0,0 +1,80 @@
|
||||
# ==========================================================================
|
||||
#
|
||||
# ZoneMinder Tag Module
|
||||
# Copyright (C) 2022 ZoneMinder Inc
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
#
|
||||
# ==========================================================================
|
||||
#
|
||||
# This module contains the common definitions and functions used by the rest
|
||||
# of the ZoneMinder scripts
|
||||
#
|
||||
package ZoneMinder::Tag;
|
||||
|
||||
use 5.006;
|
||||
use strict;
|
||||
use warnings;
|
||||
use Time::HiRes qw(usleep);
|
||||
|
||||
require ZoneMinder::Base;
|
||||
require ZoneMinder::Object;
|
||||
use ZoneMinder::Logger qw(:all);
|
||||
|
||||
use parent qw(ZoneMinder::Object);
|
||||
|
||||
use vars qw/ $table $primary_key %fields $serial %defaults $debug %transforms/;
|
||||
$table = 'Tags';
|
||||
$serial = $primary_key = 'Id';
|
||||
%fields = map { $_ => $_ } qw(
|
||||
Id
|
||||
Name
|
||||
CreateDate
|
||||
CreatedBy
|
||||
LastAssignedDate
|
||||
);
|
||||
|
||||
%defaults = (
|
||||
);
|
||||
%transforms = (
|
||||
Name => [ 's/\s+//' ],
|
||||
);
|
||||
|
||||
|
||||
1;
|
||||
__END__
|
||||
|
||||
=head1 NAME
|
||||
|
||||
ZoneMinder::Tag - Perl Class for Tags
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
use ZoneMinder::Tag;
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
Isaac Connor, E<lt>isaac@zoneminder.comE<gt>
|
||||
|
||||
=head1 COPYRIGHT AND LICENSE
|
||||
|
||||
Copyright (C) 2022 ZoneMinder Inc
|
||||
|
||||
This library is free software; you can redistribute it and/or modify
|
||||
it under the same terms as Perl itself, either Perl version 5.8.3 or,
|
||||
at your option, any later version of Perl 5 you may have available.
|
||||
|
||||
|
||||
=cut
|
||||
Reference in New Issue
Block a user