Skip to content

Commit 5012f87

Browse files
committed
Documents: #add new option to define an accessibility starting date - refs BT#22617
1 parent d204845 commit 5012f87

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

main/inc/lib/document.lib.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1826,6 +1826,17 @@ public static function is_visible_by_id(
18261826

18271827
// 4. Checking document visibility (i'm repeating the code in order to be more clear when reading ) - jm
18281828
if ($user_in_course) {
1829+
if (true === api_get_configuration_value('document_enable_accessible_from_date')) {
1830+
$extraFieldValue = new ExtraFieldValue('document');
1831+
$extraValue = $extraFieldValue->get_values_by_handler_and_field_variable($doc_id, 'accessible_from');
1832+
if (!empty($extraValue) && isset($extraValue['value'])) {
1833+
$now = new DateTime();
1834+
$accessibleDate = new DateTime($extraValue['value']);
1835+
if ($now < $accessibleDate) {
1836+
return false;
1837+
}
1838+
}
1839+
}
18291840
// 4.1 Checking document visibility for a Course
18301841
if ($session_id == 0) {
18311842
$item_info = api_get_item_property_info(

main/install/configuration.dist.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2441,6 +2441,10 @@
24412441
// Create a document extra field with field label "can_be_downloaded" of type "Checkbox options".
24422442
// $_configuration['documents_hide_download_icon'] = false;
24432443

2444+
// It adds option to define the starting date of accessibility for un document.
2445+
// Create a document extra field with field label "accessible_from" of type "Date and time".
2446+
// $_configuration['document_enable_accessible_from_date'] = false;
2447+
24442448
// Add the username value to the "subscription to session" confirmation email
24452449
//$_configuration['email_template_subscription_to_session_confirmation_username'] = false;
24462450

0 commit comments

Comments
 (0)