Document - Add extra fields list for documents - refs BT#20418

pull/4482/head
Christian 3 years ago
parent 2a50f60422
commit 3edb2bfe83
  1. 33
      main/document/edit_document.php
  2. 1
      main/inc/lib/extra_field.lib.php
  3. 6
      main/install/configuration.dist.php

@ -334,13 +334,11 @@ if ($is_allowed_to_edit) {
}
}
if (true === api_get_configuration_value('documents_hide_download_icon')) {
$extraFieldValue = new ExtraFieldValue('document');
$fieldValues = [];
$fieldValues['item_id'] = $document_id;
$fieldValues['extra_can_be_downloaded'] = (int) $_REQUEST['download']['can_download'];
$extraFieldValue->saveFieldValues($fieldValues);
}
// It saves extra fields values
$extraFieldValue = new ExtraFieldValue('document');
$values = $_REQUEST;
$values['item_id'] = $document_id;
$extraFieldValue->saveFieldValues($values);
$url = 'document.php?id='.$document_data['parent_id'].'&'.api_get_cidreq().($is_certificate_mode ? '&curdirpath=/certificates&selectcat=1' : '');
@ -467,15 +465,18 @@ if ($owner_id == api_get_user_id() ||
$form->addElement('textarea', 'comment', get_lang('Comment'), ['cols-size' => [2, 10, 0]]);
}
// Define if a document can be downloaded or not.
if (true === api_get_configuration_value('documents_hide_download_icon')) {
$itemId = isset($_GET['id']) ? (int) $_GET['id'] : 0;
$group = [];
$group[] = $form->createElement('radio', 'can_download', null, get_lang('Yes'), 1, ['id' => 'can_download_yes']);
$group[] = $form->createElement('radio', 'can_download', null, get_lang('No'), 0, ['id' => 'can_download_no']);
$form->addGroup($group, 'download', get_lang('DefineIfDocumentCanBeDownloaded'));
$defaults['download']['can_download'] = DocumentManager::getHideDownloadIcon($itemId);
}
$itemId = isset($_GET['id']) ? (int) $_GET['id'] : 0;
$extraField = new ExtraField('document');
$extraField->addElements(
$form,
$itemId,
[], //exclude
false, // filter
false, // tag as select
[], //show only fields
[], // order fields
[] // extra data
);
if ($file_type != 'link') {
if ($owner_id == api_get_user_id() || api_is_platform_admin()) {

@ -207,6 +207,7 @@ class ExtraField extends Model
'lp_view',
'course_announcement',
'message',
'document'
];
if (api_get_configuration_value('allow_scheduled_announcements')) {

@ -2318,11 +2318,7 @@ INSERT INTO `extra_field` (`extra_field_type`, `field_type`, `variable`, `displa
// $_configuration['gradebook_hide_link_to_item_for_student'] = false;
// It adds option to define if a document can be downloaded or not.
// Requires DB changes:
/*
INSERT INTO extra_field (extra_field_type, field_type, variable, display_text, default_value, field_order, visible_to_self, visible_to_others, changeable, filter, created_at) VALUES
(23, 1, 'can_be_downloaded', 'CanBeDownloaded', '', 0, 1, 0, 1, 0, NOW());
*/
// Create an extra field document named "CanBeDownloaded" of type "Yes/No" that is set to "No" by default.
// $_configuration['documents_hide_download_icon'] = false;
// KEEP THIS AT THE END

Loading…
Cancel
Save