/** * 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); }
/** * view external map (ajax) */ function externmapview__ajax() { global $user; $func = getVar("func"); $groupId = getVar("g_id"); $surname = getVar("Vorname"); $name = getVar("Nachname"); $groupId = getVar("g_id"); $email = getVar("E-Mail-Adresse"); $fon = getVar("Telefon"); $comment = getVar("Kommentar"); if ($func == 'loadMasterData') { $res["home_lat"] = getConf('churchdb_home_lat', '53.568537'); $res["home_lng"] = getConf('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, $groupId, -2, null, null, null, t("request.by.external.mapview")); sendConfirmationMail($user->email, $user->vorname, $groupId); $res = jsend()->success($res); } else { if ($func == 'editPersonGroupRelation') { include_once CHURCHDB . '/churchdb_ajax.php'; $res = _churchdb_editPersonGroupRelation($user->id, $groupId, -2, null, "null", t("request.changed.by.external.mapview")); sendConfirmationMail($user->email, $user->vorname, $groupId); $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' => $email, ':vorname' => $surname, ':name' => $name))->fetch(); $txt = ""; if ($db) { include_once CHURCHDB . '/churchdb_ajax.php'; churchdb_addPersonGroupRelation($db->id, $groupId, -2, null, null, null, t("request.by.external.mapview") . ": {$comment}"); sendConfirmationMail($email, $surname, $groupId); $txt = t("person.found.and.request.sent"); } else { $res = db_query("SELECT vorname, p.id id, g.bezeichnung\n FROM {cdb_gemeindeperson_gruppe} gpg, {cdb_gemeindeperson} gp, {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 email!='' AND gpg.status_no BETWEEN 1 AND 3 ", array(":gruppe_id" => $groupId)); $rec = array(); foreach ($res as $p) { $rec[] = $p->vorname; $data = array('title' => t('request.to.group', $p->bezeichnung), 'request' => array('surname' => $surname, 'name' => $name, 'email' => $email, 'phone' => $fon, 'comment' => $comment)); $lang = getUserLanguage($p->id); $content = getTemplateContent('email/groupRequest', 'churchdb', $data, null, $lang); $res = churchcore_sendEMailToPersonIDs($p->id, "[" . getConf('site_name') . "] " . t2($lang, 'form.request.to.group', $p->bezeichnung), $content, getConf('site_mail'), true, true); } if (!count($rec)) { $txt = t("could.not.find.group.leader.please.try.other.ways"); } else { $txt = t2($lang, "email.send.to", implode($rec, ", ")); sendConfirmationMail($email, $surname, $groupId); } } $res = jsend()->success($txt); } else { $res = jsend()->fail(t("unknown.call", $func)); } } } } drupal_json_output($res); }