diff --git a/db/access.php b/db/access.php new file mode 100644 index 0000000..b99f076 --- /dev/null +++ b/db/access.php @@ -0,0 +1,37 @@ +. + +/** + * Version details. + * + * @package local_cohort_profile + * @copyright 2024, Yuriy Yurinskiy + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +defined('MOODLE_INTERNAL') || die; + +$capabilities = array( + 'local/cohort_profile:view_cohort_list' => array( + 'captype' => 'read', + 'contextlevel' => CONTEXT_USER, + 'archetypes' => array( + 'teacher' => CAP_ALLOW, + 'editingteacher' => CAP_ALLOW, + 'manager' => CAP_ALLOW, + ), + ), +); diff --git a/lib.php b/lib.php index fe8bf8e..d3375d7 100644 --- a/lib.php +++ b/lib.php @@ -18,7 +18,7 @@ * This file contains the code for the plugin integration. * * @package local_cohort_profile - * @copyright 2019, Yuriy Yurinskiy + * @copyright 2024, Yuriy Yurinskiy * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ @@ -39,9 +39,19 @@ * @return void */ function local_cohort_profile_myprofile_navigation(core_user\output\myprofile\tree $tree, $user, $iscurrentuser, $course) { - global $CFG, $DB; + global $CFG, $DB, $USER; require_once($CFG->dirroot . '/cohort/lib.php'); + $context = context_user::instance($user->id); + + $hascapability = has_capability('local/cohort_profile:view_cohort_list', $context); + $ownprofile = $user->id == $USER->id; + + # Don't show if user doesn't have capability or is not viewing their own profile + if (!$hascapability && !$ownprofile) { + return; + } + $showallcohorts = optional_param('showallcohorts', 0, PARAM_INT); $sql = 'SELECT %s FROM {cohort} c diff --git a/version.php b/version.php index 54c6510..7157b89 100644 --- a/version.php +++ b/version.php @@ -24,7 +24,7 @@ defined('MOODLE_INTERNAL') || die; -$plugin->version = 2020022200; +$plugin->version = 2020022201; $plugin->requires = 2018120300; $plugin->component = 'local_cohort_profile'; $plugin->maturity = MATURITY_STABLE;