/** * Send an html formatted email from a form. * @param $dbConn connection * @param $sql query. Must produce email1 and name, optional email2. * @param $fsubject subject * @param $body mail body * @param $sender sender email address * @param $sender_name sic. * and open the template in the editor. */ function formMailer($dbConn, $sql, $fsubject, $body, $sender, $sender_name) { $resultSet = $dbConn->Execute($sql); if ($resultSet === false) { $dbConn->log("<br>Cannot read mail data with <pre>" . $sql . "</pre> reason " . $dbConn->ErrorMsg() . "<br>"); return; } $recipients = ""; $triggerSubject = 'You have mail at your fontys email address'; $triggerBody = "See the subject. Read your mail" . " e.g. at <a href=\\'http://webmail.fontys.nl\\'>" . "http://webmail.fontys.nl</a><br/>Kind regards, the peerweb service."; $bodypostfix = "\n</body>\n</html>\n"; while (!$resultSet->EOF) { extract($resultSet->fields); $headers = htmlmailheaders($sender, $sender_name, $email1, $tutor_email); $recipients .= "{$name} ({$email1})\n"; // eval user created subject and body template eval("\$subject=\"{$fsubject}\";"); eval("\$message=\"{$body}\";"); $bodyprefix = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>' . $subject . '</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" > </head> <body>'; domail("{$name} <{$email1}>", $subject, $bodyprefix . $message . $bodypostfix, $headers); $resultSet->moveNext(); } $headers = htmlmailheaders($sender, $sender_name, $sender, $tutor_email); domail($sender, 'your copy of mail ' . $subject, $bodyprefix . $message . "\n<br/><hr/>The above mail has been sent to the following recipients:\n<pre>\n" . $recipients . "</pre>\n" . $bodypostfix, $headers); }
echo 'Error: ' . $dbConn->ErrorMsg() . ' with <br/><pre>' . $sql . '</pre>'; } extract($resultSet->fields, EXTR_PREFIX_ALL, 'author'); $subject = 'You received feedback on one of your uploaded doucments at the peerweb'; $body = "Dear {$author_roepnaam},\n\n" . "You received feedback on the document you uploaded to the peerweb.\n" . "Have a look at\n{$server_url}{$root_url}/upload_critique.php?doc_id={$doc_id}\nKind regards,\nThe peerweb service"; $replyto = $jemail1; // if ($isTutor) // $replyto=$tutor_email; $headers = "From: peerweb@fontysvenlo.org\n" . "Reply-To: {$replyto}\n"; $toAddress = $author_email1; domail($toAddress, $subject, $body, $headers); if (isset($author_email2)) { $subject = "You received an email at your fontys email address"; $body = "Dear {$author_roepnaam},\n\n" . "You received an email at your fontys email address. Have a look.\n" . "Kind regards\nThe peerweb service"; $toAddress = $author_email2; domail($toAddress, $subject, $body, $headers); } } } if (isset($_POST['doc_update'])) { $doc_title = pg_escape_string($_POST['doc_title']); // remove nasty tokens! $groupRead = isset($_POST['groupread']) ? 't' : 'f'; $projectRead = isset($_POST['projectread']) ? 't' : 'f'; $rights = '{' . $groupRead . ',' . $projectRead . '}'; $doctype = $_POST['doctype']; $mime_type = $_POST['mime_type']; $new_prjtg_id = $_POST['new_prjtg_id']; $sql = "update uploads \n" . "set title='{$doc_title}'," . "\t rights='{$rights}', " . "\t doctype={$doctype}," . "\t mime_type=substr('{$mime_type}',1,64),\n " . "\t mime_type_long='{$mime_type}',\n" . "\t prjtg_id={$new_prjtg_id}\n " . "where upload_id={$doc_id}"; $dbConn->log($sql); $resultSet = $dbConn->execute($sql);
$bodyprefix = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>' . $subject . '</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" > </head> <body> '; $message = $bodyprefix . $mailbody . "\n</body>\n</html>\n"; domail($toAddress, $subject, $message, $headers); // send author a copy, so he 'll know he is confirmed of sending the email. $recipients = htmlentities(preg_replace('/,/', ",\n", $toAddress)); domail($replyto, $subject . ', your copy', $bodyprefix . $mailbody . "\n<br/><hr/>The above mail has been sent to the following recipients:\n<pre>" . $recipients . "\n</pre>\n" . "\n</body>\n</html>\n", $headers); if ($triggerList != '') { $subject = 'You have mail at your fontys email address'; domail($triggerList, $subject, "See the subject.\n" . "One way to read your mail there is to visit " . "http://webmail.fontys.nl\n---\nKind Regards,\n Peerweb services", 'From: peerweb@fontysvenlo.org'); //$headers } } $prjSel->setJoin('milestone_grp using (prj_id,milestone)'); $prjList = $prjSel->getSelector(); $sql = "select * from student\n" . "where snummer={$peer_id}"; $resultSet = $dbConn->Execute($sql); if ($resultSet === false) { print "error fetching judge data with {$sql} : " . $dbConn->ErrorMsg() . "<br/>\n"; } if (!$resultSet->EOF) { extract($resultSet->fields); } $page_opening = "Email to group members From: {$roepnaam} {$voorvoegsel} {$achternaam} <span style='font-family: courier'><{$email1}></span>"; $page = new PageContainer();
$to_emails = array(); while (!$resultSet3->EOF) { extract($resultSet3->fields); $to_emails[] = $email1; if (!in_array($tutor_email, $to_emails)) { $to_emails[] = $tutor_email; } $resultSet3->movenext(); } $headers = "From: peerweb@fontysvenlo.org\n" . "Content-Type: text/plain; charset=utf-8\n"; $reply_to = "Reply-To: peerweb@fontysvenlo.org"; $toAddress = implode(', ', $to_emails); $headers .= $reply_to; eval("\$message=\"{$mailbody}\";"); eval("\$subject=\"{$formsubject}\";"); domail($toAddress, $subject, $message, $headers); // no mail on personal docs. } } else { $pp['uploadMessage'] = "<span style='color:red;font-weight:bold;'>Upload failed, " . "possibly empty file ({$user_upload_path}) or Version limit ({$vesr} > {$version_limit}) exceeded, file not uploaded</span><br/>\n"; } } //$dbConn->log("2 prj_id=$prj_id, milestone=$milestone\n"); $sql = "select description as name, doctype as value,rights \n" . "from uploaddocumenttypes udt join prj_milestone pm using(prj_id) join project_deliverables pd using(prjm_id,doctype)\n" . "where pm.prjm_id={$prjm_id} and version_limit > 0 order by due asc"; $resultSet = $dbConn->Execute($sql); if ($resultSet === false) { print "error fetching document types with {$sql} : " . $dbConn->ErrorMsg() . "<br/>\n"; } $preload = array('0' => array('name' => ' ', 'value' => '1:1')); $pp['doctypeSelect'] = "<select name='doctype'>\n" . getOptionList($dbConn, $sql, $doctype) . "\n</select>\n"; // collect the rights in an array and pass it to javascript.