You are here

function apps_update_7102 in Apps 7

Reset permissions

File

./apps.install, line 30
Install operation for apps

Code

function apps_update_7102() {
  if (!module_exists('og') || !module_exists('apps')) {
    return;
  }
  $changed = FALSE;
  $all_roles = $process_apps = array();
  apps_include('manifest');
  foreach (apps_servers() as $app_server) {
    if ($apps = apps_apps($app_server)) {
      foreach ($apps as $app_name => $app_info) {
        if (!empty($app_info['og permissions'])) {
          foreach ($app_info['og permissions'] as $key => $roles) {
            list($group_type, $bundle, $perm) = explode(':', $key);
            $all_roles += og_roles($group_type, $bundle, 0);
            $process_apps[$app_name] = $app_info;
          }
        }
      }
    }
  }
  if ($process_apps) {
    $old_roles = og_role_permissions($all_roles);
    foreach ($process_apps as $app_name => $app_info) {
      apps_app_configure_og_permissions($app_info);
    }
    $new_roles = og_role_permissions($all_roles);
    if ($old_roles !== $new_roles) {
      drupal_set_message(t('Per group permissions reset for at least one app. Please <a href="@url">adjust</a> permissions as needed.', array(
        '@url' => url('admin/config/group/permissions'),
      )), 'warning');
    }
  }
}