From 10ab500ecec33e506d3434f2fe143a96a343fb51 Mon Sep 17 00:00:00 2001 From: Armanveer Gill Date: Wed, 1 Jan 2025 18:20:33 -0500 Subject: [PATCH] Resolved the issue of misssing pdo execute statements and replacing echo $pdo->errorInfo() with show_pdo_error_if_any() in communication.php --- admin/communication.php | 26 ++++++++++++++------------ js/sfiab.js | 1 + 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/admin/communication.php b/admin/communication.php index 6da761b9..947183e7 100644 --- a/admin/communication.php +++ b/admin/communication.php @@ -171,7 +171,7 @@ case 'email_save': if($key && $name) { $q = $pdo->prepare("INSERT INTO emails(type,val) VALUES('$type','$key')"); $q->execute(); - echo $pdo->errorInfo(); + show_pdo_errors_if_any($pdo); $id = lastInsertId(); } else { error_("Email Key and Name are required"); @@ -193,7 +193,7 @@ case 'email_save': fundraising_campaigns_id=$fcstr WHERE id='$id'"); $q->execute(); - echo $pdo->errorInfo(); + show_pdo_errors_if_any($pdo); happy_("Email Saved"); exit; @@ -213,6 +213,7 @@ case 'dialog_edit': $fcid = intval( $_GET['fundraising_campaigns_id']); $type = 'fundraising'; $q=$pdo->prepare("SELECT * FROM fundraising_campaigns WHERE id='$fcid'"); + $q->execute(); $fc=$q->fetch(PDO::FETCH_OBJ); $name=i18n("%1 communication for %2",array(ucfirst($key),$fc->name)); } else { @@ -619,7 +620,7 @@ case "email_send": case "email_get_list": $q = $pdo->prepare("SELECT * FROM emails ORDER BY type,name"); - + $q->execute(); echo ""; echo ""; echo " "; @@ -688,13 +689,13 @@ case "email_get_list": $emailq = $pdo->prepare("SELECT * FROM emails WHERE id='$emailid'"); - $emailq.execute(); + $emailq->execute(); $email=$emailq.fetch(PDO::FETCH_OBJ); $recipq = $pdo->prepare("SELECT * FROM fundraising_campaigns_users_link WHERE fundraising_campaigns_id='$fcid'"); - $recipq.execute(); - echo $pdo->errorInfo(); + $recipq->execute(); + show_pdo_errors_if_any($pdo); $numtotal=$recipq->rowCount(); @@ -714,7 +715,7 @@ case "email_get_list": 0)"); $q->execute(); $emailqueueid=$pdo->lastInsertId(); - echo $pdo->errorInfo(); + show_pdo_errors_if_any($pdo); $urlproto = $_SERVER['SERVER_PORT'] == 443 ? "https://" : "http://"; $urlmain = "$urlproto{$_SERVER['HTTP_HOST']}{$config['SFIABDIRECTORY']}"; @@ -792,7 +793,7 @@ case "email_get_list": } if(get_value_from_array($_GET, 'action') == "send" && get_value_from_array($_GET, 'send')) { - echo $pdo->errorInfo(); + show_pdo_errors_if_any($pdo); $q = $pdo->prepare("SELECT * FROM emails WHERE id='".$_GET['send']."'"); $q->execute(); @@ -814,7 +815,7 @@ case "email_get_list": $tq->execute(); if($pdo->errorInfo()) { - echo $pdo->errorInfo(); + show_pdo_errors_if_any($pdo); exit; } $num=$tq->rowCount(); @@ -863,6 +864,7 @@ case "email_get_list": else if(get_value_from_array($_POST, 'action') == "reallysend" && get_value_from_array($_POST, 'reallysend') && get_value_from_array($_POST, 'to')) { $emailid=intval($_POST['reallysend']); $emailq=$pdo->prepare("SELECT * FROM emails WHERE id='$emailid'"); + $emailq->execute(); $email=$emailq->fetch(PDO::FETCH_OBJ); $to=$_POST['to']; @@ -888,7 +890,7 @@ case "email_get_list": 0)"); $q->execute(); $emailqueueid=lastInsertId(); - echo $pdo->errorInfo(); + show_pdo_errors_if_any($pdo); $urlproto = $_SERVER['SERVER_PORT'] == 443 ? "https://" : "http://"; $urlmain = "$urlproto{$_SERVER['HTTP_HOST']}{$config['SFIABDIRECTORY']}"; @@ -920,7 +922,7 @@ case "email_get_list": //we only send school access codes to science heads or principals $acq=$pdo->prepare("SELECT accesscode FROM schools WHERE (sciencehead_uid='{$u['uid']}' OR principal_uid='{$u['uid']}') AND `year`='{$config['FAIRYEAR']}'"); $acq->execute(); - echo $pdo->errorInfo(); + show_pdo_errors_if_any($pdo); $acr=$acq->fetch(PDO::FETCH-OBJ); $accesscode=$acr->accesscode; @@ -949,7 +951,7 @@ case "email_get_list": '".json_encode($replacements)."', NULL)"); $q->execute(); - echo $pdo->errorInfo(); + show_pdo_errors_if_any($pdo); } $q = $pdo->prepare("UPDATE emails SET lastsent=NOW() WHERE id='$emailid'"); diff --git a/js/sfiab.js b/js/sfiab.js index e1430a06..267cee70 100644 --- a/js/sfiab.js +++ b/js/sfiab.js @@ -83,6 +83,7 @@ $(document).ready(function() //key is 'val' from emails table, or id is id, fcid simply gets passed in and saved if needed //only id or key are used to lookup which to open function opencommunicationeditor(key,id,fcid) { + console.log('yes'); var fcstr=""; if(fcid) fcstr="&fundraising_campaigns_id="+fcid;
".i18n("Name")."