Skip to content

Commit

Permalink
Merge pull request #55 from OCTRI/reddev-539-perm-fix
Browse files Browse the repository at this point in the history
REDDEV-539 removed check for module access
  • Loading branch information
wsams authored Jul 19, 2018
2 parents f8a4cb1 + 9066e35 commit 637aabc
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 20 deletions.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,15 @@ in a time series fashion to provide additional insights about their project.
# Vizr Installation and Upgrades

See [INSTALL.md](INSTALL.md).

# Vizr Permissions

All users of a project with Vizr enabled may view charts.

For users that also need to create, edit, and delete charts you must give them **Project Design and Setup** rights. To do so follow these steps:

* Navigate, on a project with Vizr, to **User Rights**
* Select a user
* Click **Edit user privileges**
* Under **Highest level privileges** check **Project Design and Setup*
* Save
21 changes: 8 additions & 13 deletions Vizr.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,16 @@
class Vizr extends AbstractExternalModule {

/**
* Override to check for Vizr User Rights. Else returns the parent value
* which checks for design rights.
* Override to allow anyone with project access to be able to view Vizr charts. The
* user will need `Project Design and Setup` rights in order to create, edit, and
* delete charts.
*/
public function redcap_module_link_check_display($project_id, $link) {
$rights = \REDCap::getUserRights(USERID);
if ($this->hasVizrUserRights($rights)) {
return $link;
} else {
return parent::redcap_module_link_check_display($project_id, $link);
}
return $link;
}

/**
* Checks to see if a user has user rights for the Vizr external module on
* the current project.
* Checks to see if a user has module rights for Vizr on the current project.
* @param array $rights Array of user rights from <code>REDCap::getUserRights</code>.
*/
public function hasVizrUserRights($rights) {
Expand All @@ -39,12 +34,12 @@ public function hasDesignRights($rights) {
}

/**
* Checks to see if the user can edit charts. A user can edit charts if they
* are a super user or have design or user rights for the vizr module.
* Checks to see if the user can edit charts in Vizr. A user can edit charts if they
* are a super user or have design rights.
*/
public function canEditVizrCharts() {
$rights = \REDCap::getUserRights(USERID);
return SUPER_USER || $this->hasDesignRights($rights) || $this->hasVizrUserRights($rights);
return SUPER_USER || $this->hasDesignRights($rights);
}

}
7 changes: 0 additions & 7 deletions config.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,6 @@
"permissions": [
"select_data"
],
"project-settings": [
{
"key": "vizr-descriptive",
"name": "To configure a chart, click the Vizr link under <strong>External Modules</strong> on the left navigation bar. On that page there's a link titled \"Vizr charts are configured\" which contains documentation for building charts.",
"type": "descriptive"
}
],
"links": {
"project": [
{
Expand Down

0 comments on commit 637aabc

Please sign in to comment.