We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 13354
    • 7 Posts
    Hi Guys,

    I'd like to be able to only show documents to a logged in user, this part im ok with, but what i'd also like to do is store statistics against files downloaded by specific users and perhaps display this info/ statistics within the manager somewhere.

    Ideally i would like to record and report against what files users have downloaded specifically.

    Has anyone done anything like this before within modx and able to share a solution or the best way of achieving this ?

    Thanks in advance.
    Jac
      • 46886
      • 1,154 Posts
      What are you using to do the download? That isn't an inbuilt function in Modx, is it? It seems to me the tool which will let the user download can probably handle the stats, or am I off base here?
        • 13354
        • 7 Posts
        No its not a built in function. Im trying the following extra for downloads at the moment:

        FileDownload R
        https://rtfm.modx.com/extras/revo/filedownload-r/filedownload-r.filedownload

        This does count downloads but its a simple count on the file itself and not per user.

        Open to any other solutions available.
          • 3749
          • 24,544 Posts
          I don't think there's any way to capture user-specific information on downloads.

            Did I help you? Buy me a beer
            Get my Book: MODX:The Official Guide
            MODX info for everyone: http://bobsguides.com/modx.html
            My MODX Extras
            Bob's Guides is now hosted at A2 MODX Hosting
            • 46886
            • 1,154 Posts
            I think you could build a tool to collect this info, but it wouldn't be sort of connected to the users. What I mean is, when downloading it seems to me it isn't that hard to collect a user name, but the data wouldn't be attached to the user, it would just be a list, 20 downloads and here is the list of users.

            So you could collect the data and output it, but it would have nothing to do with the user data. If you wanted Modx to track downloads by user, that would be a tough requirement.

            BobRay, does this make sense to you? Its just adding a tiny function to the downloading tool, kind of like onDownload --> get current user name or ID or whatever. It might not be 100% reliable but it should work.
              • 4172
              • 5,888 Posts
              shouldn't this be possible with a fileDownloadR - plugin?
              https://rtfm.modx.com/extras/revo/filedownload-r/filedownload-r.plugins
                -------------------------------

                you can buy me a beer, if you like MIGX

                http://webcmsolutions.de/migx.html

                Thanks!
                • 3749
                • 24,544 Posts
                I think you're right Bruno (and nuan88 is as well). smiley

                I had written off the plugin because it doesn't fire any system events (it should create an OnFileDownload event and invoke it, imo). But it does have the ability to run other plugins that are similar to posthooks.

                In those plugins, $modx->user should be the current user who downloaded the file. The ideal thing might be a custom table of filenames with 'filename' and 'id' fields. And a custom intersect table with two fields: 'internalKey' (the user ID) and 'fileId' (the ID of the file downloaded). That would give you the fast access to the files downloaded by each user as well as the users who downloaded each file.

                A lower-tech way to do it would be to store the filenames downloaded by the user in an extended field of the user profile. That would be easier to implement, and in some ways, it's a better solution as long as you only want to see the names of a user's downloaded files and never need to see a list of users who have downloaded a particular file.

                There's probably a MIGX solution as well, but I'll leave that to Bruno. wink

                  Did I help you? Buy me a beer
                  Get my Book: MODX:The Official Guide
                  MODX info for everyone: http://bobsguides.com/modx.html
                  My MODX Extras
                  Bob's Guides is now hosted at A2 MODX Hosting