/** * * @param array $params * @throws CTException */ public function sendEMail($params) { global $user; include_once './' . CHURCHDB . '/churchdb_db.php'; $groups = churchdb_getMyGroups($user->id, true, false); if (empty($groups[$params["groupid"]])) { throw new CTException("Group is not allowed!"); } $ids = churchdb_getAllPeopleIdsFromGroups(array($params["groupid"])); churchcore_sendEMailToPersonIDs(implode(",", $ids), "[" . getConf('site_name') . "] " . t('message.from.x', "{$user->vorname} {$user->name}"), $params["message"], null, true); }
public function sendEMailToPersonIds($params) { global $base_url; $content = $params["inhalt"]; // $usetemplate = (isset($params["usetemplate"]) && ($params["usetemplate"] == true)); $usetemplate = getVar('usetemplate', false, $params) == 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); }
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(getConf('invite_email_text', "invitation.email.standard.text", getConf('site_name'))); $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 " . getConf('site_name'), $content, getConf('site_mail'), true); cdb_log("Person {$id} wurde zu " . getConf('site_name') . " eingeladen:" . $content, 2, $id); //TODO: is $content in log really needed? no name; if admin clicks link, ontimelogin will be deleted, ... }
function churchcal_saveSplittedEvent($params) { global $user; $res = new stdClass(); // if no splitDate given it is a new event without impact if (!isset($params["splitDate"])) { throw new CTException("saveSplittedEvent: splitDate not given!"); } $splitDate = new DateTime($params["splitDate"]); $untilEnd_yn = $params["untilEnd_yn"]; $pastEventId = $params["pastEvent"]["id"]; // Get originEvent out of Database $dummy = churchcal_getCalPerCategory(array("category_ids" => array(0 => $params["pastEvent"]["category_id"]))); $originEvent = (array) $dummy[$params["pastEvent"]["category_id"]][$params["newEvent"]["old_id"]]; // Copy all entries from past to new event, cause CR und CS does not have all infos and doesn't need it :) $pastEventDB = db_query("SELECT bezeichnung, ort, notizen, link, intern_yn, category_id " . "FROM {cc_cal} WHERE id = :id ", array(":id" => $pastEventId))->fetch(); if ($pastEventDB != false) { foreach ($pastEventDB as $key => $entry) { if (empty($params["pastEvent"][$key])) { $params["pastEvent"][$key] = $entry; } if (empty($params["newEvent"][$key])) { $params["newEvent"][$key] = $entry; } } } // Save new Event without impact on CS and CR ... $res = churchcal_createEvent($params["newEvent"], false, true); // ... and now bind related bookings and services to the new event $newEventId = $res["id"]; $params["newEvent"]["id"] = $newEventId; if (churchcore_isModuleActivated("churchservice")) { include_once './' . CHURCHSERVICE . '/churchservice_db.php'; churchservice_rebindServicesToNewEvent($pastEventId, $newEventId, $splitDate, $untilEnd_yn); $params["newEvent"]["cal_id"] = $newEventId; $startdate = new Datetime($params["newEvent"]["startdate"]); if ($splitDate->format("Y-m-d H:i") != $startdate->format("Y-m-d H:i")) { $params["newEvent"]["old_startdate"] = $splitDate; } churchservice_operateEventFromChurchCal($params["newEvent"]); } // Save old Event churchcal_updateEvent($params["pastEvent"], false, true); if (getVar("informCreator", "true", $params["newEvent"]) == "true" && $originEvent["modified_pid"] != $user->id) { $data = (array) churchcal_getEventChangeImpact(array("newEvent" => $params["newEvent"], "originEvent" => $originEvent, "pastEvent" => $params["pastEvent"])); $data["caption"] = $params["newEvent"]["bezeichnung"]; $data["startdate"] = churchcore_stringToDateDe($params["newEvent"]["startdate"]); $p = db_query("SELECT name, vorname, IF(spitzname, spitzname, vorname) AS nickname\n FROM {cdb_person}\n WHERE id=:id", array(":id" => $originEvent["modified_pid"]))->fetch(); $data["p"] = $p; // get populated template and send email $lang = getUserLanguage($params["modified_pid"]); $content = getTemplateContent('email/informCreator', 'churchcal', $data, null, $lang); churchcore_sendEMailToPersonIDs($originEvent["modified_pid"], "[" . getConf('site_name') . "] " . t2($lang, 'information.for.your.event'), $content, null, true); } return array("id" => $newEventId, "bookingIds" => $res["bookingIds"]); }
/** * 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); }