/**
 * 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);
}
Beispiel #2
0
function subscribeToList($emails, $mysql, $table_prefix, $CST_MLM_SUBSCRIPTION, $log_enabled, $defaultname, $confirm_subscription, $dirpath, $cid)
{
    global $admin_general_notification_email, $already_added_list, $newly_added_list;
    $catlist = "";
    $sendmail = 0;
    $confirm = $confirm_subscription;
    // get value from configuration file.
    if ($emails != "" && is_valid_email($emails)) {
        if ($mysql->total("" . $table_prefix . "email_advt", "email='{$emails}'") == 0) {
            $ti = time();
            mysql_query("INSERT INTO `" . $table_prefix . "email_advt` ( `id` , `email` , `unsubstatus` , `time` )VALUES ('', '{$emails}', '{$confirm}', '" . $ti . "');");
            $roww = $mysql->select_last_row("" . $table_prefix . "email_advt", "id");
            $id = $roww[0];
            if ($confirm == 1) {
                //sendConfirmationMail ($defaultname,$id,$emails,$dirpath,$ti,$cid);
                $sendmail = 1;
            }
            $roww = $mysql->select_last_row("" . $table_prefix . "email_advt", "id");
            $id = $roww[0];
            if (isset($_POST['name'])) {
                $var = trim($_POST['name']);
                if ($var != "") {
                    mysql_query("insert into " . $table_prefix . "ea_extraparam values('','{$id}','name','{$var}');");
                }
            }
            $extrafields = mysql_query("select * from " . $table_prefix . "extra_personal_info order by id ");
            while ($fielddetails = mysql_fetch_row($extrafields)) {
                $reqParamName = "extra_personal_info" . $fielddetails[0];
                if (isset($_POST[$reqParamName])) {
                    $var = trim($_POST[$reqParamName]);
                    phpSafe($var);
                    if ($var != "") {
                        mysql_query("insert into " . $table_prefix . "ea_extraparam values('','{$id}','{$fielddetails['1']}','{$var}');");
                    }
                }
            }
        } else {
            //check whether unsubscribed; if so make status subscribed
            $id = $mysql->echo_one("select id from`" . $table_prefix . "email_advt` where email='{$emails}'");
            //$ti=$mysql->echo_one("select time from`".$table_prefix."email_advt` where email='$emails'");
            $ti = time();
            if ($mysql->total("" . $table_prefix . "email_advt", "id='{$id}' and unsubstatus='1'") != 0) {
                if ($confirm != 1) {
                    mysql_query("update `" . $table_prefix . "email_advt` set unsubstatus='0',time='{$ti}' where id='{$id}'");
                } else {
                    mysql_query("update `" . $table_prefix . "email_advt` set  time='{$ti}' where id='{$id}'");
                    //sendConfirmationMail ($defaultname,$id,$emails,$dirpath,$ti,$cid);
                    $sendmail = 1;
                }
            }
            if (isset($_POST['name'])) {
                $var = trim($_POST['name']);
                if (str_replace(" ", "", $var) == "") {
                    mysql_query("delete from " . $table_prefix . "ea_extraparam where eid='{$id}' and name='name'");
                } else {
                    if ($mysql->total("" . $table_prefix . "ea_extraparam", "eid='{$id}' AND name='name'") == 0) {
                        mysql_query("insert into " . $table_prefix . "ea_extraparam values('','{$id}','name','{$var}');");
                    } else {
                        mysql_query("update `" . $table_prefix . "ea_extraparam` set value='{$var}' where eid='{$id}' AND name='name'");
                    }
                }
            }
            $extrafields = mysql_query("select * from " . $table_prefix . "extra_personal_info order by id ");
            while ($fielddetails = mysql_fetch_row($extrafields)) {
                $reqParamName = "extra_personal_info" . $fielddetails[0];
                if (isset($_POST[$reqParamName])) {
                    $var = trim($_POST[$reqParamName]);
                    phpSafe($var);
                    if (str_replace(" ", "", $var) == "") {
                        mysql_query("delete from " . $table_prefix . "ea_extraparam where eid='{$id}' and name='{$fielddetails['1']}'");
                    } else {
                        if ($mysql->total("" . $table_prefix . "ea_extraparam", "eid='{$id}' and name='{$fielddetails['1']}'") == 0) {
                            mysql_query("insert into " . $table_prefix . "ea_extraparam values('','{$id}','{$fielddetails['1']}','{$var}')");
                        } else {
                            mysql_query("update " . $table_prefix . "ea_extraparam set value ='{$var}' where eid='{$id}' and name='{$fielddetails['1']}' ");
                        }
                    }
                }
            }
        }
        //		$catId  = $_GET['cid'];
        $catId = $cid;
        $catIdArr = explode(",", $catId);
        $cnt = count($catIdArr);
        for ($i = 0; $i < $cnt; $i++) {
            $curr_stat_res = mysql_query("select id,unsubstatus from " . $table_prefix . "ea_em_n_cat where cid='{$catIdArr[$i]}' and eid='{$id}'");
            if (mysql_num_rows($curr_stat_res) > 0) {
                $curr_stat_row = mysql_fetch_row($curr_stat_res);
            }
            //print_r($curr_stat_row);die;
            if (mysql_num_rows($curr_stat_res) == 0) {
                //echo "1";die;
                $catlist .= " " . $mysql->echo_one("select name from `" . $table_prefix . "email_advt_category` where id='{$catIdArr[$i]}'") . ",";
                mysql_query("insert into " . $table_prefix . "ea_em_n_cat values('','{$id}','{$catIdArr[$i]}',{$confirm},{$ti})");
                if ($confirm == 1) {
                    $sendmail = 1;
                }
            } elseif ($curr_stat_row[1] == 1) {
                //echo "2";die;
                $catlist .= " " . $mysql->echo_one("select name from `" . $table_prefix . "email_advt_category` where id='{$catIdArr[$i]}'") . ",";
                if ($confirm != 1) {
                    mysql_query("update `" . $table_prefix . "ea_em_n_cat` set unsubstatus='0',time='{$ti}' where eid='{$id}' and cid={$catIdArr[$i]}");
                } else {
                    mysql_query("update `" . $table_prefix . "ea_em_n_cat` set time='{$ti}' where eid='{$id}' and cid={$catIdArr[$i]}");
                    $sendmail = 1;
                }
            } else {
                $already_added_list .= " " . $mysql->echo_one("select name from `" . $table_prefix . "email_advt_category` where id='{$catIdArr[$i]}'") . ",";
            }
        }
        if ($already_added_list != "") {
            $already_added_list = trim(substr($already_added_list, 0, strrpos($already_added_list, ",")));
        }
        if ($catlist != "") {
            $catlist = trim(substr($catlist, 0, strrpos($catlist, ",")));
            $newly_added_list = $catlist;
            if ($log_enabled == 1) {
                mysql_query("insert into " . $table_prefix . "admin_log_info values('','-1','{$emails} subscribed(html) to {$catlist}','" . time() . "','{$CST_MLM_SUBSCRIPTION}')");
            }
            echo mysql_error();
            if ($confirm != 1) {
                $msg = "\n\t\nHello,\n\nThe following user has subscribed to the list(s) \"{$catlist}\".\n\nEmail\t\t \t: {$emails}\n\nLogin to the admin area to see his details.\n\nRegards,\nInout Mailing List Manager";
                $headers = "";
                $headers .= "From: {$admin_general_notification_email}\n";
                $headers .= "MIME-Version: 1.0\n";
                $headers .= "Content-Type: text/plain; charset=\"UTF-8\"\n";
                $headers .= "Content-Transfer-Encoding: 8bit\n";
                if (trim($admin_general_notification_email) != "") {
                    global $smtpmailer;
                    global $smtp_host;
                    global $smtp_port;
                    global $smtp_auth;
                    global $smtp_user;
                    global $smtp_pass;
                    global $smtp_secure;
                    global $flag_var;
                    if ($smtpmailer == 1 && $flag_var == 1) {
                        $mail = new PHPMailer(true);
                        //$mail->SMTPDebug  = 2;                     // enables SMTP debug information (for testing)
                        $mail->IsSMTP();
                        // set mailer to use SMTP
                        $mail->Host = $smtp_host;
                        // specify SMTP mail server
                        $mail->Port = $smtp_port;
                        // specify SMTP Port
                        $mail->SMTPAuth = $smtp_auth;
                        // turn on SMTP authentication
                        $mail->Username = $smtp_user;
                        //Full SMTP username
                        $mail->Password = $smtp_pass;
                        //SMTP password
                        //if($smtp_secure )
                        $mail->SMTPSecure = $smtp_secure;
                        // sets the prefix to the servier
                        $mail->From = "{$smtp_user}";
                        $mail->FromName = "";
                        //$mail->Sender =$error_ret_mail;
                        $mail->AddAddress($admin_general_notification_email);
                        $mail->AddReplyTo($mail->From, $mail->FromName);
                        //$mail->WordWrap = 50; //optional, you can delete this line
                        //$mail->IsHTML(true); //set email format to HTML
                        $mail->Subject = "New subscription";
                        $mail->Body = $msg;
                        //html body
                        //$mail->AltBody = $content;  //plain text body
                        $send_res = $mail->Send();
                    } else {
                        mail($admin_general_notification_email, "New subscription", $msg, $headers);
                    }
                }
            }
        }
        if ($sendmail == 1) {
            sendConfirmationMail($defaultname, $id, $emails, $dirpath, $ti, $cid);
        }
    }
}
Beispiel #3
0
/**
 * 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);
}