Skip to content

Commit

Permalink
Working on #2972 Template Conversion to Twig Format (xmlhttp) (#3258)
Browse files Browse the repository at this point in the history
* Converted xmlhttp

* Fixed indenting
  • Loading branch information
Shade- authored and euantorano committed Jun 2, 2019
1 parent 329ba53 commit 04d8942
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 18 deletions.
51 changes: 51 additions & 0 deletions inc/views/base/xmlhttp/buddyselect.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<table border="0" cellspacing="1" cellpadding="4" class="tborder" style="width: 300px;">
<thead>
<tr>
<td class="thead">
<div class="float_right" style="margin-top: 3px;">
<span class="smalltext">
<a href="javascript:void(0)" onclick="UserCP.closeBuddySelect(true); return false;">{{ lang.close }}</a>
</span>
</div>
<div><strong>{{ lang.select_buddies }}</strong></div>
</td>
</tr>
</thead>
<tbody>
<tr>
<td class="trow1 smalltext">{{ lang.select_buddies_desc }}</td>
</tr>
<tr>
<td class="trow2">
<div style="height: 200px; overflow: auto;" >
<table border="0" cellspacing="1" cellpadding="4" class="tborder" style="border: 0; width: 270px;" align="right">
{% for buddy in buddies %}
{% if buddy.lastactive > ('now'|date('U') - mybb.settings.wolcutoff) and (buddy.invisible == 0 or mybb.user.usergroup == 4) and buddy.lastvisit != buddy.lastactive %}
{% set status = 'online' %}
{% else %}
{% set status = 'offline' %}
{% endif %}
<tr>
<td class="trow1" onmouseover="this.className='trow2';" onmouseout="this.className='trow1';">
<label>
<input type="checkbox" style="vertical-align: middle;" id="checkbox_{{ buddy.uid }}" onclick="UserCP.selectBuddy('{{ buddy.uid }}', '{{ buddy.username }}');" /> <img src="{{ theme.imgdir }}/buddy_{{ status }}.png" alt="({{ attribute(lang, status) }})" title="{{ attribute(lang, status) }}" style="vertical-align: middle;" /> {{ buddy.fusername }}
</label>
</td>
</tr>
{% endfor %}
</table>
</div>
</td>
</tr>
<tr>
<td class="trow1">
<div class="smalltext"><strong>{{ lang.selected_recipients }}</strong></div>
<div id="buddyselect_buddies" class="smalltext" style="padding-left: 10px; height: 50px; overflow: auto;"></div>
<div style="text-align: right;">
<input type="button" class="button" value="{{ lang.ok }}" onclick="UserCP.closeBuddySelect();" />
<input type="button" class="button" value="{{ lang.cancel }}" onclick="UserCP.closeBuddySelect(true);" />
</div>
</td>
</tr>
</tbody>
</table>
25 changes: 7 additions & 18 deletions xmlhttp.php
Original file line number Diff line number Diff line change
Expand Up @@ -1040,31 +1040,20 @@

$plugins->run_hooks("xmlhttp_get_buddyselect_start");

$timecut = TIME_NOW - $mybb->settings['wolcutoff'];
$query = $db->simple_select("users", "uid, username, usergroup, displaygroup, lastactive, lastvisit, invisible", "uid IN ({$mybb->user['buddylist']})", $query_options);
$online = array();
$offline = array();
$buddies = [];
while($buddy = $db->fetch_array($query))
{
$buddy['username'] = htmlspecialchars_uni($buddy['username']);
$buddy_name = format_name($buddy['username'], $buddy['usergroup'], $buddy['displaygroup']);
$profile_link = build_profile_link($buddy_name, $buddy['uid'], '_blank');
if($buddy['lastactive'] > $timecut && ($buddy['invisible'] == 0 || $mybb->user['usergroup'] == 4) && $buddy['lastvisit'] != $buddy['lastactive'])
{
eval("\$online[] = \"".$templates->get("xmlhttp_buddyselect_online")."\";");
}
else
{
eval("\$offline[] = \"".$templates->get("xmlhttp_buddyselect_offline")."\";");
}
$buddy['fusername'] = format_name(htmlspecialchars_uni($buddy['username']), $buddy['usergroup'], $buddy['displaygroup']);
$buddy['fusername'] = build_profile_link($buddy['fusername'], $buddy['uid'], '_blank');
$buddies[] = $buddy;
}
$online = implode("", $online);
$offline = implode("", $offline);

$plugins->run_hooks("xmlhttp_get_buddyselect_end");

eval("\$buddy_select = \"".$templates->get("xmlhttp_buddyselect")."\";");
echo $buddy_select;
echo \MyBB\template('xmlhttp/buddyselect.twig', [
'buddies' => $buddies
]);
}
else
{
Expand Down

0 comments on commit 04d8942

Please sign in to comment.