Пример #1
0
function tmpl_drawmsg($obj, $usr, $perms, $hide_controls, &$m_num, $misc)
{
    $o1 =& $GLOBALS['FUD_OPT_1'];
    $o2 =& $GLOBALS['FUD_OPT_2'];
    $a =& $obj->users_opt;
    $b =& $usr->users_opt;
    $c =& $obj->level_opt;
    /* draw next/prev message controls */
    if (!$hide_controls && $misc) {
        /* tree view is a special condition, we only show 1 message per page */
        if ($_GET['t'] == 'tree') {
            $prev_message = $misc[0] ? '<a href="/egroupware/fudforum/3814588639/index.php?t=' . $_GET['t'] . '&amp;' . _rsid . '&amp;th=' . $obj->thread_id . '&amp;mid=' . $misc[0] . '" class="GenLink"><img src="/egroupware/fudforum/3814588639/theme/default/images/up.png" title="Go to previous message" alt="Go to previous message" width=16 height=11 /></a>' : '';
            $next_message = $misc[1] ? '<a href="/egroupware/fudforum/3814588639/index.php?t=' . $_GET['t'] . '&amp;' . _rsid . '&amp;th=' . $obj->thread_id . '&amp;mid=' . $misc[1] . '" class="GenLink"><img alt="Go to previous message" title="Go to next message" src="/egroupware/fudforum/3814588639/theme/default/images/down.png" width=16 height=11 /></a>' : '';
            $next_page = '';
        } else {
            /* handle previous link */
            if (!$m_num && $obj->id > $obj->root_msg_id) {
                /* prev link on different page */
                $msg_start = $misc[0] - $misc[1];
                $prev_message = '<a href="/egroupware/fudforum/3814588639/index.php?t=' . $_GET['t'] . '&amp;' . _rsid . '&amp;prevloaded=1&amp;th=' . $obj->thread_id . '&amp;start=' . $msg_start . reveal_lnk . unignore_tmp . '" class="GenLink"><img src="/egroupware/fudforum/3814588639/theme/default/images/up.png" title="Go to previous message" alt="Go to previous message" width=16 height=11 /></a>';
            } else {
                if ($m_num) {
                    /* inline link, same page */
                    $msg_num = $m_num;
                    $prev_message = '<a href="#msg_num_' . $msg_num . '" class="GenLink"><img alt="Go to previous message" title="Go to previous message" src="/egroupware/fudforum/3814588639/theme/default/images/up.png" width=16 height=11 /></a>';
                } else {
                    $prev_message = '';
                }
            }
            /* handle next link */
            if ($obj->id < $obj->last_post_id) {
                if ($m_num && !($misc[1] - $m_num - 1)) {
                    /* next page link */
                    $msg_start = $misc[0] + $misc[1];
                    $next_message = '<a href="/egroupware/fudforum/3814588639/index.php?t=' . $_GET['t'] . '&amp;' . _rsid . '&amp;prevloaded=1&amp;th=' . $obj->thread_id . '&amp;start=' . $msg_start . reveal_lnk . unignore_tmp . '" class="GenLink"><img alt="Go to previous message" title="Go to next message" src="/egroupware/fudforum/3814588639/theme/default/images/down.png" width=16 height=11 /></a>';
                    $next_page = '<a href="/egroupware/fudforum/3814588639/index.php?t=' . $_GET['t'] . '&amp;' . _rsid . '&amp;prevloaded=1&amp;th=' . $obj->thread_id . '&amp;start=' . $msg_start . reveal_lnk . unignore_tmp . '" class="GenLink">Next Page <img src="/egroupware/fudforum/3814588639/theme/default/images/goto.gif" alt="" /></a>';
                } else {
                    $msg_num = $m_num + 2;
                    $next_message = '<a href="#msg_num_' . $msg_num . '" class="GenLink"><img alt="Go to next message" title="Go to next message" src="/egroupware/fudforum/3814588639/theme/default/images/down.png" width=16 height=11 /></a>';
                    $next_page = '';
                }
            } else {
                $next_page = $next_message = '';
            }
        }
        $m_num++;
    } else {
        $next_page = $next_message = $prev_message = '';
    }
    if (!$obj->user_id) {
        $user_login =& $GLOBALS['ANON_NICK'];
        $user_login_td = $GLOBALS['ANON_NICK'] . ' is ignored&nbsp;';
    } else {
        $user_login =& $obj->login;
        $user_login_td = 'Post by <a href="/egroupware/fudforum/3814588639/index.php?t=usrinfo&amp;' . _rsid . '&amp;id=' . $obj->user_id . '" class="GenLink">' . $obj->login . '</a> is ignored&nbsp;';
    }
    /* check if the message should be ignored and it is not temporarily revelead */
    if ($usr->ignore_list && !empty($usr->ignore_list[$obj->poster_id]) && !isset($GLOBALS['__FMDSP__'][$obj->id])) {
        $rev_url = make_reveal_link($obj->id);
        $un_ignore_url = make_tmp_unignore_lnk($obj->poster_id);
        return !$hide_controls ? '<tr><td>
<table border=0 cellspacing=0 cellpadding=0 class="MsgTable">
<tr>
<td align="left" class="MsgIg">
<a name="msg_num_' . $m_num . '"></a>
<a name="msg_' . $obj->id . '"></a>
' . $user_login_td . '
[<a href="/egroupware/fudforum/3814588639/index.php?' . $rev_url . '" class="GenLink">reveal post</a>]&nbsp;
[<a href="/egroupware/fudforum/3814588639/index.php?' . $un_ignore_url . '" class="GenLink">reveal all posts by ' . $user_login . '</a>]&nbsp;
[<a href="/egroupware/fudforum/3814588639/index.php?t=ignore_list&amp;del=' . $obj->poster_id . '&amp;redr=1&amp;' . _rsid . '" class="GenLink">stop ignoring this user</a>]</td>
<td class="MsgIg" align="right">' . $prev_message . $next_message . '</td></tr>
</table></td></tr>' : '<tr class="MsgR1">
<td class="GenText"><a name="msg_num_' . $m_num . '"></a> <a name="msg_' . $obj->id . '"></a>Post by ' . $user_login . ' is ignored&nbsp;</td>
</tr>';
    }
    if ($obj->user_id) {
        if (!$hide_controls) {
            $custom_tag = $obj->custom_status ? '<br />' . $obj->custom_status : '';
            if ($obj->avatar_loc && $a & 8388608 && $b & 8192 && $o1 & 28 && !($c & 2)) {
                if (!($c & 1)) {
                    $level_name =& $obj->level_name;
                    $level_image = $obj->level_img ? '&nbsp;<img src="images/' . $obj->level_img . '" alt="" />' : '';
                } else {
                    $level_name = $level_image = '';
                }
            } else {
                $level_image = $obj->level_img ? '&nbsp;<img src="images/' . $obj->level_img . '" alt="" />' : '';
                $obj->avatar_loc = '';
                $level_name =& $obj->level_name;
            }
            $avatar = $obj->avatar_loc || $level_image ? '<td class="avatarPad" width="1">' . $obj->avatar_loc . $level_image . '</td>' : '';
            $dmsg_tags = $custom_tag || $level_name ? '<div class="ctags">' . $level_name . $custom_tag . '</div>' : '';
            if ($o2 & 32 && !($a & 32768) || $b & 1048576) {
                $online_indicator = $obj->time_sec + $GLOBALS['LOGEDIN_TIMEOUT'] * 60 > __request_timestamp__ ? '<img src="/egroupware/fudforum/3814588639/theme/default/images/online.gif" alt="' . $obj->login . ' is currently online" title="' . $obj->login . ' is currently online" />&nbsp;' : '<img src="/egroupware/fudforum/3814588639/theme/default/images/offline.gif" alt="' . $obj->login . '  is currently offline" title="' . $obj->login . '  is currently offline" />&nbsp;';
            } else {
                $online_indicator = '';
            }
            $user_link = '<a class="GenLink" href="/egroupware/fudforum/3814588639/index.php?t=usrinfo&amp;id=' . $obj->user_id . '&amp;' . _rsid . '">' . $user_login . '</a>';
            if ($obj->location) {
                if (strlen($obj->location) > $GLOBALS['MAX_LOCATION_SHOW']) {
                    $location = substr($obj->location, 0, $GLOBALS['MAX_LOCATION_SHOW']) . '...';
                } else {
                    $location =& $obj->location;
                }
                $location = '<br /><b>Location: </b>' . $location;
            } else {
                $location = '';
            }
            if (_uid && _uid != $obj->user_id) {
                $buddy_link = !isset($usr->buddy_list[$obj->user_id]) ? '<a href="/egroupware/fudforum/3814588639/index.php?t=buddy_list&amp;add=' . $obj->user_id . '&amp;' . _rsid . '" class="GenLink">add to buddy list</a><br />' : '<a href="/egroupware/fudforum/3814588639/index.php?t=buddy_list&amp;del=' . $obj->user_id . '&amp;redr=1&amp;' . _rsid . '" class="GenLink">remove from buddy list</a><br />';
                $ignore_link = !isset($usr->ignore_list[$obj->user_id]) ? '<a href="/egroupware/fudforum/3814588639/index.php?t=ignore_list&amp;add=' . $obj->user_id . '&amp;' . _rsid . '" class="GenLink">ignore all posts by this user</a>' : '<a href="/egroupware/fudforum/3814588639/index.php?t=ignore_list&amp;del=' . $obj->user_id . '&amp;redr=1&amp;' . _rsid . '" class="GenLink">stop ignoring posts by this user</a>';
                $dmsg_bd_il = $buddy_link . $ignore_link . '<br />';
            } else {
                $dmsg_bd_il = '';
            }
            /* show im buttons if need be */
            if ($b & 16384) {
                $im_icq = $obj->icq ? '<a href="/egroupware/fudforum/3814588639/index.php?t=usrinfo&amp;id=' . $obj->poster_id . '&amp;' . _rsid . '#icq_msg"><img title="' . $obj->icq . '" src="/egroupware/fudforum/3814588639/theme/default/images/icq.gif" alt="" /></a>' : '';
                $im_aim = $obj->aim ? '<a href="aim:goim?screenname=' . $obj->aim . '&amp;message=Hi.+Are+you+there?" target="_blank"><img alt="" src="/egroupware/fudforum/3814588639/theme/default/images/aim.gif" title="' . $obj->aim . '" /></a>' : '';
                $im_yahoo = $obj->yahoo ? '<a target="_blank" href="http://edit.yahoo.com/config/send_webmesg?.target=' . $obj->yahoo . '&amp;.src=pg"><img alt="" src="/egroupware/fudforum/3814588639/theme/default/images/yahoo.gif" title="' . $obj->yahoo . '" /></a>' : '';
                $im_msnm = $obj->msnm ? '<a href="mailto: ' . $obj->msnm . '"><img alt="" src="/egroupware/fudforum/3814588639/theme/default/images/msnm.gif" title="' . $obj->msnm . '" /></a>' : '';
                $im_jabber = $obj->jabber ? '<img src="/egroupware/fudforum/3814588639/theme/default/images/jabber.gif" title="' . $obj->jabber . '" alt="" />' : '';
                if ($o2 & 2048) {
                    $im_affero = $obj->affero ? '<a href="http://svcs.affero.net/rm.php?r=' . $obj->affero . '&amp;ll=' . $obj->forum_id . '.' . $GLOBALS['affero_domain'] . '&amp;lp=' . $obj->forum_id . '.' . urlencode($GLOBALS['affero_domain']['host']) . '&amp;ls=' . urlencode($obj->subject) . '" target=_blank><img alt="" src="/egroupware/fudforum/3814588639/theme/default/images/affero_reg.gif" /></a>' : '<a href="http://svcs.affero.net/rm.php?m=' . urlencode($obj->email) . '&amp;ll=' . $obj->forum_id . '.' . $GLOBALS['affero_domain'] . '&amp;lp=' . $obj->forum_id . '.' . urlencode($GLOBALS['affero_domain']['host']) . '&amp;ls=' . urlencode($obj->subject) . '" target=_blank><img alt="" src="/egroupware/fudforum/3814588639/theme/default/images/affero_noreg.gif" /></a>';
                } else {
                    $im_affero = '';
                }
                $dmsg_im_row = $im_icq || $im_aim || $im_yahoo || $im_msnm || $im_jabber || $im_affero ? $im_icq . ' ' . $im_aim . ' ' . $im_yahoo . ' ' . $im_msnm . ' ' . $im_jabber . ' ' . $im_affero . '<br />' : '';
            } else {
                $dmsg_im_row = '';
            }
        } else {
            $user_link = $user_login;
            $dmsg_tags = $dmsg_im_row = $dmsg_bd_il = $location = $online_indicator = $avatar = '';
        }
    } else {
        $user_link = $user_login;
        $dmsg_tags = $dmsg_im_row = $dmsg_bd_il = $location = $online_indicator = $avatar = '';
    }
    /* Display message body
     * If we have message threshold & the entirity of the post has been revelead show a preview
     * otherwise if the message body exists show an actual body
     * if there is no body show a 'no-body' message
     */
    if (!$hide_controls && $obj->message_threshold && $obj->length_preview && $obj->length > $obj->message_threshold && !isset($GLOBALS['__FMDSP__'][$obj->id])) {
        $rev_url = make_reveal_link($obj->id);
        $msg_body = read_msg_body($obj->offset_preview, $obj->length_preview, $obj->file_id_preview);
        $msg_body = '<font class="MsgBodyText">' . $msg_body . '</font>
<br /><div align="center">[<a href="/egroupware/fudforum/3814588639/index.php?' . $rev_url . '" class="GenLink">Show the rest of the message</a>]</div>';
    } else {
        if ($obj->length) {
            $msg_body = read_msg_body($obj->foff, $obj->length, $obj->file_id);
            $msg_body = '<font class="MsgBodyText">' . $msg_body . '</font>';
        } else {
            $msg_body = 'No Message Body';
        }
    }
    if ($obj->poll_cache) {
        $obj->poll_cache = @unserialize($obj->poll_cache);
    }
    /* handle poll votes */
    if (!empty($_POST['poll_opt']) && ($_POST['poll_opt'] = (int) $_POST['poll_opt']) && !($obj->thread_opt & 1) && $perms & 512) {
        if (register_vote($obj->poll_cache, $obj->poll_id, $_POST['poll_opt'], $obj->id)) {
            $obj->total_votes += 1;
            $obj->cant_vote = 1;
        }
        unset($_GET['poll_opt']);
    }
    /* display poll if there is one */
    if ($obj->poll_id && $obj->poll_cache) {
        /* we need to determine if we allow the user to vote or see poll results */
        $show_res = 1;
        if (isset($_GET['pl_view']) && !isset($_POST['pl_view'])) {
            $_POST['pl_view'] = $_GET['pl_view'];
        }
        /* various conditions that may prevent poll voting */
        if (!$hide_controls && !$obj->cant_vote && (!isset($_POST['pl_view']) || $_POST['pl_view'] != $obj->poll_id)) {
            if ($perms & 512 && (!($obj->thread_opt & 1) || $perms & 4096)) {
                if (!$obj->expiry_date || $obj->creation_date + $obj->expiry_date > __request_timestamp__) {
                    /* check if the max # of poll votes was reached */
                    if (!$obj->max_votes || $obj->total_votes < $obj->max_votes) {
                        $show_res = 0;
                    }
                }
            }
        }
        $i = 0;
        $poll_data = '';
        foreach ($obj->poll_cache as $k => $v) {
            $i++;
            if ($show_res) {
                $length = $v[1] && $obj->total_votes ? round($v[1] / $obj->total_votes * 100) : 0;
                $poll_data .= '<tr class="' . alt_var('msg_poll_alt_clr', 'RowStyleB', 'RowStyleA') . '"><td>' . $i . '.</td><td>' . $v[0] . '</td><td><img src="/egroupware/fudforum/3814588639/theme/default/images/poll_pix.gif" alt="" height="10" width="' . $length . '" /> ' . $v[1] . ' / ' . $length . '%</td></tr>';
            } else {
                $poll_data .= '<tr class="' . alt_var('msg_poll_alt_clr', 'RowStyleB', 'RowStyleA') . '"><td>' . $i . '.</td><td colspan=2><input type="radio" name="poll_opt" value="' . $k . '">&nbsp;&nbsp;' . $v[0] . '</td></tr>';
            }
        }
        if (!$show_res) {
            $view_poll_results_button = $obj->total_votes ? '<input type="submit" class="button" name="pl_res" value="View Results">' : '';
            $poll_buttons = '<tr class="' . alt_var('msg_poll_alt_clr', 'RowStyleB', 'RowStyleA') . '"><td colspan=3 align="right"><input type="submit" class="button" name="pl_vote" value="Vote">&nbsp;' . $view_poll_results_button . '</td></tr>';
            $poll = '<p>
<form action="/egroupware/fudforum/3814588639/index.php?' . $_SERVER['QUERY_STRING'] . '#msg_' . $obj->id . '" method="post">' . _hs . '
<table border=0 cellspacing=1 cellpadding=2 class="PollTable">
<tr><th nowrap colspan=3>' . $obj->poll_name . '<img src="blank.gif" alt="" height=1 width=10 /><font size="-1">[ ' . $obj->total_votes . ' vote(s) ]</font></th></tr>
' . $poll_data . '
' . $poll_buttons . '
</table><input type="hidden" name="pl_view" value="' . $obj->poll_id . '"></form><p>';
        } else {
            $poll = '<p><table border=0 cellspacing=1 cellpadding=2 class="PollTable">
<tr><th nowrap colspan=3>' . $obj->poll_name . '<img src="blank.gif" alt="" height=1 width=10 /><font size="-1">[ ' . $obj->total_votes . ' vote(s) ]</font></th></tr>
' . $poll_data . '
</table><p>';
        }
    } else {
        $poll = '';
    }
    /* draw file attachments if there are any */
    $drawmsg_file_attachments = '';
    if ($obj->attach_cnt && !empty($obj->attach_cache)) {
        $atch = @unserialize($obj->attach_cache);
        if (is_array($atch) && count($atch)) {
            foreach ($atch as $v) {
                $sz = $v[2] / 1024;
                $sz = $sz < 1000 ? number_format($sz, 2) . 'KB' : number_format($sz / 1024, 2) . 'MB';
                $drawmsg_file_attachments .= '<tr>
<td valign="middle"><a class="GenLink" href="/egroupware/fudforum/3814588639/index.php?t=getfile&amp;id=' . $v[0] . '&amp;' . _rsid . '"><img alt="" src="images/mime/' . $v[4] . '" /></a></td>
<td><font class="GenText"><b>Attachment:</b></font> <a class="GenLink" href="/egroupware/fudforum/3814588639/index.php?t=getfile&amp;id=' . $v[0] . '&amp;' . _rsid . '">' . $v[1] . '</a><br />
<font class="SmallText">(Size: ' . $sz . ', Downloaded ' . $v[3] . ' time(s))</font></td></tr>';
            }
            $drawmsg_file_attachments = '<p>
<table border=0 cellspacing=0 cellpadding=2>
' . $drawmsg_file_attachments . '
</table>';
        }
    }
    /* Determine if the message was updated and if this needs to be shown */
    if ($obj->update_stamp) {
        if ($obj->updated_by != $obj->poster_id && $o1 & 67108864) {
            $modified_message = '<p>[Updated on: ' . strftime("%a, %d %B %Y %H:%M", $obj->update_stamp) . '] by Moderator';
        } else {
            if ($obj->updated_by == $obj->poster_id && $o1 & 33554432) {
                $modified_message = '<p>[Updated on: ' . strftime("%a, %d %B %Y %H:%M", $obj->update_stamp) . ']';
            } else {
                $modified_message = '';
            }
        }
    } else {
        $modified_message = '';
    }
    $rpl = '';
    if (!$hide_controls) {
        $ip_address = $b & 1048576 || $usr->md || $o1 & 134217728 ? '<b>IP:</b> <a href="http://www.nic.com/cgi-bin/whois.cgi?query=' . $obj->ip_addr . '" target="_blank">' . $obj->ip_addr . '</a>' : '';
        $host_name = $obj->host_name && $o1 & 268435456 ? '<b>From:</b> ' . $obj->host_name . '<br />' : '';
        $msg_icon = !$obj->icon ? '' : '<img src="images/message_icons/' . $obj->icon . '" alt="' . $obj->icon . '" />&nbsp;&nbsp;';
        $signature = $obj->sig && $o1 & 32768 && $obj->msg_opt & 1 && $b & 4096 ? '<p><u>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</u><br />' . $obj->sig : '';
        $report_to_mod_link = '<div align="right"><font class="SmallText">[<a class="SmallText" href="/egroupware/fudforum/3814588639/index.php?t=report&amp;msg_id=' . $obj->id . '&amp;' . _rsid . '">Report message to a moderator</a>]</font></div>';
        if ($obj->reply_to && $obj->reply_to != $obj->id && $o2 & 536870912) {
            if ($_GET['t'] != 'tree' && $_GET['t'] != 'msg') {
                $lnk = d_thread_view;
            } else {
                $lnk =& $_GET['t'];
            }
            $rpl = '<font class="small"> [ <a href="/egroupware/fudforum/3814588639/index.php?t=' . $lnk . '&amp;' . _rsid . '&amp;th=' . $obj->thread_id . '&amp;goto=' . $obj->reply_to . '" class="small">is a reply to message #' . $obj->reply_to . '</a> ]</font>';
        }
        if ($obj->user_id) {
            $user_profile = '<a class="GenLink" href="/egroupware/fudforum/3814588639/index.php?t=usrinfo&amp;id=' . $obj->user_id . '&amp;' . _rsid . '"><img alt="" src="/egroupware/fudforum/3814588639/theme/default/images/msg_about.gif" /></a>';
            $email_link = $o1 & 4194304 && $a & 16 ? '<a class="GenLink" href="/egroupware/fudforum/3814588639/index.php?t=email&amp;toi=' . $obj->user_id . '&amp;' . _rsid . '"><img alt="" src="/egroupware/fudforum/3814588639/theme/default/images/msg_email.gif" /></a>' : '';
            $private_msg_link = $o1 & 1024 ? '<a class="GenLink" href="/egroupware/fudforum/3814588639/index.php?t=ppost&amp;toi=' . $obj->user_id . '&amp;' . _rsid . '"><img alt="Send a private message to this user" title="Send a private message to this user" src="/egroupware/fudforum/3814588639/theme/default/images/msg_pm.gif" /></a>' : '';
            $dmsg_user_info = '<br /><b>Posts:</b> ' . $obj->posted_msg_count . '<br />
<b>Registered:</b> ' . strftime("%B %Y", $obj->join_date) . '
' . $location;
        } else {
            $user_profile = $email_link = $private_msg_link = '';
            $dmsg_user_info = $host_name || $ip_address ? '' : '';
        }
        /* little trick, this variable will only be avaliable if we have a next link leading to another page */
        if (isset($next_page)) {
            $next_page = '&nbsp;';
        }
        $delete_link = $perms & 32 ? '<a class="GenLink" href="/egroupware/fudforum/3814588639/index.php?t=mmod&amp;del=' . $obj->id . '&amp;' . _rsid . '"><img alt="" src="/egroupware/fudforum/3814588639/theme/default/images/msg_delete.gif" /></a>&nbsp;' : '';
        if ($perms & 16 || _uid == $obj->poster_id && (!$GLOBALS['EDIT_TIME_LIMIT'] || __request_timestamp__ - $obj->post_stamp < $GLOBALS['EDIT_TIME_LIMIT'] * 60)) {
            $edit_link = '<a class="GenLink" href="/egroupware/fudforum/3814588639/index.php?t=post&amp;msg_id=' . $obj->id . '&amp;' . _rsid . '"><img alt="" src="/egroupware/fudforum/3814588639/theme/default/images/msg_edit.gif" /></a>&nbsp;&nbsp;&nbsp;&nbsp;';
        } else {
            $edit_link = '';
        }
        if (!($obj->thread_opt & 1) || $perms & 4096) {
            $reply_link = '<a class="GenLink" href="/egroupware/fudforum/3814588639/index.php?t=post&amp;reply_to=' . $obj->id . '&amp;' . _rsid . '"><img alt="" src="/egroupware/fudforum/3814588639/theme/default/images/msg_reply.gif" /></a>&nbsp;';
            $quote_link = '<a class="GenLink" href="/egroupware/fudforum/3814588639/index.php?t=post&amp;reply_to=' . $obj->id . '&amp;quote=true&amp;' . _rsid . '"><img alt="" src="/egroupware/fudforum/3814588639/theme/default/images/msg_quote.gif" /></a>';
        } else {
            $reply_link = $quote_link = '';
        }
        $message_toolbar = '<tr><td colspan="2" class="MsgToolBar"><table border=0 cellspacing=0 cellpadding=0 width="100%"><tr>
<td nowrap align="left">' . $user_profile . '&nbsp;' . $email_link . '&nbsp;' . $private_msg_link . '</td>
<td width="100%" align="center" class="GenText">' . $next_page . '</td>
<td nowrap align="right">' . $delete_link . $edit_link . $reply_link . $quote_link . '</td>
</tr></table></td></tr>';
    } else {
        $host_name = $ip_address = $dmsg_user_info = $msg_icon = $signature = $report_to_mod_link = $message_toolbar = '';
    }
    return '<tr><td class="MsgSpacer"><table cellspacing=0 cellpadding=0 class="MsgTable">
<tr>
<td valign="top" align="left" class="MsgR1"><font class="MsgSubText"><a name="msg_num_' . $m_num . '"></a><a name="msg_' . $obj->id . '"></a>' . $msg_icon . $obj->subject . $rpl . '</font></td>
<td valign="top" align="right" class="MsgR1"><font class="DateText">' . strftime("%a, %d %B %Y %H:%M", $obj->post_stamp) . '</font> ' . $prev_message . $next_message . '</td>
</tr>
<tr class="MsgR2"><td class="MsgR2" colspan=2><table border="0" cellspacing="0" cellpadding="0" class="ContentTable">
<tr class="MsgR2">

' . $avatar . '
<td class="msgud">' . $online_indicator . $user_link . $dmsg_user_info . '</td>
<td class="msgud">' . $dmsg_tags . '</td>
<td class="msgot">' . $dmsg_bd_il . $dmsg_im_row . $host_name . $ip_address . '</td>
</tr></table></td>
</tr>
<tr><td colspan="2" class="MsgR3">
' . $poll . $msg_body . $drawmsg_file_attachments . '
' . $modified_message . $signature . $report_to_mod_link . '
</td></tr>
' . $message_toolbar . '
</table></td></tr>';
}
function ajax_register_vote()
{
    $response = array();
    $response['success'] = true;
    $response['msg'] = '';
    $user = wp_get_current_user();
    $confirms_vote = isset($_POST['confirms_vote']) ? $_POST['confirms_vote'] : false;
    $data_fim_votacao = restore_format_date(get_theme_option('data_fim_votacao'));
    $data_inicio_troca = restore_format_date(get_theme_option('data_inicio_da_troca'));
    $vote_counter = how_many_current_user_can_vote();
    $text_change_voto = $vote_counter > 1 ? 'vezes' : 'vez';
    if (is_votacoes_abertas()) {
        $canvote = false;
        // se o usuário já votou
        if (current_user_already_voted()) {
            if (current_user_can_change_vote_by_counter()) {
                if (current_user_can_change_vote_by_date()) {
                    $canvote = true;
                    $response['code'] = 'sucess_change_voto';
                    $response['msg'] = 'Você pode mudar o voto ' . $vote_counter . ' ' . $text_change_voto . ' até o dia ' . $data_fim_votacao;
                } else {
                    $response['success'] = false;
                    $response['code'] = 'error_date_change';
                    $response['msg'] = 'Atenção!<br>Você já votou! Será possível alterar o voto apenas ' . $vote_counter . ' ' . $text_change_voto . ' entre os dias ' . $data_inicio_troca . ' e ' . $data_fim_votacao;
                }
            } else {
                $response['success'] = false;
                $response['code'] = 'error_counter_change';
                $response['msg'] = 'Você não pode mudar seu voto novamente!';
            }
        } else {
            // se o usuário ainda não votou
            $canvote = true;
        }
        // verifica se pode votar
        if (user_can_vote_in_project($user->ID, $_POST['project_id'])) {
            if ($canvote) {
                // se o usuário confirma o voto
                if ($confirms_vote == true) {
                    if (register_vote($user->ID, $_POST['project_id'])) {
                        $response['voted_project_id'] = $_POST['project_id'];
                    } else {
                        $response['success'] = false;
                        $response['code'] = 'error_vote';
                        $response['msg'] = 'Erro ao registrar voto';
                    }
                }
            }
        } else {
            $response['success'] = false;
            $response['code'] = 'error_setorial_uf';
            $response['msg'] = 'Você não se inscreveu nesta setorial deste estado. Por isso, não pode votar, somente participar do debate.';
        }
    } else {
        $response['success'] = false;
        $response['code'] = 'error_vote_closed';
        $response['msg'] = 'A votação não está aberta';
    }
    echo json_encode($response);
    die;
}