function retrieve_queued_voters_flaggers() { if (count($this->qa_voters_flaggers_queue)) { require_once QA_INCLUDE_DIR . 'qa-db-votes.php'; $postids = array_keys($this->qa_voters_flaggers_queue); foreach ($postids as $postid) { $this->qa_voters_flaggers_cache[$postid] = array(); } $newvotersflaggers = qa_db_uservoteflag_posts_get($postids); if (QA_FINAL_EXTERNAL_USERS) { $keyuserids = array(); foreach ($newvotersflaggers as $voterflagger) { $keyuserids[$voterflagger['userid']] = true; } $useridhandles = qa_get_public_from_userids(array_keys($keyuserids)); foreach ($newvotersflaggers as $index => $voterflagger) { $newvotersflaggers[$index]['handle'] = @$useridhandles[$voterflagger['userid']]; } } foreach ($newvotersflaggers as $voterflagger) { $this->qa_voters_flaggers_cache[$voterflagger['postid']][] = $voterflagger; } $this->qa_voters_flaggers_queue = array(); } }
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 getHandleFromId($userid) { require_once QA_INCLUDE_DIR . 'qa-app-users.php'; if (QA_FINAL_EXTERNAL_USERS) { $publictohandle = qa_get_public_from_userids(array($userid)); $handle = @$publictohandle[$userid]; } else { $user = qa_db_single_select(qa_db_user_account_selectspec($userid, true)); $handle = @$user['handle']; } return $handle; }
function qa_send_notification($userid, $email, $handle, $subject, $body, $subs, $html = false) { if (qa_to_override(__FUNCTION__)) { $args = func_get_args(); return qa_call_override(__FUNCTION__, $args); } global $qa_notifications_suspended; if ($qa_notifications_suspended > 0) { return false; } require_once QA_INCLUDE_DIR . 'db/selects.php'; require_once QA_INCLUDE_DIR . 'util/string.php'; if (isset($userid)) { $needemail = !qa_email_validate(@$email); // take from user if invalid, e.g. @ used in practice $needhandle = empty($handle); if ($needemail || $needhandle) { if (QA_FINAL_EXTERNAL_USERS) { if ($needhandle) { $handles = qa_get_public_from_userids(array($userid)); $handle = @$handles[$userid]; } if ($needemail) { $email = qa_get_user_email($userid); } } else { $useraccount = qa_db_select_with_pending(array('columns' => array('email', 'handle'), 'source' => '^users WHERE userid = #', 'arguments' => array($userid), 'single' => true)); if ($needhandle) { $handle = @$useraccount['handle']; } if ($needemail) { $email = @$useraccount['email']; } } } } if (isset($email) && qa_email_validate($email)) { $subs['^site_title'] = qa_opt('site_title'); $subs['^handle'] = $handle; $subs['^email'] = $email; $subs['^open'] = "\n"; $subs['^close'] = "\n"; return qa_send_email(array('fromemail' => qa_opt('from_email'), 'fromname' => qa_opt('site_title'), 'toemail' => $email, 'toname' => $handle, 'subject' => strtr($subject, $subs), 'body' => (empty($handle) ? '' : qa_lang_sub('emails/to_handle_prefix', $handle)) . strtr($body, $subs), 'html' => $html)); } else { return false; } }
function qa_send_notification($userid, $email, $handle, $subject, $body, $subs) { global $qa_notifications_suspended; if ($qa_notifications_suspended > 0) { return false; } require_once QA_INCLUDE_DIR . 'qa-db-selects.php'; require_once QA_INCLUDE_DIR . 'qa-util-emailer.php'; require_once QA_INCLUDE_DIR . 'qa-util-string.php'; if (isset($userid)) { $needemail = !qa_email_validate(@$email); // take from user if invalid, e.g. @ used in practice $needhandle = empty($handle); if ($needemail || $needhandle) { if (QA_FINAL_EXTERNAL_USERS) { if ($needhandle) { $handles = qa_get_public_from_userids(array($userid)); $handle = @$handles[$userid]; } if ($needemail) { $email = qa_get_user_email($userid); } } else { $useraccount = qa_db_select_with_pending(qa_db_user_account_selectspec($userid, true)); if ($needhandle) { $handle = @$useraccount['handle']; } if ($needemail) { $email = @$useraccount['email']; } } } } if (isset($email) && qa_email_validate($email)) { $subs['^site_title'] = qa_opt('site_title'); $subs['^handle'] = $handle; $subs['^email'] = $email; $subs['^open'] = "\n"; $subs['^close'] = "\n"; return qa_send_email(array('fromemail' => qa_opt('from_email'), 'fromname' => qa_opt('site_title'), 'toemail' => $email, 'toname' => $handle, 'subject' => strtr($subject, $subs), 'body' => (empty($handle) ? '' : $handle . ",\n\n") . strtr($body, $subs), 'html' => false)); } else { return false; } }
function qa_userids_to_handles($userids) { if (QA_FINAL_EXTERNAL_USERS) { $rawuseridhandles = qa_get_public_from_userids($userids); } else { require_once QA_INCLUDE_DIR . 'db/users.php'; $rawuseridhandles = qa_db_user_get_userid_handles($userids); } $gotuseridhandles = array(); foreach ($userids as $userid) { $gotuseridhandles[$userid] = @$rawuseridhandles[$userid]; } return $gotuseridhandles; }
public function messagelist() { $offset = (int) qa_get('offset'); $offset = isset($offset) ? $offset * 15 : 0; require_once QA_INCLUDE_DIR . 'qa-db-users.php'; // Get Events $message_events = array('u_message', 'u_wall_post'); $events = "'" . implode("','", $message_events) . "'"; $userid = qa_get_logged_in_userid(); $eventslist = qa_db_read_all_assoc(qa_db_query_sub('SELECT id, UNIX_TIMESTAMP(datetime) AS datetime, userid, postid, effecteduserid, event, params, `read` FROM ^ra_userevent WHERE effecteduserid=# AND `read` = 0 AND event IN (' . $events . ') ORDER BY id DESC LIMIT 15 OFFSET #', $userid, $offset)); if (count($eventslist) > 0) { $event = array(); $userids = array(); foreach ($eventslist as $event) { $userids[$event['userid']] = $event['userid']; $userids[$event['effecteduserid']] = $event['effecteduserid']; } if (QA_FINAL_EXTERNAL_USERS) { $handles = qa_get_public_from_userids($userids); } else { $handles = qa_db_user_get_userid_handles($userids); } // get event's: time, type, parameters // get post id of questions foreach ($eventslist as $event) { $title = ''; $link = ''; $handle = $handles[$event['userid']]; $reciever_handle = $handles[$event['effecteduserid']]; $reciever_link = qa_path('user/' . $reciever_handle); $datetime = $event['datetime']; $event['date'] = qa_html(qa_time_to_string(qa_opt('db_time') - $datetime)); $event['params'] = json_decode($event['params'], true); $message = substr($event['params']['message'], 0, 30) . '..'; $id = ' data-id="' . $event['id'] . '"'; $read = $event['read'] ? ' read' : ' unread'; $url_param = array('ra_notification' => $event['id']); $user_link = qa_path_html('user/' . $handle, $url_param); switch ($event['event']) { case 'u_message': // related question to an answer echo '<div class="event-content clearfix' . $read . '"' . $id . '> <div class="avatar"><a href="' . $user_link . '">' . ra_get_avatar($handle, 32, true) . '</a></div> <div class="event-right"> <a href="' . qa_path_html('message/' . $handle, $url_param, QW_BASE_URL) . '"> <div class="head"> <strong class="user">' . $handle . '</strong> <span class="what">' . qa_lang_html('dude/sent_you_a_private_message') . '</span> <span class="message">' . $message . '</span> </div> <div class="footer"> <span class="event-icon icon-email"></span> <span class="date">' . qa_lang_sub('dude/x_ago', $event['date']) . '</span> </div> </a> </div> </div>'; break; case 'u_wall_post': // user's question had been answered $url = qa_path_html('user/' . $reciever_handle . '/wall', $url_param, QW_BASE_URL); echo '<div class="event-content clearfix' . $read . '"' . $id . '> <div class="avatar"><a href="' . $user_link . '">' . ra_get_avatar($handle, 32, true) . '</a></div> <div class="event-right"> <a href="' . $url . '"> <div class="head"> <strong class="user">' . $handle . '</strong> <span class="what">' . qa_lang_html('dude/posted_on_your_wall') . '</span> <span class="message">' . $message . '</span> </div> <div class="footer"> <span class="event-icon icon-pin"></span> <span class="date">' . qa_lang_sub('dude/x_ago', $event['date']) . '</span> </div> </a> </div> </div>'; break; } } } else { echo '<div class="no-more-activity">' . qa_lang_html('dude/no_more_messages') . '</div>'; } die; }
function qa_post_userid_to_handle($userid) { if (isset($userid)) { if (QA_FINAL_EXTERNAL_USERS) { require_once QA_INCLUDE_DIR . 'qa-app-users.php'; $handles = qa_get_public_from_userids(array($userid)); return @$handles[$userid]; } else { $user = qa_db_single_select(qa_db_user_account_selectspec($userid, true)); if (!is_array($user)) { qa_fatal_error('User ID could not be found: ' . $userid); } return $user['handle']; } } return null; }
function qa_get_users_html($userids, $should_include_link, $relative_url_prefix) { $useridtopublic = qa_get_public_from_userids($userids); $usershtml = array(); foreach ($userids as $userid) { $publicusername = $useridtopublic[$userid]; $usershtml[$userid] = htmlspecialchars($publicusername); if ($should_include_link) { $usershtml[$userid] = '<A HREF="' . htmlspecialchars($relative_url_prefix . 'user/' . urlencode($publicusername)) . '" CLASS="qa-user-link">' . $usershtml[$userid] . '</A>'; } } return $usershtml; }
function qa_get_users_html($userids, $should_include_link, $relative_url_prefix) { // By default, show the public username linked to the Q2A profile page for each user $useridtopublic = qa_get_public_from_userids($userids); $usershtml = array(); foreach ($userids as $userid) { $publicusername = $useridtopublic[$userid]; $usershtml[$userid] = htmlspecialchars($publicusername); if ($should_include_link) { $usershtml[$userid] = '<a href="' . htmlspecialchars($relative_url_prefix . 'user/' . urlencode($publicusername)) . '" class="qa-user-link">' . $usershtml[$userid] . '</a>'; } } return $usershtml; /* Example 1 - suitable if: * Your Q2A site: http://www.mysite.com/qa/ * Your user pages: http://www.mysite.com/user/[username] $useridtopublic=qa_get_public_from_userids($userids); foreach ($userids as $userid) { $publicusername=$useridtopublic[$userid]; $usershtml[$userid]=htmlspecialchars($publicusername); if ($should_include_link) $usershtml[$userid]='<a href="'.htmlspecialchars($relative_url_prefix.'../user/'.urlencode($publicusername)). '" class="qa-user-link">'.$usershtml[$userid].'</a>'; } return $usershtml; */ /* Example 2 - suitable if: * Your Q2A site: http://qa.mysite.com/ * Your user pages: http://www.mysite.com/[username]/ * User photos (16x16): http://www.mysite.com/[username]/photo-small.jpeg $useridtopublic=qa_get_public_from_userids($userids); foreach ($userids as $userid) { $publicusername=$useridtopublic[$userid]; $usershtml[$userid]='<img src="http://www.mysite.com/'.htmlspecialchars(urlencode($publicusername)).'/photo-small.jpeg" '. 'style="width:16px; height:16px; border:0; margin-right:4px;">'.htmlspecialchars($publicusername); if ($should_include_link) $usershtml[$userid]='<a href="http://www.mysite.com/'.htmlspecialchars(urlencode($publicusername)). '/" class="qa-user-link">'.$usershtml[$userid].'</a>'; } return $usershtml; */ }
function process_request($request) { $qa_content = qa_content_prepare(); $qa_content['title'] = qa_lang('badges/badge_list_title'); $badges = qa_get_badge_list(); $totalawarded = 0; $qa_content['custom'] = '<em>' . qa_lang('badges/badge_list_pre') . '</em><br />'; $qa_content['custom2'] = '<table cellspacing="20">'; $c = 2; $result = qa_db_read_all_assoc(qa_db_query_sub('SELECT user_id,badge_slug FROM ^userbadges')); $count = array(); foreach ($result as $r) { if (qa_opt('badge_' . $r['badge_slug'] . '_enabled') == '0') { continue; } if (isset($count[$r['badge_slug']][$r['user_id']])) { $count[$r['badge_slug']][$r['user_id']]++; } else { $count[$r['badge_slug']][$r['user_id']] = 1; } $totalawarded++; if (isset($count[$r['badge_slug']]['count'])) { $count[$r['badge_slug']]['count']++; } else { $count[$r['badge_slug']]['count'] = 1; } } foreach ($badges as $slug => $info) { if (qa_opt('badge_' . $slug . '_enabled') == '0') { continue; } $badge_name = qa_badge_name($slug); if (!qa_opt('badge_' . $slug . '_name')) { qa_opt('badge_' . $slug . '_name', $badge_name); } $name = qa_opt('badge_' . $slug . '_name'); $var = qa_opt('badge_' . $slug . '_var'); $desc = qa_badge_desc_replace($slug, $var, false); $type = qa_get_badge_type($info['type']); $types = $type['slug']; $typen = $type['name']; $qa_content['custom' . ++$c] = '<tr><td class="badge-entry"><div class="badge-entry-badge"><span class="badge-' . $types . '" title="' . $typen . '">' . $name . '</span> <span class="badge-entry-desc">' . $desc . '</span>' . (isset($count[$slug]) ? ' <span title="' . $count[$slug]['count'] . ' ' . qa_lang('badges/awarded') . '" class="badge-count-link" onclick="jQuery(\'#badge-users-' . $slug . '\').slideToggle()">x' . $count[$slug]['count'] . '</span>' : '') . '</div>'; // source users if (qa_opt('badge_show_source_users') && isset($count[$slug])) { $users = array(); require_once QA_INCLUDE_DIR . 'qa-app-users.php'; $qa_content['custom' . $c] .= '<div style="display:none" id="badge-users-' . $slug . '" class="badge-users">'; foreach ($count[$slug] as $uid => $ucount) { if ($uid == 'count') { continue; } if (QA_FINAL_EXTERNAL_USERS) { $handles = qa_get_public_from_userids(array($uid)); $handle = @$handles[$uid]; } else { $useraccount = qa_db_select_with_pending(qa_db_user_account_selectspec($uid, true)); $handle = @$useraccount['handle']; } if (!$handle) { continue; } $users[] = '<a href="' . qa_path_html('user/' . $handle) . '">' . $handle . ($ucount > 1 ? ' x' . $ucount : '') . '</a>'; } $qa_content['custom' . $c] .= implode('<br/>', $users) . '</div>'; } $qa_content['custom' . $c] .= '</td></tr>'; } $qa_content['custom' . ++$c] = '<tr><td class="badge-entry"><span class="total-badges">' . count($badges) . ' ' . qa_lang('badges/badges_total') . '</span>' . ($totalawarded > 0 ? ', <span class="total-badge-count">' . $totalawarded . ' ' . qa_lang('badges/awarded_total') . '</span>' : '') . '</td></tr></table>'; if (isset($qa_content['navigation']['main']['custom-2'])) { $qa_content['navigation']['main']['custom-2']['selected'] = true; } return $qa_content; }
function qa_get_users_html($userids, $should_include_link, $relative_url_prefix) { $useridtopublic = qa_get_public_from_userids($userids); $usershtml = array(); foreach ($userids as $userid) { $publicusername = $useridtopublic[$userid]; $usershtml[$userid] = htmlspecialchars($publicusername); if ($should_include_link) { $usershtml[$userid] = '<a href="' . qa_path_html('user/' . $publicusername) . '" class="qa-user-link">' . $usershtml[$userid] . '</a>'; } } return $usershtml; }
function qw_activitylist($limit) { $offset = (int) qa_get('start'); // get points for each activity require_once QA_INCLUDE_DIR . 'qa-db-points.php'; require_once QA_INCLUDE_DIR . 'qa-db-users.php'; $optionnames = qa_db_points_option_names(); $options = qa_get_options($optionnames); $multi = (int) $options['points_multiple']; $upvote = ''; $downvote = ''; if (@$options['points_per_q_voted_up']) { $upvote = '_up'; $downvote = '_down'; } $event_point['in_q_vote_up'] = (int) $options['points_per_q_voted' . $upvote] * $multi; $event_point['in_q_vote_down'] = (int) $options['points_per_q_voted' . $downvote] * $multi * -1; $event_point['in_q_unvote_up'] = (int) $options['points_per_q_voted' . $upvote] * $multi * -1; $event_point['in_q_unvote_down'] = (int) $options['points_per_q_voted' . $downvote] * $multi; $event_point['a_vote_up'] = (int) $options['points_per_a_voted' . $upvote] * $multi; $event_point['in_a_vote_down'] = (int) $options['points_per_a_voted' . $downvote] * $multi * -1; $event_point['in_a_unvote_up'] = (int) $options['points_per_a_voted' . $upvote] * $multi * -1; $event_point['in_a_unvote_down'] = (int) $options['points_per_a_voted' . $downvote] * $multi; $event_point['in_a_select'] = (int) $options['points_a_selected'] * $multi; $event_point['in_a_unselect'] = (int) $options['points_a_selected'] * $multi * -1; $event_point['q_post'] = (int) $options['points_post_q'] * $multi; $event_point['a_post'] = (int) $options['points_post_a'] * $multi; $event_point['a_select'] = (int) $options['points_select_a'] * $multi; $event_point['q_vote_up'] = (int) $options['points_vote_up_q'] * $multi; $event_point['q_vote_down'] = (int) $options['points_vote_down_q'] * $multi; $event_point['a_vote_up'] = (int) $options['points_vote_up_a'] * $multi; $event_point['a_vote_down'] = (int) $options['points_vote_down_a'] * $multi; // Get Events $userid = qa_get_logged_in_userid(); $eventslist = qa_db_read_all_assoc(qa_db_query_sub('SELECT id, UNIX_TIMESTAMP(datetime) AS datetime, userid, postid, effecteduserid, event, params, `read` FROM ^ra_userevent WHERE effecteduserid=# AND event NOT IN ("u_wall_post", "u_message") ORDER BY datetime DESC LIMIT # OFFSET #', $userid, $limit, $offset)); if (count($eventslist) > 0) { $event = array(); $output = ''; $i = 0; // $userids = array(); foreach ($eventslist as $event) { $userids[$event['userid']] = $event['userid']; $userids[$event['effecteduserid']] = $event['effecteduserid']; } if (QA_FINAL_EXTERNAL_USERS) { $handles = qa_get_public_from_userids($userids); } else { $handles = qa_db_user_get_userid_handles($userids); } // get event's: time, type, parameters // get post id of questions foreach ($eventslist as $event) { $title = ''; $link = ''; $vote_status = ''; $handle = isset($handles[$event['userid']]) ? $handles[$event['userid']] : qa_lang('main/anonymous'); $datetime = $event['datetime']; $event['date'] = qa_html(qa_time_to_string(qa_opt('db_time') - $datetime)); $event['params'] = json_decode($event['params'], true); $id = ' data-id="' . $event['id'] . '"'; $read = $event['read'] ? ' read' : ' unread'; $mark_as_read = !$event['read'] ? '<span class="icon icon-tick"></span>' : ''; $url_param = array('ra_notification' => $event['id']); $user_link = qa_path_html('user/' . $handle, $url_param, QW_BASE_URL); switch ($event['event']) { case 'related': // related question to an answer $url = qa_path_html(qa_q_request($event['postid'], $event['params']['title']), $url_param, QW_BASE_URL, null, null); echo '<div class="event-content clearfix' . $read . '' . $read . '"' . $id . '> <div class="avatar"><a href="' . $user_link . '">' . qw_get_avatar($handle, 32, true) . '</a></div> <div class="event-right"> <a href="' . $url . '"> <div class="head"> <strong class="user">' . $handle . '</strong> <span class="what">' . qa_lang_html('dude/asked_question_related_to_your') . '</span> <strong class="where">' . qa_lang_html('dude/answer') . '</strong> </div> <div class="footer"> <span class="event-icon icon-link"></span> <span class="date">' . qa_lang_sub('dude/x_ago', $event['date']) . '</span> </div> </a> </div> </div>'; break; case 'a_post': // user's question had been answered $anchor = qa_anchor('A', $event['postid']); $url = qa_path_html(qa_q_request($event['params']['qid'], $event['params']['qtitle']), $url_param, QW_BASE_URL, null, $anchor); $title = qw_truncate($event['params']['qtitle'], 60); echo '<div class="event-content clearfix' . $read . '"' . $id . '> <div class="avatar"><a href="' . $user_link . '">' . qw_get_avatar($handle, 32, true) . '</a></div> <div class="event-right"> <a href="' . $url . '"> <div class="head"> <strong class="user">' . $handle . '</strong> <span class="what">' . qa_lang_html('dude/answered_your') . '</span> <strong class="where">' . qa_lang_html('dude/question') . '</strong> </div> <div class="footer"> <span class="event-icon icon-answer"></span> <span class="date">' . qa_lang_sub('dude/x_ago', $event['date']) . '</span> </div> </a> </div> </div>'; break; case 'c_post': // user's question had been commented $anchor = qa_anchor('C', $event['postid']); $url = qa_path_html(qa_q_request($event['params']['qid'], $event['params']['qtitle']), $url_param, QW_BASE_URL, null, $anchor); if ($event['params']['parenttype'] == 'Q') { $type = qa_lang_html('dude/question'); } elseif ($event['params']['parenttype'] == 'A') { $type = qa_lang_html('dude/answer'); } else { $type = qa_lang_html('dude/comment'); } if (isset($event['params']['parent_uid']) && $event['params']['parent_uid'] != $userid) { $what = qa_lang_html('dude/followup_comment'); $type = qa_lang_html('dude/comment'); } else { $what = qa_lang_html('dude/replied_to_your'); } echo '<div class="event-content clearfix' . $read . '"' . $id . '> <div class="avatar"><a href="' . $user_link . '">' . qw_get_avatar($handle, 32, true) . '</a></div> <div class="event-right"> <a href="' . $url . '"> <div class="head"> <strong class="user">' . $handle . '</strong> <span class="what">' . $what . '</span> <strong class="where">' . $type . '</strong> </div> <div class="footer"> <span class="event-icon icon-arrow-back"></span> <span class="date">' . qa_lang_sub('dude/x_ago', $event['date']) . '</span> </div> </a> </div> </div>'; break; case 'q_reshow': $url = qa_path_html(qa_q_request($event['params']['qid'], $event['params']['qtitle']), $url_param, QW_BASE_URL, null, null); echo '<div class="event-content clearfix' . $read . '"' . $id . '> <div class="avatar"><a class="icon icon-eye" href="' . $url . '"></a></div> <div class="event-right"> <a href="' . $url . '"> <div class="head"> <span>' . qa_lang_html('dude/your') . '</span> <strong>' . qa_lang_html('dude/question') . '</strong> <span class="what">' . qa_lang_html('dude/is_visible') . '</span> </div> <div class="footer"> <span class="date">' . qa_lang_sub('dude/x_ago', $event['date']) . '</span> </div> </a> </div> </div>'; break; case 'a_reshow': // user's question had been answered $anchor = qa_anchor('A', $event['postid']); $url = qa_path_html(qa_q_request($event['params']['qid'], $event['params']['qtitle']), $url_param, QW_BASE_URL, null, $anchor); echo '<div class="event-content clearfix' . $read . '"' . $id . '> <div class="avatar"><a class="icon icon-eye" href="' . $url . '"></a></div> <div class="event-right"> <a href="' . $url . '"> <div class="head"> <span>' . qa_lang_html('dude/your') . '</span> <strong>' . qa_lang_html('dude/answer') . '</strong> <span class="what">' . qa_lang_html('dude/is_visible') . '</span> </div> <div class="footer"> <span class="date">' . qa_lang_sub('dude/x_ago', $event['date']) . '</span> </div> </a> </div> </div>'; break; case 'c_reshow': // user's question had been answered $anchor = qa_anchor('C', $event['postid']); $url = qa_path_html(qa_q_request($event['params']['qid'], $event['params']['qtitle']), $url_param, QW_BASE_URL, null, $anchor); echo '<div class="event-content clearfix' . $read . '"' . $id . '> <div class="avatar"><a class="icon icon-eye" href="' . $url . '"></a></div> <div class="event-right"> <a href="' . $url . '"> <div class="head"> <span>' . qa_lang_html('dude/your') . '</span> <strong>' . qa_lang_html('dude/comment') . '</strong> <span class="what">' . qa_lang_html('dude/is_visible') . '</span> </div> <div class="footer"> <span class="date">' . qa_lang_sub('dude/x_ago', $event['date']) . '</span> </div> </a> </div> </div>'; break; case 'a_select': $anchor = qa_anchor('A', $event['postid']); $url = qa_path_html(qa_q_request($event['params']['qid'], $event['params']['qtitle']), $url_param, QW_BASE_URL, null, $anchor); echo '<div class="event-content clearfix' . $read . '"' . $id . '> <div class="avatar"><a href="' . $user_link . '">' . qw_get_avatar($handle, 32, true) . '</a></div> <div class="event-right"> <a href="' . $url . '"> <div class="head"> <strong class="user">' . $handle . '</strong> <span class="what">' . qa_lang_html('dude/selected_as_best') . '</span> </div> <div class="footer"> <span class="event-icon icon-award"></span> <span class="points">' . qa_lang_sub('dude/you_have_earned_x_points', $event_point['a_post']) . '</span> <span class="date">' . qa_lang_sub('dude/x_ago', $event['date']) . '</span> </div> </a> </div> </div>'; break; case 'q_vote_up': $url = qa_path_html(qa_q_request($event['params']['qid'], $event['params']['qtitle']), $url_param, QW_BASE_URL, null); $title = qw_truncate($event['params']['qtitle'], 60); echo '<div class="event-content clearfix' . $read . '"' . $id . '> <div class="avatar"><a href="' . $user_link . '">' . qw_get_avatar($handle, 32, true) . '</a></div> <div class="event-right"> <a href="' . $url . '"> <div class="head"> <strong class="user">' . $handle . '</strong> <span class="what">' . qa_lang_html('dude/upvoted_on_your') . '</span> <strong class="where">' . qa_lang_html('dude/question') . '</strong> </div> <div class="footer"> <span class="event-icon icon-thumb-up"></span> <span class="points">' . qa_lang_sub('dude/you_have_earned_x_points', $event_point['a_vote_up']) . '</span> <span class="date">' . qa_lang_sub('dude/x_ago', $event['date']) . '</span> </div> </a> </div> </div>'; break; case 'a_vote_up': $anchor = qa_anchor('A', $event['postid']); $url = qa_path_html(qa_q_request($event['params']['qid'], $event['params']['qtitle']), $url_param, QW_BASE_URL, null, $anchor); echo '<div class="event-content clearfix' . $read . '"' . $id . '> <div class="avatar"><a href="' . $user_link . '">' . qw_get_avatar($handle, 32, true) . '</a></div> <div class="event-right"> <a href="' . $url . '"> <div class="head"> <strong class="user">' . $handle . '</strong> <span class="what">' . qa_lang_html('dude/upvoted_on_your') . '</span> <strong class="where">' . qa_lang_html('dude/answer') . '</strong> </div> <div class="footer"> <span class="event-icon icon-thumb-up"></span> <span class="points">' . qa_lang_sub('dude/you_have_earned_x_points', $event_point['a_vote_up']) . '</span> <span class="date">' . qa_lang_sub('dude/x_ago', $event['date']) . '</span> </div> </a> </div> </div>'; break; case 'q_approve': $url = qa_path_html(qa_q_request($event['params']['qid'], $event['params']['qtitle']), $url_param, QW_BASE_URL, null); echo '<div class="event-content clearfix' . $read . '"' . $id . '> <div class="avatar"><a class="icon icon-input-checked" href="' . $url . '"></a></div> <div class="event-right"> <a href="' . $url . '"> <div class="head"> <strong class="user">' . $handle . '</strong> <span class="what">' . qa_lang_html('dude/approved_your') . '</span> <strong class="where">' . qa_lang_html('dude/question') . '</strong> </div> <div class="footer"> <span class="date">' . qa_lang_sub('dude/x_ago', $event['date']) . '</span> </div> </a> </div> </div>'; break; case 'a_approve': $anchor = qa_anchor('A', $event['postid']); $url = qa_path_html(qa_q_request($event['params']['qid'], $event['params']['qtitle']), $url_param, QW_BASE_URL, null, $anchor); echo '<div class="event-content clearfix' . $read . '"' . $id . '> <div class="avatar"><a class="icon icon-input-checked" href="' . $url . '"></a></div> <div class="event-right"> <a href="' . $url . '"> <div class="head"> <strong class="user">' . $handle . '</strong> <span class="what">' . qa_lang_html('dude/approved_your') . '</span> <strong class="where">' . qa_lang_html('dude/answer') . '</strong> </div> <div class="footer"> <span class="date">' . qa_lang_sub('dude/x_ago', $event['date']) . '</span> </div> </a> </div> </div>'; break; case 'u_favorite': echo '<div class="event-content clearfix' . $read . '"' . $id . '> <div class="avatar"><a href="' . $user_link . '">' . qw_get_avatar($handle, 32, true) . '</a></div> <div class="event-right"> <a href="' . $user_link . '"> <div class="head"> <strong class="user">' . $handle . '</strong> <span class="what">' . qa_lang_html('dude/added_you_to') . '</span> <strong class="where">' . qa_lang_html('dude/favourite') . '</strong> </div> <div class="footer"> <span class="event-icon icon-heart"></span> <span class="date">' . qa_lang_sub('dude/x_ago', $event['date']) . '</span> </div> </a> </div> </div>'; break; case 'q_favorite': echo '<div class="event-content clearfix' . $read . '"' . $id . '> <div class="avatar"><a href="' . $user_link . '">' . qw_get_avatar($handle, 32, true) . '</a></div> <div class="event-right"> <a href="' . $user_link . '"> <div class="head"> <strong class="user">' . $handle . '</strong> <span class="what">' . qa_lang_html('dude/added_your_question_to') . '</span> <strong class="where">' . qa_lang_html('dude/favourite') . '</strong> </div> <div class="footer"> <span class="event-icon icon-heart"></span> <span class="date">' . qa_lang_sub('dude/x_ago', $event['date']) . '</span> </div> </a> </div> </div>'; break; case 'q_vote_down': $url = qa_path_html(qa_q_request($event['params']['qid'], $event['params']['qtitle']), $url_param, QW_BASE_URL, null); echo '<div class="event-content clearfix' . $read . '"' . $id . '> <div class="avatar"><a class="icon icon-thumb-down" href="' . $url . '"></a></div> <div class="event-right"> <a href="' . $url . '"> <div class="head"> <span class="what">' . qa_lang_html('dude/you_have_received_down_vote') . '</span> <strong class="where">' . qa_lang_html('dude/question') . '</strong> </div> <div class="footer"> <span class="points">' . qa_lang_sub('dude/you_have_lost_x_points', $event_point['q_vote_down']) . '</span> <span class="date">' . qa_lang_sub('dude/x_ago', $event['date']) . '</span> </div> </a> </div> </div>'; break; case 'c_approve': $anchor = qa_anchor('C', $event['postid']); $url = qa_path_html(qa_q_request($event['params']['qid'], $event['params']['qtitle']), $url_param, QW_BASE_URL, null, $anchor); echo '<div class="event-content clearfix' . $read . '"' . $id . '> <div class="avatar"><a class="icon icon-input-checked" href="' . $url . '"></a></div> <div class="event-right"> <a href="' . $url . '"> <div class="head"> <strong class="user">' . $handle . '</strong> <span class="what">' . qa_lang_html('dude/approved_your') . '</span> <strong class="where">' . qa_lang_html('dude/comment') . '</strong> </div> <div class="footer"> <span class="date">' . qa_lang_sub('dude/x_ago', $event['date']) . '</span> </div> </a> </div> </div>'; break; case 'q_reject': $url = qa_path_html(qa_q_request($event['params']['qid'], $event['params']['qtitle']), $url_param, QW_BASE_URL, null); echo '<div class="event-content clearfix' . $read . '"' . $id . '> <div class="avatar"><a class="icon icon-times" href="' . $url . '"></a></div> <div class="event-right"> <a href="' . $url . '"> <div class="head"> <strong class="user">' . $handle . '</strong> <span class="what">' . qa_lang_html('dude/your_question_is_rejected') . '</span> </div> <div class="footer"> <span class="date">' . qa_lang_sub('dude/x_ago', $event['date']) . '</span> </div> </a> </div> </div>'; break; case 'a_reject': $anchor = qa_anchor('A', $event['postid']); $url = qa_path_html(qa_q_request($event['params']['qid'], $event['params']['qtitle']), $url_param, QW_BASE_URL, null, $anchor); echo '<div class="event-content clearfix' . $read . '"' . $id . '> <div class="avatar"><a class="icon icon-times" href="' . $url . '"></a></div> <div class="event-right"> <a href="' . $url . '"> <div class="head"> <strong class="user">' . $handle . '</strong> <span class="what">' . qa_lang_html('dude/your_answer_is_rejected') . '</span> </div> <div class="footer"> <span class="date">' . qa_lang_sub('dude/x_ago', $event['date']) . '</span> </div> </a> </div> </div>'; break; case 'c_reject': $anchor = qa_anchor('C', $event['postid']); $url = qa_path_html(qa_q_request($event['params']['qid'], $event['params']['qtitle']), $url_param, QW_BASE_URL, null, $anchor); echo '<div class="event-content clearfix' . $read . '"' . $id . '> <div class="avatar"><a class="icon icon-times" href="' . $url . '"></a></div> <div class="event-right"> <a href="' . $url . '"> <div class="head"> <strong class="user">' . $handle . '</strong> <span class="what">' . qa_lang_html('dude/your_comment_is_rejected') . '</span> </div> <div class="footer"> <span class="date">' . qa_lang_sub('dude/x_ago', $event['date']) . '</span> </div> </a> </div> </div>'; break; case 'u_level': $url = qa_path_absolute('user/' . $event['params']['handle']); $old_level = $event['params']['oldlevel']; $new_level = $event['params']['level']; if ($new_level < $old_level) { break; } $approved_only = ""; if ($new_level == QA_USER_LEVEL_APPROVED && $old_level < QA_USER_LEVEL_APPROVED) { $approved_only = true; } else { $approved_only = false; } if ($approved_only === false) { $new_designation = qw_get_user_desg($new_level); } $content = strtr(qa_lang($approved_only ? 'notification/u_level_approved_notf' : 'notification/u_level_improved_notf'), array('^new_designation' => @$new_designation)); echo '<div class="event-content clearfix' . $read . '"' . $id . '> <div class="avatar"><a class="icon icon-user" href="' . $url . '"></a></div> <div class="event-right"> <a href="' . $url . '"> <div class="head"> <strong class="user">' . $handle . '</strong> <span class="what">' . @$content . '</span> </div> <div class="footer"> <span class="points">' . qa_lang_sub('dude/you_have_earned_x_points', $event_point['a_vote_up']) . '</span> <span class="date">' . qa_lang_sub('dude/x_ago', $event['date']) . '</span> </div> </a> </div> </div>'; break; } } //code for pagination } else { echo '<div class="no-more-activity">' . qa_lang_html('dude/no_more_activity') . '</div>'; } }
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); }
function getHandleFromID($uid) { require_once QA_INCLUDE_DIR . 'qa-app-users.php'; if (QA_FINAL_EXTERNAL_USERS) { $publictouserid = qa_get_public_from_userids(array($uid)); $handle = @$publictouserid[$uid]; } else { $handle = qa_db_read_one_value(qa_db_query_sub('SELECT handle FROM ^users WHERE userid = #', $uid), true); } if (!isset($handle)) { return; } return $handle; }