Account created on 16 April 2021, over 3 years ago
#

Recent comments

Here is a sample plugin for above.

Note it would break complex permissions, for example block rules below or beside allow rules.

web/modules/custom/zzz/src/Plugin/ImcePlugin/ZzzImceFolders.php


namespace Drupal\zzz\Plugin\ImcePlugin;


use Drupal\Core\Session\AccountProxyInterface;
use Drupal\imce\Imce;
use Drupal\imce\ImcePluginBase;

/**
 * Custom IMCE folder perms merge.
 *
 * @ImcePlugin(
 *   id = "zzz_imce_folders",
 *   label = "IMCE ZZZ Folders",
 *   weight = 10,
 * )
 *
 * Explain.
 */
class ZzzImceFolders extends ImcePluginBase {

  /**
   * {@inheritdoc}
   */
  public function processUserConf(array &$conf, AccountProxyInterface $user) {

    // Skip administrators.
    if ($user->hasPermission("administer imce")) {
      return;
    }

    // Skip admin roles.
    if (array_intersect($user->getRoles(), [
      'administrator',
      'custom_client_admin',
    ])) {
      return;
    }

    // Get imce settings.
    $settings = \Drupal::config('imce.settings');
    $imce_roles = $settings->get('roles_profiles');

    // Get user roles, from more permissive to less permissive.
    $user_roles = array_reverse(array_flip($user->getRoles()));
    $user_imce_roles = array_keys(array_intersect_key($imce_roles, $user_roles));

    // Get storage.
    $scheme = \Drupal::config('system.file')->get('default_scheme');
    $storage = \Drupal::entityTypeManager()->getStorage('imce_profile');

    // Get folders for each role.
    foreach ($user_imce_roles as $id) {
      if ($profile = $storage->load($imce_roles[$id][$scheme])) {
        if ($folders = $profile->getConf('folders', [])) {
          $processed = Imce::processUserFolders($folders, $user);
          $conf['folders'][$id] = $processed;
        }
      }
    }
  }

}

This still occurs on 3.0.0-beta8.

Oddly, the patch still applies too.

looks like the issue may be multiple dialogs getting inserted.

Production build 0.71.5 2024