Merge branch 'master' into fix_2167
commit
c095b9cd33
|
@ -78,8 +78,11 @@ class AppController extends Controller {
|
|||
if ( ZM_OPT_USE_AUTH ) {
|
||||
// We need to reject methods that are not authenticated
|
||||
// besides login and logout
|
||||
if ( strcasecmp($this->params->action, 'login') &&
|
||||
strcasecmp($this->params->action, 'logout')) {
|
||||
if (
|
||||
strcasecmp($this->params->action, 'login')
|
||||
&&
|
||||
strcasecmp($this->params->action, 'logout')
|
||||
) {
|
||||
if ( !( $user and $user['Username'] ) ) {
|
||||
throw new UnauthorizedException(__('Not Authenticated'));
|
||||
return;
|
||||
|
|
|
@ -8,12 +8,12 @@ App::uses('AppController', 'Controller');
|
|||
*/
|
||||
class EventsController extends AppController {
|
||||
|
||||
/**
|
||||
* Components
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $components = array('RequestHandler', 'Scaler', 'Image', 'Paginator');
|
||||
/**
|
||||
* Components
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $components = array('RequestHandler', 'Scaler', 'Image', 'Paginator');
|
||||
|
||||
public function beforeFilter() {
|
||||
parent::beforeFilter();
|
||||
|
@ -25,14 +25,14 @@ class EventsController extends AppController {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* index method
|
||||
*
|
||||
* @return void
|
||||
* This also creates a thumbnail for each event.
|
||||
*/
|
||||
public function index() {
|
||||
$this->Event->recursive = -1;
|
||||
/**
|
||||
* index method
|
||||
*
|
||||
* @return void
|
||||
* This also creates a thumbnail for each event.
|
||||
*/
|
||||
public function index() {
|
||||
$this->Event->recursive = -1;
|
||||
|
||||
global $user;
|
||||
$allowedMonitors = $user ? preg_split('@,@', $user['MonitorIds'], NULL, PREG_SPLIT_NO_EMPTY) : null;
|
||||
|
@ -43,26 +43,26 @@ class EventsController extends AppController {
|
|||
$mon_options = '';
|
||||
}
|
||||
|
||||
if ( $this->request->params['named'] ) {
|
||||
//$this->FilterComponent = $this->Components->load('Filter');
|
||||
//$conditions = $this->FilterComponent->buildFilter($this->request->params['named']);
|
||||
if ( $this->request->params['named'] ) {
|
||||
//$this->FilterComponent = $this->Components->load('Filter');
|
||||
//$conditions = $this->FilterComponent->buildFilter($this->request->params['named']);
|
||||
$conditions = $this->request->params['named'];
|
||||
} else {
|
||||
$conditions = array();
|
||||
}
|
||||
} else {
|
||||
$conditions = array();
|
||||
}
|
||||
$settings = array(
|
||||
// https://github.com/ZoneMinder/ZoneMinder/issues/995
|
||||
// 'limit' => $limit['ZM_WEB_EVENTS_PER_PAGE'],
|
||||
// 25 events per page which is what the above
|
||||
// default is, is way too low for an API
|
||||
// changing this to 100 so we don't kill ZM
|
||||
// with many event APIs. In future, we can
|
||||
// make a nice ZM_API_ITEMS_PER_PAGE for all pagination
|
||||
// API
|
||||
// https://github.com/ZoneMinder/ZoneMinder/issues/995
|
||||
// 'limit' => $limit['ZM_WEB_EVENTS_PER_PAGE'],
|
||||
// 25 events per page which is what the above
|
||||
// default is, is way too low for an API
|
||||
// changing this to 100 so we don't kill ZM
|
||||
// with many event APIs. In future, we can
|
||||
// make a nice ZM_API_ITEMS_PER_PAGE for all pagination
|
||||
// API
|
||||
|
||||
'limit' => '100',
|
||||
'order' => array('StartTime'),
|
||||
'paramType' => 'querystring',
|
||||
'limit' => '100',
|
||||
'order' => array('StartTime'),
|
||||
'paramType' => 'querystring',
|
||||
);
|
||||
if ( isset($conditions['GroupId']) ) {
|
||||
$settings['joins'] = array(
|
||||
|
@ -78,36 +78,36 @@ class EventsController extends AppController {
|
|||
}
|
||||
$settings['conditions'] = array($conditions, $mon_options);
|
||||
|
||||
// How many events to return
|
||||
$this->loadModel('Config');
|
||||
$limit = $this->Config->find('list', array(
|
||||
'conditions' => array('Name' => 'ZM_WEB_EVENTS_PER_PAGE'),
|
||||
'fields' => array('Name', 'Value')
|
||||
));
|
||||
$this->Paginator->settings = $settings;
|
||||
$events = $this->Paginator->paginate('Event');
|
||||
// How many events to return
|
||||
$this->loadModel('Config');
|
||||
$limit = $this->Config->find('list', array(
|
||||
'conditions' => array('Name' => 'ZM_WEB_EVENTS_PER_PAGE'),
|
||||
'fields' => array('Name', 'Value')
|
||||
));
|
||||
$this->Paginator->settings = $settings;
|
||||
$events = $this->Paginator->paginate('Event');
|
||||
|
||||
// For each event, get the frameID which has the largest score
|
||||
foreach ( $events as $key => $value ) {
|
||||
$maxScoreFrameId = $this->getMaxScoreAlarmFrameId($value['Event']['Id']);
|
||||
$events[$key]['Event']['MaxScoreFrameId'] = $maxScoreFrameId;
|
||||
}
|
||||
// For each event, get the frameID which has the largest score
|
||||
foreach ( $events as $key => $value ) {
|
||||
$maxScoreFrameId = $this->getMaxScoreAlarmFrameId($value['Event']['Id']);
|
||||
$events[$key]['Event']['MaxScoreFrameId'] = $maxScoreFrameId;
|
||||
}
|
||||
|
||||
$this->set(compact('events'));
|
||||
} // end public function index()
|
||||
$this->set(compact('events'));
|
||||
} // end public function index()
|
||||
|
||||
/**
|
||||
* view method
|
||||
*
|
||||
* @throws NotFoundException
|
||||
* @param string $id
|
||||
* @return void
|
||||
*/
|
||||
public function view($id = null) {
|
||||
/**
|
||||
* view method
|
||||
*
|
||||
* @throws NotFoundException
|
||||
* @param string $id
|
||||
* @return void
|
||||
*/
|
||||
public function view($id = null) {
|
||||
$this->loadModel('Config');
|
||||
|
||||
$this->Event->recursive = 1;
|
||||
if (!$this->Event->exists($id)) {
|
||||
if ( !$this->Event->exists($id) ) {
|
||||
throw new NotFoundException(__('Invalid event'));
|
||||
}
|
||||
|
||||
|
@ -232,7 +232,7 @@ class EventsController extends AppController {
|
|||
|
||||
foreach ($this->params['named'] as $param_name => $value) {
|
||||
// Transform params into mysql
|
||||
if (preg_match('/interval/i', $value, $matches)) {
|
||||
if ( preg_match('/interval/i', $value, $matches) ) {
|
||||
$condition = array("$param_name >= (date_sub(now(), $value))");
|
||||
} else {
|
||||
$condition = array($param_name => $value);
|
||||
|
@ -289,12 +289,12 @@ class EventsController extends AppController {
|
|||
|
||||
// Find the max Frame for this Event. Error out otherwise.
|
||||
$this->loadModel('Frame');
|
||||
if (! $frame = $this->Frame->find('first', array(
|
||||
if ( !( $frame = $this->Frame->find('first', array(
|
||||
'conditions' => array(
|
||||
'EventId' => $event['Event']['Id'],
|
||||
'Score' => $event['Event']['MaxScore']
|
||||
)
|
||||
))) {
|
||||
))) ) {
|
||||
throw new NotFoundException(__('Can not find Frame for Event ' . $event['Event']['Id']));
|
||||
}
|
||||
|
||||
|
@ -315,8 +315,8 @@ class EventsController extends AppController {
|
|||
'ZM_DIR_IMAGES',
|
||||
$thumbs,
|
||||
'ZM_DIR_EVENTS'
|
||||
)
|
||||
)),
|
||||
)
|
||||
)),
|
||||
'fields' => array('Name', 'Value')
|
||||
));
|
||||
$config['ZM_WEB_SCALE_THUMBS'] = $config[$thumbs];
|
||||
|
@ -345,7 +345,7 @@ class EventsController extends AppController {
|
|||
|
||||
public function archive($id = null) {
|
||||
$this->Event->recursive = -1;
|
||||
if (!$this->Event->exists($id)) {
|
||||
if ( !$this->Event->exists($id) ) {
|
||||
throw new NotFoundException(__('Invalid event'));
|
||||
}
|
||||
|
||||
|
@ -370,7 +370,7 @@ class EventsController extends AppController {
|
|||
public function getMaxScoreAlarmFrameId($id = null) {
|
||||
$this->Event->recursive = -1;
|
||||
|
||||
if (!$this->Event->exists($id)) {
|
||||
if ( !$this->Event->exists($id) ) {
|
||||
throw new NotFoundException(__('Invalid event'));
|
||||
}
|
||||
|
||||
|
@ -387,7 +387,7 @@ class EventsController extends AppController {
|
|||
'Score' => $event['Event']['MaxScore']
|
||||
)
|
||||
))) {
|
||||
throw new NotFoundException(__("Can not find Frame for Event " . $event['Event']['Id']));
|
||||
throw new NotFoundException(__('Can not find Frame for Event ' . $event['Event']['Id']));
|
||||
}
|
||||
return $frame['Frame']['Id'];
|
||||
}
|
||||
|
|
|
@ -127,7 +127,7 @@ class MonitorsController extends AppController {
|
|||
}
|
||||
|
||||
$this->Monitor->create();
|
||||
if ($this->Monitor->save($this->request->data)) {
|
||||
if ( $this->Monitor->save($this->request->data) ) {
|
||||
$this->daemonControl($this->Monitor->id, 'start');
|
||||
//return $this->flash(__('The monitor has been saved.'), array('action' => 'index'));
|
||||
$message = 'Saved';
|
||||
|
@ -151,7 +151,7 @@ class MonitorsController extends AppController {
|
|||
public function edit($id = null) {
|
||||
$this->Monitor->id = $id;
|
||||
|
||||
if (!$this->Monitor->exists($id)) {
|
||||
if ( !$this->Monitor->exists($id) ) {
|
||||
throw new NotFoundException(__('Invalid monitor'));
|
||||
}
|
||||
global $user;
|
||||
|
@ -243,7 +243,7 @@ class MonitorsController extends AppController {
|
|||
public function alarm() {
|
||||
$id = $this->request->params['named']['id'];
|
||||
$cmd = strtolower($this->request->params['named']['command']);
|
||||
if (!$this->Monitor->exists($id)) {
|
||||
if ( !$this->Monitor->exists($id) ) {
|
||||
throw new NotFoundException(__('Invalid monitor'));
|
||||
}
|
||||
if ( $cmd != 'on' && $cmd != 'off' && $cmd != 'status' ) {
|
||||
|
|
|
@ -8,92 +8,93 @@ App::uses('AppController', 'Controller');
|
|||
*/
|
||||
class ZonePresetsController extends AppController {
|
||||
|
||||
/**
|
||||
* Components
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $components = array('RequestHandler');
|
||||
/**
|
||||
* Components
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $components = array('RequestHandler');
|
||||
|
||||
/**
|
||||
* index method
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function index() {
|
||||
$zonePresets = $this->ZonePreset->find('all');
|
||||
$this->set(array(
|
||||
'zonePresets' => $zonePresets,
|
||||
'_serialize' => array('zonePresets')
|
||||
));
|
||||
}
|
||||
/**
|
||||
* index method
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function index() {
|
||||
$zonePresets = $this->ZonePreset->find('all');
|
||||
$this->set(array(
|
||||
'zonePresets' => $zonePresets,
|
||||
'_serialize' => array('zonePresets')
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* view method
|
||||
*
|
||||
* @throws NotFoundException
|
||||
* @param string $id
|
||||
* @return void
|
||||
*/
|
||||
public function view($id = null) {
|
||||
if (!$this->ZonePreset->exists($id)) {
|
||||
throw new NotFoundException(__('Invalid zone preset'));
|
||||
}
|
||||
$options = array('conditions' => array('ZonePreset.' . $this->ZonePreset->primaryKey => $id));
|
||||
$this->set('zonePreset', $this->ZonePreset->find('first', $options));
|
||||
}
|
||||
/**
|
||||
* view method
|
||||
*
|
||||
* @throws NotFoundException
|
||||
* @param string $id
|
||||
* @return void
|
||||
*/
|
||||
public function view($id = null) {
|
||||
if ( !$this->ZonePreset->exists($id) ) {
|
||||
throw new NotFoundException(__('Invalid zone preset'));
|
||||
}
|
||||
$options = array('conditions' => array('ZonePreset.' . $this->ZonePreset->primaryKey => $id));
|
||||
$this->set('zonePreset', $this->ZonePreset->find('first', $options));
|
||||
}
|
||||
|
||||
/**
|
||||
* add method
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function add() {
|
||||
if ($this->request->is('post')) {
|
||||
$this->ZonePreset->create();
|
||||
if ($this->ZonePreset->save($this->request->data)) {
|
||||
return $this->flash(__('The zone preset has been saved.'), array('action' => 'index'));
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* add method
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function add() {
|
||||
if ( $this->request->is('post') ) {
|
||||
$this->ZonePreset->create();
|
||||
if ( $this->ZonePreset->save($this->request->data) ) {
|
||||
return $this->flash(__('The zone preset has been saved.'), array('action' => 'index'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* edit method
|
||||
*
|
||||
* @throws NotFoundException
|
||||
* @param string $id
|
||||
* @return void
|
||||
*/
|
||||
public function edit($id = null) {
|
||||
if (!$this->ZonePreset->exists($id)) {
|
||||
throw new NotFoundException(__('Invalid zone preset'));
|
||||
}
|
||||
if ($this->request->is(array('post', 'put'))) {
|
||||
if ($this->ZonePreset->save($this->request->data)) {
|
||||
return $this->flash(__('The zone preset has been saved.'), array('action' => 'index'));
|
||||
}
|
||||
} else {
|
||||
$options = array('conditions' => array('ZonePreset.' . $this->ZonePreset->primaryKey => $id));
|
||||
$this->request->data = $this->ZonePreset->find('first', $options);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* edit method
|
||||
*
|
||||
* @throws NotFoundException
|
||||
* @param string $id
|
||||
* @return void
|
||||
*/
|
||||
public function edit($id = null) {
|
||||
if ( !$this->ZonePreset->exists($id) ) {
|
||||
throw new NotFoundException(__('Invalid zone preset'));
|
||||
}
|
||||
if ( $this->request->is(array('post', 'put')) ) {
|
||||
if ( $this->ZonePreset->save($this->request->data) ) {
|
||||
return $this->flash(__('The zone preset has been saved.'), array('action' => 'index'));
|
||||
}
|
||||
} else {
|
||||
$options = array('conditions' => array('ZonePreset.' . $this->ZonePreset->primaryKey => $id));
|
||||
$this->request->data = $this->ZonePreset->find('first', $options);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* delete method
|
||||
*
|
||||
* @throws NotFoundException
|
||||
* @param string $id
|
||||
* @return void
|
||||
*/
|
||||
public function delete($id = null) {
|
||||
$this->ZonePreset->id = $id;
|
||||
if (!$this->ZonePreset->exists()) {
|
||||
throw new NotFoundException(__('Invalid zone preset'));
|
||||
}
|
||||
$this->request->allowMethod('post', 'delete');
|
||||
if ($this->ZonePreset->delete()) {
|
||||
return $this->flash(__('The zone preset has been deleted.'), array('action' => 'index'));
|
||||
} else {
|
||||
return $this->flash(__('The zone preset could not be deleted. Please, try again.'), array('action' => 'index'));
|
||||
}
|
||||
}}
|
||||
/**
|
||||
* delete method
|
||||
*
|
||||
* @throws NotFoundException
|
||||
* @param string $id
|
||||
* @return void
|
||||
*/
|
||||
public function delete($id = null) {
|
||||
$this->ZonePreset->id = $id;
|
||||
if ( !$this->ZonePreset->exists() ) {
|
||||
throw new NotFoundException(__('Invalid zone preset'));
|
||||
}
|
||||
$this->request->allowMethod('post', 'delete');
|
||||
if ( $this->ZonePreset->delete() ) {
|
||||
return $this->flash(__('The zone preset has been deleted.'), array('action' => 'index'));
|
||||
} else {
|
||||
return $this->flash(__('The zone preset could not be deleted. Please, try again.'), array('action' => 'index'));
|
||||
}
|
||||
}
|
||||
} // end class ZonePresetsController
|
||||
|
|
|
@ -56,6 +56,7 @@ class ZonesController extends AppController {
|
|||
'_serialize' => array('zones')
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* add method
|
||||
*
|
||||
|
@ -137,7 +138,7 @@ class ZonesController extends AppController {
|
|||
}
|
||||
}
|
||||
|
||||
public function createZoneImage( $id = null ) {
|
||||
public function createZoneImage($id = null) {
|
||||
$this->loadModel('Monitor');
|
||||
$this->Monitor->id = $id;
|
||||
if ( !$this->Monitor->exists() ) {
|
||||
|
@ -158,7 +159,7 @@ class ZonesController extends AppController {
|
|||
chdir($images_path);
|
||||
|
||||
$command = escapeshellcmd("$zm_path_bin/zmu -z -m $id");
|
||||
system( $command, $status );
|
||||
system($command, $status);
|
||||
|
||||
$this->set(array(
|
||||
'status' => $status,
|
||||
|
|
|
@ -54,7 +54,7 @@ var popupSizes = {
|
|||
'monitorselect':{ 'width': 160, 'height': 200 },
|
||||
'montage': { 'width': -1, 'height': -1 },
|
||||
'onvifprobe': { 'width': 700, 'height': 550 },
|
||||
'optionhelp': { 'width': 400, 'height': 320 },
|
||||
'optionhelp': { 'width': 400, 'height': 400 },
|
||||
'options': { 'width': 1000, 'height': 660 },
|
||||
'preset': { 'width': 300, 'height': 220 },
|
||||
'server': { 'width': 600, 'height': 405 },
|
||||
|
|
Loading…
Reference in New Issue