Skip to content

Commit

Permalink
shoutbox access git
Browse files Browse the repository at this point in the history
  • Loading branch information
karrak1 committed Oct 2, 2021
1 parent 829cf4c commit 291af47
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 7 deletions.
5 changes: 3 additions & 2 deletions infusions/shoutbox_panel/infusion.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
// Infusion general information
$inf_title = $locale['SB_title'];
$inf_description = $locale['SB_desc'];
$inf_version = "1.1.0";
$inf_version = "1.1.1";
$inf_developer = "PHP Fusion Development Team";
$inf_email = "info@phpfusion.com";
$inf_weburl = "https://phpfusion.com";
Expand Down Expand Up @@ -50,7 +50,8 @@
$settings = [
'visible_shouts' => 5,
'guest_shouts' => 0,
'hidden_shouts' => 0
'hidden_shouts' => 0,
'user_access' => 0
];

foreach ($settings as $name => $value) {
Expand Down
12 changes: 7 additions & 5 deletions infusions/shoutbox_panel/shoutbox.php
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,8 @@ private function setShoutboxDb() {
$inputArray = [
'visible_shouts' => sanitizer('visible_shouts', 5, 'visible_shouts'),
'guest_shouts' => check_post('guest_shouts') ? 1 : 0,
'hidden_shouts' => sanitizer(['hidden_shouts'], '', 'hidden_shouts')
'hidden_shouts' => check_post('hidden_shouts') ? 1 : 0,
'user_access' => sanitizer(['user_access'], '', 'user_access')
];

if (fusion_safe()) {
Expand Down Expand Up @@ -286,7 +287,7 @@ public function sbForm($form_name = 'sbform') {
}
$html = '';

if (iGUEST && !self::$sb_settings['guest_shouts'] && !checkgroup(self::$sb_settings['hidden_shouts'])) {
if (iGUEST && !self::$sb_settings['guest_shouts'] && empty(self::$sb_settings['hidden_shouts']) && !checkgroup(self::$sb_settings['user_access'])) {
$html .= "<div class='text-center'>".self::$locale['SB_login_req']."</div>\n";
} else {
$html .= openform($form_name, 'post', $this->postLink);
Expand Down Expand Up @@ -332,7 +333,7 @@ public function sbForm($form_name = 'sbform') {
$html .= form_hidden('shout_language', '', $this->data['shout_language']);
}

if (iMEMBER && checkgroup(self::$sb_settings['hidden_shouts'])) {
if (iMEMBER && self::$sb_settings['hidden_shouts']) {
$html .= "<div class='btn-group btn-group-sm dropup'>
".form_button('shout_box', (empty(get('shout_id')) ? self::$locale['SB_save_shout'] : (get('s_action') == 'reply' ? self::$locale['SB_reply'] : self::$locale['SB_update_shout'])), (empty(get('shout_id')) ? self::$locale['send_message'] : (get('s_action') == 'reply' ? self::$locale['SB_reply'] : self::$locale['SB_update_shout'])), ['class' => 'btn-primary'])."
<button id='ddsg' type='button' class='btn btn-default dropdown-toggle' data-toggle='dropdown' aria-haspopup='true' aria-expanded='false'>";
Expand Down Expand Up @@ -367,9 +368,10 @@ public function settingsForm() {
openside('');
echo form_text('visible_shouts', self::$locale['SB_visible_shouts'], self::$sb_settings['visible_shouts'], ['required' => TRUE, 'inline' => TRUE, 'inner_width' => '100px', "type" => "number"]);
echo form_checkbox('guest_shouts', self::$locale['SB_guest_shouts'], self::$sb_settings['guest_shouts'], ['toggle' => TRUE]);
echo form_select('hidden_shouts[]', self::$locale['SB_hidden_shouts'], self::$sb_settings['hidden_shouts'], [
echo form_checkbox('hidden_shouts', self::$locale['SB_hidden_shouts'], self::$sb_settings['hidden_shouts'], ['toggle' => TRUE]);
echo form_select('user_access[]', self::$locale['SB_visbility'], self::$sb_settings['user_access'], [
'options' => fusion_get_groups(),
'placeholder' => $locale['choose']
'placeholder' => self::$locale['choose']
]);
echo form_button('sb_settings', self::$locale['save'], self::$locale['save'], ['class' => 'btn-success']);
closeside();
Expand Down
28 changes: 28 additions & 0 deletions infusions/shoutbox_panel/upgrade/1.1.1.upgrade.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php
/*-------------------------------------------------------+
| PHPFusion Content Management System
| Copyright (C) PHP Fusion Inc
| https://phpfusion.com/
+--------------------------------------------------------+
| Filename: 1.1.1.upgrade.inc
| Author: Core Development Team
+--------------------------------------------------------+
| This program is released as free software under the
| Affero GPL license. You can redistribute it and/or
| modify it under the terms of this license which you
| can read by viewing the included agpl.txt or online
| at www.gnu.org/licenses/agpl.html. Removal of this
| copyright header is strictly prohibited without
| written permission from the original author(s).
+--------------------------------------------------------*/
$inf_version = '1.1.1';

$settings = get_settings('shoutbox_panel');
$check_array = [
'user_access' => 0
];
foreach ($check_array as $key => $value) {
if (!isset($settings[$key])) {
$inf_insertdbrow[] = DB_SETTINGS_INF." (settings_name, settings_value, settings_inf) VALUES ('$key', '$value', 'shoutbox_panel')";
}
}

0 comments on commit 291af47

Please sign in to comment.