We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 11694
    • 13 Posts
    Ever tried to force media browser (embedded in TINYMCE) to open in a certain root folder?

    For example force the browser to open in a folder dedicated to a certain user so that this user will not be able to manage other folders [ed. note: halvid last edited this post 14 years, 3 months ago.]
      • 11694
      • 13 Posts
      Well probably there are even better ways to do this and more secure but an easy and dirty solution is:
      First go to /manager/media/browser/mcpuk/connectors/php/Commands
      and then change in every file the following line:
      $this->actual_cwd=str_replace("//","/",($this->fckphp_config['UserFilesPath']."/$type/".$this->raw_cwd));
      with:
      if(isset($_SESSION['activeFolder'])) $activeFolder=$_SESSION['activeFolder'].'/';
      $this->actual_cwd=str_replace("//","/",($fckphp_config['UserFilesPath']."/$type/".$activeFolder.$this->raw_cwd));

      after that you will be able to set a session variable called 'activeFolder' wherever you like (in a plugin, snippet, module) with the name of the active folder you like eg.:
      $_SESSION['activeFolder']='Products';
      now the folder Products must exist either in the /assets/files (for uploading files)
      or in /assets/images/ (for uploading images)

      warning do not try to create the custom folder by an ftp client because you might create a folder with wrong ownership. Just do it through the modx->elements->files

      hope i helped somebody
      and please if any one believes that this is a bad security approach let me know [ed. note: halvid last edited this post 14 years, 3 months ago.]