Skip to content

Commit 8e950a9

Browse files
authored
Add flag to disable teammaker (#771)
1 parent abbebe2 commit 8e950a9

7 files changed

Lines changed: 37 additions & 16 deletions

File tree

app/app_controller.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ class AppController extends Controller
3535
public $breadcrumb;
3636
public $validTZ;
3737
public $emailInterfaceEnabled = true;
38+
public $teamMakerEnabled = true;
3839

3940
/**
4041
* if this request has session transfer data
@@ -176,6 +177,14 @@ public function beforeFilter()
176177
);
177178
$this->set('emailInterfaceEnabled', $this->emailInterfaceEnabled);
178179

180+
// check if TeamMaker is enabled. Set here rather than per-controller
181+
// because the footer, which renders on every layout, needs it.
182+
$this->teamMakerEnabled = in_array(
183+
$this->SysParameter->get('system.teammaker_enabled', 'true'),
184+
array('1', 'true', 'yes')
185+
);
186+
$this->set('teamMakerEnabled', $this->teamMakerEnabled);
187+
179188
// for setting up google analytics
180189
$trackingId = $this->SysParameter->findByParameterCode('google_analytics.tracking_id');
181190
$domain = $this->SysParameter->findByParameterCode('google_analytics.domain');

app/views/courses/home.ctp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ $submenuTitle = __('Evaluation Events', true);
6161
$params = array('controller'=>'courses', 'submenu'=>$submenu, 'submenuTitle'=>$submenuTitle, 'course_id'=>$data['Course']['id']);
6262
echo $this->element('courses/submenu', $params);
6363

64-
if (User::hasPermission('controllers/Surveys')) {
64+
if (($teamMakerEnabled ?? true) && User::hasPermission('controllers/Surveys')) {
6565
$submenu = 'TeamMaker';
6666
$submenuTitle = __('Team Maker', true);
6767
$params = array('controller'=>'courses', 'submenu'=>$submenu, 'submenuTitle'=>$submenuTitle, 'course_id'=>$data['Course']['id']);

app/views/elements/courses/submenu.ctp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ switch($submenu) {
5555
);
5656
break;
5757
case "TeamMaker":
58+
if (!($teamMakerEnabled ?? true)) {
59+
break;
60+
}
5861
if ($status == 'A') {
5962
array_push(
6063
$items,
@@ -91,6 +94,12 @@ switch($submenu) {
9194
}
9295
break;
9396
}
97+
98+
// nothing to show (e.g. the section is disabled) - skip the heading and
99+
// border rather than rendering an empty box
100+
if (empty($items)) {
101+
return;
102+
}
94103
?>
95104
<div class="course_submenu course_submenu-<?php echo $submenu; ?>">
96105
<h3>

app/views/elements/global/footer.ctp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
<div id='footer' class='pagewidth'>
22
<p>
3-
<?php __('Powered by iPeer and TeamMaker - Created by UBC and Rose-Hulman')?>
3+
<?php if ($teamMakerEnabled ?? true) {
4+
__('Powered by iPeer and TeamMaker - Created by UBC and Rose-Hulman');
5+
} else {
6+
__('Powered by iPeer - Created by UBC and Rose-Hulman');
7+
} ?>
48
</p>
59
<?php if (!empty($ipeerCommitHash)): ?>
610
<p>

app/views/elements/list/ajaxList.ctp

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,6 @@
1414
echo "<span style='color:red'>ajaxList: $message</span><br />";
1515
}
1616

17-
function utf8ize($d) {
18-
if (is_array($d)) {
19-
foreach ($d as $k => $v) {
20-
$d[$k] = utf8ize($v);
21-
}
22-
} else if (is_string ($d)) {
23-
return utf8_encode($d);
24-
}
25-
return $d;
26-
}
27-
2817
$divisionName = "ajaxListDiv";
2918
// The main div containing the controll
3019
echo "<div id='$divisionName'>";
@@ -45,7 +34,9 @@
4534
} else {
4635

4736
// Start Up the element
48-
$variables = json_encode(utf8ize($paramsForList));
37+
// Data is already UTF-8; substitute rather than re-encode so valid
38+
// multi-byte characters aren't mangled (matches the AJAX refresh path).
39+
$variables = json_encode($paramsForList, JSON_INVALID_UTF8_SUBSTITUTE);
4940

5041
echo $html->script("ajaxList");
5142
echo $html->scriptBlock("var ajaxList = new AjaxList({$variables},'$divisionName')");

app/views/home/combined.ctp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,11 @@ if (isset($course_list['I']))
9191
<li><?php __('Then <i>register students</i> into that course from that course\'s home page. This display will be available (once the course is created) by clicking on the course\'s name from most menus.')?>
9292
</li>
9393

94-
<li><?php __('Put your students into <i>groups</i> manually, (or, if you have the students complete a survey, iPeer can do it for you, using TeamMaker).')?>
94+
<li><?php if ($teamMakerEnabled ?? true) {
95+
__('Put your students into <i>groups</i> (or, if you have the students complete a survey, iPeer can do it for you, using TeamMaker).');
96+
} else {
97+
__('Put your students into <i>groups</i>.');
98+
} ?>
9599
</li>
96100

97101
<li>

app/views/home/index.ctp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,11 @@ if (isset($course_list['I']))
8686
<li><?php __('Then <i>register students</i> into that course from that course\'s home page. This display will be available (once the course is created) by clicking on the course\'s name from most menus.')?>
8787
</li>
8888

89-
<li><?php __('Put your students into <i>groups</i> manually, (or, if you have the students complete a survey, iPeer can do it for you, using TeamMaker).')?>
89+
<li><?php if ($teamMakerEnabled ?? true) {
90+
__('Put your students into <i>groups</i> (or, if you have the students complete a survey, iPeer can do it for you, using TeamMaker).');
91+
} else {
92+
__('Put your students into <i>groups</i>.');
93+
} ?>
9094
</li>
9195

9296
<li>

0 commit comments

Comments
 (0)