Disable e-mailing globally for an instance

pull/762/head
Iglocska 2015-12-15 10:52:31 +01:00
parent 3a2df829a0
commit bc2c14c815
3 changed files with 42 additions and 0 deletions

View File

@ -840,6 +840,20 @@ class ShadowAttributesController extends AppController {
private function __sendProposalAlertEmail($id) {
if (Configure::read('MISP.disable_emailing')) {
$this->Log = ClassRegistry::init('Log');
$this->Log->create();
$this->Log->save(array(
'org' => 'SYSTEM',
'model' => 'User',
'model_id' => $this->Auth->user('id'),
'email' => $this->Auth->user('email'),
'action' => 'email',
'title' => 'The sending of new proposal alert e-mails for event ' . $id . ' failed. Reason: Emailing is currently disabled on this instance.',
'change' => null,
));
return true;
}
$this->loadModel('Event');
$this->Event->recursive = -1;
$event = $this->Event->read(null, $id);

View File

@ -288,6 +288,15 @@ class Server extends AppModel {
'test' => 'testForEmpty',
'type' => 'string',
),
'disable_emailing' => array(
'level' => 0,
'description' => 'You can disable all e-mailing using this setting. When enabled, no outgoing e-mails will be sent by MISP.',
'value' => false,
'errorMessage' => '',
'null' => true,
'test' => 'testDisableEmail',
'type' => 'boolean',
),
'contact' => array(
'level' => 1,
'description' => 'The e-mail address that MISP should include as a contact address for the instance\'s support team.',
@ -1481,6 +1490,11 @@ class Server extends AppModel {
return true;
}
public function testDisableEmail($value) {
if (isset($value) && $value) return 'E-mailing is blocked.';
return true;
}
public function testLive($value) {
if ($this->testBool($value) !== true) return $this->testBool($value);
if (!$value) return 'MISP disabled.';

View File

@ -497,6 +497,20 @@ class User extends AppModel {
// Just pass the user ID in an array that is the target of the e-mail along with the message body and the alternate message body if the message cannot be encrypted
// the remaining two parameters are the e-mail subject and a secondary user object which will be used as the replyto address if set. If it is set and an encryption key for the replyTo user exists, then his/her public key will also be attached
public function sendEmail($user, $body, $bodyNoEnc = false, $subject, $replyToUser = false) {
if (Configure::read('MISP.disable_emailing')) {
$this->Log = ClassRegistry::init('Log');
$this->Log->create();
$this->Log->save(array(
'org' => 'SYSTEM',
'model' => 'User',
'model_id' => $user['User']['id'],
'email' => $user['User']['email'],
'action' => 'email',
'title' => 'Email to ' . $user['User']['email'] . ', titled "' . $subject . '" failed. Reason: Emailing is currently disabled on this instance.',
'change' => null,
));
return true;
}
$failed = false;
$failureReason = "";
// check if the e-mail can be encrypted