When there is an error saving, add the invalidFields() info to the error message. Only restart the daemon on success.

This commit is contained in:
Isaac Connor 2018-01-26 10:30:29 -05:00
parent 6d0b5fb86f
commit 1503c586d2
1 changed files with 17 additions and 16 deletions

View File

@ -151,17 +151,9 @@ class MonitorsController extends AppController {
throw new UnauthorizedException(__('Insufficient privileges')); throw new UnauthorizedException(__('Insufficient privileges'));
return; return;
} }
if ($this->Monitor->save($this->request->data)) {
$message = 'Saved';
} else {
$message = 'Error';
}
$this->set(array(
'message' => $message,
'_serialize' => array('message')
));
if ( $this->Monitor->save($this->request->data) ) {
$message .= 'Saved';
$Monitor = $this->Monitor->find('first', array( $Monitor = $this->Monitor->find('first', array(
'fields' => array('Function','ServerId'), 'fields' => array('Function','ServerId'),
'conditions' => array('Id' => $id) 'conditions' => array('Id' => $id)
@ -174,6 +166,15 @@ class MonitorsController extends AppController {
if ( ( $func != 'None' ) and ( (!defined('ZM_SERVER_ID')) or ($Monitor['ServerId']==ZM_SERVER_ID) ) ) { if ( ( $func != 'None' ) and ( (!defined('ZM_SERVER_ID')) or ($Monitor['ServerId']==ZM_SERVER_ID) ) ) {
$this->daemonControl( $this->Monitor->id, 'start' ); $this->daemonControl( $this->Monitor->id, 'start' );
} }
} else {
$message .= 'Error ' . print_r($this->Monitor->invalidFields(), true);
}
$this->set(array(
'message' => $message,
'_serialize' => array('message')
));
} // end function edit } // end function edit
/** /**