Exemplo n.º 1
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>';
    }
}
Exemplo n.º 2
0
function qw_prepare_email_body($email_queue_data, $email)
{
    $email_body_arr = array();
    $summerized_email_body = array();
    $email_body = "";
    if (is_array($email_queue_data)) {
        foreach ($email_queue_data as $queue_data) {
            if ($queue_data['email'] === $email) {
                $event = $queue_data['event'];
                $body_subs = json_decode($queue_data['body'], true);
                $body_subs['^author_link'] = qa_path_absolute('user/' . $body_subs['^done_by']);
                $body = strtr(qw_get_email_body($event), $body_subs);
                if (!!$body) {
                    $header = "";
                    if (!isset($email_body_arr[$event]['body']) || empty($email_body_arr[$event]['body'])) {
                        // Now attach the headers
                        $header = '<div class="content event-item"><table><tr>';
                        $header .= '<td style="vertical-align: top;">';
                        $header .= qw_get_email_headers($event);
                        $header .= '</td>';
                        $header .= '</tr></table></div>';
                    }
                    $email_body_arr[$event]['body'] = isset($email_body_arr[$event]['body']) && !empty($email_body_arr[$event]['body']) ? $email_body_arr[$event]['body'] . "" : $header;
                    $event_body = '<div class="content event-item"><table><tr>';
                    $event_body .= '<td class="small" width="60px" style="vertical-align: top; padding-right:10px;">' . qw_get_avatar($body_subs['^done_by'], 40) . '</td>';
                    $event_body .= '<td style="vertical-align: top;">';
                    $event_body .= $body;
                    $event_body .= '</td>';
                    $event_body .= '</tr></table></div>';
                    $email_body_arr[$event]['body'] .= $event_body;
                }
            }
            //outer if
        }
        //foreach
        foreach ($email_body_arr as $event => $email_body_for_event) {
            if (isset($email_body_for_event['body']) && !empty($email_body_for_event['body'])) {
                if (!isset($summerized_email_body[$event]) || empty($summerized_email_body[$event])) {
                    $summerized_email_body[$event] = $email_body_for_event['body'];
                } else {
                    $summerized_email_body[$event] .= $email_body_for_event['body'];
                }
            }
        }
        //foreach
        foreach ($summerized_email_body as $event => $email_body_chunk) {
            if (!!$email_body_chunk) {
                $email_body .= $email_body_chunk;
            }
        }
        //foreach
    }
    //if
    return $email_body;
}