We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 24676
    • 60 Posts
    Hi everyone! I am looking for some advice on using MODX as a document management system.

    I have client who I am building a client portal for. The idea being that their clients have a log in to a secure area from where they can interact with their project, download files, leave messages for a project manager etc.

    I have been pushing to use MODX for this project but I am having a few problems with the document management side of the project.

    Some of the files that need downloading are large in size (8GB) so using a plugin like filelister wasn't really working as the server memory isn't big enough. They also wanted to have notifications when files we uploaded and updated so I figured that adding them as static resources would be the best as it seemed to give me the most control over sending email notifications. The only downside of this is that my client is saying they don't have the time to add each file individually and they want to be able to add a bulk upload.

    Has anyone got any suggestions on what I can do? Am I missing something obvious (or even not that obvious!)

    Any help is much appreciated!
      • 41592 ☆ A M B ☆
      • 83 Posts
      There are several ways you can go. maybe the best thing for your case is to create a small CMP (custom management component) that allows you to upload multiple files, or check a server folder and automatically creates the corresponding resources in relation to the files in it.
      you say that's those file are so large(8gb!), so maybe for your client could be better to upload it outside modx manager (maybe with ftp) and then use your CMP to register uploaded file as static resource with a bulk script.
        Francesco Mussoni | MODX Ambassador | Skype: solidusite2 | Email: [email protected]
        • 24676
        • 60 Posts
        Thanks for your reply. think they will be happy uploading via ftp. I figured i would have to build something fairly custom to make this happen. I have never build a CMP in MODX before so I guess it will be a bit of a challenge!

          • 28042 ☆ A M B ☆
          • 24,524 Posts
          You could actually use PHP's FTP library to build a MODx-based FTP client.

          Or you could use the ftp:// or the ftps:// stream wrapper.

          http://us2.php.net/manual/en/intro.ftp.php
          http://us2.php.net/manual/en/wrappers.ftp.php
            Studying MODX in the desert - http://sottwell.com
            Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
            Join the Slack Community - http://modx.org
            • 24676
            • 60 Posts
            Thanks Sottwell.

            I think that the key issue is making the files secure. They my client can upload the files via ftp, but those files need to be restricted to the website users (depending on their login).

            I was thinking of just using a simple directory binding and listing the files in that directory but is there a way to restrict access to those files if the user doesn't have permission?

            I hope that makes sense
              • 41592 ☆ A M B ☆
              • 83 Posts
              of course you can make it! one way could be by using the access policy of Modx and their user.
              you can make a group of resource available only for a restricted user choosen by the policy.
                Francesco Mussoni | MODX Ambassador | Skype: solidusite2 | Email: [email protected]
                • 24676
                • 60 Posts
                thanks solidusite!

                I greatly appreciate the help you guys are giving. I just can't quite get my head around this one.

                I have a folder on my server that has a a load of documents in it specific to a particular web user group. These files mustn't be accessible by other user groups.

                I can create a @directory binding and use that to list out all the files in the directory when the web user is logged in, but how to I stop other people accessing those files if they are not part of the right group. How do I stop access to those files if someone has a direct file path?

                I am not sure how to link the user permissions to the directory?!?
                  • 41592 ☆ A M B ☆
                  • 83 Posts
                  i'm not sure but I think you've to register your file in this directory as Modx Resource. once you've make it you can handle this resource as you want. create a group of resource related and choose what policy use for every group of user (anonymous too). direct consequence of this method allow you to deny all access from anonymous(or any other group of user) from those resources.

                  hope can help. btw it's better to wait other opinions about that!
                    Francesco Mussoni | MODX Ambassador | Skype: solidusite2 | Email: [email protected]
                    • 24676
                    • 60 Posts
                    thanks Soliduste....its given me something to think about...maybe someone else will be able to confirm!!
                      • 28042 ☆ A M B ☆
                      • 24,524 Posts
                      Here's how I do that.

                      1. Put the files in a directory outside of the web root. That way nobody can access them from the web. Let's say /path/to/files/.

                      2. Create a Media Source with its path set to /path/to/files/, and the relative option set to no. I ignore the URL settings, since they have no relevance in the case of files outside of the web root (no URL can reach them).

                      3. Create a chunk, pathPrefix, with this same path in it. The reason why will become clear later.

                      4. Create a custom Content Type for your files, for example for .pdf files. Make sure they're set as binary.

                      5. Now, for each file, create a Static Resource. You will be able to select your Media Source, and upload and select files within the path you set for your Media Source. (rest/of/path/to/file.pdf). The Static Resource can have templates, TVs, summary, every field normal resources have except the content will be that inner path. For the alias, skip the .pdf part, MODx will add that automatically.

                      Here's where the chunk comes in. Since Static Resources don't really work with Media Sources, what you see in the resource's content field will be the path MODx tries to work with - rest/of/path/to/file.pdf. So, put the chunk tags in front of the path:
                      [[$pathPrefix]]rest/of/path/to/file.pdf
                      Now when MODx processes the resource, the chunk's content will be added in front of the resource's content, resulting in the full /path/to/files/rest/of/path/to/file.pdf.

                      6. In the resource's Settings tab, set the Content Type to your custom type (PDF, for example), and set the Content Disposition to Attachment. This will cause the browser to deal with the file as it is configured to do so, either loading a PDF reader browser plugin or opening a download dialog. This will also tell MODx what suffix to use for the alias - file.pdf

                      When MODx processes a binary Static Resource, it sets the appropriate HTTP headers and streams the file.

                      Now you can treat this Static Resource as you would any resource. Assign it to resource groups, use search snippets on its fields (except its content field) and tagging snippets on its TVs, even use getResources to have nice lists with images and summaries if you like.

                      The user will only see the URL to the static resource, never the path to the file.

                        Studying MODX in the desert - http://sottwell.com
                        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                        Join the Slack Community - http://modx.org