Sending someone a link to a file in a resource

Sending someone a link to a file in a resource

by Deleted user -
Number of replies: 4
I have some files in my moodledata. From Moodle I can browse to them and see them (for example: http://mysite/moodle/mod/resource/view.php?id=2).

I want to browse to a file and then send the link to another Moodle user via e-mail (so I want to say: hey person, look at this file!).

What I would like is...
  • That person to click the link I sent them
  • Assuming their browser is closed (so they are not on Moodle) they get the Moodle login page
  • They login
  • They then get redirected to that file. This works for all other parts of Moodle except for when I send file links!

Here is an example of what happens:
  • I send this link: http://mysite/moodle/file.php/2/shareddata/myfile.doc
  • The recipient clicks the link
  • The user gets a login page
  • The user then logs in and goes to the Front Page (instead of going to the resource as I want them to do!)
Thank you!

Average of ratings: -
In reply to Deleted user

Re: Sending someone a link to a file in a resource

by Deleted user -
Followup...

OK I just realized this has to do with MDL-14495 (see notes in /moodle/file.php).

Is there a way around this?

Thank you!

In reply to Deleted user

Re: Sending someone a link to a file in a resource

by Gareth J Barnard -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers
Hi Matt,

There are two ways of solving this:

1. Put the file in Site Administration -> Front Page -> Site files and then send them the link to this area - disadvantage is that anybody can get access to the file and you need to be an administrator.

2. Create an account for the person you are sending to and allow them access to the course containing the file.

Cheers,

Gareth
In reply to Gareth J Barnard

Re: Sending someone a link to a file in a resource

by Deleted user -
Hi --

I can not use method 1 above since I need the files to remain secure and only available to logged in users.

The problem:
  • I have a course with some files.
  • I can email a course member and tell them to login and then what to click to find the file in question. That could be difficult fo rthe user since the file may be several subdirectories deap
  • I want to just navigate to the file myself and then send the user the url from the address bar.
    • They would then click it, go to the login screen, and then be redirected to that file.
    • That will not work because file.php does not allow these kinds of links to go into the Session (this has to do with MDL-14495 (see notes in /moodle/file.php).

    So the key idea is how can someone email a link to a user, that user login, and then be redirected to that link. It works for everything except files (see notes in/moodle/file.php).
From file.php:
//Note: file.php always calls require_login() with $setwantsurltome=false
//in order to avoid messing redirects. MDL-14495

In reply to Deleted user

Re: Sending someone a link to a file in a resource

by Petr Skoda -
Picture of Core developers Picture of Documentation writers Picture of Peer reviewers Picture of Plugin developers
I personally did not like the changes of session use in file.php, it was supposed to solve one specific roblem when ppl incorrectly linked images in course descriptions, but it inevitably broke this kind of links.

Finally this will be solved properly in 2.0 thanks to new file api big grin