mirror of
https://github.com/DanielnetoDotCom/YouPHPTube
synced 2025-10-06 03:50:04 +02:00
This commit is contained in:
parent
1da638bfd6
commit
770a555fc2
2 changed files with 14 additions and 27 deletions
|
@ -8,8 +8,7 @@ if (!isset($global['systemRootPath'])) {
|
||||||
require_once $global['systemRootPath'] . 'objects/user.php';
|
require_once $global['systemRootPath'] . 'objects/user.php';
|
||||||
|
|
||||||
if (!User::canUpload()) {
|
if (!User::canUpload()) {
|
||||||
header("Location: {$global['webSiteRootURL']}?error=" . __("You can not notify"));
|
forbiddenPage('You can not notify');
|
||||||
exit;
|
|
||||||
}
|
}
|
||||||
$user_id = User::getId();
|
$user_id = User::getId();
|
||||||
// if admin bring all subscribers
|
// if admin bring all subscribers
|
||||||
|
@ -23,28 +22,21 @@ header('Content-Type: application/json');
|
||||||
$Subscribes = Subscribe::getAllSubscribes($user_id);
|
$Subscribes = Subscribe::getAllSubscribes($user_id);
|
||||||
|
|
||||||
$obj = new stdClass();
|
$obj = new stdClass();
|
||||||
//Create a new PHPMailer instance
|
$obj->error = true;
|
||||||
$mail = new \PHPMailer\PHPMailer\PHPMailer();
|
$obj->msg = '';
|
||||||
setSiteSendMessage($mail);
|
|
||||||
//Set who the message is to be sent from
|
|
||||||
$mail->setFrom($config->getContactEmail());
|
|
||||||
//Set who the message is to be sent to
|
|
||||||
//$mail->addAddress($config->getContactEmail());
|
|
||||||
foreach ($Subscribes as $value) {
|
|
||||||
$mail->addBCC($value["email"]);
|
|
||||||
}
|
|
||||||
$obj->total = count($Subscribes);
|
|
||||||
//Set the subject line
|
|
||||||
$mail->Subject = 'Message From Site ' . $config->getWebSiteTitle();
|
|
||||||
$mail->msgHTML($_POST['message']);
|
|
||||||
|
|
||||||
//send the message, check for errors
|
$to = array();
|
||||||
if (!$mail->send()) {
|
foreach ($Subscribes as $value) {
|
||||||
$obj->error = __("Message could not be sent") . " " . $mail->ErrorInfo;
|
$to[] = $value["email"];
|
||||||
} else {
|
|
||||||
$obj->success = __("Message sent");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$subject = 'Message From Site ' . $config->getWebSiteTitle();
|
||||||
|
$message = $_POST['message'];
|
||||||
|
|
||||||
|
$resp = sendSiteEmail($to, $subject, $message);
|
||||||
|
|
||||||
|
$obj->error = empty($resp);
|
||||||
|
|
||||||
$json = json_encode($obj);
|
$json = json_encode($obj);
|
||||||
|
|
||||||
_error_log('NotifySubscribers emails: '.$json);
|
_error_log('NotifySubscribers emails: '.$json);
|
||||||
|
|
|
@ -82,12 +82,7 @@ $_page = new Page(array('Subscribes'));
|
||||||
'message': $(tinymce.get('emailMessage').getBody()).html()
|
'message': $(tinymce.get('emailMessage').getBody()).html()
|
||||||
},
|
},
|
||||||
success: function(response) {
|
success: function(response) {
|
||||||
console.log(response);
|
avideoResponse(response);
|
||||||
if (response.error) {
|
|
||||||
avideoAlert("<?php echo __("Sorry!"); ?>", response.error, "error");
|
|
||||||
} else {
|
|
||||||
avideoAlert("<?php echo __("Success"); ?>", "<?php echo __("You have sent the notification"); ?>", "success");
|
|
||||||
}
|
|
||||||
modal.hidePleaseWait();
|
modal.hidePleaseWait();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue