I was looking in the permission setting the way to show the selection browser only but not the upload options. If you have a role that only are going to be able to select images and don't upload it (because can screw it) So the browser need other permission.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

killua99’s picture

And the patch ... that I forgot to attach.

Devin Carlson’s picture

Status: Needs review » Needs work

The last submitted patch, 1: select-media-browser-permission-fix.patch, failed testing.

killua99’s picture

Issue summary: View changes
Status: Needs work » Needs review
FileSize
906 bytes

New patch

killua99’s picture

FileSize
939 bytes

Need remove the callback function. So the permission will work without any issue.

The last submitted patch, 4: select-media-browser-2048359-4.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 5: select-media-browser-2048359-5.patch, failed testing.

Devin Carlson’s picture

Accommodated the introduction of the permission in the existing tests and added an update function to grant the permission to users who were already able to access the browser.

Also related is #1505120: Show an 'empty' tab if the user has no access to any browser plugins.

Devin Carlson’s picture

Status: Needs review » Fixed

Deployed #8 on a number of existing sites and didn't have any issues with existing users not able to access the media browser after running the update function.

Committed #2 to Media 7.x-2.x.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

joseph.olstad’s picture

Status: Closed (fixed) » Needs review
FileSize
896 bytes

Applying patch 8 left us with a permissions denied issue because the permission 'create files' didn't exist in our schema.

Copy from 'administer edit media' instead.

I should really put this in another issue and reference 2048359 (this one) , but here's a patch for the patch in comment #8 (apply the one from #8 first, then this)

Edit 7226 so as to not break other patches after (there's already a 7227 in another patch) , just fix this 7226 once for the next release...

BEFORE

/**
 * Accommodate the introduction of a new permission which restricts access to
 * the media browser by granting it to existing users who were able to access
 * it.
 */
function media_update_7226() {
  $roles = user_roles(FALSE, 'create files');

  foreach ($roles as $rid => $role) {
    user_role_grant_permissions($rid, array('access media browser'));
  }
}

NEW CODE (had to test it as a higher number 722x for testing increase x as number desired)

/**
 * Redo update_7226 as previous patch inadvertently copied
 * from 'create files' instead of 'administer media browser'
 * Accommodate the introduction of a new permission which restricts access to
 * the media browser by granting it to existing users who were able to access
 * it.
 */

function media_update_7226() {
  $roles = user_roles(TRUE, 'administer media browser'); //pass TRUE to exclude the 'anonymous' role https://api.drupal.org/api/drupal/modules!user!user.module/function/user_roles/7

  foreach ($roles as $rid => $role) {
    user_role_grant_permissions($rid, array('access media browser'));
  }
}

See patch

joseph.olstad’s picture

FileSize
846 bytes

comment 11 should have contained this file

joseph.olstad’s picture

Status: Needs review » Closed (fixed)

closing this , this creeped in because of a few bad changes to the media.install file that we ran various versions of. Our schema was out of sync and media_update_7226 never ran so we synched the schema it with code in the function seen below


/*
 * function for resyncing schema
 * if your schema gets out of sync, just call this function, if your installed version is higher than the available version the schema value will be set to the latest available version value 
 * (occurs after an incorrectly patched module.install file or a few bad commits to a module.install file )
 */
function wetkit_core_resyncschema() {

$modules = module_list(FALSE, FALSE, TRUE);
$schema_versions = drupal_get_installed_schema_version(NULL, FALSE, TRUE);
  foreach ($schema_versions as $module => $current_version) {
    if (in_array($module, $modules) && $current_version != SCHEMA_UNINSTALLED) {
      $available_versions = drupal_get_schema_versions($module);
      if (!empty($available_versions)) {
        $latest_version = max($available_versions);
        if ($current_version > $latest_version) {
          // watchdog debug warnings for site administrators in case they didn't see the console messages
          watchdog('debug', 'schema_resync: ' . $module . '.install  ' . ':$latest_version:' . $latest_version . '- $current_version:' . $current_version . ' (value loaded from system table) '  );
          // pretty console out messages
          print("\nThe " . $module . ".install file last " . $module . "_update_" . $latest_version . " is lower than the current schema version found in the system table (" . $current_version . ") ,\n this needs your drupal site administrators attention immediately because schema version ($current_version) is greater than " . $module . "_update_" . $latest_version . "\n");
          print("automatically repairing schema version \ndrupal_set_installed_schema_version($module, $latest_version)\n");
          drupal_set_installed_schema_version($module, $latest_version);
        }
      }
    }
  } //end second foreach
}//end of resyncschema

Just call this function from somewhere within a drupal module and it will re-sync your schema. This way at least your schema will be in sync. This function scans all modules for schema issues and automatically fixes them.

sort of related patch

Or you can just use this drush script (after unzip make sure to change the first line of the script with the path to drush for your environment)