Skip to content

Commit

Permalink
Merge pull request #14 from andreasschenkel/develop
Browse files Browse the repository at this point in the history
v2.0.4
  • Loading branch information
andreasschenkel authored Nov 10, 2021
2 parents fcbb37c + 82552ce commit ef8dc5e
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 5 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ At the end of the block a list of all courses is shown where the usere is enroll


# Changelog #
## [[v2.0.4]] ##
- configurable max courses if is_siteadmin

## [[v2.0.3]] ##
- add list of all moodle courses is is_siteadmin
- some refactoring
Expand Down
12 changes: 9 additions & 3 deletions block_course_list_advanced.php
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,8 @@ public function get_content()
. '</div></div>';
$countCoursesNoneditingTeacher++;
}
if (is_siteadmin()) {

if (is_siteadmin() && $countCoursesAll <= $configHandler->getMax_for_siteadmin()) {
$listAllCourses = $listAllCourses . '<div ' . $linkcss . '>' . '<div ' . $coursecss . '>' . $htmllinktocourse . ' ' . $linkViewOrphanedFiles . ' ' . $htmllinktocoursedeletion . ' ' . $roles . '<br>' . $duration . '</div></div>';
$countCoursesAll++;
}
Expand All @@ -237,7 +238,7 @@ public function get_content()
$title = '';
$title = get_string('blocktitle', 'block_course_list_advanced');
if (is_siteadmin()) {
$title = $title . ' (Adminmodus)';
$title = 'Adminmodus' ;
}
$this->title = $title;
/// If we can update any course of the view all isn't hidden, show the view all courses link
Expand Down Expand Up @@ -269,7 +270,12 @@ public function get_content()
}

if ($countCoursesAll) {
$this->content->items[] = '<div class="course_list_advanced">' . $countCoursesAll . ' ' . get_string('headlinenallcourses', 'block_course_list_advanced') . '</div>';
$this->content->items[] = '<div class="course_list_advanced">'
. $countCoursesAll . ' '
. get_string('headlinenallcourses', 'block_course_list_advanced')
. ' (max. '
. $configHandler->getMax_for_siteadmin()
. ')</div>';
$this->content->items[] = $listAllCourses . '<br />';
}

Expand Down
24 changes: 23 additions & 1 deletion classes/config_handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,14 @@ class config_handler
*/
private $usesphorphanedfiles = false;

/**
* @var int
*/
private $max_for_siteadmin = 22;




public function __construct(stdClass $config)
{

Expand Down Expand Up @@ -71,6 +79,10 @@ public function __construct(stdClass $config)
$this->usesphorphanedfiles = $config->block_course_list_advanced_usesphorphanedfiles == true ? true : false;
}

if (isset($config->block_course_list_advanced_max_for_siteadmin)) {
$this->max_for_siteadmin = $config->block_course_list_advanced_max_for_siteadmin;
}

}


Expand Down Expand Up @@ -125,8 +137,18 @@ public function getIsallowedonmypage(): bool
*
* @return bool
*/
public function getUsesphorphanedfiles()
public function getUsesphorphanedfiles(): bool
{
return $this->usesphorphanedfiles;
}

/**
* Get the value of maxforsiteadmin
*
* @return int
*/
public function getMax_for_siteadmin(): int
{
return $this->max_for_siteadmin;
}
}
3 changes: 3 additions & 0 deletions lang/de/block_course_list_advanced.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@
$string['isallowedonmypage'] = 'Block auf my-Seite (Dashboard/Arbeitsplatz) erlauben';
$string['configisallowedonmypage'] = 'Wenn aktiviert kann der Block auf der my-Seite hinzugefügt werden (wenn Berechtigung vorhanden).';

$string['max_for_siteadmin'] = 'Maximale Kursanzahl im Abschnitt Alle Kurse für Siteadmins';
$string['configmax_for_siteadmin'] = 'Für SiteAdmins werden nur maximal so viele Kurse im Abschnitt AlleKurse angezeigt.';

$string['course_list_advanced:view'] = 'Block anzeigen';
$string['course_list_advanced:addinstance'] = 'Block Kursliste erweitert hinzufügen';
$string['course_list_advanced:myaddinstance'] = 'Block Kursliste erweitert zum Arbeitsplatz hinzufügen';
Expand Down
3 changes: 3 additions & 0 deletions lang/en/block_course_list_advanced.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@
$string['isallowedonmypage'] = 'Allow to add block on the mypage';
$string['configisallowedonmypage'] = 'When activated it is allowed to add block to mypage.';

$string['max_for_siteadmin'] = 'Maximum number of courses in section all courses for siteadmins';
$string['configmax_for_siteadmin'] = 'Maximum number of courses in section all courses for siteadmins';

$string['course_list_advanced:view'] = 'Show block';
$string['course_list_advanced:addinstance'] = 'Add a new courses block';
$string['course_list_advanced:myaddinstance'] = 'Add a new courses block to Dashboard';
Expand Down
10 changes: 10 additions & 0 deletions settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,5 +70,15 @@
0
));

$options = array(5=>'5', 10=>'10', 20=>'20', 30=>'30', 40=>'40', 50=>'50', 100=>'100', 10000=>'10000');

$settings->add(new admin_setting_configselect(
'block_course_list_advanced_max_for_siteadmin',
get_string('max_for_siteadmin', 'block_course_list_advanced'),
get_string('configmax_for_siteadmin', 'block_course_list_advanced'),
'30',
$options
));


}
2 changes: 1 addition & 1 deletion version.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@

defined('MOODLE_INTERNAL') || die();

$plugin->version = 2021110801; // The current plugin version (Date: YYYYMMDDXX)
$plugin->version = 2021111001; // The current plugin version (Date: YYYYMMDDXX)
$plugin->requires = 2020060900; // Requires this Moodle version
$plugin->component = 'block_course_list_advanced'; // Full name of the plugin (used for diagnostics)

0 comments on commit ef8dc5e

Please sign in to comment.