Skip to content

Commit

Permalink
Add Reply function to shoutbox
Browse files Browse the repository at this point in the history
  • Loading branch information
RobiNN1 committed Sep 6, 2021
1 parent 88e7a07 commit d925fa7
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 13 deletions.
2 changes: 2 additions & 0 deletions infusions/shoutbox_panel/locale/English/shoutbox.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
$locale['SB_login_req'] = "You must login to post a message.";
$locale['SB_message'] = "Message";
$locale['SB_name'] = "Name";
$locale['SB_reply'] = "Reply";
$locale['SB_reply_to'] = "Reply to:";
$locale['SB_no_msgs'] = "No messages have been posted.";
$locale['SB_noentries'] = "Not Selected Shout.";
$locale['SB_save_shout'] = "Save Shout";
Expand Down
13 changes: 10 additions & 3 deletions infusions/shoutbox_panel/shoutbox.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function __construct() {
// Just use this. You do not want "s_action" and "shoutbox_id"
$this->postLink = clean_request("", ["s_action", "shout_id"], FALSE);

switch (get("s_action")) {
switch (get('s_action')) {
case 'delete':
$id = defined('ADMIN_PANEL') ? get("shout_id") : $this->getSecureShoutId(get("shout_id"));
self::deleteShout($id);
Expand All @@ -73,7 +73,7 @@ public function __construct() {
}
break;
case 'edit':
$id = defined('ADMIN_PANEL') ? get("shout_id") : $this->getSecureShoutId(get("shout_id"));
$id = defined('ADMIN_PANEL') ? get('shout_id') : $this->getSecureShoutId(get('shout_id'));

if (self::verifyShout($id)) {
$result = dbquery("SELECT shout_id, shout_name, shout_message, shout_datestamp, shout_ip, shout_ip_type, shout_hidden, shout_language
Expand All @@ -86,6 +86,10 @@ public function __construct() {
}
}
break;
case 'reply':
$id = defined('ADMIN_PANEL') ? get('shout_id') : $this->getSecureShoutId(get('shout_id'));
$this->data['shout_message'] = self::$locale['SB_reply_to'].' [shoutid-'.$id.']';
break;
default:
break;
}
Expand Down Expand Up @@ -359,7 +363,6 @@ public function sbForm($form_name = 'sbform') {
}

public function settingsForm() {

add_to_jquery("$('#sb_delete_old').bind('click', function() { return confirm('".self::$locale['SB_warning_shouts']."'); });");
echo openform('shoutbox', 'post', $this->postLink);

Expand Down Expand Up @@ -519,6 +522,8 @@ public function getShoutboxData($archive = FALSE) {
$data['user_name'] = !empty($data['user_id']) ? $data['user_name'] : $data['shout_name'];
if ((iADMIN && checkrights("S")) || (iMEMBER && $data['shout_name'] == fusion_get_userdata('user_id') && isset($data['user_name']))) {
$shout_id = $this->doSecureShoutId($data['shout_id']);
$data['reply_link'] = INFUSIONS.'shoutbox_panel/shoutbox_archive.php?s_action=reply&shout_id='.$shout_id;
$data['reply_title'] = self::$locale['SB_reply'];
$data['edit_link'] = INFUSIONS.'shoutbox_panel/shoutbox_archive.php?s_action=edit&shout_id='.$shout_id;
$data['edit_title'] = self::$locale['edit'];
$data['delete_link'] = INFUSIONS.'shoutbox_panel/shoutbox_archive.php?s_action=delete&shout_id='.$shout_id;
Expand All @@ -532,6 +537,8 @@ public function getShoutboxData($archive = FALSE) {
'add_line_breaks' => TRUE
]);

$data['message'] = preg_replace('#\[shoutid-(.*?)\]#i', '<a href="#shout\1">#\1</a>', $data['message']);

$sdata['items'][] = $data;
}
}
Expand Down
27 changes: 17 additions & 10 deletions infusions/shoutbox_panel/templates/shoutbox.tpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,30 @@ function render_shoutbox($info) {
if (!empty($info['items'])) {
echo '<div class="shoutbox-items m-t-10">';
foreach ($info['items'] as $item) {
echo '<div class="shoutbox-item clearfix m-b-10">';
echo '<div class="shoutbox-item clearfix m-b-20" id="shout'.$item['shout_id'].'">';
echo '<div class="shoutboxavatar pull-left m-r-5 m-t-5">';
echo display_avatar($item, '30px', '', !empty($item['user_id']), 'img-rounded');
echo display_avatar($item, '20px', '', !empty($item['user_id']), 'img-rounded');

if (!empty($item['user_lastvisit'])) {
echo '<span style="font-size:7px;position:absolute;margin-left:-5px;margin-top:-3px;">';
echo '<i class="fas fa-circle text-'.($item['user_lastvisit'] >= time() - 300 ? 'success' : 'danger').'"></i>';
echo '</span>';
}
echo '</div>';

if (!empty($item['edit_link']) && !empty($item['delete_link'])) {
echo '<div class="pull-right btn-group btn-group-xs">';
echo '<a class="btn btn-default" href="'.$item['edit_link'].'" title="'.$item['edit_title'].'"><i class="fa fa-edit"></i></a>';
echo '<a class="btn btn-default" href="'.$item['delete_link'].'" title="'.$item['delete_title'].'"><i class="fa fa-trash"></i></a>';
echo '</div>';
}
echo '<div class="pull-right btn-group btn-group-xs">';
echo '<a class="btn btn-default" href="'.$item['reply_link'].'" title="'.$item['reply_title'].'"><i class="fas fa-reply"></i></a>';

$online = !empty($item['user_lastvisit']) ? '<span style="color: #5CB85C; font-size: 10px;"><i class="m-l-5 m-r-5 fa fa-'.($item['user_lastvisit'] >= time() - 300 ? 'circle' : 'circle-thin').'"></i></span>' : '';
if (!empty($item['edit_link']) && !empty($item['delete_link'])) {
echo '<a class="btn btn-default" href="'.$item['edit_link'].'" title="'.$item['edit_title'].'"><i class="fas fa-edit"></i></a>';
echo '<a class="btn btn-default" href="'.$item['delete_link'].'" title="'.$item['delete_title'].'"><i class="fas fa-trash"></i></a>';
}
echo '</div>';

echo '<div class="clearfix">';
echo '<strong class="display-block">'.(!empty($item['user_id']) ? $item['profile_link'].$online : '<span class="m-r-5">'.$item['shout_name'].'</span>').'</strong>';
echo '<strong class="display-block">'.(!empty($item['user_id']) ? $item['profile_link'] : $item['shout_name']).'</strong>';
echo timer($item['shout_datestamp']);
echo '<span class="m-l-5">#'.$item['shout_id'].'</span>';
echo '</div>';

echo '<div class="shoutbox-message word-break">'.$item['message'].'</div>';
Expand Down

0 comments on commit d925fa7

Please sign in to comment.