Merge branch 'storageareas' into tesla
This commit is contained in:
commit
b8cfff2b6d
|
@ -2,3 +2,6 @@
|
||||||
path = web/api/app/Plugin/Crud
|
path = web/api/app/Plugin/Crud
|
||||||
url = https://github.com/FriendsOfCake/crud.git
|
url = https://github.com/FriendsOfCake/crud.git
|
||||||
branch = 3.0
|
branch = 3.0
|
||||||
|
[submodule "web/api/app/Plugin/CakePHP-Enum-Behavior"]
|
||||||
|
path = web/api/app/Plugin/CakePHP-Enum-Behavior
|
||||||
|
url = https://github.com/asper/CakePHP-Enum-Behavior.git
|
||||||
|
|
|
@ -647,13 +647,13 @@ if(NOT ZM_NO_LIBVLC)
|
||||||
endif(LIBVLC_LIBRARIES)
|
endif(LIBVLC_LIBRARIES)
|
||||||
endif(NOT ZM_NO_LIBVLC)
|
endif(NOT ZM_NO_LIBVLC)
|
||||||
|
|
||||||
find_package(Boost 1.36.0)
|
#find_package(Boost 1.36.0)
|
||||||
if(Boost_FOUND)
|
#if(Boost_FOUND)
|
||||||
include_directories(${Boost_INCLUDE_DIRS})
|
#include_directories(${Boost_INCLUDE_DIRS})
|
||||||
set(CMAKE_REQUIRED_INCLUDES "${Boost_INCLUDE_DIRS}")
|
##set(CMAKE_REQUIRED_INCLUDES "${Boost_INCLUDE_DIRS}")
|
||||||
list(APPEND ZM_BIN_LIBS "${Boost_LIBRARIES}")
|
#list(APPEND ZM_BIN_LIBS "${Boost_LIBRARIES}")
|
||||||
endif()
|
#endif()
|
||||||
|
#
|
||||||
# *** END OF LIBRARY CHECKS ***
|
# *** END OF LIBRARY CHECKS ***
|
||||||
|
|
||||||
# Check for gnutls or crypto
|
# Check for gnutls or crypto
|
||||||
|
|
|
@ -200,6 +200,32 @@ sub RelativePath {
|
||||||
return $$event{RelativePath};
|
return $$event{RelativePath};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub LinkPath {
|
||||||
|
my $event = shift;
|
||||||
|
if ( @_ ) {
|
||||||
|
$$event{LinkPath} = $_[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( ! $$event{LinkPath} ) {
|
||||||
|
if ( $$event{Scheme} eq 'Deep' ) {
|
||||||
|
if ( $event->Time() ) {
|
||||||
|
$$event{LinkPath} = join('/',
|
||||||
|
$event->{MonitorId},
|
||||||
|
strftime( '%y/%m/%d',
|
||||||
|
localtime($event->Time())
|
||||||
|
),
|
||||||
|
'.'.$$event{Id}
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
Error("Event $$event{Id} has no value for Time(), unable to determine link path");
|
||||||
|
$$event{LinkPath} = '';
|
||||||
|
}
|
||||||
|
} # end if Scheme
|
||||||
|
} # end if ! Path
|
||||||
|
|
||||||
|
return $$event{LinkPath};
|
||||||
|
} # end sub LinkPath
|
||||||
|
|
||||||
sub GenerateVideo {
|
sub GenerateVideo {
|
||||||
my ( $self, $rate, $fps, $scale, $size, $overwrite, $format ) = @_;
|
my ( $self, $rate, $fps, $scale, $size, $overwrite, $format ) = @_;
|
||||||
|
|
||||||
|
@ -292,10 +318,10 @@ sub delete {
|
||||||
my $event = $_[0];
|
my $event = $_[0];
|
||||||
if ( ! ( $event->{Id} and $event->{MonitorId} and $event->{StartTime} ) ) {
|
if ( ! ( $event->{Id} and $event->{MonitorId} and $event->{StartTime} ) ) {
|
||||||
my ( $caller, undef, $line ) = caller;
|
my ( $caller, undef, $line ) = caller;
|
||||||
Warning( "Can't Delete event $event->{Id} from Monitor $event->{MonitorId} $event->{StartTime} from $caller:$line\n" );
|
Warning( "Can't Delete event $event->{Id} from Monitor $event->{MonitorId} StartTime:$event->{StartTime} from $caller:$line\n" );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Info( "Deleting event $event->{Id} from Monitor $event->{MonitorId} $event->{StartTime}\n" );
|
Info( "Deleting event $event->{Id} from Monitor $event->{MonitorId} StartTime:$event->{StartTime}\n" );
|
||||||
$ZoneMinder::Database::dbh->ping();
|
$ZoneMinder::Database::dbh->ping();
|
||||||
# Do it individually to avoid locking up the table for new events
|
# Do it individually to avoid locking up the table for new events
|
||||||
my $sql = 'DELETE FROM Events WHERE Id=?';
|
my $sql = 'DELETE FROM Events WHERE Id=?';
|
||||||
|
@ -337,50 +363,25 @@ sub delete_files {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
chdir( $storage_path );
|
|
||||||
|
|
||||||
if ( $$event{Scheme} eq 'Deep' ) {
|
|
||||||
if ( ! $$event{MonitorId} ) {
|
if ( ! $$event{MonitorId} ) {
|
||||||
Error("No monitor id assigned to event $$event{Id}");
|
Error("No monitor id assigned to event $$event{Id}");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Debug("Deleting files for Event $$event{Id} from $storage_path.");
|
my $event_path = $event->Path();
|
||||||
my $link_path = $$event{MonitorId}.'/*/*/*/.'.$$event{Id};
|
Debug("Deleting files for Event $$event{Id} from $event_path.");
|
||||||
#Debug( "LP1:$link_path" );
|
if ( $event_path ) {
|
||||||
my @links = glob($link_path);
|
|
||||||
#Debug( "L:".$links[0].": $!" );
|
|
||||||
if ( @links ) {
|
|
||||||
( $link_path ) = ( $links[0] =~ /^(.*)$/ ); # De-taint
|
|
||||||
#Debug( "LP2:$link_path" );
|
|
||||||
|
|
||||||
( my $day_path = $link_path ) =~ s/\.\d+//;
|
|
||||||
#Debug( "DP:$day_path" );
|
|
||||||
my $event_path = $day_path.readlink( $link_path );
|
|
||||||
( $event_path ) = ( $event_path =~ /^(.*)$/ ); # De-taint
|
( $event_path ) = ( $event_path =~ /^(.*)$/ ); # De-taint
|
||||||
#Debug( "EP:$event_path" );
|
|
||||||
my $command = "/bin/rm -rf $event_path";
|
my $command = "/bin/rm -rf $event_path";
|
||||||
#Debug( "C:$command" );
|
|
||||||
ZoneMinder::General::executeShellCommand( $command );
|
|
||||||
|
|
||||||
unlink( $link_path ) or Error( "Unable to unlink '$link_path': $!" );
|
|
||||||
|
|
||||||
my @path_parts = split( /\//, $event_path );
|
|
||||||
for ( my $i = int(@path_parts)-2; $i >= 1; $i-- ) {
|
|
||||||
my $delete_path = join( '/', @path_parts[0..$i] );
|
|
||||||
#Debug( "DP$i:$delete_path" );
|
|
||||||
my @has_files = glob( join('/', $storage_path,$delete_path,'*' ) );
|
|
||||||
#Debug( "HF1:".$has_files[0] ) if ( @has_files );
|
|
||||||
last if ( @has_files );
|
|
||||||
@has_files = glob( join('/', $storage_path, $delete_path, '.[0-9]*' ) );
|
|
||||||
#Debug( "HF2:".$has_files[0] ) if ( @has_files );
|
|
||||||
last if ( @has_files );
|
|
||||||
my $command = "/bin/rm -rf $storage_path/$delete_path";
|
|
||||||
ZoneMinder::General::executeShellCommand( $command );
|
ZoneMinder::General::executeShellCommand( $command );
|
||||||
}
|
}
|
||||||
} # end if links
|
|
||||||
} else {
|
if ( $$event{Scheme} eq 'Deep' ) {
|
||||||
my $command = '/bin/rm -rf '. $storage_path . '/'. $event->RelativePath();
|
my $link_path = $event->LinkPath();
|
||||||
ZoneMinder::General::executeShellCommand( $command );
|
Debug("Deleting files for Event $$event{Id} from $storage_path/$link_path.");
|
||||||
|
if ( $link_path ) {
|
||||||
|
( $link_path ) = ( $link_path =~ /^(.*)$/ ); # De-taint
|
||||||
|
unlink( $storage_path.'/'.$link_path ) or Error( "Unable to unlink '$storage_path/$link_path': $!" );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} # end sub delete_files
|
} # end sub delete_files
|
||||||
|
|
||||||
|
|
|
@ -219,24 +219,18 @@ sub getFilters {
|
||||||
) ORDER BY Name';
|
) ORDER BY Name';
|
||||||
my $sth = $dbh->prepare_cached( $sql )
|
my $sth = $dbh->prepare_cached( $sql )
|
||||||
or Fatal( "Unable to prepare '$sql': ".$dbh->errstr() );
|
or Fatal( "Unable to prepare '$sql': ".$dbh->errstr() );
|
||||||
my $res;
|
my $res = $sth->execute( @sql_values )
|
||||||
if ( $filter_name ) {
|
|
||||||
$res = $sth->execute( $filter_name )
|
|
||||||
or Fatal( "Unable to execute '$sql': ".$sth->errstr() );
|
or Fatal( "Unable to execute '$sql': ".$sth->errstr() );
|
||||||
} else {
|
|
||||||
$res = $sth->execute()
|
|
||||||
or Fatal( "Unable to execute '$sql': ".$sth->errstr() );
|
|
||||||
}
|
|
||||||
FILTER: while( my $db_filter = $sth->fetchrow_hashref() ) {
|
FILTER: while( my $db_filter = $sth->fetchrow_hashref() ) {
|
||||||
my $filter = new ZoneMinder::Filter( $$db_filter{Id}, $db_filter );
|
my $filter = new ZoneMinder::Filter( $$db_filter{Id}, $db_filter );
|
||||||
Debug( "Found filter '$db_filter->{Name}'\n" );
|
Debug( "Found filter '$db_filter->{Name}'\n" );
|
||||||
my $sql = $filter->Sql();
|
my $filter_sql = $filter->Sql();
|
||||||
|
|
||||||
if ( ! $sql ) {
|
if ( ! $filter_sql ) {
|
||||||
Error( "Error parsing Sql. skipping filter '$db_filter->{Name}'\n" );
|
Error( "Error parsing Sql. skipping filter '$db_filter->{Name}'\n" );
|
||||||
next FILTER;
|
next FILTER;
|
||||||
}
|
}
|
||||||
push( @filters, $filter );
|
push @filters, $filter;
|
||||||
}
|
}
|
||||||
$sth->finish();
|
$sth->finish();
|
||||||
if ( ! @filters ) {
|
if ( ! @filters ) {
|
||||||
|
@ -245,7 +239,7 @@ FILTER: while( my $db_filter = $sth->fetchrow_hashref() ) {
|
||||||
Debug( "Got " . @filters . " filters" );
|
Debug( "Got " . @filters . " filters" );
|
||||||
}
|
}
|
||||||
|
|
||||||
return( @filters );
|
return @filters;
|
||||||
} # end sub getFilters
|
} # end sub getFilters
|
||||||
|
|
||||||
sub checkFilter {
|
sub checkFilter {
|
||||||
|
|
|
@ -70,6 +70,7 @@ Cache::config('default', array('engine' => 'Apc'));
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
CakePlugin::load('Crud');
|
CakePlugin::load('Crud');
|
||||||
|
CakePlugin::load('CakePHP-Enum-Behavior');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* You can attach event listeners to the request lifecycle as Dispatcher Filter. By default CakePHP bundles two filters:
|
* You can attach event listeners to the request lifecycle as Dispatcher Filter. By default CakePHP bundles two filters:
|
||||||
|
|
|
@ -15,6 +15,9 @@ class MonitorsController extends AppController {
|
||||||
*/
|
*/
|
||||||
public $components = array('Paginator', 'RequestHandler');
|
public $components = array('Paginator', 'RequestHandler');
|
||||||
|
|
||||||
|
public function beforeRender() {
|
||||||
|
$this->set($this->Monitor->enumValues());
|
||||||
|
}
|
||||||
public function beforeFilter() {
|
public function beforeFilter() {
|
||||||
parent::beforeFilter();
|
parent::beforeFilter();
|
||||||
$canView = $this->Session->Read('monitorPermission');
|
$canView = $this->Session->Read('monitorPermission');
|
||||||
|
@ -111,8 +114,7 @@ class MonitorsController extends AppController {
|
||||||
public function add() {
|
public function add() {
|
||||||
if ( $this->request->is('post') ) {
|
if ( $this->request->is('post') ) {
|
||||||
|
|
||||||
if ($this->Session->Read('systemPermission') != 'Edit')
|
if ( $this->Session->Read('systemPermission') != 'Edit' ) {
|
||||||
{
|
|
||||||
throw new UnauthorizedException(__('Insufficient privileges'));
|
throw new UnauthorizedException(__('Insufficient privileges'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -120,8 +122,15 @@ class MonitorsController extends AppController {
|
||||||
$this->Monitor->create();
|
$this->Monitor->create();
|
||||||
if ($this->Monitor->save($this->request->data)) {
|
if ($this->Monitor->save($this->request->data)) {
|
||||||
$this->daemonControl($this->Monitor->id, 'start');
|
$this->daemonControl($this->Monitor->id, 'start');
|
||||||
return $this->flash(__('The monitor has been saved.'), array('action' => 'index'));
|
//return $this->flash(__('The monitor has been saved.'), array('action' => 'index'));
|
||||||
|
$message = 'Saved';
|
||||||
|
} else {
|
||||||
|
$message = 'Error';
|
||||||
}
|
}
|
||||||
|
$this->set(array(
|
||||||
|
'message' => $message,
|
||||||
|
'_serialize' => array('message')
|
||||||
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -138,8 +147,7 @@ class MonitorsController extends AppController {
|
||||||
if (!$this->Monitor->exists($id)) {
|
if (!$this->Monitor->exists($id)) {
|
||||||
throw new NotFoundException(__('Invalid monitor'));
|
throw new NotFoundException(__('Invalid monitor'));
|
||||||
}
|
}
|
||||||
if ($this->Session->Read('monitorPermission') != 'Edit')
|
if ($this->Session->Read('monitorPermission') != 'Edit') {
|
||||||
{
|
|
||||||
throw new UnauthorizedException(__('Insufficient privileges'));
|
throw new UnauthorizedException(__('Insufficient privileges'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -86,10 +86,10 @@ class Monitor extends AppModel {
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* * hasMany associations
|
* hasMany associations
|
||||||
* *
|
*
|
||||||
* * @var array
|
* @var array
|
||||||
* */
|
*/
|
||||||
public $hasAndBelongsToMany = array(
|
public $hasAndBelongsToMany = array(
|
||||||
'Group' => array(
|
'Group' => array(
|
||||||
'className' => 'Group',
|
'className' => 'Group',
|
||||||
|
@ -108,5 +108,16 @@ class Monitor extends AppModel {
|
||||||
'counterQuery' => ''
|
'counterQuery' => ''
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
public $actsAs = array(
|
||||||
|
'CakePHP-Enum-Behavior.Enum' => array(
|
||||||
|
'Type' => array('Local','Remote','File','Ffmpeg','Libvlc','cURL'),
|
||||||
|
'Function' => array('None','Monitor','Modect','Record','Mocord','Nodect'),
|
||||||
|
'Orientation' => array('0','90','180','270','hori','vert'),
|
||||||
|
'OutputCodec' => array('h264','mjpeg','mpeg1','mpeg2'),
|
||||||
|
'OutputContainer' => array('auto','mp4','mkv'),
|
||||||
|
'DefaultView' => array('Events','Control'),
|
||||||
|
'Status' => array('Unknown','NotRunning','Running','NoSignal','Signal'),
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
Subproject commit 7108489f218c54d36d235d3af91d6da2f8311237
|
|
@ -0,0 +1,2 @@
|
||||||
|
echo json_encode($message);
|
||||||
|
echo json_encode($monitor);
|
|
@ -0,0 +1,2 @@
|
||||||
|
$xml = Xml::fromArray(array('response' => $message));
|
||||||
|
echo $xml->asXML();
|
Loading…
Reference in New Issue