public static function sendVONotification($user, $vappliance, $notificationtype, $vos, $subject, $message) { $notification = null; $usermessage = "" . $message; $usersubject = "" . $subject; $result = self::createVONotification($user, $vappliance, $notificationtype, $vos, $subject, $message, $notification); if ($result !== true) { return $result; } if (!$notification) { return "Could not send notification"; } $recipients = $notification["recipients"]; $subject = $notification["subject"]; $message = $notification["message"]; $replyto = $notification["useremail"]; try { foreach ($recipients as $rec) { $voname = $rec["vo"]; $to = array(); foreach ($rec["contacts"] as $cnt) { $to[] = trim($cnt["email"]); } $txtbody = preg_replace('/\\{\\{vo\\.name\\}\\}/i', $voname, $message); $subj = preg_replace('/\\{\\{vo\\.name\\}\\}/i', $voname, $subject); if (ApplicationConfiguration::isProductionInstance() === FALSE) { self::debugSendMultipart($subj, $to, $txtbody, null, "appdb reports username", "appdb reports password", $replyto, null, false, null); } else { //sendMultipartMail($subj, $to, $txtbody, null, '*****@*****.**', 'enadyskolopassword', $replyto, null, false, array("Precedence"=>"bulk")); EmailService::sendBulkReport($subj, $to, $txtbody, null, $replyto); } } self::sendVONotificationReportMessage($notification, $user, $vappliance, $notificationtype, $usersubject, $usermessage); } catch (Exception $ex) { return $ex->getMessage(); } return true; }
public static function sendMessages($isReminder = false) { $items = db()->query("SELECT * FROM nonvalidated_apps_per_owner")->fetchAll(); foreach ($items as $item) { $text = ""; $body = ""; if (is_null($item["contact"])) { error_log("[OutdatedApps]: No contact info for " . $item["ownerid"] . ":" . $item["firstname"] . " " . $item["lastname"]); //TODO: Case where the owner of the application has no contact point continue; } $recipients = array($item["contact"]); $subject = "Notification:"; if (isnull($item["lastsent"]) == false) { $subject = "Reminder:"; } $subject .= "EGI AppDB outdated software profile"; $appids = $item["appids"]; $appids = explode(";", $appids); $appnames = $item["appnames"]; $appnames = explode(";", $appnames); if (count($appids) == 0) { continue; } if (count($appids) == 1) { $template = self::getTemplateBody($item["firstname"] . " " . $item["lastname"]); $body = preg_replace("/\\[1\\]/", "<a href='http://" . $_SERVER["APPLICATION_UI_HOSTNAME"] . "?p=" . base64_encode("/apps/details?id=" . $appids[0]) . "' target='_blank'>" . $appnames[0] . "</a>", $template); $body = preg_replace("/\\[2\\]/", "<a href='http://" . $_SERVER["APPLICATION_UI_HOSTNAME"] . "' target='_blank'>EGI Applications Database</a>", $body); $body = "<html><head></head><body><pre>" . $body . "</pre></body></html>"; $text = preg_replace("/\\[1\\]/", "" . $appnames[0] . " [1]", $template); $text = preg_replace("/\\[2\\]/", "EGI Applications Database [2]", $text); $text .= "\n\n________________________________________________________________________________________________________\n"; $text .= "[1]. http://" . $_SERVER["APPLICATION_UI_HOSTNAME"] . "?p=" . base64_encode("/apps/details?id=" . $appids[0]) . "\n"; $text .= "[2]. http://" . $_SERVER["APPLICATION_UI_HOSTNAME"]; } else { $template = self::getTemplateListBody($item["firstname"] . " " . $item["lastname"]); $listpermalink = "http://" . $_SERVER["APPLICATION_UI_HOSTNAME"] . "?p=" . base64_encode('{"url":"/apps","query":{"flt":"=application.owner:' . $item["ownerid"] . ' +=application.validated:false"},"ext":{"isBaseQuery":true,"append":true,"filterDisplay":"Search outdated...","mainTitle":"Outdated entries"}}'); $body = preg_replace("/\\[1\\]/", "<a href='" . $listpermalink . "' target='_blank'>software</a>", $template); $body = preg_replace("/\\[2\\]/", "<a href='http://" . $_SERVER["APPLICATION_UI_HOSTNAME"] . "' target='_blank'>EGI Applications Database</a>", $body); $body = "<html><head></head><body><pre>" . $body . "</pre></body></html>"; $text = preg_replace("/\\[1\\]/", "software [1]", $template); $text = preg_replace("/\\[2\\]/", "EGI Applications Database [2]", $text); $text .= "\n\n________________________________________________________________________________________________________\n"; $text .= "[1]. " . $listpermalink . " \n"; $text .= "[2]. http://" . $_SERVER["APPLICATION_UI_HOSTNAME"]; $bodylist = ""; $textlist = ""; //Make unique arrays of application ids and names $unames = array(); $uids = array(); for ($i = 0; $i < count($appids); $i += 1) { if (in_array($appids[$i], $uids) === false) { $uids[] = $appids[$i]; $unames[] = $appnames[$i]; } } $appids = $uids; $appnames = $unames; for ($i = 0; $i < count($appids); $i += 1) { $bodylist .= "<div style='padding-left:10px;'>-<a href='http://" . $_SERVER["APPLICATION_UI_HOSTNAME"] . "?p=" . base64_encode("/apps/details?id=" . $appids[$i]) . "' target='_blank'>" . $appnames[$i] . "</a></div>"; $textlist .= "\t- " . $appnames[$i] . "\n"; } $body = preg_replace("/\\[\\*\\]/", $bodylist, $body); $text = preg_replace("/\\[\\*\\]/", $textlist, $text); } if (ApplicationConfiguration::isProductionInstance() === FALSE) { error_log("SENDING OUTDATED TO:"); error_log("SUBJECT:" . $subject); error_log("RECIPIENTS: " . var_export($recipients, true)); error_log("BODY: " . $text); echo "<div style='background-color:lightgrey;border:1px solid black'><b>subject:</b>" . $subject . "</div><div style='background-color:lightgrey;margin-bottom:10px;border:1px solid black'><b>TO:</b>" . implode(",", $recipients) . "</div><div style='background-color:lightgreen;border:1px solid black;'>" . $body . "</div><div style='background-color:#99DBFF;margin-bottom:10px;border:1px solid black'><pre>" . $text . "</pre></div>"; } else { //sendMultipartMail($subject,$recipients,$text,$body,'*****@*****.**','enadyskolopassword','*****@*****.**',null, false,array("Precedence"=>"bulk")); EmailService::sendBulkReport($subject, $recipients, $text, $body, EmailConfiguration::getSupportAddress()); } } if (APPLICATION_ENV === "production") { db()->query("INSERT INTO app_validation_log (appid) SELECT DISTINCT id FROM applications, (SELECT string_to_array(array_to_string(array_agg(array_to_string(ids,',')),','),',') as ids FROM (SELECT string_to_array(appids, ';') as ids FROM (SELECT * FROM nonvalidated_apps_per_owner) AS t) as tt) as ttt WHERE id::text = ANY(ttt.ids)")->fetchAll(); } return true; }
private static function sendConfirmationEmail($session, $pending) { $researcher = $pending->getResearcher(); $email = $researcher->getPrimaryContact(); $accounttype = str_replace("-", " ", trim($pending->accountType)); $accountname = trim($pending->accountName) === "" ? $pending->accountID : $pending->accountName; $res = "Dear " . $researcher->name . ",\n\n"; $res .= " a request has been made to connect the " . $accounttype . " account of " . $accountname . "\n"; $res .= "to your profile in the EGI Applications Database [1].\n"; $res .= "If it is really you the one that made this request and you wish to proceed with the account connection\n"; $res .= " - go to the EGI Applications Database Portal[1] and\n"; $res .= " - sign in with the same " . $accounttype . " account.\n"; $res .= "The system will prompt you with a form where you should enter the confirmation code bellow:\n\n"; $res .= " Confirmation Code: " . $pending->code . "\n\n"; $res .= "Note: The confirmation code expires 30 minutes after this message was sent.\n\n"; $res .= "If you are not the one that made this request, then please report the incident by replying to this message.\n\n"; $res .= "Best regards,\n"; $res .= "EGI AppDB team\n"; $res .= "\n\n__________________________________________________\n"; $res .= "[1]. http://" . $_SERVER["APPLICATION_UI_HOSTNAME"]; $subject = "EGI AppDB: Request to connect " . $accounttype . " account to your profile"; $text = $res; $body = $body = preg_replace("/\n/", "<br/>", $res); $body = "<div>" . $body . "</div>"; //DEVELOPMENT CODE if (ApplicationConfiguration::isProductionInstance() === FALSE) { error_log("\nSending to: " . $email); error_log("\n\n" . $res); } $recipients = array($email); //sendMultipartMail($subject,$recipients,$text,$body,'*****@*****.**','enadyskolopassword','*****@*****.**',null, false,array("Precedence"=>"bulk")); EmailService::sendBulkReport($subject, $recipients, $text, $body, EmailConfiguration::getSupportAddress()); }
private static function sendNotification($notification) { $subject = $notification["subject"]; $to = $notification["recipient"]; $txtbody = $notification["message"]; if (ApplicationConfiguration::isProductionInstance() === FALSE) { self::debugSendMultipart($subject, $to, $txtbody, null, "appdb reports username", "appdb reports password", false, null, false, null); } else { //sendMultipartMail($subject, $to, $txtbody, null, '*****@*****.**', 'enadyskolopassword', false, null, false, array("Precedence"=>"bulk")); EmailService::sendBulkReport($subject, $to, $txtbody); } }
private static function mailDispatchReport($recipients, $filename, $folder) { $reportcsv = file_get_contents($folder . $filename . ".csv"); if ($reportcsv === false) { error_log("[SocialReport::mailDispatch]: Could not load report " . $filename); return false; } $subject = "EGI AppDB Social media sharing report (" . date('Y') . "-" . date('m') . "-" . date('d') . ")"; $sbody = "This is an automatically generated report for social media sharing count per registered software item."; $sbody = $sbody . "Please find attached a CSV file containing the report.<br/>"; $sbody = $sbody . "You can access this report at http://" . $_SERVER['APPLICATION_UI_HOSTNAME'] . "/reports/social/" . $filename . ".csv <br/><br/>"; $sbody = $sbody . "Regards,<br/>"; $sbody = $sbody . "EGI AppDB Team"; $textsbody = simpleHTML2Text($sbody); $att = array("data" => $reportcsv, "type" => "application/vnd.ms-excel", "name" => $filename . ".csv"); //sendMultipartMail($subject, $recipients, $textsbody, $sbody, '*****@*****.**', 'enadyskolopassword', '*****@*****.**',$att, false,array("Precedence"=>"bulk")); EmailService::sendBulkReport($subject, $recipients, $textsbody, $sbody, EmailConfiguration::getSupportAddress(), $att); }