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; }
if (QA_FINAL_EXTERNAL_USERS) { $publictouserid = qa_get_userids_from_public(array($handle)); if (!count($publictouserid)) { return include QA_INCLUDE_DIR . 'qa-page-not-found.php'; } $userid = reset($publictouserid); // don't use $publictouserid[$handle] since $handle capitalization might be different $usershtml = qa_get_users_html(array($userid), false, qa_path_to_root(), true); $userhtml = @$usershtml[$userid]; } else { $userhtml = qa_html($handle); } // Find the user profile and questions and answers for this handle $loginuserid = qa_get_logged_in_userid(); $identifier = QA_FINAL_EXTERNAL_USERS ? $userid : $handle; @(list($useraccount, $userprofile, $userfields, $userpoints, $userrank, $questions, $answerqs, $commentqs, $editqs, $favorite) = qa_db_select_with_pending(QA_FINAL_EXTERNAL_USERS ? null : qa_db_user_account_selectspec($handle, false), QA_FINAL_EXTERNAL_USERS ? null : qa_db_user_profile_selectspec($handle, false), QA_FINAL_EXTERNAL_USERS ? null : qa_db_userfields_selectspec(), qa_db_user_points_selectspec($identifier), qa_db_user_rank_selectspec($identifier), qa_db_user_recent_qs_selectspec($loginuserid, $identifier, qa_opt_if_loaded('page_size_user_posts')), 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), isset($loginuserid) && !QA_FINAL_EXTERNAL_USERS ? qa_db_is_favorite_selectspec($loginuserid, QA_ENTITY_USER, $handle) : null)); // Check the user exists and work out what can and can't be set (if not using single sign-on) $loginlevel = qa_get_logged_in_level(); if (!QA_FINAL_EXTERNAL_USERS) { // if we're using integrated user management, we can know and show more if (!is_array($userpoints) && !is_array($useraccount)) { return include QA_INCLUDE_DIR . 'qa-page-not-found.php'; } $userid = $useraccount['userid']; $fieldseditable = false; $maxlevelassign = null; if ($loginuserid && $loginuserid != $userid && ($loginlevel >= QA_USER_LEVEL_SUPER || $loginlevel > $useraccount['level']) && !qa_user_permit_error()) { // can't change self - or someone on your level (or higher, obviously) unless you're a super admin if ($loginlevel >= QA_USER_LEVEL_SUPER) { $maxlevelassign = QA_USER_LEVEL_SUPER; } elseif ($loginlevel >= QA_USER_LEVEL_ADMIN) {
GNU General Public License for more details. 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; } require_once QA_INCLUDE_DIR . 'qa-db-selects.php'; require_once QA_INCLUDE_DIR . 'qa-app-format.php'; // $handle, $userhtml are already set by qa-page-user.php - also $userid if using external user integration // Find the recent activity for this user $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); // Prepare content for theme $qa_content = qa_content_prepare(true); if (count($questions)) { $qa_content['title'] = qa_lang_html_sub('profile/recent_activity_by_x', $userhtml); } else { $qa_content['title'] = qa_lang_html_sub('profile/no_posts_by_x', $userhtml); }
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; }
if (QA_FINAL_EXTERNAL_USERS) { $publictouserid = qa_get_userids_from_public(array(@$pass_subrequests[0])); $userid = @$publictouserid[@$pass_subrequests[0]]; if (!isset($userid)) { return include QA_INCLUDE_DIR . 'qa-page-not-found.php'; } $usershtml = qa_get_users_html(array($userid), false, $qa_root_url_relative, true); $userhtml = @$usershtml[$userid]; } else { $handle = @$pass_subrequests[0]; // picked up from qa-page.php $userhtml = qa_html($handle); } // Find the user profile and questions and answers for this handle $identifier = QA_FINAL_EXTERNAL_USERS ? $userid : $handle; @(list($useraccount, $userprofile, $userfields, $userpoints, $userrank, $questions, $answerquestions, $commentquestions) = qa_db_select_with_pending(QA_FINAL_EXTERNAL_USERS ? null : qa_db_user_account_selectspec($handle, false), QA_FINAL_EXTERNAL_USERS ? null : qa_db_user_profile_selectspec($handle, false), QA_FINAL_EXTERNAL_USERS ? null : qa_db_userfields_selectspec(), qa_db_user_points_selectspec($identifier), qa_db_user_rank_selectspec($identifier), qa_db_user_recent_qs_selectspec($qa_login_userid, $identifier), qa_db_user_recent_a_qs_selectspec($qa_login_userid, $identifier), qa_db_user_recent_c_qs_selectspec($qa_login_userid, $identifier))); // Check the user exists and work out what can and can't be set (if not using single sign-on) if (!QA_FINAL_EXTERNAL_USERS) { // if we're using integrated user management, we can know and show more if (!is_array($userpoints) && !is_array($useraccount)) { return include QA_INCLUDE_DIR . 'qa-page-not-found.php'; } $userid = $useraccount['userid']; $loginlevel = qa_get_logged_in_level(); $fieldseditable = false; $maxlevelassign = null; if ($qa_login_userid && $qa_login_userid != $userid && ($loginlevel >= QA_USER_LEVEL_SUPER || $loginlevel > $useraccount['level']) && !qa_user_permit_error()) { // can't change self - or someone on your level (or higher, obviously) unless you're a super admin if ($loginlevel >= QA_USER_LEVEL_SUPER) { $maxlevelassign = QA_USER_LEVEL_SUPER; } elseif ($loginlevel >= QA_USER_LEVEL_ADMIN) {