Skip to content

Commit e797ca0

Browse files
committed
Plugin: Add courseToolDefaultVisibility property to Plugin class to enable course plugins that are not visible by default (set it from the plugin with $this->setCourseToolDefaultVisibility(false); before install_course_fields_in_all_courses()). Enabled on positioning plugin - refs #5717
1 parent 57356f1 commit e797ca0

File tree

4 files changed

+23
-31
lines changed

4 files changed

+23
-31
lines changed

main/inc/lib/plugin.class.php

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ class Plugin
2727
// Adds icon in the course home
2828
public $addCourseTool = true;
2929
public $hasPersonalEvents = false;
30+
// Whether the tool created should be visible immediately or disabled first (defaults to visible)
31+
public bool $courseToolDefaultVisibility = true;
3032

3133
/**
3234
* When creating a new course, these settings are added to the course, in
@@ -986,16 +988,6 @@ public function getToolIconVisibilityPerUserStatus()
986988
return '';
987989
}
988990

989-
/**
990-
* Default tool icon visibility.
991-
*
992-
* @return bool
993-
*/
994-
public function isIconVisibleByDefault()
995-
{
996-
return true;
997-
}
998-
999991
/**
1000992
* Get the admin URL for the plugin if Plugin::isAdminPlugin is true.
1001993
*
@@ -1093,7 +1085,7 @@ protected function createLinkToCourseTool(
10931085
}
10941086

10951087
$visibilityPerStatus = $this->getToolIconVisibilityPerUserStatus();
1096-
$visibility = $this->isIconVisibleByDefault();
1088+
$visibility = $this->getCourseToolDefaultVisibility();
10971089

10981090
$em = Database::getManager();
10991091

@@ -1136,4 +1128,21 @@ protected function createLinkToCourseTool(
11361128

11371129
return $tool;
11381130
}
1131+
/**
1132+
* Get whether the course tool should be visible by default or not
1133+
*/
1134+
protected function getCourseToolDefaultVisibility(): bool
1135+
{
1136+
return $this->courseToolDefaultVisibility;
1137+
}
1138+
1139+
/**
1140+
* Set whether the tool created in the course must be visible or not
1141+
* @param bool $visibility
1142+
* @return void
1143+
*/
1144+
protected function setCourseToolDefaultVisibility(bool $visibility)
1145+
{
1146+
$this->courseToolDefaultVisibility = $visibility;
1147+
}
11391148
}

plugin/customcertificate/src/CustomCertificatePlugin.php

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ public static function create()
6161
public function install()
6262
{
6363
//Installing course settings
64+
$this->setCourseToolDefaultVisibility(false);
6465
$this->install_course_fields_in_all_courses();
6566

6667
$tablesToBeCompared = [self::TABLE_CUSTOMCERTIFICATE];
@@ -192,16 +193,6 @@ public function update()
192193
}
193194
}
194195

195-
/**
196-
* By default new icon is invisible.
197-
*
198-
* @return bool
199-
*/
200-
public function isIconVisibleByDefault()
201-
{
202-
return false;
203-
}
204-
205196
/**
206197
* Get certificate data.
207198
*

plugin/positioning/src/Positioning.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ public function install()
4747
Database::query($sql);
4848

4949
// Installing course settings
50+
$this->setCourseToolDefaultVisibility(false);
5051
$this->install_course_fields_in_all_courses(true, 'positioning.png');
5152
}
5253

plugin/test2pdf/src/test2pdf_plugin.class.php

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ public static function create()
3737
public function install()
3838
{
3939
//Installing course settings
40+
$this->setCourseToolDefaultVisibility(false);
4041
$this->install_course_fields_in_all_courses();
4142

4243
$list = [
@@ -64,16 +65,6 @@ public function install()
6465
}
6566
}
6667

67-
/**
68-
* By default new icon is invisible.
69-
*
70-
* @return bool
71-
*/
72-
public function isIconVisibleByDefault()
73-
{
74-
return false;
75-
}
76-
7768
/**
7869
* This method drops the plugin tables.
7970
*/

0 commit comments

Comments
 (0)