Esempio n. 1
0
function qa_complete_reset_user($userid)
{
    require_once QA_INCLUDE_DIR . 'qa-util-string.php';
    require_once QA_INCLUDE_DIR . 'qa-app-options.php';
    require_once QA_INCLUDE_DIR . 'qa-app-emails.php';
    require_once QA_INCLUDE_DIR . 'qa-app-cookies.php';
    require_once QA_INCLUDE_DIR . 'qa-db-selects.php';
    $password = qa_random_alphanum(max(QA_MIN_PASSWORD_LEN, QA_NEW_PASSWORD_LEN));
    $userinfo = qa_db_select_with_pending(qa_db_user_account_selectspec($userid, true));
    if (!qw_send_notification($userid, $userinfo['email'], $userinfo['handle'], qa_lang('emails/new_password_subject'), nl2br(qa_lang('emails/new_password_body')), array('^password' => $password, '^url' => qa_opt('site_url')))) {
        qa_fatal_error('Could not send new password - password not reset');
    }
    qa_db_user_set_password($userid, $password);
    // do this last, to be safe
    qa_db_user_set($userid, 'emailcode', '');
    // so can't be reused
    qa_report_event('u_reset', $userid, $userinfo['handle'], qa_cookie_get(), array('email' => $userinfo['email']));
}
 function send_default_emails($event, $userid, $handle, $cookieid, $params)
 {
     switch ($event) {
         case 'q_queue':
         case 'q_requeue':
             if (qa_opt('moderate_notify_admin')) {
                 qw_send_notification(null, qa_opt('feedback_email'), null, $event == 'q_requeue' ? qa_lang('emails/remoderate_subject') : qa_lang('emails/moderate_subject'), $event == 'q_requeue' ? nl2br(qa_lang('emails/remoderate_body')) : nl2br(qa_lang('emails/moderate_body')), array('^p_handle' => isset($handle) ? $handle : (strlen($params['name']) ? $params['name'] : (strlen(@$oldquestion['name']) ? $oldquestion['name'] : qa_lang('main/anonymous'))), '^p_context' => trim(@$params['title'] . "\n\n" . $params['text']), '^url' => qa_q_path($params['postid'], $params['title'], true), '^a_url' => qa_path_absolute('admin/moderate')));
             }
             break;
         case 'a_queue':
         case 'a_requeue':
             if (qa_opt('moderate_notify_admin')) {
                 qw_send_notification(null, qa_opt('feedback_email'), null, $event == 'a_requeue' ? qa_lang('emails/remoderate_subject') : qa_lang('emails/moderate_subject'), $event == 'a_requeue' ? nl2br(qa_lang('emails/remoderate_body')) : nl2br(qa_lang('emails/moderate_body')), array('^p_handle' => isset($handle) ? $handle : (strlen($params['name']) ? $params['name'] : (strlen(@$oldanswer['name']) ? $oldanswer['name'] : qa_lang('main/anonymous'))), '^p_context' => $params['text'], '^url' => qa_q_path($params['parentid'], $params['parent']['title'], true, 'A', $params['postid']), '^a_url' => qa_path_absolute('admin/moderate')));
             }
             break;
         case 'c_queue':
         case 'c_requeue':
             if (qa_opt('moderate_notify_admin')) {
                 qw_send_notification(null, qa_opt('feedback_email'), null, $event == 'c_requeue' ? qa_lang('emails/remoderate_subject') : qa_lang('emails/moderate_subject'), $event == 'c_requeue' ? nl2br(qa_lang('emails/remoderate_body')) : nl2br(qa_lang('emails/moderate_body')), array('^p_handle' => isset($handle) ? $handle : (strlen($params['name']) ? $params['name'] : (strlen(@$oldcomment['name']) ? $oldcomment['name'] : (strlen(@$oldanswer['name']) ? $oldanswer['name'] : qa_lang('main/anonymous')))), '^p_context' => $params['text'], '^url' => qa_q_path($params['questionid'], $params['question']['title'], true, 'C', $params['postid']), '^a_url' => qa_path_absolute('admin/moderate')));
             }
             break;
         case 'q_flag':
         case 'a_flag':
         case 'c_flag':
             $flagcount = $params['flagcount'];
             $oldpost = $params['oldpost'];
             $notifycount = $flagcount - qa_opt('flagging_notify_first');
             if ($notifycount >= 0 && $notifycount % qa_opt('flagging_notify_every') == 0) {
                 qw_send_notification(null, qa_opt('feedback_email'), null, qa_lang('emails/flagged_subject'), nl2br(qa_lang('emails/flagged_body')), array('^p_handle' => isset($oldpost['handle']) ? $oldpost['handle'] : (strlen($oldpost['name']) ? $oldpost['name'] : qa_lang('main/anonymous')), '^flags' => $flagcount == 1 ? qa_lang_html_sub('main/1_flag', '1', '1') : qa_lang_html_sub('main/x_flags', $flagcount), '^p_context' => trim(@$oldpost['title'] . "\n\n" . qa_viewer_text($oldpost['content'], $oldpost['format'])), '^url' => qa_q_path($params['questionid'], $params['question']['title'], true, $oldpost['basetype'], $oldpost['postid']), '^a_url' => qa_path_absolute('admin/flagged')));
             }
             break;
         case 'u_register':
             if (qa_opt('register_notify_admin')) {
                 qw_send_notification(null, qa_opt('feedback_email'), null, qa_lang('emails/u_registered_subject'), qa_opt('moderate_users') ? nl2br(qa_lang('emails/u_to_approve_body')) : nl2br(qa_lang('emails/u_registered_body')), array('^u_handle' => $handle, '^url' => qa_path_absolute('user/' . $handle), '^a_url' => qa_path_absolute('admin/approve')));
             }
             break;
     }
 }