/**
 * send emails to persons with given id(s)
 *
 * @param string $ids; comma separated
 * @param string $subject
 * @param string $content
 * @param string $from; default: null (use current users email)
 * @param string $htmlmail; default: false
 * @param string $withtemplate; default: true
 */
function churchcore_sendEMailToPersonIDs($ids, $subject, $content, $from = null, $htmlmail = false, $withtemplate = true)
{
    global $base_url;
    if ($ids == null || $ids == "") {
        ct_log("Konnte Email {$subject} nicht senden, kein Empfänger angegeben!", 1);
        return;
    }
    if (!$from) {
        $user_pid = $_SESSION["user"]->id;
        $res = db_query("SELECT vorname, name, email FROM {cdb_person}\n                     WHERE id={$user_pid}")->fetch();
        $from = "{$res->vorname} {$res->name} <{$res->email}>";
    }
    $persons = db_query("SELECT * FROM {cdb_person} WHERE id IN ({$ids})");
    $error = array();
    foreach ($persons as $p) {
        $mailtxt = $content;
        if (empty($p->email)) {
            $error[] = $p->vorname . " " . $p->name;
        } else {
            $mailtxt = str_replace('\\"', '"', $mailtxt);
            $mailtxt = churchcore_personalizeTemplate($mailtxt, $p);
            churchcore_mail($from, $p->email, $subject, $mailtxt, $htmlmail, $withtemplate);
        }
    }
    if (count($error)) {
        throw new CTFail(t('following.persons.have.no.email.address') . ' ' . implode($error, ", "));
    }
}
/**
 * send emails to persons with given id(s)
 * 
 * @param string $ids, ids, comma separated
 * @param string $subject
 * @param string $content
 * @param string $from, if empty, current users email 
 */
function churchcore_sendEMailToPersonids($ids, $subject, $content, $from = null, $htmlmail = false, $withtemplate = true)
{
    global $base_url;
    if ($from == null) {
        $user_pid = $_SESSION["user"]->id;
        $res = db_query("select vorname, name, email from {cdb_person} where id={$user_pid}")->fetch();
        $from = "{$res->vorname} {$res->name} <{$res->email}>";
    }
    $arr = db_query("select * from {cdb_person} where id in ({$ids})");
    $error = array();
    foreach ($arr as $p) {
        $mailtxt = $content;
        if (empty($p->email)) {
            $error[] = $p->vorname . " " . $p->name;
        } else {
            $mailtxt = str_replace('\\"', '"', $mailtxt);
            $mailtxt = churchcore_personalizeTemplate($mailtxt, $p);
            //ct_log("[ChurchCore] - Sende Mail an $p->email $mailtxt",2,-1,"mail");
            churchcore_mail($from, $p->email, $subject, $mailtxt, $htmlmail, $withtemplate);
        }
    }
    if (count($error) > 0) {
        throw new CTFail(t('following.persons.have.no.email.address') . ' ' . implode($error, ", "));
    }
}
Example #3
0
/**
 * For footer e-mail function
 */
function about__ajax()
{
    global $config, $user;
    $params = $_POST;
    if ($params["func"] == "sendEmailToAdmin") {
        if (getConf("mail_enabled")) {
            $recipients = explode(",", getConf("admin_mail", $config["site_mail"]));
            foreach ($recipients as $recipient) {
                churchcore_mail("{$user->vorname} {$user->name} <{$user->email}>", trim($recipient), $params["subject"], $params["text"], true, true, 0);
            }
            $res = jsend()->success();
        } else {
            $res = jsend()->fail("EMails sind deaktivert!");
        }
    } else {
        if ($params["func"] == "amILoggedIn") {
            if ($user == null) {
                $res = jsend()->success(false);
            } else {
                $res = jsend()->success($user->id != -1);
            }
        } else {
            $res = jsend()->error("Unkown call: " . $params["func"]);
        }
    }
    drupal_json_output($res);
}
/**
 * send confirmation email
 *
 * TODO: use email template (customisable!) from file, f.e.:
 *		extract($vars);
 *	    eval ('$content = "$message"');
 *
 * @param string $mail
 * @param string $vorname
 * @param int $g_id
 */
function sendConfirmationMail($mail, $vorname = "", $g_id)
{
    $g = db_query("select * from {cdb_gruppe} where id=:id", array(":id" => $g_id))->fetch();
    if ($g != false) {
        $content = "<h3>" . t("hello.name") . "</h3><p>";
        $content .= "Dein Antrag f&uuml;r die Gruppe <i>{$g->bezeichnung}</i> ist eingegangen. <p>Vielen Dank!";
        $res = churchcore_mail(variable_get('site_mail'), $mail, "[" . variable_get('site_name') . "] Teilnahmeantrag zur Gruppe " . $g->bezeichnung, $content, true, true, 2);
    }
}
Example #5
0
/**
 * send confirmation email
 *
 * @param string $mail
 * @param string $vorname
 * @param int $g_id
 */
function sendConfirmationMail($mail, $vorname = "", $g_id)
{
    $g = db_query("SELECT * FROM {cdb_gruppe}\n                 WHERE id=:id", array(":id" => $g_id))->fetch();
    if ($g) {
        $data = array('surname' => $vorname, 'groupName' => $g->bezeichnung);
        $content = getTemplateContent('email/groupRequestSent', 'churchdb', $data);
        $res = churchcore_mail(getConf('site_mail'), $mail, "[" . getConf('site_name') . "] " . '<i>' . $g->bezeichnung . '</i>', $content, true, true, 2);
    }
}