Skip to content

Commit f923b5c

Browse files
committed
Fixes to Permissions
1 parent e917c4e commit f923b5c

File tree

3 files changed

+25
-14
lines changed

3 files changed

+25
-14
lines changed

admin/class-bread-admin.php

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -248,9 +248,6 @@ function pwsix_process_settings_export()
248248
if (!isset($_POST['pwsix_export_nonce']) || ! wp_verify_nonce($_POST['pwsix_export_nonce'], 'pwsix_export_nonce')) {
249249
return;
250250
}
251-
if (! current_user_can('manage_bread')) { // TODO: Is this necessary? Why not let the user make a copy
252-
return;
253-
}
254251
$this->download_settings_inner();
255252
}
256253
function download_settings()
@@ -317,13 +314,13 @@ function exportLogFile($file)
317314
}
318315
function current_user_can_modify()
319316
{
320-
if (! current_user_can('manage_bread')) {
321-
return false;
322-
}
323317
$user = wp_get_current_user();
324318
if (in_array('administrator', $user->roles)) {
325319
return true;
326320
}
321+
if (! current_user_can('manage_bread')) {
322+
return false;
323+
}
327324
$authors_safe = $this->bread->getOption('authors');
328325
if (!is_array($authors_safe) || empty($authors_safe)) {
329326
return true;
@@ -335,10 +332,17 @@ function current_user_can_modify()
335332
}
336333
function current_user_can_create()
337334
{
338-
if (! current_user_can('manage_bread')) {
339-
return false;
335+
$user = wp_get_current_user();
336+
if (in_array('administrator', $user->roles)) {
337+
return true;
338+
}
339+
if (current_user_can('manage_options')) {
340+
return true;
341+
}
342+
if (current_user_can('manage_bread')) {
343+
return true;
340344
}
341-
return true;
345+
return false;
342346
}
343347
/**
344348
* Process a settings import from a json file
@@ -348,7 +352,7 @@ function pwsix_process_settings_import()
348352
if (empty($_REQUEST['pwsix_import_nonce']) || !wp_verify_nonce($_REQUEST['pwsix_import_nonce'], 'pwsix_import_nonce')) {
349353
return;
350354
}
351-
if (! current_user_can('manage_bread')) {
355+
if (! $this->current_user_can_modify()) {
352356
return;
353357
}
354358
$this->bread->getConfigurationForSettingId($this->bread->getRequestedSetting());
@@ -376,7 +380,7 @@ function pwsix_process_settings_import()
376380
update_option($this->bread->getOptionsName(), $this->bread->getOptions());
377381
setcookie('current-meeting-list', $this->bread->getRequestedSetting(), time() + 10);
378382
setcookie('bread_import_file', $import_file, time() + 10);
379-
wp_safe_redirect(admin_url('?page=class-bread-admin.php'));
383+
wp_safe_redirect(admin_url('?page=bmlt-enabled-bread'));
380384
}
381385
function my_theme_add_editor_styles()
382386
{
@@ -433,11 +437,15 @@ function admin_submenu_link($parent_slug)
433437
activate_bread();
434438
$this->bmltEnabled_admin->createMenu();
435439

440+
$cap = 'manage_options';
441+
if (!current_user_can($cap)) {
442+
$cap = 'manage_bread';
443+
}
436444
$this->hook = add_submenu_page(
437445
$parent_slug,
438446
'Printable Meeting Lists',
439447
'Printable Meeting Lists',
440-
'manage_bread',
448+
$cap,
441449
'bmlt-enabled-bread',
442450
array(&$this, 'admin_options_page'),
443451
2

bmlt-meeting-list.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* Plugin Name: Bread
1212
* Plugin URI: https://bmlt.app
1313
* Description: Maintains and generates PDF Meeting Lists from BMLT.
14-
* Version: 2.9.6
14+
* Version: 2.9.7
1515
* Author: bmlt-enabled
1616
* Author URI: https://bmlt.app/
1717
* License: GPL-2.0+

readme.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Tags: meeting list, bmlt, narcotics anonymous, na
55
Requires PHP: 8.1
66
Requires at least: 6.2
77
Tested up to: 6.8
8-
Stable tag: 2.9.6
8+
Stable tag: 2.9.7
99

1010
License: GPLv2 or later
1111
License URI: http://www.gnu.org/licenses/gpl-2.0.html
@@ -55,6 +55,9 @@ Follow all these steps, keep in mind that once you start using bread, it's not g
5555

5656
== Changelog ==
5757

58+
= 2.9.7 =
59+
* Bug fixes to permission stuff.
60+
5861
= 2.9.6 =
5962
* Farsi Translation
6063
* Replaced deprecated "chosen" with "select2"

0 commit comments

Comments
 (0)