Email Log: Database class integration.

This commit is contained in:
Nate
2019-08-05 21:22:26 -06:00
parent b47615c389
commit 72ae5998a3
4 changed files with 91 additions and 81 deletions
+19 -12
View File
@@ -1,7 +1,7 @@
<?php
//restrict to command line only
if(defined('STDIN')) {
if (defined('STDIN')) {
$document_root = str_replace("\\", "/", $_SERVER["PHP_SELF"]);
preg_match("/^(.*)\/app\/.*$/", $document_root, $matches);
$document_root = $matches[1];
@@ -22,13 +22,12 @@
//get the failed emails
$sql = "select email_log_uuid, email from v_email_logs limit 100";
$prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute();
$emails = $prep_statement->fetchAll(PDO::FETCH_NAMED);
$database = new database;
$emails = $database->select($sql, null, 'all');
//process the emails
if (is_array($emails)) {
foreach($emails as $row) {
if (is_array($emails) && @sizeof($emails) != 0) {
foreach($emails as $index => $row) {
$email_log_uuid = $row['email_log_uuid'];
$msg = $row['email'];
@@ -37,15 +36,23 @@
//get the message
message::add($text['message-message_resent']);
//delete the email
$sql = "delete from v_email_logs ";
$sql .= "where email_log_uuid = '".$email_log_uuid."' ";
$prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute();
unset($sql, $prep_statement);
//add to array
$array['email_logs'][$index]['email_log_uuid'] = $email_log_uuid;
}
unset($mailer_error);
}
if (is_array($array) && @sizeof($array) != 0) {
$p = new permissions;
$p->add('email_log_delete', 'temp');
$database = new database;
$database->app_name = 'email_logs';
$database->app_uuid = 'bd64f590-9a24-468d-951f-6639ac728694';
$database->delete($array);
unset($array);
$p->delete('email_log_delete', 'temp');
}
}
unset ($prep_statement, $sql, $emails);