<commit_before>if Authorization::activate_authorization_rules_browser?

require File.join(File.dirname(__FILE__), %w{.. .. lib declarative_authorization development_support analyzer})
require File.join(File.dirname(__FILE__), %w{.. .. lib declarative_authorization development_support change_supporter})

begin
  # for nice auth_rules output:
  require "parse_tree"
  require "parse_tree_extensions"
  require "ruby2ruby"
rescue LoadError; end

class AuthorizationRulesController < ApplicationController
  unloadable
  
  filter_access_to :all, :require => :read
  def index
    respond_to do |format|
      format.html do
        @auth_rules_script = File.read("#{RAILS_ROOT}/config/authorization_rules.rb")
      end
    end
  end

  def graph
    if params[:format] == "svg"
      render :text => dot_to_svg(auth_to_dot(graph_options)),
          :content_type => "image/svg+xml"
    end
  end

  def change
    @users = find_all_users
    @users.sort! {|a, b| a.login <=> b.login }
    
    @privileges = authorization_engine.auth_rules.collect {|rule| rule.privileges.to_a}.flatten.uniq
    @privilege = params[:privilege].to_sym rescue @privileges.first
    @contexts = authorization_engine.auth_rules.collect {|rule| rule.contexts.to_a}.flatten.uniq
    @context = params[:context].to_sym rescue @contexts.first

    respond_to do |format|
      format.html
      format.js do<commit_msg>Fix Change Support GUI to show all privileges<commit_after>if Authorization::activate_authorization_rules_browser?

require File.join(File.dirname(__FILE__), %w{.. .. lib declarative_authorization development_support analyzer})
require File.join(File.dirname(__FILE__), %w{.. .. lib declarative_authorization development_support change_supporter})
require File.join(File.dirname(__FILE__), %w{.. .. lib declarative_authorization development_support development_support})

begin
  # for nice auth_rules output:
  require "parse_tree"
  require "parse_tree_extensions"
  require "ruby2ruby"
rescue LoadError; end

class AuthorizationRulesController < ApplicationController
  unloadable
  
  filter_access_to :all, :require => :read
  def index
    respond_to do |format|
      format.html do
        @auth_rules_script = File.read("#{RAILS_ROOT}/config/authorization_rules.rb")
      end
    end
  end

  def graph
    if params[:format] == "svg"
      render :text => dot_to_svg(auth_to_dot(graph_options)),
          :content_type => "image/svg+xml"
    end
  end

  def change
    @users = find_all_users
    @users.sort! {|a, b| a.login <=> b.login }
    
    @privileges = authorization_engine.auth_rules.collect {|rule| rule.privileges.to_a}.flatten.uniq
    @privileges = @privileges.collect {|priv| Authorization::DevelopmentSupport::AnalyzerEngine::Privilege.for_sym(priv, authorization_engine).descendants.map(&:to_sym) }.flatten.uniq
    @privileges.sort_by {|priv| priv.to_s}
    @privilege = params[:privilege].to_sym rescue @privileges.first
    @contexts = authorization_engine.auth_rules.collect {|rule| rule.contexts.to_a}.flatten.uniq
    @context = params[:context].to_sym rescue @contexts.first

    respond_to do |format|
      format.html
      format.js do
{'fraction_non_alphanumeric': 0.1075031525851198, 'fraction_numerical': 0.0006305170239596469, 'mean_word_length': 4.306020066889632, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3948009', 'n_tokens_mistral': 1024, 'n_tokens_neox': 1000, 'n_words': 208}