mirror of
https://github.com/DanielnetoDotCom/YouPHPTube
synced 2025-10-03 01:39:24 +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';
|
||||
|
||||
if (!User::canUpload()) {
|
||||
header("Location: {$global['webSiteRootURL']}?error=" . __("You can not notify"));
|
||||
exit;
|
||||
forbiddenPage('You can not notify');
|
||||
}
|
||||
$user_id = User::getId();
|
||||
// if admin bring all subscribers
|
||||
|
@ -23,28 +22,21 @@ header('Content-Type: application/json');
|
|||
$Subscribes = Subscribe::getAllSubscribes($user_id);
|
||||
|
||||
$obj = new stdClass();
|
||||
//Create a new PHPMailer instance
|
||||
$mail = new \PHPMailer\PHPMailer\PHPMailer();
|
||||
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']);
|
||||
$obj->error = true;
|
||||
$obj->msg = '';
|
||||
|
||||
//send the message, check for errors
|
||||
if (!$mail->send()) {
|
||||
$obj->error = __("Message could not be sent") . " " . $mail->ErrorInfo;
|
||||
} else {
|
||||
$obj->success = __("Message sent");
|
||||
$to = array();
|
||||
foreach ($Subscribes as $value) {
|
||||
$to[] = $value["email"];
|
||||
}
|
||||
|
||||
$subject = 'Message From Site ' . $config->getWebSiteTitle();
|
||||
$message = $_POST['message'];
|
||||
|
||||
$resp = sendSiteEmail($to, $subject, $message);
|
||||
|
||||
$obj->error = empty($resp);
|
||||
|
||||
$json = json_encode($obj);
|
||||
|
||||
_error_log('NotifySubscribers emails: '.$json);
|
||||
|
|
|
@ -82,12 +82,7 @@ $_page = new Page(array('Subscribes'));
|
|||
'message': $(tinymce.get('emailMessage').getBody()).html()
|
||||
},
|
||||
success: function(response) {
|
||||
console.log(response);
|
||||
if (response.error) {
|
||||
avideoAlert("<?php echo __("Sorry!"); ?>", response.error, "error");
|
||||
} else {
|
||||
avideoAlert("<?php echo __("Success"); ?>", "<?php echo __("You have sent the notification"); ?>", "success");
|
||||
}
|
||||
avideoResponse(response);
|
||||
modal.hidePleaseWait();
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue