public function process_request($request)
 {
     $requestparts = explode('/', qa_request());
     $slugs = array_slice($requestparts, 1);
     $countslugs = count($slugs);
     $userid = qa_get_logged_in_userid();
     $start = qa_get_start();
     $count = qa_opt_if_loaded('page_size_activity');
     $totalcount = qa_opt('cache_qcount');
     $qspec = qa_db_posts_basic_selectspec($userid, false);
     qa_db_add_selectspec_opost($qspec, 'ra', false, false);
     qa_db_add_selectspec_ousers($qspec, 'rau', 'raup');
     $qspec['source'] .= " JOIN (SELECT questionid, childid FROM ^homepage ORDER BY ^homepage.updated DESC) AS rcaq ON ^posts.postid=rcaq.questionid" . " LEFT JOIN ^posts AS ra ON childid=ra.postid" . (QA_FINAL_EXTERNAL_USERS ? "" : " LEFT JOIN ^users AS rau ON ra.userid=rau.userid") . " LEFT JOIN ^userpoints AS raup ON ra.userid=raup.userid LIMIT #,#";
     array_push($qspec['columns'], 'childid');
     array_push($qspec['arguments'], $start, $count);
     $qspec['sortdesc'] = 'otime';
     $query = 'SELECT ';
     foreach ($qspec['columns'] as $columnas => $columnfrom) {
         $query .= $columnfrom . (is_int($columnas) ? '' : ' AS ' . $columnas) . ', ';
     }
     $query = qa_db_apply_sub(substr($query, 0, -2) . (strlen(@$qspec['source']) ? ' FROM ' . $qspec['source'] : ''), @$qspec['arguments']);
     $results = qa_db_read_all_assoc(qa_db_query_raw($query));
     qa_db_post_select($results, $qspec);
     list($categories, $categoryid) = qa_db_select_with_pending(qa_db_category_nav_selectspec($slugs, false, false, true), $countslugs ? qa_db_slugs_to_category_id_selectspec($slugs) : null);
     $questions = qa_any_sort_and_dedupe($results);
     // $questions=qa_any_sort_and_dedupe(array_merge($recentquestions,$recentanswers));
     $pagesize = qa_opt('page_size_home');
     if ($countslugs) {
         if (!isset($categoryid)) {
             return include QA_INCLUDE_DIR . 'qa-page-not-found.php';
         }
         $categorytitlehtml = qa_html($categories[$categoryid]['title']);
         $sometitle = qa_lang_html_sub('main/recent_qs_as_in_x', $categorytitlehtml);
         $nonetitle = qa_lang_html_sub('main/no_questions_in_x', $categorytitlehtml);
     } else {
         $sometitle = qa_lang_html('main/recent_qs_as_title');
         $nonetitle = qa_lang_html('main/no_questions_found');
     }
     require_once QA_INCLUDE_DIR . 'qa-app-q-list.php';
     $qa_content = qa_q_list_page_content($questions, $pagesize, $start, $totalcount, $sometitle, $nonetitle, $categories, $categoryid, true, qa_opt('eql_homepage_url'), qa_opt('feed_for_qa') ? qa_opt('eql_homepage_url') : null, count($questions) < $pagesize ? qa_html_suggest_ask($categoryid) : qa_html_suggest_qs_tags(qa_using_tags(), qa_category_path_request($categories, $categoryid)), null, null);
     return $qa_content;
 }
function qa_db_user_updates_selectspec($userid, $forfavorites = true, $forcontent = true)
{
    require_once QA_INCLUDE_DIR . 'qa-app-updates.php';
    $selectspec = qa_db_posts_basic_selectspec($userid);
    $nonesql = qa_db_argument_to_mysql(QA_ENTITY_NONE, true);
    $selectspec['columns']['obasetype'] = 'LEFT(updateposts.type, 1)';
    $selectspec['columns']['oupdatetype'] = 'fullevents.updatetype';
    $selectspec['columns']['ohidden'] = "INSTR(updateposts.type, '_HIDDEN')>0";
    $selectspec['columns']['opostid'] = 'fullevents.lastpostid';
    $selectspec['columns']['ouserid'] = 'fullevents.lastuserid';
    $selectspec['columns']['otime'] = 'UNIX_TIMESTAMP(fullevents.updated)';
    $selectspec['columns']['opersonal'] = 'fullevents.entitytype=' . $nonesql;
    $selectspec['columns']['oparentid'] = 'updateposts.parentid';
    qa_db_add_selectspec_ousers($selectspec, 'eventusers', 'eventuserpoints');
    if ($forfavorites) {
        // life is hard
        $selectspec['source'] .= ' JOIN ' . "(SELECT entitytype, questionid, lastpostid, updatetype, lastuserid, updated FROM ^userevents WHERE userid=\$" . ($forcontent ? '' : " AND entitytype!=" . $nonesql) . " UNION SELECT ^sharedevents.entitytype, questionid, lastpostid, updatetype, lastuserid, updated FROM ^sharedevents JOIN ^userfavorites ON ^sharedevents.entitytype=^userfavorites.entitytype AND ^sharedevents.entityid=^userfavorites.entityid AND ^userfavorites.nouserevents=1 WHERE userid=\$) fullevents ON ^posts.postid=fullevents.questionid";
        array_push($selectspec['arguments'], $userid, $userid);
    } else {
        // life is easy
        $selectspec['source'] .= " JOIN ^userevents AS fullevents ON ^posts.postid=fullevents.questionid AND fullevents.userid=\$ AND fullevents.entitytype=" . $nonesql;
        $selectspec['arguments'][] = $userid;
    }
    $selectspec['source'] .= " JOIN ^posts AS updateposts ON updateposts.postid=fullevents.lastpostid" . " AND (updateposts.type IN ('Q', 'A', 'C') OR fullevents.entitytype=" . $nonesql . ")" . " AND (^posts.selchildid=fullevents.lastpostid OR NOT fullevents.updatetype<=>\$) AND ^posts.type IN ('Q', 'Q_HIDDEN')" . (QA_FINAL_EXTERNAL_USERS ? '' : ' LEFT JOIN ^users AS eventusers ON fullevents.lastuserid=eventusers.userid') . ' LEFT JOIN ^userpoints AS eventuserpoints ON fullevents.lastuserid=eventuserpoints.userid';
    $selectspec['arguments'][] = QA_UPDATE_SELECTED;
    unset($selectspec['arraykey']);
    // allow same question to be retrieved multiple times
    $selectspec['sortdesc'] = 'otime';
    return $selectspec;
}