Exemplo n.º 1
0
function send_email_to_site_admins($user_role_permissions, $from_email_addr, $subject, $message, &$errors)
{
    $success = TRUE;
    if (!is_valid_email_addr($from_email_addr)) {
        $errors[] = get_opendb_lang_var('invalid_from_address');
        $success = FALSE;
    }
    if (strlen($subject) == 0) {
        $errors[] = get_opendb_lang_var('invalid_subject');
        $success = FALSE;
    }
    if ($success) {
        $success = FALSE;
        $results = fetch_user_rs($user_role_permissions);
        while ($user_r = db_fetch_assoc($results)) {
            if (opendb_user_email($user_r['user_id'], $from_email_addr, $subject, $message, $errors)) {
                $success = TRUE;
            }
        }
    }
    return $success;
}
Exemplo n.º 2
0
/**
   Send notification to user that account is active
   
   @param - $user_r - a single record from user table
*/
function send_newuser_email($user_r, $passwd, &$errors)
{
    $from_user_r = fetch_user_r(get_opendb_session_var('user_id'));
    $subject = get_opendb_lang_var('new_site_account', 'site', get_opendb_config_var('site', 'title'));
    $message = get_opendb_lang_var('to_user_email_intro', 'fullname', $user_r['fullname']) . "\n\n" . get_opendb_lang_var('welcome_email', 'site', get_opendb_config_var('site', 'title')) . "\n\n" . get_opendb_lang_var('userid') . ": " . $user_r['user_id'] . "\n" . get_opendb_lang_var('new_passwd') . ": " . $passwd;
    if (is_user_granted_permission(PERM_EDIT_USER_PROFILE)) {
        // Provide a link to open User Info form in edit mode.
        $message .= "\n\n" . get_opendb_lang_var('edit_my_info') . ":\n" . get_site_url() . "user_admin.php?op=edit&user_id=" . urlencode($user_r['user_id']);
    }
    if (is_valid_email_addr($user_r['email_addr'])) {
        return opendb_user_email($user_r['user_id'], $from_user_r['user_id'], $subject, $message, $errors, FALSE);
    }
}
Exemplo n.º 3
0
function perform_newpassword($HTTP_VARS, &$errors)
{
    if (!is_user_valid($HTTP_VARS['uid'])) {
        opendb_logger(OPENDB_LOG_WARN, __FILE__, __FUNCTION__, 'New password request failure: User does not exist', array($HTTP_VARS['uid']));
        // make user look successful to prevent mining for valid userids
        return TRUE;
    } else {
        if (!is_user_active($HTTP_VARS['uid'])) {
            // Do not allow new password operation for 'deactivated' user.
            opendb_logger(OPENDB_LOG_WARN, __FILE__, __FUNCTION__, 'New password request failure: User is not active', array($HTTP_VARS['uid']));
            return FALSE;
        } else {
            if (!is_user_granted_permission(PERM_CHANGE_PASSWORD, $HTTP_VARS['uid'])) {
                opendb_logger(OPENDB_LOG_WARN, __FILE__, __FUNCTION__, 'New password request failure: User does not have permission to change password', array($HTTP_VARS['uid']));
                return FALSE;
            } else {
                if (get_opendb_config_var('user_admin', 'user_passwd_change_allowed') === FALSE && !is_user_granted_permission(PERM_ADMIN_CHANGE_PASSWORD)) {
                    opendb_logger(OPENDB_LOG_WARN, __FILE__, __FUNCTION__, 'New password request failure: Password change is disabled', array($HTTP_VARS['uid']));
                    return FALSE;
                } else {
                    opendb_logger(OPENDB_LOG_INFO, __FILE__, __FUNCTION__, 'User requested to be emailed a new password', array($HTTP_VARS['uid']));
                    $user_r = fetch_user_r($HTTP_VARS['uid']);
                    $user_passwd = generate_password(8);
                    // only send if valid user (email)
                    if (strlen($user_r['email_addr']) > 0) {
                        $pass_result = update_user_passwd($HTTP_VARS['uid'], $user_passwd);
                        if ($pass_result === TRUE) {
                            $subject = get_opendb_lang_var('lost_password');
                            $message = get_opendb_lang_var('to_user_email_intro', 'fullname', $user_r['fullname']) . "\n\n" . get_opendb_lang_var('new_passwd_email') . "\n\n" . get_opendb_lang_var('userid') . ": " . $HTTP_VARS['uid'] . "\n" . get_opendb_lang_var('password') . ": " . $user_passwd;
                            if (opendb_user_email($user_r['user_id'], NULL, $subject, $message, $errors)) {
                                return TRUE;
                            } else {
                                return "EMAIL_NOT_SENT";
                            }
                        }
                    } else {
                        $errors[] = "User '" . $HTTP_VARS['uid'] . "' does not have a valid email address.";
                        return FALSE;
                    }
                }
            }
        }
    }
}
Exemplo n.º 4
0
function send_email_to_userids($user_id_rs, $from_userid, $subject, $message, &$errors)
{
    if (strlen($subject) == 0) {
        $errors[] = get_opendb_lang_var('invalid_subject');
        return FALSE;
    }
    reset($user_id_rs);
    while (list(, $user_id) = each($user_id_rs)) {
        $touser_r = fetch_user_r($user_id);
        if (is_not_empty_array($touser_r)) {
            if (opendb_user_email($touser_r['user_id'], $from_userid, $subject, $message, $errors)) {
                $success[] = $touser_r['fullname'] . " (" . $user_id . ")";
            } else {
                $failures[] = array(user => $touser_r['fullname'] . " (" . $user_id . ")", error => $errors);
            }
            $errors = NULL;
        }
    }
    if (is_not_empty_array($success)) {
        echo "<p class=\"success\">" . get_opendb_lang_var('message_sent_to') . ": <ul>";
        while (list(, $touser) = each($success)) {
            echo "<li class=\"smsuccess\">" . $touser . "</li>";
        }
        echo "</ul></p>";
    }
    if (is_not_empty_array($failures)) {
        echo "<p class=\"error\">" . get_opendb_lang_var('message_not_sent_to') . ": <ul>";
        while (list(, $failure_r) = each($failures)) {
            echo "<li class=\\smerror\">" . $failure_r['user'] . format_error_block($failure_r['error']) . "</li>";
        }
        echo "</ul></p>";
    }
    return TRUE;
}
Exemplo n.º 5
0
/**
   The $borrow_item_r array format:
       $item_r
       $details
*/
function send_notification_email($to_user, $from_user, $heading, $introduction, $more_information, $item_entry_rs, &$errors)
{
    // Format the entire message.
    $message = get_opendb_lang_var('to_user_email_intro', 'fullname', fetch_user_name($to_user)) . "\n\n" . $introduction;
    while (list(, $item_entry_r) = each($item_entry_rs)) {
        $message .= "\n*    " . $item_entry_r['display_title'];
        // Add any item Borrow (overdue,due,reminder,etc) details here.
        while (list(, $detail) = @each($item_entry_r['detail'])) {
            $message .= "\n     - " . $detail;
        }
    }
    if (strlen($more_information) > 0) {
        $message .= "\n\n\n" . $more_information . "\n";
    }
    // Send the mail!
    return opendb_user_email($to_user, $from_user, $heading, $message, $errors);
}