mirror of https://github.com/MISP/MISP
new: [users/mails] add confirmation popup before sending mails
parent
1924af4732
commit
9b44050e1c
|
@ -1442,6 +1442,30 @@ class UsersController extends AppController
|
|||
}
|
||||
}
|
||||
|
||||
public function admin_email_confirm() {
|
||||
if (!$this->_isAdmin()) {
|
||||
throw new MethodNotAllowedException();
|
||||
}
|
||||
// User has filled in his contact form, send out the email.
|
||||
if ($this->request->is('get')) {
|
||||
$conditions = array();
|
||||
if (!$this->_isSiteAdmin()) {
|
||||
$conditions = array('org_id' => $this->Auth->user('org_id'));
|
||||
}
|
||||
if ($this->request->query['recipient'] != 1) {
|
||||
$recipientEmailList = isset($this->request->query['recipientEmailList']) ? $this->request->query['recipientEmailList'] : 0;
|
||||
$conditions['id'] = $recipientEmailList;
|
||||
}
|
||||
$conditions['AND'][] = array('User.disabled' => 0);
|
||||
$users = $this->User->find('list', array('recursive' => -1, 'order' => array('email ASC'), 'conditions' => $conditions, 'fields' => array('email')));
|
||||
} else {
|
||||
$users = array();
|
||||
}
|
||||
$this->set('emails', $users);
|
||||
$this->set('emailsCount', count($users));
|
||||
$this->render('ajax/emailConfirmTemplate');
|
||||
}
|
||||
|
||||
public function initiatePasswordReset($id, $firstTime = false)
|
||||
{
|
||||
if (!$this->_isAdmin()) {
|
||||
|
|
|
@ -64,13 +64,32 @@ $("#customMessage").change(setAll);
|
|||
$("#action").change(populateSubject);
|
||||
var subjects = [];
|
||||
var standardTexts = [];
|
||||
var submitAllowed = false;
|
||||
$(document).ready(function() {
|
||||
var org = "<?php echo $org;?>";
|
||||
subjects = ["", "[" + org + " MISP] " + "<?php echo __('New user registration');?>" , "[" + org + " MISP] " + "<?php echo __('Password reset');?>"];
|
||||
standardTexts = ['', '<?php echo h($newUserText); ?>', '<?php echo h($passwordResetText); ?>'];
|
||||
//setAll();
|
||||
|
||||
// Confirm before submit
|
||||
$('#UserAdminEmailForm').submit(function(e) {
|
||||
var url = 'http://127.0.0.1:8085/admin/users/email_confirm?';
|
||||
url += 'recipient=' + $('#recipient').val();
|
||||
url += '&recipientEmailList=' + $('#UserRecipientEmailList').val();
|
||||
$.get(url, function(data) {
|
||||
$("#confirmation_box").html(data);
|
||||
openPopup("#confirmation_box");
|
||||
});
|
||||
return submitAllowed;
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
function submitMailsForm() {
|
||||
submitAllowed = true;
|
||||
$('#UserAdminEmailForm').submit();
|
||||
}
|
||||
|
||||
function populateSubject() {
|
||||
$("#UserSubject").val(subjects[$("#action").val()]);
|
||||
$("#UserMessage").html(standardTexts[$("#action").val()]).text();
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
<div class="confirmation">
|
||||
<legend><?php echo __('Confirm sending'); ?> </legend>
|
||||
<div style="padding-left:5px;padding-right:5px;padding-bottom:5px;">
|
||||
<p><?php echo __('You are about to send a mail to %s recipient(s)?', '<strong>' . h($emailsCount) . '</strong>'); ?></p>
|
||||
<div>
|
||||
<select multiple=1 size=15 style="width: 100%">
|
||||
<?php foreach($emails as $email): ?>
|
||||
<option><?php echo h($email); ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
<div>
|
||||
<span role="button" tabindex="0" aria-label="<?php echo __('Send');?>" title="<?php echo __('Send');?>" class="btn btn-success" id="PromptYesButton" onClick="submitMailsForm();"><?php echo __('Send');?></span>
|
||||
<span role="button" tabindex="0" aria-label="<?php echo __('Cancel');?>" title="<?php echo __('Cancel');?>" class="btn btn-danger" id="PromptNoButton" style="float:right;" onClick="cancelPrompt();"><?php echo __('Cancel');?></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
Loading…
Reference in New Issue