Example #1
0
function saveMessage($option)
{
    global $database, $mainframe, $my;
    $row = new mosMessage($database);
    if (!$row->bind($_POST)) {
        echo "<script> alert('" . $row->getError() . "'); window.history.go(-1); </script>\n";
        exit;
    }
    if (!$row->send()) {
        mosRedirect("index2.php?option=com_messages&mosmsg=" . $row->getError());
    }
    mosRedirect("index2.php?option=com_messages");
}
Example #2
0
function saveMessage($option)
{
    global $database, $mainframe, $my, $mosConfig_absolute_path;
    global $mosConfig_mailfrom, $mosConfig_fromname;
    require_once $mosConfig_absolute_path . "/includes/mambofunc.php";
    $row = new mosMessage($database);
    if (!$row->bind($_POST)) {
        echo "<script> alert('" . $row->getError() . "'); window.history.go(-1); </script>\n";
        exit;
    }
    require_once mamboCore::get('mosConfig_absolute_path') . '/includes/phpInputFilter/class.inputfilter.php';
    $iFilter = new InputFilter(null, null, 1, 1);
    $row->subject = trim($iFilter->process($row->subject));
    $row->message = trim($iFilter->process($row->message));
    if (!$row->send()) {
        mosRedirect("index2.php?option=com_messages&mosmsg=" . $row->getError());
    }
    $msg = $row->subject . ' - ' . $row->message;
    $sql = "SELECT a.id, a.name, a.email" . "\nFROM #__users AS a" . "\nWHERE a.sendEmail = '1'" . "\nAND a.id = '" . $row->user_id_to . "'";
    $database->setQuery($sql);
    $rows = $database->loadObjectList();
    if ($rows) {
        foreach ($rows as $row) {
            $recipient = $row->email;
            $subject = "New private message from " . $row->name;
            mosMail($mosConfig_mailfrom, $mosConfig_fromname, $recipient, $subject, $msg);
        }
    }
    mosRedirect("index2.php?option=com_messages");
}