modxcms / revolution

MODX Revolution - Content Management Framework
https://modx.com/
GNU General Public License v2.0
1.36k stars 529 forks source link

filemanager doesn't show media sources correctly #6660

Open modxbot opened 12 years ago

modxbot commented 12 years ago

manu37new created Redmine issue ID 6660

I create a new media source and set the ACL for Editors. I lock down the media source "filesystem" to Admins. When I call the filemanager while inserting a image as a Editor at the place of "filesystem" a digit "1" appears, not selectable. I first have to choose another media source. Shouldn't it be inivisible?

modxbot commented 12 years ago

bezumkin2 submitted:

Just set needed default_media_source in user settings.

In my opinion - this is not a bug.

Remember, you can override every system settings by defining them in user settings or\and context settings.

XoD commented 12 years ago

xod submitted:

=), that's exactly what I tried a couple days ago. I needed different media sources in a multidomain setup (because the paths are different) where an image TV would access the media source. My first thought to achieve this, was to set a context setting "default_media_source" = 2 (or whatever the desired ms number is) but that didn't work at all (yes, I clearded the cache).

To solve this issue I had to edit the image TV itself and specify the correct media source for each context in the tab "Media Sources", that worked!

So I don't know, but for me it looks like a bug (or just missing knowledge?) that the system setting "default_media_source" is not working as expected when set on a context. I don't know about User Settings, never tried that one, anybody tried this?

(PS: The site runs Revo 2.2.1pl traditional)

jgulledge19 commented 7 years ago

modxbughunt

Here is a quick fix, open file: core/model/modx/processors/system/config.js.php and after line 91

// Line 91:
$c = array_merge($modx->config,$workingContext->config,$modx->_userConfig,$c);

add:

$default_media_source = $modx->getOption('default_media_source',$c,1);
$mediaSource = $modx->getObject('sources.modMediaSource',$default_media_source);
if (empty($mediaSource) || !$mediaSource->checkPolicy('view')) {
    // iterate all:
    $q = $modx->newQuery('sources.modMediaSource');
    $q->sortby('name');
    $mediaSources = $modx->getCollection('sources.modMediaSource', $q);
    foreach ($mediaSources as $mediaSource) {
        if ( $mediaSource->checkPolicy('view')) {
            $default_media_source = $mediaSource->get('id');
            break;
        }
    }
}
$c['default_media_source'] = $default_media_source;