Skip to content

Commit

Permalink
feature - Course Size - minor updates
Browse files Browse the repository at this point in the history
  • Loading branch information
ChaoticDalo committed Feb 20, 2024
1 parent 4001d78 commit bc47e5e
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 11 deletions.
2 changes: 1 addition & 1 deletion report/coursesize/course.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

$courseid = required_param('id', PARAM_INT);

$isspeshul = lsu_snippets::role_check_course_size($courseid);
$isspeshul = lsu_snippets::role_check_course_size($courseid, "report_coursesize_manualroles");

// Check to see if we are allowing special access to this page.
if (!$isspeshul['found']) {
Expand Down
7 changes: 1 addition & 6 deletions report/coursesize/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
Expand Down Expand Up @@ -234,14 +234,9 @@
$row[] = display_size($totalbackupsize);
$coursetable->data[] = $row;



$downloaddata[] = [get_string('total'), '', display_size($totalsize), display_size($totalbackupsize)];
unset($courses);




$systemsizereadable = display_size($systemsize);
$systembackupreadable = display_size($systembackupsize);

Expand Down
18 changes: 16 additions & 2 deletions theme/lsu.php
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,11 @@ public function are_you_student() {
*/
class lsu_snippets {

/**
* A simple function to remove double spaces in between words and trim the edges.
* @param string $word The string to clean.
* @return string $word The cleaned string.
*/
private static function quick_string_clean($word) {
// Make sure there are not double spaces.
$word = str_replace(" ", " ", $word);
Expand Down Expand Up @@ -315,7 +320,14 @@ public static function config_to_array($configstring, $arraytype = "multi", $boo
return $final;
}

public static function role_check_course_size($cid = 0) {
/**
* This grabs the rols from a plugins settings (manual entries) and checks to
* see if they have access.
* @param integer $cid course id number.
* @param string $plugin the name of the setting to get.
* @return [array] Array showing if it was found and if they have access.
*/
public static function role_check_course_size($cid = 0, $plugin = "") {
global $OUTPUT, $COURSE, $CFG, $USER;

$found = false;
Expand All @@ -333,7 +345,9 @@ public static function role_check_course_size($cid = 0) {
}
$role = key($roles);
$rolename = $roles[$role]->shortname;
if ($customroles = self::config_to_array('report_coursesize_manualroles', "comma", true)) {

// Get the list of roles in course size settings that allows specific roles access to view.
if ($customroles = self::config_to_array($plugin, "comma", true)) {
foreach ($customroles as $k => $v) {
if (strtolower($k) == strtolower($rolename)) {
$found = true;
Expand Down
5 changes: 3 additions & 2 deletions theme/snap/layout/course.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,12 @@
if ($showcs) {
include_once($CFG->dirroot. "/theme/lsu.php");
$showcssnippet = new lsu_theme_snippets();
$roles = get_config('report_coursesize', 'report_coursesize/roles');

// Was calling this func twice so call once and send to show_course_size.
$isadmin = is_siteadmin();
$isspeshul = lsu_snippets::role_check_course_size($COURSE->id);

// Returns an array
$isspeshul = lsu_snippets::role_check_course_size($COURSE->id, "report_coursesize_manualroles");
// Checks if they are a student or someone that can edit grades
// Also checks if they match a role in the settings that is allowed.
if (!$showcssnippet->are_you_student()) {
Expand Down

0 comments on commit bc47e5e

Please sign in to comment.