function qa_question_set_selchildid($userid, $handle, $cookieid, $oldquestion, $selchildid, $answers) { $oldselchildid = $oldquestion['selchildid']; qa_db_post_set_selchildid($oldquestion['postid'], isset($selchildid) ? $selchildid : null); qa_db_points_update_ifuser($oldquestion['userid'], 'aselects'); if (isset($oldselchildid)) { if (isset($answers[$oldselchildid])) { qa_db_points_update_ifuser($answers[$oldselchildid]['userid'], 'aselecteds'); qa_report_event('a_unselect', $userid, $handle, $cookieid, array('parentid' => $oldquestion['postid'], 'postid' => $oldselchildid)); } } if (isset($selchildid)) { $answer = $answers[$selchildid]; qa_db_points_update_ifuser($answer['userid'], 'aselecteds'); if (isset($answer['notify']) && !qa_post_is_by_user($answer, $userid, $cookieid)) { require_once QA_INCLUDE_DIR . 'qa-app-emails.php'; require_once QA_INCLUDE_DIR . 'qa-app-options.php'; require_once QA_INCLUDE_DIR . 'qa-util-string.php'; require_once QA_INCLUDE_DIR . 'qa-app-format.php'; $blockwordspreg = qa_get_block_words_preg(); $sendtitle = qa_block_words_replace($oldquestion['title'], $blockwordspreg); $sendcontent = qa_viewer_text($answer['content'], $answer['format'], array('blockwordspreg' => $blockwordspreg)); qa_send_notification($answer['userid'], $answer['notify'], @$answer['handle'], qa_lang('emails/a_selected_subject'), qa_lang('emails/a_selected_body'), array('^s_handle' => isset($handle) ? $handle : qa_lang('main/anonymous'), '^q_title' => $sendtitle, '^a_content' => $sendcontent, '^url' => qa_path(qa_q_request($oldquestion['postid'], $sendtitle), null, qa_opt('site_url'), null, qa_anchor('A', $selchildid)))); } qa_report_event('a_select', $userid, $handle, $cookieid, array('parentid' => $oldquestion['postid'], 'postid' => $selchildid)); } }
function qa_priv_notification($uid, $oid, $badge_slug) { require_once QA_INCLUDE_DIR . 'qa-app-users.php'; require_once QA_INCLUDE_DIR . 'qa-app-emails.php'; if (QA_FINAL_EXTERNAL_USERS) { $publictohandle = qa_get_public_from_userids(array($uid)); $handle = @$publictohandle[$uid]; } else { $user = qa_db_single_select(qa_db_user_account_selectspec($uid, true)); $handle = @$user['handle']; } $subject = qa_opt('badge_email_subject'); $body = qa_opt('badge_email_body'); $body = preg_replace('/\\^if_post_text="([^"]*)"/', $oid ? '$1' : '', $body); // if post text $site_url = qa_opt('site_url'); $profile_url = qa_path_html('user/' . $handle, null, $site_url); if ($oid) { $post = qa_db_read_one_assoc(qa_db_query_sub('SELECT * FROM ^posts WHERE postid=#', $oid), true); if ($post['parentid']) { $parent = qa_db_read_one_assoc(qa_db_query_sub('SELECT * FROM ^posts WHERE postid=#', $post['parentid']), true); } if (isset($parent)) { $anchor = urlencode(qa_anchor($post['basetype'], $oid)); $post_title = $parent['title']; $post_url = qa_path_html(qa_q_request($parent['postid'], $parent['title']), null, qa_opt('site_url'), null, $anchor); } else { $post_title = $post['title']; $post_url = qa_path_html(qa_q_request($post['postid'], $post['title']), null, qa_opt('site_url')); } } $subs = array('^badge_name' => qa_opt('badge_' . $badge_slug . '_name'), '^post_title' => @$post_title, '^post_url' => @$post_url, '^profile_url' => $profile_url, '^site_url' => $site_url); qa_send_notification($uid, '@', $handle, $subject, $body, $subs); }
function mp_announcement_create($userid, $handle, $cookieid, $title, $content, $format, $text, $notify, $categoryid) { /* * Proceeds to create an announcement * */ require_once QA_INCLUDE_DIR . 'qa-db-post-create.php'; require_once QA_INCLUDE_DIR . 'qa-app-emails.php'; require_once QA_INCLUDE_DIR . 'mp-app-users.php'; // persist data to database $postid = qa_db_post_create('AN', null, $userid, $cookieid, qa_remote_ip_address(), $title, $content, $format, null, $notify, $categoryid); qa_user_report_action(qa_get_logged_in_userid(), null, null, null, null); // update new post with category path hierarchy qa_db_posts_calc_category_path($postid); // send notifications if ($notify && isset($postid)) { $category = mp_get_categoryinfo($categoryid); $recipients = mp_get_category_userids($categoryid); foreach ($recipients as $recipient) { // retrieve the user flags $userflags = mp_get_user_flags($recipient['userid']); // check user flags to determine whether user should be notified or not // of the new answer post if (!($userflags & QA_USER_FLAGS_NOTIFY_ANNOUNCEMENTS)) { qa_send_notification($recipient['userid'], null, null, qa_lang('emails/an_posted_subject'), qa_lang('emails/an_posted_body'), array('^an_handle' => $handle, '^category_title' => $category['title'], '^an_title' => $title, '^an_url' => qa_path('mp-announcements-page', null, qa_opt('site_url'), null, null))); } } } // report announcement create event qa_report_event('an_post', $userid, $handle, $cookieid, array('postid' => $postid, 'title' => $title, 'content' => $content, 'format' => $format, 'text' => $text, 'categoryid' => $categoryid, 'notify' => $notify)); return $postid; }
function sendEmail($event, $userid, $handle, $params) { $email = $this->getEmail($userid); if ($email == qa_opt('feedback_email')) { return; } $parent = qa_db_read_one_assoc(qa_db_query_sub('SELECT * FROM ^posts WHERE postid=#', $params['parentid']), true); if ($parent['type'] == 'A') { $parent = qa_db_read_one_assoc(qa_db_query_sub('SELECT * FROM ^posts WHERE postid=#', $parent['parentid']), true); } $url = qa_q_path($parent['postid'], $parent['title'], true, $event == 'a_post' ? 'A' : 'C', $params['postid']); $title = $parent['title']; $type = $event == 'a_post' ? 'answer' : 'comment'; $subs = array(); qa_send_notification(null, qa_opt('feedback_email'), null, qa_lang('admin_plus/posted_subject'), qa_lang('admin_plus/posted_body'), array('^post_handle' => isset($handle) ? $handle : qa_lang('main/anonymous'), '^post_type' => $type, '^post_title' => $title, '^post_content' => $params['content'], '^site_url' => qa_opt('site_url'), '^url' => $url)); }
function sendNewConfirm($userid) { require_once QA_INCLUDE_DIR . 'db/users.php'; require_once QA_INCLUDE_DIR . 'db/selects.php'; require_once QA_INCLUDE_DIR . 'app/emails.php'; $userinfo = qa_db_select_with_pending(qa_db_user_account_selectspec($userid, true)); if (!qa_send_notification($userid, $userinfo['email'], $userinfo['handle'], qa_lang('emails/confirm_subject'), qa_lang('emails/confirm_body'), array('^url' => getNewConfirmUrl($userid, $userinfo['handle'])))) { qa_fatal_error('Could not send email confirmation'); } // $userinfo=qa_db_select_with_pending(qa_db_user_account_selectspec($userid, true)); // $params = array(); // $params['fromemail'] = qa_opt('from_email'), // $params['fromname'] = qa_opt('site_title'), // $params['toemail'] = $userinfo['email']; // $params['toname'] = $userinfo['handle']; // $params['subject'] = qa_lang('emails/confirm_subject'); // $params['body'] = qa_lang('emails/confirm_body'); // qa_send_email($params); }
function process_event($event, $userid, $handle, $cookieid, $params) { if (qa_opt('expert_question_enable')) { switch ($event) { case 'q_post': if (qa_post_text('is_expert_question') == 'yes' || in_array(qa_opt('expert_question_type'), array(1, 2)) && !qa_get_logged_in_userid() || qa_opt('expert_question_type') == 3) { require_once QA_INCLUDE_DIR . 'qa-app-post-update.php'; qa_question_set_hidden($params, true, $userid, $handle, $cookieid, array(), array()); qa_db_query_sub('CREATE TABLE IF NOT EXISTS ^postmeta ( meta_id bigint(20) unsigned NOT NULL AUTO_INCREMENT, post_id bigint(20) unsigned NOT NULL, meta_key varchar(255) DEFAULT \'\', meta_value longtext, PRIMARY KEY (meta_id), KEY post_id (post_id), KEY meta_key (meta_key) ) ENGINE=MyISAM DEFAULT CHARSET=utf8'); qa_db_query_sub("INSERT INTO ^postmeta (post_id,meta_key,meta_value) VALUES (#,'is_expert_question','1')", $params['postid']); if (qa_opt('expert_question_email_experts')) { $subs = array('^post_title' => $params['title'], '^post_url' => qa_path_html(qa_q_request($params['postid'], $params['title']), null, qa_opt('site_url')), '^questions_list' => qa_path_html(qa_opt('expert_question_page_url'), null, qa_opt('site_url')), '^site_url' => qa_opt('site_url')); $experts = explode("\n", qa_opt('expert_question_users')); foreach ($experts as $expert) { if (strpos($expert, '=')) { $expert = explode('=', $expert); $catnames = explode(',', $expert[1]); $cats = qa_db_read_all_values(qa_db_query_sub('SELECT categoryid FROM ^categories WHERE title IN ($)', $catnames)); if (in_array($params['categoryid'], $cats)) { qa_send_notification($this->getuserfromhandle($expert[0]), '@', $expert[0], qa_opt('expert_question_email_subject'), qa_opt('expert_question_email_body'), $subs); } } else { qa_send_notification($this->getuserfromhandle($expert), '@', $expert, qa_opt('expert_question_email_subject'), qa_opt('expert_question_email_body'), $subs); } } } } break; default: break; } } }
function process_event($event, $userid, $handle, $cookieid, $params) { require_once QA_INCLUDE_DIR . 'qa-app-emails.php'; require_once QA_INCLUDE_DIR . 'qa-app-format.php'; require_once QA_INCLUDE_DIR . 'qa-util-string.php'; switch ($event) { case 'q_post': $followanswer = @$params['followanswer']; $sendhandle = isset($handle) ? $handle : (strlen($params['name']) ? $params['name'] : qa_lang('main/anonymous')); if (isset($followanswer['notify']) && !qa_post_is_by_user($followanswer, $userid, $cookieid)) { $blockwordspreg = qa_get_block_words_preg(); $sendtext = qa_viewer_text($followanswer['content'], $followanswer['format'], array('blockwordspreg' => $blockwordspreg)); qa_send_notification($followanswer['userid'], $followanswer['notify'], @$followanswer['handle'], qa_lang('emails/a_followed_subject'), qa_lang('emails/a_followed_body'), array('^q_handle' => $sendhandle, '^q_title' => qa_block_words_replace($params['title'], $blockwordspreg), '^a_content' => $sendtext, '^url' => qa_q_path($params['postid'], $params['title'], true))); } if (qa_opt('notify_admin_q_post')) { qa_send_notification(null, qa_opt('feedback_email'), null, qa_lang('emails/q_posted_subject'), qa_lang('emails/q_posted_body'), array('^q_handle' => $sendhandle, '^q_title' => $params['title'], '^q_content' => $params['text'], '^url' => qa_q_path($params['postid'], $params['title'], true))); } break; case 'a_post': $question = $params['parent']; if (isset($question['notify']) && !qa_post_is_by_user($question, $userid, $cookieid)) { qa_send_notification($question['userid'], $question['notify'], @$question['handle'], qa_lang('emails/q_answered_subject'), qa_lang('emails/q_answered_body'), array('^a_handle' => isset($handle) ? $handle : (strlen($params['name']) ? $params['name'] : qa_lang('main/anonymous')), '^q_title' => $question['title'], '^a_content' => qa_block_words_replace($params['text'], qa_get_block_words_preg()), '^url' => qa_q_path($question['postid'], $question['title'], true, 'A', $params['postid']))); } break; case 'c_post': $parent = $params['parent']; $question = $params['question']; $senttoemail = array(); // to ensure each user or email gets only one notification about an added comment $senttouserid = array(); switch ($parent['basetype']) { case 'Q': $subject = qa_lang('emails/q_commented_subject'); $body = qa_lang('emails/q_commented_body'); $context = $parent['title']; break; case 'A': $subject = qa_lang('emails/a_commented_subject'); $body = qa_lang('emails/a_commented_body'); $context = qa_viewer_text($parent['content'], $parent['format']); break; } $blockwordspreg = qa_get_block_words_preg(); $sendhandle = isset($handle) ? $handle : (strlen($params['name']) ? $params['name'] : qa_lang('main/anonymous')); $sendcontext = qa_block_words_replace($context, $blockwordspreg); $sendtext = qa_block_words_replace($params['text'], $blockwordspreg); $sendurl = qa_q_path($question['postid'], $question['title'], true, 'C', $params['postid']); if (isset($parent['notify']) && !qa_post_is_by_user($parent, $userid, $cookieid)) { $senduserid = $parent['userid']; $sendemail = @$parent['notify']; if (qa_email_validate($sendemail)) { $senttoemail[$sendemail] = true; } elseif (isset($senduserid)) { $senttouserid[$senduserid] = true; } qa_send_notification($senduserid, $sendemail, @$parent['handle'], $subject, $body, array('^c_handle' => $sendhandle, '^c_context' => $sendcontext, '^c_content' => $sendtext, '^url' => $sendurl)); } foreach ($params['thread'] as $comment) { if (isset($comment['notify']) && !qa_post_is_by_user($comment, $userid, $cookieid)) { $senduserid = $comment['userid']; $sendemail = @$comment['notify']; if (qa_email_validate($sendemail)) { if (@$senttoemail[$sendemail]) { continue; } $senttoemail[$sendemail] = true; } elseif (isset($senduserid)) { if (@$senttouserid[$senduserid]) { continue; } $senttouserid[$senduserid] = true; } qa_send_notification($senduserid, $sendemail, @$comment['handle'], qa_lang('emails/c_commented_subject'), qa_lang('emails/c_commented_body'), array('^c_handle' => $sendhandle, '^c_context' => $sendcontext, '^c_content' => $sendtext, '^url' => $sendurl)); } } break; case 'q_queue': case 'q_requeue': if (qa_opt('moderate_notify_admin')) { qa_send_notification(null, qa_opt('feedback_email'), null, $event == 'q_requeue' ? qa_lang('emails/remoderate_subject') : qa_lang('emails/moderate_subject'), $event == 'q_requeue' ? qa_lang('emails/remoderate_body') : 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')) { qa_send_notification(null, qa_opt('feedback_email'), null, $event == 'a_requeue' ? qa_lang('emails/remoderate_subject') : qa_lang('emails/moderate_subject'), $event == 'a_requeue' ? qa_lang('emails/remoderate_body') : 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')) { qa_send_notification(null, qa_opt('feedback_email'), null, $event == 'c_requeue' ? qa_lang('emails/remoderate_subject') : qa_lang('emails/moderate_subject'), $event == 'c_requeue' ? qa_lang('emails/remoderate_body') : 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) { qa_send_notification(null, qa_opt('feedback_email'), null, qa_lang('emails/flagged_subject'), 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 'a_select': $answer = $params['answer']; if (isset($answer['notify']) && !qa_post_is_by_user($answer, $userid, $cookieid)) { $blockwordspreg = qa_get_block_words_preg(); $sendcontent = qa_viewer_text($answer['content'], $answer['format'], array('blockwordspreg' => $blockwordspreg)); qa_send_notification($answer['userid'], $answer['notify'], @$answer['handle'], qa_lang('emails/a_selected_subject'), qa_lang('emails/a_selected_body'), array('^s_handle' => isset($handle) ? $handle : qa_lang('main/anonymous'), '^q_title' => qa_block_words_replace($params['parent']['title'], $blockwordspreg), '^a_content' => $sendcontent, '^url' => qa_q_path($params['parentid'], $params['parent']['title'], true, 'A', $params['postid']))); } break; case 'u_register': if (qa_opt('register_notify_admin')) { qa_send_notification(null, qa_opt('feedback_email'), null, qa_lang('emails/u_registered_subject'), qa_opt('moderate_users') ? qa_lang('emails/u_to_approve_body') : qa_lang('emails/u_registered_body'), array('^u_handle' => $handle, '^url' => qa_path_absolute('user/' . $handle), '^a_url' => qa_path_absolute('admin/approve'))); } break; case 'u_level': if ($params['level'] >= QA_USER_LEVEL_APPROVED && $params['oldlevel'] < QA_USER_LEVEL_APPROVED) { qa_send_notification($params['userid'], null, $params['handle'], qa_lang('emails/u_approved_subject'), qa_lang('emails/u_approved_body'), array('^url' => qa_path_absolute('user/' . $params['handle']))); } break; case 'u_wall_post': if ($userid != $params['userid']) { $blockwordspreg = qa_get_block_words_preg(); qa_send_notification($params['userid'], null, $params['handle'], qa_lang('emails/wall_post_subject'), qa_lang('emails/wall_post_body'), array('^f_handle' => isset($handle) ? $handle : qa_lang('main/anonymous'), '^post' => qa_block_words_replace($params['text'], $blockwordspreg), '^url' => qa_path_absolute('user/' . $params['handle'], null, 'wall'))); } break; } }
function qa_flag_set_tohide($post, $userid, $handle, $cookieid, $question) { require_once QA_INCLUDE_DIR . 'qa-db-votes.php'; require_once QA_INCLUDE_DIR . 'qa-app-limits.php'; qa_db_userflag_set($post['postid'], $userid, true); qa_db_post_recount_flags($post['postid']); switch ($post['basetype']) { case 'Q': $action = 'q_flag'; break; case 'A': $action = 'a_flag'; break; case 'C': $action = 'c_flag'; break; } qa_report_write_action($userid, null, $action, $post['basetype'] == 'Q' ? $post['postid'] : null, $post['basetype'] == 'A' ? $post['postid'] : null, $post['basetype'] == 'C' ? $post['postid'] : null); qa_report_event($action, $userid, $handle, $cookieid, array('postid' => $post['postid'])); $post = qa_db_select_with_pending(qa_db_full_post_selectspec(null, $post['postid'])); $flagcount = $post['flagcount']; $notifycount = $flagcount - qa_opt('flagging_notify_first'); if ($notifycount >= 0 && $notifycount % qa_opt('flagging_notify_every') == 0) { require_once QA_INCLUDE_DIR . 'qa-app-emails.php'; require_once QA_INCLUDE_DIR . 'qa-app-format.php'; $anchor = $post['basetype'] == 'Q' ? null : qa_anchor($post['basetype'], $post['postid']); qa_send_notification(null, qa_opt('feedback_email'), null, qa_lang('emails/flagged_subject'), qa_lang('emails/flagged_body'), array('^p_handle' => isset($post['handle']) ? $post['handle'] : 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(@$post['title'] . "\n\n" . qa_viewer_text($post['content'], $post['format'])), '^url' => qa_path(qa_q_request($question['postid'], $question['title']), null, qa_opt('site_url'), null, $anchor))); } if ($flagcount >= qa_opt('flagging_hide_after') && !$post['hidden']) { return true; } return false; }
if (empty($inmessage)) { $errors['message'] = qa_lang('misc/message_empty'); } if (empty($errors)) { require_once QA_INCLUDE_DIR . 'qa-db-messages.php'; require_once QA_INCLUDE_DIR . 'qa-app-emails.php'; if (qa_opt('show_message_history')) { $messageid = qa_db_message_create($loginuserid, $toaccount['userid'], $inmessage, '', false); } else { $messageid = null; } $fromhandle = qa_get_logged_in_handle(); $canreply = !(qa_get_logged_in_flags() & QA_USER_FLAGS_NO_MESSAGES); $more = strtr(qa_lang($canreply ? 'emails/private_message_reply' : 'emails/private_message_info'), array('^f_handle' => $fromhandle, '^url' => qa_path_absolute($canreply ? 'message/' . $fromhandle : 'user/' . $fromhandle))); $subs = array('^message' => $inmessage, '^f_handle' => $fromhandle, '^f_url' => qa_path_absolute('user/' . $fromhandle), '^more' => $more, '^a_url' => qa_path_absolute('account')); if (qa_send_notification($toaccount['userid'], $toaccount['email'], $toaccount['handle'], qa_lang('emails/private_message_subject'), qa_lang('emails/private_message_body'), $subs)) { $messagesent = true; } else { $pageerror = qa_lang_html('main/general_error'); } qa_report_event('u_message', $loginuserid, qa_get_logged_in_handle(), qa_cookie_get(), array('userid' => $toaccount['userid'], 'handle' => $toaccount['handle'], 'messageid' => $messageid, 'message' => $inmessage)); if ($messagesent && qa_opt('show_message_history')) { // show message as part of general history qa_redirect(qa_request(), array('state' => 'message-sent')); } } } } // Prepare content for theme $qa_content = qa_content_prepare(); $qa_content['title'] = qa_lang_html('misc/private_message_title');
function qa_complete_reset_user($userid) { if (qa_to_override(__FUNCTION__)) { $args = func_get_args(); return qa_call_override(__FUNCTION__, $args); } 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 (!qa_send_notification($userid, $userinfo['email'], $userinfo['handle'], qa_lang('emails/new_password_subject'), 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 qa_comment_create($userid, $handle, $cookieid, $content, $format, $text, $notify, $email, $question, $answer, $commentsfollows) { require_once QA_INCLUDE_DIR . 'qa-app-emails.php'; require_once QA_INCLUDE_DIR . 'qa-app-options.php'; require_once QA_INCLUDE_DIR . 'qa-app-format.php'; require_once QA_INCLUDE_DIR . 'qa-util-string.php'; $parent = isset($answer) ? $answer : $question; $postid = qa_db_post_create('C', $parent['postid'], $userid, isset($userid) ? null : $cookieid, qa_remote_ip_address(), null, $content, $format, null, qa_combine_notify_email($userid, $notify, $email), $question['categoryid']); qa_db_posts_calc_category_path($postid); if (!($question['hidden'] || @$answer['hidden'])) { // don't index comment if parent or parent of parent is hidden qa_post_index($postid, 'C', $question['postid'], null, $text, null); } qa_db_points_update_ifuser($userid, 'cposts'); qa_db_ccount_update(); // $senttoemail and $senttouserid ensure each user or email gets only one notification about an added comment, // even if they have several previous comments in the same thread and asked for notifications for the parent. // Still, if a person posted some comments as a registered user and some others anonymously, // they could get two emails about a subsequent comment. Shouldn't be much of a problem in practice. $senttoemail = array(); $senttouserid = array(); switch ($parent['basetype']) { case 'Q': $subject = qa_lang('emails/q_commented_subject'); $body = qa_lang('emails/q_commented_body'); $context = $parent['title']; break; case 'A': $subject = qa_lang('emails/a_commented_subject'); $body = qa_lang('emails/a_commented_body'); $context = qa_viewer_text($parent['content'], $parent['format']); break; } $blockwordspreg = qa_get_block_words_preg(); $sendhandle = isset($handle) ? $handle : qa_lang('main/anonymous'); $sendcontext = qa_block_words_replace($context, $blockwordspreg); $sendtext = qa_block_words_replace($text, $blockwordspreg); $sendtitle = qa_block_words_replace($question['title'], $blockwordspreg); $sendurl = qa_path(qa_q_request($question['postid'], $sendtitle), null, qa_opt('site_url'), null, qa_anchor($parent['basetype'], $parent['postid'])); if (isset($parent['notify']) && !qa_post_is_by_user($parent, $userid, $cookieid)) { $senduserid = $parent['userid']; $sendemail = @$parent['notify']; if (qa_email_validate($sendemail)) { $senttoemail[$sendemail] = true; } elseif (isset($senduserid)) { $senttouserid[$senduserid] = true; } qa_send_notification($senduserid, $sendemail, @$parent['handle'], $subject, $body, array('^c_handle' => $sendhandle, '^c_context' => $sendcontext, '^c_content' => $sendtext, '^url' => $sendurl)); } foreach ($commentsfollows as $comment) { if ($comment['basetype'] == 'C' && $comment['parentid'] == $parent['postid'] && !$comment['hidden']) { // find just those for this parent if (isset($comment['notify']) && !qa_post_is_by_user($comment, $userid, $cookieid)) { $senduserid = $comment['userid']; $sendemail = @$comment['notify']; if (qa_email_validate($sendemail)) { if (@$senttoemail[$sendemail]) { continue; } $senttoemail[$sendemail] = true; } elseif (isset($senduserid)) { if (@$senttouserid[$senduserid]) { continue; } $senttouserid[$senduserid] = true; } qa_send_notification($senduserid, $sendemail, @$comment['handle'], qa_lang('emails/c_commented_subject'), qa_lang('emails/c_commented_body'), array('^c_handle' => $sendhandle, '^c_context' => $sendcontext, '^c_content' => $sendtext, '^url' => $sendurl)); } } } qa_report_event('c_post', $userid, $handle, $cookieid, array('postid' => $postid, 'parentid' => $parent['postid'], 'parenttype' => $parent['basetype'], 'questionid' => $question['postid'], 'content' => $content, 'format' => $format, 'text' => $text, 'categoryid' => $question['categoryid'], 'notify' => $notify, 'email' => $email)); return $postid; }
function notify($uid, $notices) { require_once QA_INCLUDE_DIR . 'qa-app-users.php'; require_once QA_INCLUDE_DIR . 'qa-app-emails.php'; if (QA_FINAL_EXTERNAL_USERS) { $publictohandle = qa_get_public_from_userids(array($uid)); $handle = @$publictohandle[$uid]; } else { $user = qa_db_single_select(qa_db_user_account_selectspec($uid, true)); $handle = @$user['handle']; } $subject = qa_opt('priv_email_subject'); $body = qa_opt('priv_email_body'); $n = explode(',', $notices); if (count($n) > 1) { $body = preg_replace('/\\^single=`([^`]+)`/', '', $body); preg_match('/\\^multi=`([^`]+)`/', $body, $multi); $m = str_replace('#', count($n), $multi[1]); $body = preg_replace('/\\^multi=`([^`]+)`/', $m, $body); } else { $body = preg_replace('/\\^single=`([^`]+)`/', '$1', $body); $body = preg_replace('/\\^multi=`([^`]+)`/', '', $body); } $site_url = qa_opt('site_url'); $profile_url = qa_path_html('user/' . $handle, null, $site_url); $subs = array('^profile_url' => $profile_url, '^site_url' => $site_url); qa_send_notification($uid, '@', $handle, $subject, $body, $subs); }
$body .= sprintf("It has been %s days since you last posted a question.\n", mp_get_days_since_last_post($user['userid'], $category, 'Q')); } else { $body .= sprintf("You have not posted a question before. Posting a question will help increase your activity points while motivating the knowledge sharing process.\n\n"); } $answercount = mp_get_count_posts_by_userid_category_posttype($user['userid'], $category, 'A'); if ($answercount > 0) { $body .= sprintf("You have posted %d answers so far. ", $answercount); $body .= sprintf("It has been %d days since you last posted an answer.\n", mp_get_days_since_last_post($user['userid'], $category, 'A')); } else { $body .= sprintf("You have not posted an answer before. Posting an answer will help increase your activity and knowledge sharing points while helping your fellow students.\n\n"); } // point awareness $body .= sprintf("\nPOINTS INFORMATION\n"); $body .= sprintf("You currently have %6s activity points.\n", mp_get_activity_points_by_userid($user['userid'], $category)); $body .= sprintf("You currently have %6s knowledge contribution points.\n", mp_get_contribution_points_by_userid($user['userid'], $category)); $body .= sprintf("You currently have %6s participation points.\n", mp_get_participation_points_by_userid($user['userid'], $category)); $body .= sprintf("You currently have %6s total points.\n\n", mp_get_total_points_by_userid($user['userid'], $category)); // contribution //$body.= "Within last month, a total of X questions were asked. Of those questions, X were asked by you. Of those question N were answered.<br />"; //$body.= "Maybe you can help by answered those questions.<br />"; $body .= sprintf("You can increase your points by logging in to the system, asking questions, posting answers, or voting for either a question or an answer.\n\n"); $body .= sprintf("Sincerely,\nThe MicroProbe team"); // send the mail to the user //qa_send_notification($user['userid'], null, null, $subject, $body, null); if ($debug == FALSE) { qa_send_notification($user['userid'], null, null, $subjects[$subjectindex] . $categoryinfo['title'], $body, null); //qa_send_notification(1, null, null, $subjects[$subjectindex].$categoryinfo['title'], $body, null); } echo $debug . '<hr>' . $body; } }