public function sendEMailToPersonIds($params)
 {
     global $base_url;
     $content = $params["inhalt"];
     $usetemplate = isset($params["usetemplate"]) && $params["usetemplate"] == true;
     if ($params["domain_id"] != "null") {
         $content .= '<p><a class="btn btn-royal" href="' . $base_url . '?q=churchservice&id=' . $params["domain_id"] . '">Event aufrufen</a>';
     }
     return churchcore_sendEMailToPersonIds($params["ids"], $params["betreff"], $content, null, true, $usetemplate);
 }
/**
 * view external map (ajax)
 */
function externmapview__ajax()
{
    global $user;
    $func = $_GET["func"];
    if ($func == 'loadMasterData') {
        $res["home_lat"] = variable_get('churchdb_home_lat', '53.568537');
        $res["home_lng"] = variable_get('churchdb_home_lng', '10.03656');
        $res["districts"] = churchcore_getTableData("cdb_distrikt", "bezeichnung");
        $res["groups"] = getExternalGroupData();
        $res["modulespath"] = CHURCHDB;
        $res["user_pid"] = $user->id;
        $res["vorname"] = $user->vorname;
        $res = jsend()->success($res);
    } else {
        if ($func == 'addPersonGroupRelation') {
            include_once CHURCHDB . '/churchdb_ajax.php';
            $res = churchdb_addPersonGroupRelation($user->id, $_GET["g_id"], -2, null, null, null, t("request.by.external.mapview"));
            sendConfirmationMail($user->email, $user->vorname, $_GET["g_id"]);
            $res = jsend()->success($res);
        } else {
            if ($func == 'editPersonGroupRelation') {
                include_once CHURCHDB . '/churchdb_ajax.php';
                $res = _churchdb_editPersonGroupRelation($user->id, $_GET["g_id"], -2, null, "null", t("request.changed.by.external.mapview"));
                sendConfirmationMail($user->email, $user->vorname, $_GET["g_id"]);
                $res = jsend()->success($res);
            } else {
                if ($func == 'sendEMail') {
                    $db = db_query('select * from {cdb_person} where upper(email) like upper(:email) and upper(vorname) like upper(:vorname) and upper(name) like upper(:name)', array(':email' => $_GET["E-Mail-Adresse"], ':vorname' => $_GET["Vorname"], ':name' => $_GET["Nachname"]))->fetch();
                    $txt = "";
                    if ($db != false) {
                        include_once CHURCHDB . '/churchdb_ajax.php';
                        churchdb_addPersonGroupRelation($db->id, $_GET["g_id"], -2, null, null, null, t("request.by.external.mapview") . ": " . $_GET["Kommentar"]);
                        sendConfirmationMail($_GET["E-Mail-Adresse"], $_GET["Vorname"], $_GET["g_id"]);
                        $txt = t("person.found.and.request.sent");
                    } else {
                        $res = db_query("select vorname, p.id id, g.bezeichnung from {cdb_gemeindeperson_gruppe} gpg, {cdb_gemeindeperson} gp, \n            {cdb_person} p, {cdb_gruppe} g\n             where gpg.gemeindeperson_id=gp.id and gp.person_id=p.id and g.id=:gruppe_id \n             and gpg.gruppe_id=g.id and status_no>=1 and status_no!=4", array(":gruppe_id" => $_GET["g_id"]));
                        $rec = array();
                        foreach ($res as $p) {
                            $rec[] = $p->vorname;
                            $content = "<h4>" . t('request.to.group', $p->bezeichnung) . "<h4/>";
                            $content .= "<ul><li>" . t('surname') . ": " . $_GET["Vorname"];
                            $content .= "<li>" . t('name') . ": " . $_GET["Nachname"];
                            $content .= "<li>" . t('email') . ": " . $_GET["E-Mail-Adresse"];
                            $content .= "<li>" . t('phone') . ": " . $_GET["Telefon"];
                            $content .= "<li>" . t('comment') . ": " . $_GET["Kommentar"];
                            $content .= "</ul>";
                            $res = churchcore_sendEMailToPersonIds($p->id, "[" . variable_get('site_name', 'ChurchTools') . "] " . t('form.request.to.group', $p->bezeichnung), $content, variable_get('site_mail'), true, true);
                        }
                        if (count($rec) == 0) {
                            $txt = t("could.not.find.group.leader.please.try.other.ways");
                        } else {
                            $txt = t("email.send.to", implode($rec, ", "));
                            sendConfirmationMail($_GET["E-Mail-Adresse"], $_GET["Vorname"], $_GET["g_id"]);
                        }
                    }
                    $res = jsend()->success($txt);
                } else {
                    $res = jsend()->fail(t("unknown.call", $func));
                }
            }
        }
    }
    drupal_json_output($res);
}
 public function sendEMailToPersonIds($params)
 {
     return churchcore_sendEMailToPersonIds($_POST["ids"], $_POST["betreff"], $_POST["inhalt"], null, true, false);
 }
/**
 * send person an invitation with singleuse loginstring per email 
 * 
 * @param int $id          
 */
function churchdb_invitePersonToSystem($id)
{
    global $base_url;
    $loginstr = churchcore_createOnTimeLoginKey($id);
    $content = "<h3>Hallo [Vorname],</h3><P>";
    $content .= htmlize(readConf('invite_email_text', "invitation.email.standard.text", readConf('site_name', 'ChurchTools')));
    $content .= '<p><a href="' . $base_url . "?q=profile&loginstr={$loginstr}&id={$id}" . '" class="btn btn-royal">Auf %sitename anmelden</a>';
    $res = churchcore_sendEMailToPersonIds($id, "Einladung zu " . readConf('site_name', 'ChurchTools'), $content, readConf('site_mail'), true);
    cdb_log("Person {$id} wurde zu " . readConf('site_name', 'ChurchTools') . " eingeladen:" . $content, 2, $id);
}