Beispiel #1
0
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;
}
Beispiel #2
0
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>';
    }
}
Beispiel #3
0
    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;
    }
Beispiel #4
0
    function messagelist()
    {
        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 UNIX_TIMESTAMP(datetime) AS datetime, userid, postid, effecteduserid, event, params FROM ^userlog WHERE effecteduserid=# AND 
				DATE_SUB(CURDATE(),INTERVAL # DAY) <= datetime AND
				event IN (' . $events . ')
				ORDER BY datetime DESC' . (qa_opt('qat_activity_number') ? ' LIMIT ' . (int) qa_opt('qat_activity_number') : ''), $userid, qa_opt('qat_activity_age')));
        $event = array();
        $output = '';
        //
        $userids = array();
        foreach ($eventslist as $event) {
            $userids[$event['userid']] = $event['userid'];
            $userids[$event['effecteduserid']] = $event['effecteduserid'];
        }
        $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']];
            $user_link = qa_path('user/' . $handle);
            $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, 20);
            $output .= '<li>';
            switch ($event['event']) {
                case 'u_message':
                    // related question to an answer
                    $url = qa_path_html(qa_path('message/' . $handle));
                    $output .= '<div class="event-icon pull-left icon-chat"></div>
								<div class="event-content">
									<p class="title"><strong class="avatar"><a href="' . $user_link . '">' . $handle . '</a></strong>
									<span class="what">left you a message</span>
									</p>
									<a class="title" href="' . $url . '">' . $message . '</a>
									<span class="date"> ' . $event['date'] . '</span>
								</div>';
                    break;
                case 'u_wall_post':
                    // user's question had been answered
                    $url = qa_path_html(qa_path('user/' . $reciever_handle . '/wall'));
                    $output .= '<div class="event-icon pull-left icon-chat"></div>
								<div class="event-content">
									<p class="title"><strong class="avatar"><a href="' . $user_link . '">' . $handle . '</a></strong>
									<span class="what">posted a message on your wall</span>
									</p>
									<a class="title" href="' . $url . '">' . $message . '</a>
									<span class="date"> ' . $event['date'] . '</span>
								</div>';
                    break;
            }
        }
        $output .= '</li>';
        return $output;
    }