We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 40088
    • 708 Posts
    Quote from: BobRay at Apr 11, 2018, 06:32 AM
    If the user is a sudo user and you've flushed permissions and logged out all users, and manually deleted all files in the core/cache directory, and it still doesn't work, it's not a MODX permission issue. sudo users bypass all MODX permissions.

    That suggests a permission or ownership problem with the directory the files are going to.

    It appears the problem is RFM is not auto-creating the unique user folder. So basically RFM is trying to load a folder that does not exist, hence the error message.

    Oddly, it works fine for me, a Super Admin.
      Todd
      • 38783
      • 571 Posts
      Quote from: donshakespeare at Apr 11, 2018, 08:19 PM
      Yup it is as simple as what they have on their official site.
      If you want any of my speciality TinyMCE plugins, they are available on your server when you installed TinymceWrapper.
      
      
        <script src="https://cloud.tinymce.com/stable/tinymce.min.js"></script>
        <script>tinymce.init({ selector:'textarea' });</script>
      
      
        <textarea>Next, start a free trial!</textarea>
      
      

      As my requirements were minimal (just bold, italic, insert url and create bulleted list) I downloaded the community edition of Tiny MCE and used it using their examples. Thank you for pointing out how simple this actually was!

      When I need more functionality and integration with MODX I will use tinymceWrapper.
        If I help you out on these forums I would be very grateful if you would consider rating me on Trustpilot: https://uk.trustpilot.com/review/andytough.com

        email: [email protected] | website: https://andytough.com
        • 40088
        • 708 Posts
        Quote from: todd.b at Apr 11, 2018, 09:08 PM
        Quote from: BobRay at Apr 11, 2018, 06:32 AM
        If the user is a sudo user and you've flushed permissions and logged out all users, and manually deleted all files in the core/cache directory, and it still doesn't work, it's not a MODX permission issue. sudo users bypass all MODX permissions.

        That suggests a permission or ownership problem with the directory the files are going to.

        It appears the problem is RFM is not auto-creating the unique user folder. So basically RFM is trying to load a folder that does not exist, hence the error message.

        Solved
        I had modified the TW autoCreateFoldersTWrfm file but mistakenly placed file_exists before everything else. Below is the corrected and working code (partial):
        $myPersonal = $modx->user->get('username');
        $myPersonal = substr(md5($myPersonal), 0, 24);  //add only one line
        $rfmUser = $modx->user;
        $rfmUserProfile = $rfmUser->getOne('Profile');
        if ($rfmUserProfile) {
          $extended = $rfmUserProfile->get('extended');
          $extended['mediaFolder'] = $myPersonal; //change ['responsivefilemanager'] if you like
          $rfmUserProfile->set('extended', $extended);
          $rfmUserProfile->save();
        }
        //$path is supplied by the calling connector, elFinder or responsivefilemanager
        if (!file_exists($path.$myPersonal.'/')) {
          mkdir($path.$myPersonal.'/', 0755, true);
        }
        ...
        [ed. note: todd.b last edited this post 6 years, 1 month ago.]
          Todd
          • 40088
          • 708 Posts
          Revo 2.6.2

          In the TW autoCreateFoldersTWrfm file I added:
          $readmeFile = $copyPath.'README.txt';
          if (!file_exists($readmeFile)) {
          $myfile = fopen($readmeFile, "w") or die("Unable to create/open file.");
          fclose($myfile);
          }

          It creates an empty README.txt file. So far so good.

          Now I'm trying to write one-time content ( a brief paragraph or two) to the file using file_put_contents, but it's not working.
            Todd
            • 3749
            • 24,544 Posts
            You don't use fopen() or fclose() with file_put_contents(). It's probably not working because the file is locked by fopen().
            file_put_contents() is identical to calling fopen(), fwrite() and fclose() successively to write data to a file.

            Try this:

            if (!file_exists($readmeFile)) {
                if (file_put_contents($readmeFile, $content) == false) {
                  return 'Failed to write to file ' . $readmeFile;
                }
            }


            You don't need the file_exists test unless you want to avoid overwriting the file. file_put_contents() will create it if it doesn't exist, and overwrite it if it does, unless you send FILE_APPEND as a third argument.
              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
              • 40088
              • 708 Posts
              Thank you, Bob. Works a treat.

              I changed $content to $content='My custom message here...' which seems to work fine.

              Is that the correct syntax or is there a better way?

              Also, I noticed when I update the message (in the Chunk) the file in RFM is not updated. It must be deleted from RFM and when regenerated the update then appears. [ed. note: todd.b last edited this post 6 years, 1 month ago.]
                Todd
                • 3749
                • 24,544 Posts
                If you're using the literal string, you don't need the $content variable:

                if (file_put_contents($readmeFile, 'My custom message here...' ) == false) {


                If the actual message is longer, you might want to put it in a chunk and do this:

                if (file_put_contents($readmeFile, $modx->getChunk('MyCustomMessage') ) == false) {

                  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
                  • 40088
                  • 708 Posts
                  Oh yeah, a Chunk would be better. Thanks for the suggestion.

                  Though I wish the README file would update when changes are made to its Chunk.
                    Todd
                    • 40088
                    • 708 Posts
                    Has anyone tried manually updating TW Responsive Filemanager? I'm guessing it's not a simple drop-in replacement.
                      Todd
                      • 3749
                      • 24,544 Posts
                      @donshakespeare: I notice that TinyMCEWrapper does not show up when you search the MODX extras repo, or Downloads in Package Manager for "richtext" or "rich text". You might want to work those into the description.
                        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