function cs_user_post_list($handle, $type, $limit) { $userid = qa_handle_to_userid($handle); require_once QA_INCLUDE_DIR . 'qa-app-posts.php'; $post = qa_db_read_all_assoc(qa_db_query_sub('SELECT * FROM ^posts INNER JOIN ^users ON ^posts.userid=^users.userid WHERE ^posts.type=$ and ^posts.userid=# ORDER BY ^posts.created DESC LIMIT #', $type, $userid, $limit)); $output = '<ul class="question-list users-post-widget post-type-' . $type . '">'; if (count($post) > 0) { foreach ($post as $p) { if ($type == 'Q') { $what = qa_lang_html('cleanstrap/asked'); } elseif ($type == 'A') { $what = qa_lang_html('cleanstrap/answered'); } elseif ('C') { $what = qa_lang_html('cleanstrap/commented'); } $handle = $p['handle']; $output .= '<li id="q-list-' . $p['postid'] . '" class="question-item">'; if ($type == 'Q') { $output .= '<div class="big-ans-count pull-left">' . $p['acount'] . '<span>' . qa_lang_html('cleanstrap/ans') . '</span></div>'; } elseif ($type == 'A') { $output .= '<div class="big-ans-count pull-left icon-answer"></div>'; } elseif ($type == 'C') { $output .= '<div class="big-ans-count pull-left icon-comment icon-comments"></div>'; } $output .= '<div class="list-right">'; $timeCode = qa_when_to_html(strtotime($p['created']), 7); $when = @$timeCode['prefix'] . @$timeCode['data'] . @$timeCode['suffix']; if ($type == 'Q') { $output .= '<h5><a href="' . qa_q_path_html($p['postid'], $p['title']) . '" title="' . $p['title'] . '">' . qa_html($p['title']) . '</a></h5>'; } elseif ($type == 'A') { $output .= '<h5><a href="' . cs_post_link($p['parentid']) . '#a' . $p['postid'] . '">' . cs_truncate(strip_tags($p['content']), 300) . '</a></h5>'; } else { $output .= '<h5><a href="' . cs_post_link($p['parentid']) . '#c' . $p['postid'] . '">' . cs_truncate(strip_tags($p['content']), 300) . '</a></h5>'; } $output .= '<div class="list-date"><span class="icon-clock">' . $when . '</span>'; $output .= '<span class="icon-thumbs-up2">' . qa_lang_sub('cleanstrap/x_votes', $p['netvotes']) . '</span></div>'; $output .= '</div>'; $output .= '</li>'; } } else { if ($type == 'Q') { $what = 'questions'; } elseif ($type == 'A') { $what = 'answers'; } elseif ('C') { $what = 'comments'; } $output .= '<li class="no-post-found">' . qa_lang('cleanstrap/no_' . $what) . ' </li>'; } $output .= '</ul>'; echo $output; }
function get_user_activity($handle, $limit = 10) { $userid = qa_handle_to_userid($handle); require_once QA_INCLUDE_DIR . 'qa-db-selects.php'; require_once QA_INCLUDE_DIR . 'qa-app-format.php'; $identifier = QA_FINAL_EXTERNAL_USERS ? $userid : $handle; list($useraccount, $questions, $answerqs, $commentqs, $editqs) = qa_db_select_with_pending(QA_FINAL_EXTERNAL_USERS ? null : qa_db_user_account_selectspec($handle, false), qa_db_user_recent_qs_selectspec($userid, $identifier, $limit), qa_db_user_recent_a_qs_selectspec($userid, $identifier), qa_db_user_recent_c_qs_selectspec($userid, $identifier), qa_db_user_recent_edit_qs_selectspec($userid, $identifier)); if (!QA_FINAL_EXTERNAL_USERS && !is_array($useraccount)) { // check the user exists return include QA_INCLUDE_DIR . 'qa-page-not-found.php'; } // Get information on user references $questions = qa_any_sort_and_dedupe(array_merge($questions, $answerqs, $commentqs, $editqs)); $questions = array_slice($questions, 0, $limit); $usershtml = qa_userids_handles_html(qa_any_get_userids_handles($questions), false); $htmldefaults = qa_post_html_defaults('Q'); $htmldefaults['whoview'] = false; $htmldefaults['voteview'] = false; $htmldefaults['avatarsize'] = 0; foreach ($questions as $question) { $qa_content[] = qa_any_to_q_html_fields($question, $userid, qa_cookie_get(), $usershtml, null, array('voteview' => false) + qa_post_html_options($question, $htmldefaults)); } $output = '<div class="user-activities">'; $output .= '<ul>'; if (isset($qa_content)) { foreach ($qa_content as $qs) { $icon = 'icon-time undefined'; $output .= '<li class="activity-item">'; $output .= '<div class="list-right">'; $output .= '<div class="type pull-left ' . $icon . '"></div>'; $output .= '<div class="what"><a class="what-task" href="' . @$qs['url'] . '">' . $qs['what'] . '</a>'; $output .= '<a href="' . $qs['url'] . '">' . $qs['title'] . '</a> </div>'; $output .= '<strong class="when">' . implode(' ', $qs['when']) . '</strong>'; $output .= '</div>'; $output .= '</li>'; } } else { $output .= '<li>' . qa_lang('cleanstrap/no_activity_yet') . '</li>'; } $output .= '</ul>'; $output .= '</div>'; return $output; }
function cs_new_users($limit, $size, $widget_opt) { $output = '<ul class="users-list clearfix">'; if (defined('QA_FINAL_WORDPRESS_INTEGRATE_PATH')) { global $wpdb; $users = $wpdb->get_results("SELECT ID from {$wpdb->users} order by ID DESC LIMIT {$limit}"); require_once QA_INCLUDE_DIR . 'qa-app-posts.php'; foreach ($users as $u) { $handle = qa_post_userid_to_handle($u->ID); $output .= '<li class="user">'; $output .= '<div class="avatar" data-handle="' . $handle . '" data-id="' . qa_handle_to_userid($handle) . '"><img src="' . cs_get_avatar($u['handle'], $size, false) . '" /></div>'; $output .= '</li>'; } } else { if (qa_opt('avatar_allow_upload') && @$widget_opt['cs_nu_with_avatar']) { $users = qa_db_read_all_assoc(qa_db_query_sub("SELECT * FROM ^users WHERE avatarblobid IS NOT NULL ORDER BY created DESC LIMIT #", $limit)); } elseif (qa_opt('avatar_allow_gravatar') || qa_opt('avatar_default_show') && strlen(qa_opt('avatar_default_blobid'))) { $users = qa_db_read_all_assoc(qa_db_query_sub("SELECT * FROM ^users ORDER BY created DESC LIMIT #", $limit)); } //refresh every 10 minutes foreach ($users as $u) { if (isset($u['handle'])) { $handle = $u['handle']; $avatar = cs_get_avatar($handle, $size, false); if (isset($u['useid'])) { $id = $u['useid']; } else { $id = qa_handle_to_userid($handle); } $output .= '<li class="user">'; if (!empty($avatar)) { $output .= '<a href="' . qa_path_html('user/' . $handle) . '"><div class="avatar" data-handle="' . $handle . '" data-id="' . $id . '"><img src="' . $avatar . '" /></div></a>'; } $output .= '</li>'; } } } $output .= '</ul>'; echo $output; }
function qw_get_avatar($handle, $size = 40, $html = true) { $userid = qa_handle_to_userid($handle); if (defined('QA_WORDPRESS_INTEGRATE_PATH')) { $img_html = get_avatar(qa_get_user_email($userid), $size); } else { if (QA_FINAL_EXTERNAL_USERS) { $img_html = qa_get_external_avatar_html($userid, $size, false); } else { if (!isset($handle)) { if (qa_opt('avatar_allow_upload') && qa_opt('avatar_default_show') && strlen(qa_opt('avatar_default_blobid'))) { $img = qa_opt('avatar_default_blobid'); } else { $img = ''; } } else { $f = ra_user_data($handle); if (empty($f['account']['avatarblobid'])) { if (qa_opt('avatar_allow_upload') && qa_opt('avatar_default_show') && strlen(qa_opt('avatar_default_blobid'))) { $img = qa_opt('avatar_default_blobid'); } else { $img = ''; } } else { $img = $f['account']['avatarblobid']; } } } } if (empty($img)) { return; } if ($html) { return '<a href="' . qa_path_absolute('user/' . $handle) . '"><img src="' . qa_path_absolute('', array('qa' => 'image', 'qa_blobid' => $img, 'qa_size' => $size)) . '" /></a>'; } elseif (!empty($img)) { return qa_path_absolute('', array('qa' => 'image', 'qa_blobid' => $img, 'qa_size' => $size)); } }
function cs_ajax_user_popover() { $handle_id = qa_post_text('handle'); $handle = qa_post_text('handle'); require_once QA_INCLUDE_DIR . 'qa-db-users.php'; if (isset($handle)) { $userid = qa_handle_to_userid($handle); //$badges = cs_user_badge($handle); if (defined('QA_WORDPRESS_INTEGRATE_PATH')) { $userid = qa_handle_to_userid($handle); $cover = get_user_meta($userid, 'cover'); $cover = $cover[0]; } else { $data = cs_user_data($handle); } ?> <div id="<?php echo $userid; ?> _popover" class="user-popover"> <div class="counts clearfix"> <div class="points"> <?php echo '<span>' . $data['points'] . '</span>Points'; ?> </div> <div class="qcount"> <?php echo '<span>' . $data['qposts'] . '</span>Questions'; ?> </div> <div class="acount"> <?php echo '<span>' . $data['aposts'] . '</span>Answers'; ?> </div> <div class="ccount"> <?php echo '<span>' . $data['cposts'] . '</span>Comments'; ?> </div> </div> <div class="bottom"> <div class="avatar pull-left"><?php echo cs_get_avatar($handle, 30); ?> </div> <span class="name"><?php echo cs_name($handle); ?> </span> <span class="level"><?php echo qa_user_level_string($data['level']); ?> </span> </div> </div> <?php } die; }
?> " <?php echo @$args['tags']; ?> > <?php if (isset($args['raw']['userfavoriteq']) && $args['raw']['userfavoriteq'] == 1) { echo '<i class="fav-indicator icon-star"></i>'; } ?> <div class="for-left"> <div class="list-avatar avatar pull-left" data-handle="<?php echo $handle; ?> " data-id="<?php echo qa_handle_to_userid($handle); ?> "> <a href="<?php echo qa_path_html('user/' . $handle); ?> "> <?php $context->ra_list_avatar($args, 50); ?> </a> </div> <div class="list_content"> <div class="list-counts pull-right"> <div class="vote"> <?php
function ra_ajax_user_popover() { $handle_id = qa_post_text('handle'); $handle = qa_post_text('handle'); require_once QA_INCLUDE_DIR . 'qa-db-users.php'; if (isset($handle)) { $userid = qa_handle_to_userid($handle); $badges = ra_user_badge($handle); if (defined('QA_WORDPRESS_INTEGRATE_PATH')) { $userid = qa_handle_to_userid($handle); $cover = get_user_meta($userid, 'cover'); $cover = $cover[0]; } else { $profile = ra_user_profile($handle); $cover = @$profile['cover']; } if (isset($cover)) { $image_file = explode('.', $cover); $cover = 'style="background:url(' . qa_opt('site_url') . 'images/' . @$image_file[0] . '_s.' . $image_file[1] . ') no-repeat scroll 0 0 / cover;"'; } ?> <div id="<?php echo $userid; ?> _popover" class="user-popover"> <div class="cover" <?php echo @$cover; ?> > <div class="avatar pull-left"><?php echo ra_get_avatar($handle, 50); ?> </div> </div> <div class="bar"> <span class="followers-count pull-right icon-star btn btn-warning"><?php echo ra_user_followers_count($handle); ?> </span> <h3 class="name"><?php echo ra_name($handle); ?> </h3> </div> <div class="extra clearfix"> <div class="points"> <?php echo '<span>' . ra_user_points($handle) . '</span>' . _ra_lang('P'); ?> </div> <div class="badges"> <?php echo $badges; ?> </div> </div> </div> <?php } die; }
More about this license: http://www.question2answer.org/license.php */ if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser header('Location: ../'); exit; } // Determine the identify of the user $handle = qa_request_part(1); if (!strlen($handle)) { $handle = qa_get_logged_in_handle(); qa_redirect(isset($handle) ? 'user/' . $handle : 'users'); } // Get the HTML to display for the handle, and if we're using external users, determine the userid if (QA_FINAL_EXTERNAL_USERS) { $userid = qa_handle_to_userid($handle); if (!isset($userid)) { return include QA_INCLUDE_DIR . 'qa-page-not-found.php'; } $usershtml = qa_get_users_html(array($userid), false, qa_path_to_root(), true); $userhtml = @$usershtml[$userid]; } else { $userhtml = qa_html($handle); } // Display the appropriate page based on the request switch (qa_request_part(2)) { case 'wall': qa_set_template('user-wall'); $qa_content = (include QA_INCLUDE_DIR . 'pages/user-wall.php'); break; case 'activity':
function get_user_activity($handle) { $userid = qa_handle_to_userid($handle); require_once QA_INCLUDE_DIR . 'qa-db-selects.php'; require_once QA_INCLUDE_DIR . 'qa-app-format.php'; $loginuserid = qa_get_logged_in_userid(); $identifier = QA_FINAL_EXTERNAL_USERS ? $userid : $handle; list($useraccount, $questions, $answerqs, $commentqs, $editqs) = qa_db_select_with_pending(QA_FINAL_EXTERNAL_USERS ? null : qa_db_user_account_selectspec($handle, false), qa_db_user_recent_qs_selectspec($loginuserid, $identifier, qa_opt_if_loaded('page_size_activity')), qa_db_user_recent_a_qs_selectspec($loginuserid, $identifier), qa_db_user_recent_c_qs_selectspec($loginuserid, $identifier), qa_db_user_recent_edit_qs_selectspec($loginuserid, $identifier)); if (!QA_FINAL_EXTERNAL_USERS && !is_array($useraccount)) { // check the user exists return include QA_INCLUDE_DIR . 'qa-page-not-found.php'; } // Get information on user references $questions = qa_any_sort_and_dedupe(array_merge($questions, $answerqs, $commentqs, $editqs)); $questions = array_slice($questions, 0, qa_opt('page_size_activity')); $usershtml = qa_userids_handles_html(qa_any_get_userids_handles($questions), false); $htmldefaults = qa_post_html_defaults('Q'); $htmldefaults['whoview'] = false; $htmldefaults['voteview'] = false; $htmldefaults['avatarsize'] = 0; foreach ($questions as $question) { $qa_content[] = qa_any_to_q_html_fields($question, $loginuserid, qa_cookie_get(), $usershtml, null, array('voteview' => false) + qa_post_html_options($question, $htmldefaults)); } $output = '<div class="widget user-activities">'; $output .= '<h3 class="widget-title">' . ra_name($handle) . '\'s ' . _ra_lang('activities') . '</h3>'; $output .= '<ul class="question-list">'; if (isset($qa_content)) { foreach ($qa_content as $qs) { if ($qs['what'] == 'answered') { $icon = 'icon-chat-3 answered'; } elseif ($qs['what'] == 'asked') { $icon = 'icon-question asked'; } elseif ($qs['what'] == 'commented') { $icon = 'icon-chat-2 commented'; } elseif ($qs['what'] == 'edited' || $qs['what'] == 'answer edited') { $icon = 'icon-edit edited'; } elseif ($qs['what'] == 'closed') { $icon = 'icon-error closed'; } elseif ($qs['what'] == 'answer selected') { $icon = 'icon-checked selected'; } elseif ($qs['what'] == 'recategorized') { $icon = 'icon-folder-close recategorized'; } else { $icon = 'icon-pin undefined'; } $output .= '<li class="activity-item">'; $output .= '<div class="type pull-left ' . $icon . '"></div>'; $output .= '<div class="list-right">'; $output .= '<h5 class="when"><a href="' . @$qs['what_url'] . '">' . $qs['what'] . '</a> ' . implode(' ', $qs['when']) . '</h5>'; $output .= '<h5 class="what"><a href="' . $qs['url'] . '">' . $qs['title'] . '</a></h5>'; $output .= '</div>'; $output .= '</li>'; } } else { $output .= '<li>' . _ra_lang('No activity yet.') . '</li>'; } $output .= '</ul>'; $output .= '</div>'; return $output; }
function cs_relative_post_list($limit, $slug, $type, $return = false, $avatar_size) { require_once QA_INCLUDE_DIR . 'qa-app-posts.php'; if (!empty($slug)) { if ($type == 'Category') { $post_type = 'Q'; $categories = explode("/", $slug); if (count($categories)) { $category_bread_crup = implode(" > ", $categories); $category_link = implode("/", $categories); $categories = array_reverse($categories); $slug = implode("/", $categories); } $posts = qa_db_read_all_assoc(qa_db_query_sub('SELECT * FROM ^posts WHERE ^posts.type=$ AND categoryid=(SELECT categoryid FROM ^categories WHERE ^categories.backpath=$ LIMIT 1) ORDER BY ^posts.created DESC LIMIT #', 'Q', $slug, $limit)); //refresh every 15 minutes $title = 'Questions in <a href="' . qa_path_html('questions/' . qa_strtolower($category_link)) . '">' . $category_bread_crup . '</a>'; } elseif ($type == 'Tags') { $post_type = 'Q'; $title = 'Questions in <a href="' . qa_path_html('tag/' . qa_strtolower($slug)) . '">' . $slug . '</a>'; $posts = qa_db_read_all_assoc(qa_db_query_sub('SELECT * FROM ^posts WHERE ^posts.type=$ AND ^posts.postid IN (SELECT postid FROM ^posttags WHERE wordid=(SELECT wordid FROM ^words WHERE word=$ OR word=$ COLLATE utf8_bin LIMIT 1) ORDER BY postcreated DESC) ORDER BY ^posts.created DESC LIMIT #', 'Q', $slug, qa_strtolower($slug), $limit)); } else { // Relative to Keyword require_once QA_INCLUDE_DIR . 'qa-app-search.php'; $keyword = $slug; $userid = qa_get_logged_in_userid(); $title = 'Posts About <a href="' . qa_path_html('search/' . qa_strtolower($keyword)) . '">' . $keyword . '</a>'; //$post=qa_get_search_results($keyword, 0, $limit, $userid , false, false); $words = qa_string_to_words($keyword); $posts = qa_db_select_with_pending(qa_db_search_posts_selectspec($userid, $words, $words, $words, $words, trim($keyword), 0, false, $limit)); $output = '<h3 class="widget-title">' . $title . '</h3>'; $output .= '<ul class="question-list">'; foreach ($posts as $post) { $post_type = $post['type']; if ($post_type == 'Q') { $what = qa_lang('cleanstrap/asked'); } elseif ($post_type == 'A') { $what = qa_lang('cleanstrap/answered'); } elseif ('C') { $what = qa_lang('cleanstrap/commented'); } $handle = qa_post_userid_to_handle($post['userid']); $avatar = cs_get_post_avatar($post, $avatar_size); $output .= '<li id="q-list-' . $post['postid'] . '" class="question-item">'; $output .= '<div class="pull-left avatar" data-handle="' . $handle . '" data-id="' . $post['userid'] . '">' . $avatar . '</div>'; $output .= '<div class="list-right">'; if ($post_type == 'Q') { $output .= '<a class="title" href="' . qa_q_path_html($post['postid'], $post['title']) . '" title="' . $post['title'] . '">' . cs_truncate(strip_tags($post['title']), 70) . '</a>'; } elseif ($post_type == 'A') { $output .= '<p><a href="' . cs_post_link($post['parentid']) . '#a' . $post['postid'] . '">' . cs_truncate(strip_tags($post['content']), 70) . '</a></p>'; } else { $output .= '<p><a href="' . cs_post_link($post['parentid']) . '#c' . $post['postid'] . '">' . cs_truncate(strip_tags($post['content']), 70) . '</a></p>'; } $output .= '<div class="meta"><a href="' . qa_path_html('user/' . $handle) . '">' . cs_name($handle) . '</a> ' . $what; if ($post_type == 'Q') { $output .= ' <span class="vote-count">' . $post['netvotes'] . ' votes</span>'; $output .= ' <span class="ans-count">' . $post['acount'] . ' ans</span>'; } elseif ($post_type == 'A') { $output .= ' <span class="vote-count">' . $post['netvotes'] . ' votes</span>'; } $output .= '</div></div>'; $output .= '</li>'; } $output .= '</ul>'; if ($return) { return $output; } echo $output; return; } } else { return; } $output = '<h3 class="widget-title">' . $title . '</h3>'; $output .= '<ul class="question-list">'; foreach ($posts as $p) { if (empty($p['userid'])) { $p['userid'] = NULL; } // to prevent error for anonymous posts while calling qa_post_userid_to_handle() if ($post_type == 'Q') { $what = qa_lang_html('cleanstrap/asked'); } elseif ($post_type == 'A') { $what = qa_lang_html('cleanstrap/answered'); } elseif ('C') { $what = qa_lang_html('cleanstrap/commented'); } $handle = qa_post_userid_to_handle($p['userid']); $avatar = cs_get_avatar($handle, 35, false); $output .= '<li id="q-list-' . $p['postid'] . '" class="question-item">'; $output .= '<div class="pull-left avatar" data-handle="' . $handle . '" data-id="' . qa_handle_to_userid($handle) . '">' . (isset($avatar) ? '<img src="' . $avatar . '" />' : '') . '</div>'; $output .= '<div class="list-right">'; if ($post_type == 'Q') { $output .= '<a class="title" href="' . qa_q_path_html($p['postid'], $p['title']) . '" title="' . $p['title'] . '">' . cs_truncate(qa_html($p['title']), 70) . '</a>'; } elseif ($post_type == 'A') { $output .= '<p><a href="' . cs_post_link($p['parentid']) . '#a' . $p['postid'] . '">' . cs_truncate(strip_tags($p['content']), 70) . '</a></p>'; } else { $output .= '<p><a href="' . cs_post_link($p['parentid']) . '#c' . $p['postid'] . '">' . cs_truncate(strip_tags($p['content']), 70) . '</a></p>'; } $output .= '<div class="meta"><a href="' . qa_path_html('user/' . $handle) . '">' . cs_name($handle) . '</a> ' . $what; if ($post_type == 'Q') { $output .= ' <span class="vote-count">' . $p['netvotes'] . ' votes</span>'; $output .= ' <span class="ans-count">' . $p['acount'] . ' ans</span>'; } elseif ($post_type == 'A') { $output .= ' <span class="vote-count">' . $p['netvotes'] . ' votes</span>'; } $output .= '</div></div>'; $output .= '</li>'; } $output .= '</ul>'; if ($return) { return $output; } echo $output; }
function donut_user_profile($handle, $field = NULL) { $userid = qa_handle_to_userid($handle); if (defined('QA_WORDPRESS_INTEGRATE_PATH')) { return get_user_meta($userid); } else { $query = qa_db_select_with_pending(qa_db_user_profile_selectspec($userid, true)); if (!$field) { return $query; } if (isset($query[$field])) { return $query[$field]; } } return false; }