From ccc7d3012bfc2d62aca2da9d008d912faf100b16 Mon Sep 17 00:00:00 2001 From: DariusIII Date: Thu, 13 Apr 2017 09:44:06 +0200 Subject: [PATCH] Fix settings statuses of groups in admin groups page --- Changelog | 1 + nntmux/Groups.php | 2 +- www/admin/ajax.php | 18 +++++++++--------- www/admin/ajax_group-edit.php | 4 ++-- www/admin/group-edit.php | 18 +++++++++--------- www/admin/group-list.php | 6 +++--- 6 files changed, 25 insertions(+), 24 deletions(-) diff --git a/Changelog b/Changelog index 041d34f7e..69aa9eebe 100755 --- a/Changelog +++ b/Changelog @@ -1,4 +1,5 @@ 2017-04-13 DariusIII + * Fix: Fix settings statuses of groups in admin groups page * Chg: Update forum and forumpost related tpl's and pages 2017-04-12 DariusIII * Chg: Update dariusiii/rarinfo package diff --git a/nntmux/Groups.php b/nntmux/Groups.php index 103bdf241..5de519911 100755 --- a/nntmux/Groups.php +++ b/nntmux/Groups.php @@ -576,7 +576,7 @@ class Groups WHERE id = {$id}" ); - return "Group {$id}: {$column} has been " . (($status == 0) ? 'deactivated' : 'activated') . '.'; + return "Group {$id}: {$column} has been " . (($status === 0) ? 'deactivated' : 'activated') . '.'; } /** diff --git a/www/admin/ajax.php b/www/admin/ajax.php index 4dd826f71..bd2a5ef9d 100644 --- a/www/admin/ajax.php +++ b/www/admin/ajax.php @@ -45,12 +45,12 @@ switch($_GET['action']) { case 'group_edit_purge_all': session_write_close(); (new Groups($settings))->purge(); - print "All groups purged."; + print 'All groups purged.'; break; case 'group_edit_reset_all': (new Groups($settings))->resetall(); - print "All groups reset."; + print 'All groups reset.'; break; case 'group_edit_purge_single': @@ -88,17 +88,17 @@ switch($_GET['action']) { case 'sharing_toggle_status': $admin->settings->queryExec(sprintf('UPDATE sharing_sites SET enabled = %d WHERE id = %d', $_GET['site_status'], $_GET['site_id'])); - print ($_GET['site_status'] == 1 ? 'Activated' : 'Deactivated') . ' site ' . $_GET['site_id']; + print ($_GET['site_status'] === 1 ? 'Activated' : 'Deactivated') . ' site ' . $_GET['site_id']; break; case 'sharing_toggle_enabled': $admin->settings->queryExec(sprintf('UPDATE sharing SET enabled = %d', $_GET['enabled_status'])); - print ($_GET['enabled_status'] == 1 ? 'Enabled' : 'Disabled') . ' sharing!'; + print ($_GET['enabled_status'] === 1 ? 'Enabled' : 'Disabled') . ' sharing!'; break; case 'sharing_start_position': $admin->settings->queryExec(sprintf('UPDATE sharing SET start_position = %d', $_GET['start_position'])); - print ($_GET['start_position'] == 1 ? 'Enabled' : 'Disabled') . ' fetching from start of group!'; + print ($_GET['start_position'] === 1 ? 'Enabled' : 'Disabled') . ' fetching from start of group!'; break; case 'sharing_reset_settings': @@ -128,22 +128,22 @@ switch($_GET['action']) { case 'sharing_toggle_posting': $admin->settings->queryExec(sprintf('UPDATE sharing SET posting = %d', $_GET['posting_status'])); - print ($_GET['posting_status'] == 1 ? 'Enabled' : 'Disabled') . ' posting!'; + print ($_GET['posting_status'] === 1 ? 'Enabled' : 'Disabled') . ' posting!'; break; case 'sharing_toggle_fetching': $admin->settings->queryExec(sprintf('UPDATE sharing SET fetching = %d', $_GET['fetching_status'])); - print ($_GET['fetching_status'] == 1 ? 'Enabled' : 'Disabled') . ' fetching!'; + print ($_GET['fetching_status'] === 1 ? 'Enabled' : 'Disabled') . ' fetching!'; break; case 'sharing_toggle_site_auto_enabling'; $admin->settings->queryExec(sprintf('UPDATE sharing SET auto_enable = %d', $_GET['auto_status'])); - print ($_GET['auto_status'] == 1 ? 'Enabled' : 'Disabled') . ' automatic site enabling!'; + print ($_GET['auto_status'] === 1 ? 'Enabled' : 'Disabled') . ' automatic site enabling!'; break; case 'sharing_toggle_hide_users': $admin->settings->queryExec(sprintf('UPDATE sharing SET hide_users = %d', $_GET['hide_status'])); - print ($_GET['hide_status'] == 1? 'Enabled' : 'Disabled') . ' hiding of user names!'; + print ($_GET['hide_status'] === 1? 'Enabled' : 'Disabled') . ' hiding of user names!'; break; case 'sharing_toggle_all_sites': diff --git a/www/admin/ajax_group-edit.php b/www/admin/ajax_group-edit.php index c2d93e089..ba5c9a14a 100644 --- a/www/admin/ajax_group-edit.php +++ b/www/admin/ajax_group-edit.php @@ -35,11 +35,11 @@ if (isset($_GET['action']) && $_GET['action'] === 2) { $id = (int)$_GET['group_id']; if(isset($_GET['group_status'])) { $status = isset($_GET['group_status']) ? (int)$_GET['group_status'] : 0; - print $group->updateGroupStatus($id, $status); + print $group->updateGroupStatus($id, 'active', $status); } if(isset($_GET['backfill_status'])) { $status = isset($_GET['backfill_status']) ? (int)$_GET['backfill_status'] : 0; - print $group->updateGroupStatus($id, $status); + print $group->updateGroupStatus($id, 'backfill', $status); } } } diff --git a/www/admin/group-edit.php b/www/admin/group-edit.php index db0b0c920..8dd417916 100644 --- a/www/admin/group-edit.php +++ b/www/admin/group-edit.php @@ -10,31 +10,31 @@ $groups = new Groups(['Settings' => $page->settings]); $id = 0; // Set the current action. -$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : 'view'; +$action = $_REQUEST['action'] ?? 'view'; switch($action) { case 'submit': - if ($_POST["id"] == "") { + if ($_POST['id'] === '') { // Add a new group. - $_POST["name"] = $groups->isValidGroup($_POST["name"]); - if ($_POST["name"] !== false) { + $_POST['name'] = $groups->isValidGroup($_POST['name']); + if ($_POST['name'] !== false) { $groups->add($_POST); } } else { // Update an existing group. $groups->update($_POST); } - header("Location:".WWW_TOP."/group-list.php"); + header('Location:' . WWW_TOP . '/group-list.php'); break; case 'view': default: - if (isset($_GET["id"])) { - $page->title = "Newsgroup Edit"; - $id = $_GET["id"]; + if (isset($_GET['id'])) { + $page->title = 'Newsgroup Edit'; + $id = $_GET['id']; $group = $groups->getByID($id); } else { - $page->title = "Newsgroup Add"; + $page->title = 'Newsgroup Add'; $group = [ 'id' => '', 'name' => '', diff --git a/www/admin/group-list.php b/www/admin/group-list.php index f7ca674b0..83cbd60bb 100644 --- a/www/admin/group-list.php +++ b/www/admin/group-list.php @@ -6,8 +6,8 @@ use nntmux\Groups; $page = new AdminPage(); $groups = new Groups(['Settings' => $page->settings]); -$groupName = (isset($_REQUEST['groupname']) && !empty($_REQUEST['groupname']) ? $_REQUEST['groupname'] : ''); -$offset = (isset($_REQUEST['offset']) ? $_REQUEST['offset'] : 0); +$groupName = $_REQUEST['groupname'] ?? ''; +$offset = $_REQUEST['offset'] ?? 0; $page->smarty->assign( [ @@ -16,7 +16,7 @@ $page->smarty->assign( 'pageroffset' => $offset, 'pageritemsperpage' => ITEMS_PER_PAGE, 'pagerquerybase' => - WWW_TOP . "/group-list.php?" . (($groupName != '') ? "groupname=$groupName&" : '') . 'offset=', + WWW_TOP . '/group-list.php?' . (($groupName !== '') ? "groupname=$groupName" : '') . '&offset=', 'pagerquerysuffix' => '', 'grouplist' => $groups->getRange($offset, ITEMS_PER_PAGE, $groupName, -1) ]