Example #1
0
function user_notify($eid)
{
    global $xoopsDB, $xoopsConfig;
    $result = $xoopsDB->query("SELECT title,edate,expire,status,topicid FROM " . EGTBL . " WHERE eid={$eid}");
    if (!$result || $xoopsDB->getRowsNum($result) == 0) {
        echo "<div class='error'>Not found Event(eid='{$eid}')</div>\n";
        return;
    }
    $data = $xoopsDB->fetchArray($result);
    $title = $data['title'];
    $edate = $data['edate'];
    $expire = $data['expire'];
    // using XOOPS2 notification system
    if (!$GLOBALS['xoopsModuleConfig']['user_notify'] || ($expire > $edate ? $expire < time() : $edate + $expire < time()) || $data['status'] != STAT_NORMAL) {
        return false;
    }
    $tags = array('EVENT_TITLE' => $title, 'EVENT_DATE' => eventdate($edate, _MD_TIME_FMT), 'EVENT_NOTE' => '', 'EVENT_URL' => EGUIDE_URL . "/event.php?eid={$eid}");
    $notification_handler =& xoops_gethandler('notification');
    $notification_handler->triggerEvent('global', 0, 'new', $tags);
    $notification_handler->triggerEvent('category', $data['topicid'], 'new', $tags);
    $result = $xoopsDB->query("SELECT rvid, email, confirm FROM " . RVTBL . " WHERE eid=0");
    while ($data = $xoopsDB->fetchArray($result)) {
        $xoopsMailer =& getMailer();
        $xoopsMailer->useMail();
        $xoopsMailer->setSubject(_MD_NEWSUB);
        $tpl = 'notify_user_new.tpl';
        $xoopsMailer->setTemplateDir(template_dir($tpl));
        $xoopsMailer->setTemplate($tpl);
        $xoopsMailer->setFromEmail($xoopsConfig['adminmail']);
        $xoopsMailer->setFromName(eguide_from_name());
        $xoopsMailer->assign($tags);
        $xoopsMailer->assign("CANCEL_URL", EGUIDE_URL . "/reserv.php?op=cancel&rvid=" . $data['rvid'] . "&key=" . $data['confirm']);
        $xoopsMailer->setToEmails($data['email']);
        if (!$xoopsMailer->send()) {
            echo "<div class='error'>" . $xoopsMailer->getErrors() . "</div>\n";
        }
    }
}
Example #2
0
function order_notify($data, $email, $value)
{
    global $xoopsModuleConfig, $xoopsUser, $xoopsModule;
    $poster = new XoopsUser($data['uid']);
    $eid = $data['eid'];
    $exid = $data['exid'];
    $url = EGUIDE_URL . '/event.php?eid=' . $eid . ($exid ? "&sub={$exid}" : '');
    $xoopsMailer =& getMailer();
    $xoopsMailer->useMail();
    $tplname = $data['autoaccept'] ? "accept%s.tpl" : "order%s.tpl";
    $extra = eguide_form_options('reply_extension');
    $tplfile = sprintf($tplname, '');
    // default template name
    $tmpdir = template_dir($tplfile);
    if ($extra) {
        $vals = unserialize_text($value);
        if (isset($vals[$extra])) {
            $extpl = sprintf($tplname, $vals[$extra]);
            if (file_exists("{$tmpdir}{$extpl}")) {
                $tplfile = $extpl;
            }
        }
    } else {
        $extra = eguide_form_options('reply_tpl_suffix');
        if ($extra) {
            $extpl = sprintf($tplname, $extra);
            if (file_exists("{$tmpdir}{$extpl}")) {
                $tplfile = $extpl;
            }
        }
    }
    $xoopsMailer->setTemplateDir($tmpdir);
    $xoopsMailer->setTemplate($tplfile);
    if ($xoopsModuleConfig['member_only'] && is_object($xoopsUser)) {
        $user = $xoopsUser;
        if (isset($data['reserv_uid'])) {
            $ruid = $data['reserv_uid'];
            $user = new XoopsUser($ruid);
        } else {
            $xoopsMailer->setToUsers($user);
        }
        $uinfo = sprintf("%s: %s (%s)\n", _MD_UNAME, $user->getVar('uname'), $user->getVar('name'));
    } else {
        if (!empty($email)) {
            $xoopsMailer->setToEmails($email);
        }
        $uinfo = "";
    }
    if ($email) {
        $uinfo .= sprintf("%s: %s\n", _MD_EMAIL, $email);
    }
    $rvid = $data['rvid'];
    $conf = $data['confirm'];
    $edate = eventdate($data['edate']);
    $tags = array("EVENT_URL" => $url, "RVID" => $rvid, "CANCEL_KEY" => $conf, "CANCEL_URL" => EGUIDE_URL . "/reserv.php?op=cancel&rvid={$rvid}&key={$conf}", "INFO" => $uinfo . $value, "TITLE" => $edate . " " . $data['title'], "EVENT_DATE" => $edate, "EVENT_TITLE" => $data['title'], "SUMMARY" => strip_tags($data['summary']));
    $subj = eguide_form_options('reply_subject', _MD_SUBJECT);
    $xoopsMailer->assign($tags);
    $xoopsMailer->setSubject($subj);
    $xoopsMailer->setFromEmail($poster->getVar('email'));
    $xoopsMailer->setFromName(eguide_from_name());
    $ret = $xoopsMailer->send();
    // send to order person
    if (!$ret) {
        return $ret;
    }
    $xoopsMailer->reset();
    $xoopsMailer->useMail();
    $xoopsMailer->setTemplateDir(template_dir($tplfile));
    $xoopsMailer->setTemplate($tplfile);
    $xoopsMailer->assign($tags);
    $xoopsMailer->setSubject($subj);
    $xoopsMailer->setFromEmail($poster->getVar('email'));
    $xoopsMailer->setFromName(eguide_from_name());
    if ($data['notify']) {
        if (!in_array($xoopsModuleConfig['notify_group'], $poster->groups())) {
            $xoopsMailer->setToUsers($poster);
        }
        $member_handler =& xoops_gethandler('member');
        $notify_group = $member_handler->getGroup($xoopsModuleConfig['notify_group']);
        $xoopsMailer->setToGroups($notify_group);
        $xoopsMailer->send();
    }
    return $ret;
}
Example #3
0
include XOOPS_ROOT_PATH . "/header.php";
assign_module_css();
$result = $xoopsDB->query("SELECT IF(exdate,exdate,edate) edate, title, uid FROM " . EGTBL . " LEFT JOIN " . EXTBL . " ON eid=eidref AND exid={$exid} WHERE eid={$eid}");
$data = $xoopsDB->fetchArray($result);
$edate = eventdate($data['edate']);
$title = $edate . " " . htmlspecialchars($data['title']);
$evurl = EGUIDE_URL . "/event.php?eid={$eid}" . ($exid ? "&sub={$exid}" : "");
echo "<p><a href='{$evurl}' class='evhead'>{$title}</a></p>\n";
if ($op == "doit") {
    $title = param('title', '');
    $xoopsMailer =& getMailer();
    $xoopsMailer->useMail();
    $xoopsMailer->setSubject($title);
    $xoopsMailer->setBody(param('body', ''));
    $xoopsMailer->setFromEmail($xoopsUser->email());
    $xoopsMailer->setFromName(eguide_from_name());
    $xoopsMailer->assign("EVENT_URL", EGUIDE_URL . "/event.php?eid={$eid}");
    $req = param('request') ? " OR eid=0" : "";
    $status = param('status');
    if (empty($status)) {
        $status = _RVSTAT_RESERVED;
    }
    $result = $xoopsDB->query("SELECT email,uid FROM " . RVTBL . " WHERE (eid={$eid} AND status={$status} AND exid={$exid}){$req}");
    $emails = array();
    $uids = array();
    while ($data = $xoopsDB->fetchArray($result)) {
        if (empty($data['uid'])) {
            $emails[] = $data['email'];
        } else {
            $uids[] = $data['uid'];
        }