Skip to content

Commit be9edb7

Browse files
David AlaDavid Ala
David Ala
authored and
David Ala
committed
Bugfix: booking places information now correctly overriden when places are unlimited #868
1 parent 7dd7396 commit be9edb7

File tree

7 files changed

+40
-13
lines changed

7 files changed

+40
-13
lines changed

classes/booking_answers.php

+7
Original file line numberDiff line numberDiff line change
@@ -636,6 +636,13 @@ public static function add_availability_info_texts_to_booking_information(array
636636
$bookinginformation['bookingplacesclass'] = 'text-success avail';
637637
$bookinginformation['bookingplacesiconclass'] = 'avail';
638638
}
639+
} else {
640+
if (
641+
!has_capability('mod/booking:updatebooking', $context)
642+
&& get_config('booking', 'dontshowbookingswhenunlimited')
643+
) {
644+
$bookinginformation['dontshowbookingswhenunlimited'] = true;
645+
}
639646
}
640647
// Waiting list places.
641648
if (!empty($bookinginformation['maxoverbooking'])) {

classes/output/view.php

+10-10
Original file line numberDiff line numberDiff line change
@@ -1122,11 +1122,11 @@ public static function generate_table_for_cards(wunderbyte_table &$wbtable, arra
11221122
['columnclass' => 'text-left text-gray pr-2'],
11231123
['bookings']
11241124
);
1125-
$wbtable->add_classes_to_subcolumns(
1126-
'cardlist',
1127-
['columniclassbefore' => 'fa fa-ticket fa-fw text-gray'],
1128-
['bookings']
1129-
);
1125+
// $wbtable->add_classes_to_subcolumns(
1126+
// 'cardlist',
1127+
// ['columniclassbefore' => 'fa fa-ticket fa-fw text-gray'],
1128+
// ['bookings']
1129+
// );
11301130
if (in_array('minanswers', $optionsfields)) {
11311131
$wbtable->add_classes_to_subcolumns(
11321132
'cardlist',
@@ -1352,11 +1352,11 @@ public static function generate_table_for_list(wunderbyte_table &$wbtable, array
13521352
['columnclass' => 'text-left text-gray pr-2 font-size-sm'],
13531353
['bookings']
13541354
);
1355-
$wbtable->add_classes_to_subcolumns(
1356-
'footer',
1357-
['columniclassbefore' => 'fa fa-ticket fa-fw text-gray font-size-sm'],
1358-
['bookings']
1359-
);
1355+
// $wbtable->add_classes_to_subcolumns(
1356+
// 'footer',
1357+
// ['columniclassbefore' => 'fa fa-ticket fa-fw text-gray font-size-sm'],
1358+
// ['bookings']
1359+
// );
13601360
if (in_array('minanswers', $optionsfields)) {
13611361
$wbtable->add_classes_to_subcolumns(
13621362
'footer',

classes/table/bookingoptions_wbtable.php

+7-1
Original file line numberDiff line numberDiff line change
@@ -531,10 +531,16 @@ public function col_bookings($values) {
531531
if ($maxoverbooking) {
532532
$ret .= " (" . get_string('waitinglist', 'mod_booking') . ": $waiting / $maxoverbooking)";
533533
}
534+
return $ret;
534535
} else {
535536
$ret = $output->render_col_availableplaces($data);
537+
if (strlen(trim($ret)) > 0) {
538+
$icon = html_writer::tag('i', '', ['class' => "fa fa-ticket fa-fw text-gray font-size-sm"]);
539+
return $icon . $ret;
540+
}
541+
return '';
536542
}
537-
return $ret;
543+
538544
}
539545

540546
/**

lang/de/booking.php

+2
Original file line numberDiff line numberDiff line change
@@ -980,6 +980,8 @@
980980
$string['dontaddpersonalevents'] = 'Keine Einträge im persönlichen Kalender erstellen.';
981981
$string['dontaddpersonaleventsdesc'] = 'Für jede Buchung und alle Termine werden eigene Einträge im persönlichen Kalender der TeilnehmerInnen erstellt. Für eine bessere Performance auf sehr intensiv genutzten Seiten kann diese Funktion deaktiviert werden.';
982982
$string['dontmove'] = 'Nicht bewegen';
983+
$string['dontshowbookingswhenunlimited'] = "Zeige keine Buchungen wenn Plätze unlimitert sind";
984+
$string['dontshowbookingswhenunlimited_desc'] = "Nutzer:innen ohne Bearbeitungsrechte sehen nicht die Anzahl der gebuchten Plätze.";
983985
$string['dontuse'] = 'Vorlage nicht verwenden';
984986
$string['download'] = 'Download';
985987
$string['downloadallresponses'] = 'Alle Buchungen herunterladen';

lang/en/booking.php

+2
Original file line numberDiff line numberDiff line change
@@ -991,6 +991,8 @@
991991
$string['dontaddpersonalevents'] = 'Dont add personal calendar events';
992992
$string['dontaddpersonaleventsdesc'] = 'For each booked option and for all of its sessions, personal events are created in the moodle calendar. Suppressing them improves performance for heavy load sites.';
993993
$string['dontmove'] = 'Don\'t move';
994+
$string['dontshowbookingswhenunlimited'] = "Don\'t show number of booked users when places are unlimited";
995+
$string['dontshowbookingswhenunlimited_desc'] = "Users without managing rights won\'t see bookings when this is set.";
994996
$string['dontuse'] = 'Don\'t use template';
995997
$string['download'] = 'Download';
996998
$string['downloadallresponses'] = 'Download all responses for all booking options';

settings.php

+9
Original file line numberDiff line numberDiff line change
@@ -1322,6 +1322,15 @@
13221322
)
13231323
);
13241324

1325+
$settings->add(
1326+
new admin_setting_configcheckbox(
1327+
'booking/dontshowbookingswhenunlimited',
1328+
get_string('dontshowbookingswhenunlimited', 'mod_booking'),
1329+
get_string('dontshowbookingswhenunlimited_desc', 'booking'),
1330+
0
1331+
)
1332+
);
1333+
13251334
$bookingplaceslowpercentages = [
13261335
0 => ' 0%',
13271336
5 => ' 5%',

templates/col_availableplaces.mustache

+3-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
{{#showmanageresponses}}
3232
<a href="{{{manageresponsesurl}}}" style="text-decoration: none;">
3333
{{/showmanageresponses}}
34-
3534
{{! Booking places }}
3635
{{#maxanswers}}
3736
<span class="col-ap-availableplaces {{#bookingplacesclass}}{{.}}{{/bookingplacesclass}}">
@@ -50,8 +49,10 @@
5049
</span>
5150
{{/maxanswers}}
5251
{{^maxanswers}}
53-
<span class="text-success font-weight-bold">{{booked}}</span>
52+
{{^dontshowbookingswhenunlimited}}
53+
<span class="text-success font-weight-bold">{{booked}} </span>
5454
/ {{#str}} unlimitedplaces, mod_booking {{/str}}
55+
{{/dontshowbookingswhenunlimited}}
5556
{{/maxanswers}}
5657

5758
{{! Waiting list places }}

0 commit comments

Comments
 (0)