Commit e8098be1 authored by joelstein's avatar joelstein Committed by tstoeckler

Issue #2816781 by joelstein: Add a 'access library reports' permission

parent e4d4d58c
Libraries 7.x-2.x, xxxx-xx-xx Libraries 7.x-2.x, xxxx-xx-xx
----------------------------- -----------------------------
#2816781 by joelstein: Add a 'access library reports' permission.
#2823735 by amanaplan, tstoeckler: Add admin_menu cache clear integration. #2823735 by amanaplan, tstoeckler: Add admin_menu cache clear integration.
#2745763 by Albert Volkman, tstoeckler: Allow downloading all libraries at once. #2745763 by Albert Volkman, tstoeckler: Allow downloading all libraries at once.
#2310753 by tstoeckler: Avoid libraries_get_libraries() scanning the root. #2310753 by tstoeckler: Avoid libraries_get_libraries() scanning the root.
......
...@@ -34,3 +34,13 @@ function libraries_update_7201() { ...@@ -34,3 +34,13 @@ function libraries_update_7201() {
// during the 7.x-2.x cycle. // during the 7.x-2.x cycle.
registry_rebuild(); registry_rebuild();
} }
/**
* Grant the "View library reports" permission to roles with the "View site reports" permission.
*/
function libraries_update_7202() {
$rids = array_keys(user_roles(FALSE, 'access site reports'));
foreach ($rids as $rid) {
_update_7000_user_role_grant_permissions($rid, array('access library reports'), 'libraries');
}
}
...@@ -927,6 +927,17 @@ function libraries_help($path, $arg) { ...@@ -927,6 +927,17 @@ function libraries_help($path, $arg) {
} }
} }
/**
* Implements hook_permission().
*/
function libraries_permission() {
return array(
'access library reports' => array(
'title' => t('View library reports'),
),
);
}
/** /**
* Implements hook_menu(). * Implements hook_menu().
*/ */
...@@ -937,7 +948,7 @@ function libraries_menu() { ...@@ -937,7 +948,7 @@ function libraries_menu() {
'description' => 'An overview of libraries installed on this site.', 'description' => 'An overview of libraries installed on this site.',
'page callback' => 'drupal_get_form', 'page callback' => 'drupal_get_form',
'page arguments' => array('libraries_admin_overview'), 'page arguments' => array('libraries_admin_overview'),
'access arguments' => array('access site reports'), 'access arguments' => array('access library reports'),
'file' => 'libraries.admin.inc' 'file' => 'libraries.admin.inc'
); );
$items['admin/reports/libraries/%libraries_ui'] = array( $items['admin/reports/libraries/%libraries_ui'] = array(
...@@ -945,7 +956,7 @@ function libraries_menu() { ...@@ -945,7 +956,7 @@ function libraries_menu() {
'description' => 'Status overview for a single library', 'description' => 'Status overview for a single library',
'page callback' => 'drupal_get_form', 'page callback' => 'drupal_get_form',
'page arguments' => array('libraries_admin_library_status_form', 3), 'page arguments' => array('libraries_admin_library_status_form', 3),
'access arguments' => array('access site reports'), 'access arguments' => array('access library reports'),
'file' => 'libraries.admin.inc' 'file' => 'libraries.admin.inc'
); );
return $items; return $items;
......
...@@ -40,7 +40,7 @@ class LibrariesAdminWebTest extends LibrariesWebTestBase { ...@@ -40,7 +40,7 @@ class LibrariesAdminWebTest extends LibrariesWebTestBase {
* Tests the libraries report at /admin/reports/libraries. * Tests the libraries report at /admin/reports/libraries.
*/ */
public function testLibrariesReportOverview() { public function testLibrariesReportOverview() {
$this->getWithPermissions(array('access site reports'), 'admin/reports/libraries'); $this->getWithPermissions(array('access library reports'), 'admin/reports/libraries');
// Assert the page title and table titles show up. // Assert the page title and table titles show up.
$this->assertText('Libraries'); $this->assertText('Libraries');
$this->assertRaw('<h2>Installed</h2>'); $this->assertRaw('<h2>Installed</h2>');
...@@ -84,7 +84,7 @@ class LibrariesAdminWebTest extends LibrariesWebTestBase { ...@@ -84,7 +84,7 @@ class LibrariesAdminWebTest extends LibrariesWebTestBase {
* Tests the libraries report for an installed library. * Tests the libraries report for an installed library.
*/ */
public function testLibrariesReportInstalled() { public function testLibrariesReportInstalled() {
$this->getWithPermissions(array('access site reports'), 'admin/reports/libraries/example_files'); $this->getWithPermissions(array('access library reports'), 'admin/reports/libraries/example_files');
$this->assertRaw('Status report for library <em class="placeholder">Example files</em>'); $this->assertRaw('Status report for library <em class="placeholder">Example files</em>');
$this->assertRaw('The <em class="placeholder">Example files</em> library is installed correctly.'); $this->assertRaw('The <em class="placeholder">Example files</em> library is installed correctly.');
// Check that the information in the status report is displayed. // Check that the information in the status report is displayed.
...@@ -99,7 +99,7 @@ class LibrariesAdminWebTest extends LibrariesWebTestBase { ...@@ -99,7 +99,7 @@ class LibrariesAdminWebTest extends LibrariesWebTestBase {
* Tests the libraries report for a missing library. * Tests the libraries report for a missing library.
*/ */
public function testLibrariesReportMissing() { public function testLibrariesReportMissing() {
$this->getWithPermissions(array('access site reports'), 'admin/reports/libraries/example_missing'); $this->getWithPermissions(array('access library reports'), 'admin/reports/libraries/example_missing');
$this->assertRaw('Status report for library <em class="placeholder">Example missing</em>'); $this->assertRaw('Status report for library <em class="placeholder">Example missing</em>');
$this->assertRaw('The <em class="placeholder">Example missing</em> library could not be found.'); $this->assertRaw('The <em class="placeholder">Example missing</em> library could not be found.');
// Check that the download link is being displayed. // Check that the download link is being displayed.
...@@ -111,7 +111,7 @@ class LibrariesAdminWebTest extends LibrariesWebTestBase { ...@@ -111,7 +111,7 @@ class LibrariesAdminWebTest extends LibrariesWebTestBase {
* Tests the libraries report for a missing library. * Tests the libraries report for a missing library.
*/ */
public function testLibrariesReportNotDetected() { public function testLibrariesReportNotDetected() {
$this->getWithPermissions(array('access site reports'), 'admin/reports/libraries/example_undetected_version'); $this->getWithPermissions(array('access library reports'), 'admin/reports/libraries/example_undetected_version');
$this->assertRaw('Status report for library <em class="placeholder">Example undetected version</em>'); $this->assertRaw('Status report for library <em class="placeholder">Example undetected version</em>');
$this->assertRaw('The version of the <em class="placeholder">Example undetected version</em> library could not be detected.'); $this->assertRaw('The version of the <em class="placeholder">Example undetected version</em> library could not be detected.');
} }
...@@ -120,7 +120,7 @@ class LibrariesAdminWebTest extends LibrariesWebTestBase { ...@@ -120,7 +120,7 @@ class LibrariesAdminWebTest extends LibrariesWebTestBase {
* Tests the libraries report for a missing library. * Tests the libraries report for a missing library.
*/ */
public function testLibrariesReportNotSupported() { public function testLibrariesReportNotSupported() {
$this->getWithPermissions(array('access site reports'), 'admin/reports/libraries/example_unsupported_version'); $this->getWithPermissions(array('access library reports'), 'admin/reports/libraries/example_unsupported_version');
$this->assertRaw('Status report for library <em class="placeholder">Example unsupported version</em>'); $this->assertRaw('Status report for library <em class="placeholder">Example unsupported version</em>');
$this->assertRaw('The installed version <em class="placeholder">1</em> of the <em class="placeholder">Example unsupported version</em> library is not supported.'); $this->assertRaw('The installed version <em class="placeholder">1</em> of the <em class="placeholder">Example unsupported version</em> library is not supported.');
// Check that the download link is being displayed. // Check that the download link is being displayed.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment