/**
 * Add to email queue
 * @param EmailData $p_email_data Email Data structure.
 * @return integer
 */
function email_queue_add(EmailData $p_email_data)
{
    $t_email_data = email_queue_prepare_db($p_email_data);
    # email cannot be blank
    if (is_blank($t_email_data->email)) {
        error_parameters(lang_get('email'));
        trigger_error(ERROR_EMPTY_FIELD, ERROR);
    }
    # subject cannot be blank
    if (is_blank($t_email_data->subject)) {
        error_parameters(lang_get('subject'));
        trigger_error(ERROR_EMPTY_FIELD, ERROR);
    }
    # body cannot be blank
    if (is_blank($t_email_data->body)) {
        error_parameters(lang_get('body'));
        trigger_error(ERROR_EMPTY_FIELD, ERROR);
    }
    $c_email = $t_email_data->email;
    $c_subject = $t_email_data->subject;
    $c_body = $t_email_data->body;
    $c_metadata = serialize($t_email_data->metadata);
    db_param_push();
    $t_query = 'INSERT INTO {email}
				    ( email, subject, body, submitted, metadata)
				  VALUES
				    (' . db_param() . ',' . db_param() . ',' . db_param() . ',' . db_param() . ',' . db_param() . ')';
    db_query($t_query, array($c_email, $c_subject, $c_body, db_now(), $c_metadata));
    $t_id = db_insert_id(db_get_table('email'), 'email_id');
    log_event(LOG_EMAIL_VERBOSE, sprintf('message %d queued', $t_id));
    return $t_id;
}
function email_queue_add($p_email_data)
{
    $t_email_data = email_queue_prepare_db($p_email_data);
    # email cannot be blank
    if (is_blank($t_email_data->email)) {
        error_parameters(lang_get('email'));
        trigger_error(ERROR_EMPTY_FIELD, ERROR);
    }
    # subject cannot be blank
    if (is_blank($t_email_data->subject)) {
        error_parameters(lang_get('subject'));
        trigger_error(ERROR_EMPTY_FIELD, ERROR);
    }
    # body cannot be blank
    if (is_blank($t_email_data->body)) {
        error_parameters(lang_get('body'));
        trigger_error(ERROR_EMPTY_FIELD, ERROR);
    }
    $t_email_table = config_get('mantis_email_table');
    $c_email = $t_email_data->email;
    $c_subject = $t_email_data->subject;
    $c_body = $t_email_data->body;
    $c_metadata = serialize($t_email_data->metadata);
    $query = "INSERT INTO {$t_email_table}\r\n\t\t\t\t    ( email,\r\n\t\t\t\t      subject,\r\n\t\t\t\t\t  body,\r\n\t\t\t\t\t  submitted,\r\n\t\t\t\t\t  metadata)\r\n\t\t\t\t  VALUES\r\n\t\t\t\t    ( '{$c_email}',\r\n\t\t\t\t      '{$c_subject}',\r\n\t\t\t\t      '{$c_body}',\r\n\t\t\t\t\t  " . db_now() . ",\r\n\t\t\t\t\t  '{$c_metadata}'\r\n\t\t\t\t\t)";
    db_query($query);
    return db_insert_id($t_email_table);
}
Exemple #3
0
/**
 * Add to email queue
 * @param EmailData $p_email_data
 * @return int
 */
function email_queue_add($p_email_data)
{
    $t_email_data = email_queue_prepare_db($p_email_data);
    # email cannot be blank
    if (is_blank($t_email_data->email)) {
        error_parameters(lang_get('email'));
        trigger_error(ERROR_EMPTY_FIELD, ERROR);
    }
    # subject cannot be blank
    if (is_blank($t_email_data->subject)) {
        error_parameters(lang_get('subject'));
        trigger_error(ERROR_EMPTY_FIELD, ERROR);
    }
    # body cannot be blank
    if (is_blank($t_email_data->body)) {
        error_parameters(lang_get('body'));
        trigger_error(ERROR_EMPTY_FIELD, ERROR);
    }
    $t_email_table = db_get_table('email');
    $c_email = $t_email_data->email;
    $c_subject = $t_email_data->subject;
    $c_body = $t_email_data->body;
    $c_metadata = serialize($t_email_data->metadata);
    $query = "INSERT INTO {$t_email_table}\n\t\t\t\t    ( email,\n\t\t\t\t      subject,\n\t\t\t\t\t  body,\n\t\t\t\t\t  submitted,\n\t\t\t\t\t  metadata)\n\t\t\t\t  VALUES\n\t\t\t\t    ( " . db_param() . ",\n\t\t\t\t      " . db_param() . ",\n\t\t\t\t      " . db_param() . ",\n\t\t\t\t\t  " . db_param() . ",\n\t\t\t\t\t  " . db_param() . "\n\t\t\t\t\t)";
    db_query_bound($query, array($c_email, $c_subject, $c_body, db_now(), $c_metadata));
    return db_insert_id($t_email_table, 'email_id');
}