Exemple #1
0
function mail_shift_removed($user, $shift)
{
    if ($user["email_shiftinfo"]) {
        $room = Room($shift["RID"]);
        $message = _("You have been removed from a Shift:") . "\n";
        $message .= $shift["name"] . "\n";
        $message .= $shift["title"] . "\n";
        $message .= date("y-m-d H:i", $shift["start"]) . " - " . date("H:i", $shift["end"]) . "\n";
        $message .= $room["Name"] . "\n";
        engelsystem_email_to_user($user, '[engelsystem] ' . _("Removed from Shift"), $message, true);
    }
}
Exemple #2
0
function mail_shift_reminder($user, $shift, $untilStart)
{
    if ($user["email_shiftinfo"]) {
        // send email to user about shortly starting shift
        $message = _("Your shift starts in less than ");
        $message .= $untilStart . '.\\n\\n';
        $message .= _('Shift: ') . $shift['title'] . '\\n';
        $message .= _('Scheduled: ') . date("Y-m-d H:i", $shift['start']) . " - " . date("H:i", $shift['end']) . '\\n';
        $message .= _('Location: ') . $shift['RID']['Location'] . '\\n';
        engelsystem_email_to_user($user, '[engelsystem] ' . _("Reminder: Your Shift starts soon"), $message);
    }
}
Exemple #3
0
function user_activate_account_controller()
{
    global $customization;
    if (!isset($_GET['token'])) {
        error(_("Invalid confirmation token."));
        redirect('?');
        die;
    }
    $token = $_GET['token'];
    $checkQuery = 'SELECT *
                 FROM `User`
                 WHERE `mailaddress_verification_token` = "' . sql_escape($token) . '"';
    $checkResult = sql_select($checkQuery);
    // check that validation code exists for user
    if (is_array($checkResult) && isset($checkResult[0])) {
        $confirmSql = 'UPDATE `User`
                   SET `user_account_approved` = "1"
                   WHERE `UID` = "' . $checkResult[0]['UID'] . '"';
        sql_query($confirmSql);
        success(_('Your account is confirmed now. You might want to log in:'));
        // send introductory eMail
        $msg = _('Your e-Mail address was successfully verified.');
        if ($customization['introduction_mail_content']) {
            $msg .= "\n" . $customization['introduction_mail_content'];
        }
        engelsystem_email_to_user($checkResult[0], _('E-Mail verified successful and introduction to Engelsystem'), $msg);
        redirect(page_link_to('login'));
    } else {
        error(_("Invalid confirmation token."));
        redirect('?');
        die;
    }
}
/**
 * User password recovery.
 * (By email)
 */
function user_password_recovery_controller()
{
    if (isset($_REQUEST['token'])) {
        $user_source = User_by_password_recovery_token($_REQUEST['token']);
        if ($user_source === false) {
            engelsystem_error("Unable to load user.");
        }
        if ($user_source == null) {
            error(_("Token is not correct."));
            redirect(page_link_to('login'));
        }
        if (isset($_REQUEST['submit'])) {
            $ok = true;
            if (isset($_REQUEST['password']) && strlen($_REQUEST['password']) >= MIN_PASSWORD_LENGTH) {
                if ($_REQUEST['password'] != $_REQUEST['password2']) {
                    $ok = false;
                    error(_("Your passwords don't match."));
                }
            } else {
                $ok = false;
                error(_("Your password is to short (please use at least 6 characters)."));
            }
            if ($ok) {
                $result = set_password($user_source['UID'], $_REQUEST['password']);
                if ($result === false) {
                    engelsystem_error(_("Password could not be updated."));
                }
                success(_("Password saved."));
                redirect(page_link_to('login'));
            }
        }
        return User_password_set_view();
    } else {
        if (isset($_REQUEST['submit'])) {
            $ok = true;
            if (isset($_REQUEST['email']) && strlen(strip_request_item('email')) > 0) {
                $email = strip_request_item('email');
                if (check_email($email)) {
                    $user_source = User_by_email($email);
                    if ($user_source === false) {
                        engelsystem_error("Unable to load user.");
                    }
                    if ($user_source == null) {
                        $ok = false;
                        error(_("E-mail address is not correct."));
                    }
                } else {
                    $ok = false;
                    error(_("E-mail address is not correct."));
                }
            } else {
                $ok = false;
                error(_("Please enter your e-mail."));
            }
            if ($ok) {
                $token = User_generate_password_recovery_token($user_source);
                if ($token === false) {
                    engelsystem_error("Unable to generate password recovery token.");
                }
                $result = engelsystem_email_to_user($user_source, _("Password recovery"), sprintf(_("Please visit %s to recover your password."), page_link_to_absolute('user_password_recovery') . '&token=' . $token));
                if ($result === false) {
                    engelsystem_error("Unable to send password recovery email.");
                }
                success(_("We sent an email containing your password recovery link."));
                redirect(page_link_to('login'));
            }
        }
        return User_password_recovery_view();
    }
}
/**
 * @param User $user_source
 */
function mail_user_delete($user)
{
    engelsystem_email_to_user($user, '[engelsystem] ' . _("Your account has been deleted"), _("Your angelsystem account has been deleted. If you have any questions regarding your account deletion, please contact heaven."));
}