add tnc_col_all_* capabilities support #274
This commit is contained in:
parent
7e91b4bd69
commit
807fe2759d
|
@ -186,7 +186,14 @@ class Roles {
|
|||
|
||||
$col_id = preg_replace('/[a-z_]+(\d+)[a-z_]+?$/', '$1', $cap );
|
||||
|
||||
if ( $user->has_cap('manage_tainacan_collection_' . $col_id) ) {
|
||||
if ( ! is_numeric($col_id) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// check for tnc_col_all_* capabilities
|
||||
$all_collections_cap = preg_replace('/([a-z_]+)(\d+)([a-z_]+?)$/', '${1}all${3}', $cap );
|
||||
|
||||
if ( $user->has_cap('manage_tainacan_collection_' . $col_id) || $user->has_cap($all_collections_cap) ) {
|
||||
$allcaps = array_merge($allcaps, [ $cap => true ]);
|
||||
} else {
|
||||
// check if the user is the owner
|
||||
|
|
|
@ -278,6 +278,19 @@ class Capabilities extends TAINACAN_UnitTestCase {
|
|||
|
||||
}
|
||||
|
||||
function test_super_all_collection () {
|
||||
|
||||
$this->assertFalse( user_can($this->subscriber, 'tnc_col_25_read_private_filters') );
|
||||
|
||||
$this->subscriber->add_cap('tnc_col_all_read_private_filters');
|
||||
$this->subscriber->get_role_caps();
|
||||
|
||||
$this->assertTrue( user_can($this->subscriber, 'tnc_col_25_read_private_filters') );
|
||||
$this->assertTrue( user_can($this->subscriber, 'tnc_col_36_read_private_filters') );
|
||||
$this->assertFalse( user_can($this->subscriber, 'tnc_col_25_edit_posts') );
|
||||
|
||||
}
|
||||
|
||||
// function test_items_capabilities() {
|
||||
//
|
||||
// $collection = $this->tainacan_entity_factory->create_entity(
|
||||
|
|
Loading…
Reference in New Issue