Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add User Groups Report #1502

Merged
merged 2 commits into from Apr 9, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 11 additions & 0 deletions reports/users/user_groups_report/en.yml
@@ -0,0 +1,11 @@
en:
reports:
user_groups_report:
title: User Groups Report
description: Displays users and repository access groups
name: Name
department: Department
user_title: Title
groups: Groups
email: Email
telephone: Telephone
11 changes: 11 additions & 0 deletions reports/users/user_groups_report/es.yml
@@ -0,0 +1,11 @@
es:
reports:
user_groups_report:
title: Informe de grupos de usuarios
description: Muestra usuarios y grupos de acceso al repositorio.
name: Nombre
department: Departamento
user_title: Título
groups: Los grupos
email: Email
telephone: Teléfono
11 changes: 11 additions & 0 deletions reports/users/user_groups_report/fr.yml
@@ -0,0 +1,11 @@
fr:
reports:
user_groups_report:
title: Rapport sur les groupes d'utilisateurs
description: Affiche les utilisateurs et les groupes d'accès au référentiel
name: Prénom
department: Département
user_title: Titre
groups: Groupes
email: Email
telephone: Téléphone
11 changes: 11 additions & 0 deletions reports/users/user_groups_report/jp.yml
@@ -0,0 +1,11 @@
jp:
reports:
user_groups_report:
title: ユーザーグループレポート
description: ユーザーとリポジトリアクセスグループを表示します。
name: 名
department: 部門
user_title: タイトル
groups: グループ
email: Eメール
telephone: 電話
71 changes: 71 additions & 0 deletions reports/users/user_groups_report/user_groups_report.rb
@@ -0,0 +1,71 @@

class UserGroupsReport < AbstractReport

register_report


def query_string

"SELECT id,username as identifier,name,department,title as user_title,email,telephone,source,is_system_user,is_hidden_user from user"

end


def fix_row(row)

user_id = row[:id]
nbsp = '   '

if format == 'pdf' || format == 'html'
row[:source] = row[:source] + nbsp * 12
row[:source] = row[:source] + " SYSTEM_USER " + nbsp * 8 if row[:is_system_user] != 0
row[:source] = row[:source] + " HIDDEN_USER " if row[:is_hidden_user] != 0
row.delete(:is_system_user); row.delete(:is_hidden_user); row.delete(:id)
else
row[:title] = row[:user_title]; row.delete(:user_title) # as user_title, because title displays as "User Group Report" in HTML report
end

row[:groups] = UserGroupsSubreport.new( self, user_id ).get_content

puts row
end


def identifier_field
:name
end

def page_break
false
end


# these two go together because the base class and templates assume all reports are repository based.
def repository
"Global repository"
end

def after_tasks
info.delete(:repository)
end

end

class UserGroupsSubreport < AbstractSubreport

register_subreport('groups', [ 'user' ])

def initialize( parent_report, user_id )
super(parent_report)
@user_id = user_id
end

def query_string
"select description from `group`
where id in (select group_id from group_user where user_id = #{db.literal(@user_id)} )"
end

def self.field_name
'groups'
end
end