Add download URL function (getResourceFileDownloadUrl)

pull/3124/head
Julio Montoya 6 years ago
parent adf0b52e44
commit 6078d3677d
  1. 2
      public/main/forum/forumfunction.inc.php
  2. 2
      public/main/forum/viewthread.php
  3. 2
      public/main/inc/lib/AnnouncementEmail.php
  4. 2
      public/main/inc/lib/AnnouncementManager.php
  5. 2
      public/main/inc/lib/tracking.lib.php
  6. 2
      public/main/work/work.lib.php
  7. 7
      src/CoreBundle/Repository/ResourceRepository.php

@ -6206,7 +6206,7 @@ function getAttachedFiles(
while ($row = Database::fetch_array($result, 'ASSOC')) {
/** @var CForumAttachment $attachment */
$attachment = $repo->find($row['iid']);
$downloadUrl = $repo->getResourceFileUrl($attachment);
$downloadUrl = $repo->getResourceFileDownloadUrl($attachment);
// name contains an URL to download attachment file and its filename
$json['name'] = Display::url(

@ -651,7 +651,7 @@ foreach ($posts as $post) {
/** @var \Chamilo\CourseBundle\Entity\CForumAttachment $attachment */
foreach ($attachments as $attachment) {
$post['post_attachments'] .= Display::return_icon('attachment.png', get_lang('Attachment'));
$url = $repo->getResourceFileUrl($attachment);
$url = $repo->getResourceFileDownloadUrl($attachment);
$post['post_attachments'] .= Display::url($attachment->getFilename(), $url);
$post['post_attachments'] .= '<span class="forum_attach_comment" >'.$attachment->getComment().'</span>';

@ -198,7 +198,7 @@ class AnnouncementEmail
if (!empty($attachments)) {
$repo = Container::getAnnouncementAttachmentRepository();
foreach ($attachments as $attachment) {
$url = $repo->getResourceFileUrl($attachment, ['mode' => 'download']);
$url = $repo->getResourceFileDownloadUrl($attachment);
$result .= '<br />';
$result .= Display::url(
$attachment->getFilename(),

@ -543,7 +543,7 @@ class AnnouncementManager
$repo = Container::getAnnouncementAttachmentRepository();
foreach ($attachments as $attachment) {
$attachmentId = $attachment->getIid();
$url = $repo->getResourceFileUrl($attachment, ['mode' => 'download']);
$url = $repo->getResourceFileDownloadUrl($attachment);
$html .= "<tr><td>";
$html .= '<br/>';
$html .= Display::returnFontAwesomeIcon('paperclip');

@ -217,7 +217,7 @@ class Tracking
});
</script>';
$extra .= '<div id="dialog-confirm" title="'.get_lang('ConfirmYourChoice').'">';
$extra .= '<div id="dialog-confirm" title="'.get_lang('Please confirm your choice').'">';
$form = new FormValidator('report', 'post', null, null, ['class' => 'form-vertical']);
$form->addCheckBox('add_logo', '', get_lang('AddRightLogo'), ['id' => 'export_format_csv_label']);
$extra .= $form->returnForm();

@ -3377,7 +3377,7 @@ function getWorkComment($id, $courseInfo = [])
$deleteUrl = null;
$fileName = null;
if ($commentEntity->getResourceNode()->hasResourceFile()) {
$fileUrl = $repo->getResourceFileUrl($commentEntity);
$fileUrl = $repo->getResourceFileDownloadUrl($commentEntity);
$workId = $commentEntity->getWorkId();
$filePath = '';
$deleteUrl = api_get_path(WEB_CODE_PATH).'work/view.php?'.api_get_cidreq().'&id='.$workId.'&action=delete_attachment&comment_id='.$id;

@ -748,6 +748,13 @@ class ResourceRepository extends BaseEntityRepository
return $this->resourceNodeRepository->getResourceNodeFileStream($resourceNode);
}
public function getResourceFileDownloadUrl(AbstractResource $resource, array $extraParams = [], $referenceType = null): string
{
$extraParams['mode'] = 'download';
return $this->getResourceFileUrl($resource, $extraParams, $referenceType);
}
public function getResourceFileUrl(AbstractResource $resource, array $extraParams = [], $referenceType = null): string
{
try {

Loading…
Cancel
Save