Fixed #29 and added admin menu item
This commit is contained in:
parent
7fa359e7aa
commit
50e16d211b
@ -2,6 +2,12 @@
|
|||||||
|
|
||||||
## Changelog
|
## Changelog
|
||||||
|
|
||||||
|
### 0.5.8-dev
|
||||||
|
|
||||||
|
- Fixed top menu items permissions for anonymous and non member #29
|
||||||
|
- Fixed bug with overwriting application handler, which cases problem with other plugins
|
||||||
|
- Tweaks link added to admin menu
|
||||||
|
|
||||||
### 0.5.7
|
### 0.5.7
|
||||||
|
|
||||||
- Custom source URL for Garfield source
|
- Custom source URL for Garfield source
|
||||||
|
@ -9,41 +9,7 @@
|
|||||||
<%
|
<%
|
||||||
user_roles = User.current.memberships.collect {|m| m.roles}.flatten.uniq
|
user_roles = User.current.memberships.collect {|m| m.roles}.flatten.uniq
|
||||||
5.times do |i|
|
5.times do |i|
|
||||||
menu_name = 'custom_menu'+i.to_s
|
add_top_menu_custom_item(i, user_roles)
|
||||||
url = Setting.plugin_redmine_tweaks[menu_name+'_url']
|
|
||||||
name = Setting.plugin_redmine_tweaks[menu_name+'_name']
|
|
||||||
title = Setting.plugin_redmine_tweaks[menu_name+'_title']
|
|
||||||
roles = Setting.plugin_redmine_tweaks[menu_name+'_roles']
|
|
||||||
|
|
||||||
unless name.nil? || name.empty? || url.empty? || roles.nil?
|
|
||||||
show_entry = false
|
|
||||||
roles.each do |role|
|
|
||||||
user_roles.each do |user_role|
|
|
||||||
if role.to_i == user_role.id.to_i
|
|
||||||
show_entry = true
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
|
||||||
if show_entry == true
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
if Redmine::MenuManager.map(:top_menu).exists?(menu_name.to_sym)
|
|
||||||
Redmine::MenuManager.map(:top_menu).delete(menu_name.to_sym)
|
|
||||||
end
|
|
||||||
|
|
||||||
if show_entry
|
|
||||||
html_options = {}
|
|
||||||
if url.include? "://"
|
|
||||||
html_options[:class] = 'external'
|
|
||||||
end
|
|
||||||
unless title.empty?
|
|
||||||
html_options[:title] = title
|
|
||||||
end
|
|
||||||
Redmine::MenuManager.map(:top_menu).push menu_name, url, :caption => name.to_s, :html => html_options, :before => :help
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
%>
|
%>
|
||||||
|
|
||||||
|
BIN
assets/images/tweaks.png
Normal file
BIN
assets/images/tweaks.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 914 B |
@ -1,4 +1,5 @@
|
|||||||
.nodata.nodata-left { text-align: left; }
|
.nodata.nodata-left { text-align: left; }
|
||||||
|
#admin-menu a.tweaks { background-image: url(../images/tweaks.png); }
|
||||||
|
|
||||||
/* Go to top link */
|
/* Go to top link */
|
||||||
.gototop {
|
.gototop {
|
||||||
|
@ -82,3 +82,4 @@ de:
|
|||||||
messages:
|
messages:
|
||||||
issue_cannot_close_with_open_children: "Das Ticket kann nicht geschlossen werden, bevor nicht alle Untertickets geschlossen wurden."
|
issue_cannot_close_with_open_children: "Das Ticket kann nicht geschlossen werden, bevor nicht alle Untertickets geschlossen wurden."
|
||||||
issue_current_user_status: "Der ausgewählte Status erfordert, dass \"Zugewiesen an\" Dir selbst zugeordnet wird."
|
issue_current_user_status: "Der ausgewählte Status erfordert, dass \"Zugewiesen an\" Dir selbst zugeordnet wird."
|
||||||
|
label_tweaks: Tweaks
|
||||||
|
@ -82,3 +82,4 @@ en:
|
|||||||
messages:
|
messages:
|
||||||
issue_cannot_close_with_open_children: "This issue can only be closed, if all sub-issues are closed, too."
|
issue_cannot_close_with_open_children: "This issue can only be closed, if all sub-issues are closed, too."
|
||||||
issue_current_user_status: "The selected status requires that the \"Assignee\" is yourself."
|
issue_current_user_status: "The selected status requires that the \"Assignee\" is yourself."
|
||||||
|
label_tweaks: Tweaks
|
||||||
|
@ -5,6 +5,7 @@ ja:
|
|||||||
label_settings_general: "共通"
|
label_settings_general: "共通"
|
||||||
label_settings_content: "コンテンツ"
|
label_settings_content: "コンテンツ"
|
||||||
label_settings_menu: "メニュー"
|
label_settings_menu: "メニュー"
|
||||||
|
label_settings_rules: "Issue rules"
|
||||||
label_menu_entry: "メニュー項目"
|
label_menu_entry: "メニュー項目"
|
||||||
label_top_menu_help: "ここで新しいトップメニューの項目を定義出来ます。リンクの追加・削除を行った場合、ウェブサーバを再起動してください。"
|
label_top_menu_help: "ここで新しいトップメニューの項目を定義出来ます。リンクの追加・削除を行った場合、ウェブサーバを再起動してください。"
|
||||||
label_optional: "任意"
|
label_optional: "任意"
|
||||||
@ -14,14 +15,18 @@ ja:
|
|||||||
label_external_urls: "外部URL"
|
label_external_urls: "外部URL"
|
||||||
external_url_default: "規程の扱い"
|
external_url_default: "規程の扱い"
|
||||||
external_url_new_window: "新しいウインドウで開く"
|
external_url_new_window: "新しいウインドウで開く"
|
||||||
external_url_anonymize: "レフェラーを匿名化"
|
external_url_noreferrer: "レフェラーを匿名化"
|
||||||
external_urls_info_html: "外部URLの扱いを指定する。"
|
external_urls_info_html: "外部URLの扱いを指定する。"
|
||||||
label_custom_help_url: "カスタムヘルプURL"
|
label_custom_help_url: "カスタムヘルプURL"
|
||||||
custom_help_url_info_html: "このURLを変更した後、反映するためにウェブサーバを再起動しなければなりません。URLの指定がない場合、規程のヘルプURLが使用されます。"
|
custom_help_url_info_html: "このURLを変更した後、反映するためにウェブサーバを再起動しなければなりません。URLの指定がない場合、規程のヘルプURLが使用されます。"
|
||||||
label_remove_mypage: "「マイ・ページ」をトップメニューから外す"
|
|
||||||
label_remove_help: "「ヘルプ」をトップメニューから外す"
|
label_remove_help: "「ヘルプ」をトップメニューから外す"
|
||||||
remove_mypage_info: 'タスクボードを導入するために、「マイ・ページ」のリンクを隠した方が便利な場合があります。タスクボードにより、ステータス毎の順番並び替えに出来るメリットがあります。'
|
label_remove_news: "Remove 'Lastest news' from overview page"
|
||||||
|
label_remove_latest_projects: "Remove 'Lastest projects' from overview page"
|
||||||
|
label_remove_mypage: "「マイ・ページ」をトップメニューから外す"
|
||||||
remove_help_info: "「ヘルプ」項目をトップメニューから外す"
|
remove_help_info: "「ヘルプ」項目をトップメニューから外す"
|
||||||
|
remove_news_info: "Remove latest news from overview page."
|
||||||
|
remove_latest_projects_info: "Remove latest projects from overview page."
|
||||||
|
remove_mypage_info: 'タスクボードを導入するために、「マイ・ページ」のリンクを隠した方が便利な場合があります。タスクボードにより、ステータス毎の順番並び替えに出来るメリットがあります。'
|
||||||
label_account_login: "ログイン画面の文章"
|
label_account_login: "ログイン画面の文章"
|
||||||
account_login_info: "この文章は、ログイン画面で表示され、登録情報の掲載を目的にしています。これらの設定は全プロジェクトで有効です。"
|
account_login_info: "この文章は、ログイン画面で表示され、登録情報の掲載を目的にしています。これらの設定は全プロジェクトで有効です。"
|
||||||
label_new_ticket_message: "新規チケットのメモ"
|
label_new_ticket_message: "新規チケットのメモ"
|
||||||
@ -41,3 +46,41 @@ ja:
|
|||||||
global_footer_info: 'プロジェクト全体のWikiフッターをここに入力する'
|
global_footer_info: 'プロジェクト全体のWikiフッターをここに入力する'
|
||||||
label_disabled_modules: "無効化したいモジュール"
|
label_disabled_modules: "無効化したいモジュール"
|
||||||
disabled_modules_info: "プロジェクト内で選択させたくないモジュール。もしこのモジュールが既存のプロジェクトで既に有効な場合、設定変更した上で、ウェブサーバを再起動しなければなりません。"
|
disabled_modules_info: "プロジェクト内で選択させたくないモジュール。もしこのモジュールが既存のプロジェクトで既に有効な場合、設定変更した上で、ウェブサーバを再起動しなければなりません。"
|
||||||
|
label_overview_right: "Overview page, right"
|
||||||
|
label_overview_top: "Overview page, top"
|
||||||
|
label_overview_bottom: "Overview page, bottom"
|
||||||
|
overview_right_info: "Here you can add your text, which will be shown on the overview page at the right side. For example you can link to a wiki page."
|
||||||
|
overview_top_info: "Here you can add your text, which will be shown on the overview page at the top. For example you can link to a wiki page."
|
||||||
|
overview_bottom_info: "Here you can add your text, which will be shown on the overview page at the bottom. For example you can link to a wiki page."
|
||||||
|
label_settings_macros: "Macros"
|
||||||
|
label_top_macros_help_html: "Here you get a list of all available Redmine macros of your installation, which are provided by Redmine and the Redmine plugins."
|
||||||
|
permission_hide_in_memberbox: "Hide in memberbox"
|
||||||
|
permission_show_hidden_roles_in_memberbox: "Show hidden roles in member box"
|
||||||
|
permission_edit_closed_issues: "Edit closed issues"
|
||||||
|
menu_roles_info: "Only members of selected roles will see this menu entry."
|
||||||
|
label_rule_issue_close_with_open_children: Issues with open sub-issues cannot be closed
|
||||||
|
top_rules_help: "Here you can define rules, which are used in issues of all projects."
|
||||||
|
top_content_help: "Here you can define texts, which will be displayed in diverse areas of Redmine. Use simple text, macros and wiki syntax for your content."
|
||||||
|
label_rule_issue_status_change: "If \"Assignee\" is unchanged and the issue status changed from x to y, than the author is assigned to the issue"
|
||||||
|
rule_issue_status_change_info: "Use Case: issues should be automatically assigned to autor, if the status changes to \"Approval\"."
|
||||||
|
label_rule_issue_current_user_status: "Current issue status x is only allowed if \"Assignee\" is the current user."
|
||||||
|
rule_issue_current_user_status_info: "Use Case: Users are only allowed to change the status to \"In Progress\" if they are the person who is actually working on the issue right now."
|
||||||
|
label_garfield_source: Garfield source host
|
||||||
|
garfield_source_info: "Enter the server here (only host name), by which the single comics by the use of SSL are offered. Please make sure to respect the particular terms of use and copyright laws."
|
||||||
|
minutes:
|
||||||
|
one: minute
|
||||||
|
other: minutes
|
||||||
|
hours:
|
||||||
|
one: hour
|
||||||
|
other: hours
|
||||||
|
days:
|
||||||
|
one: day
|
||||||
|
other: days
|
||||||
|
label_system_info: System info
|
||||||
|
label_uptime: Uptime
|
||||||
|
activerecord:
|
||||||
|
errors:
|
||||||
|
messages:
|
||||||
|
issue_cannot_close_with_open_children: "This issue can only be closed, if all sub-issues are closed, too."
|
||||||
|
issue_current_user_status: "The selected status requires that the \"Assignee\" is yourself."
|
||||||
|
label_tweaks: Tweaks
|
||||||
|
6
init.rb
6
init.rb
@ -8,7 +8,7 @@ Redmine::Plugin.register :redmine_tweaks do
|
|||||||
name 'Redmine Tweaks'
|
name 'Redmine Tweaks'
|
||||||
author 'AlphaNodes GmbH'
|
author 'AlphaNodes GmbH'
|
||||||
description 'Wiki and content extensions'
|
description 'Wiki and content extensions'
|
||||||
version '0.5.7'
|
version '0.5.8-dev'
|
||||||
author_url 'https://alphanodes.com/'
|
author_url 'https://alphanodes.com/'
|
||||||
url 'https://github.com/alexandermeindl/redmine_tweaks'
|
url 'https://github.com/alexandermeindl/redmine_tweaks'
|
||||||
|
|
||||||
@ -62,7 +62,9 @@ Redmine::Plugin.register :redmine_tweaks do
|
|||||||
:my_page,
|
:my_page,
|
||||||
{ controller: 'my', action: 'page' },
|
{ controller: 'my', action: 'page' },
|
||||||
via: :get,
|
via: :get,
|
||||||
if: proc { User.current && !RedmineTweaks.settings[:remove_mypage] }
|
if: proc { User.current.logged? && !RedmineTweaks.settings[:remove_mypage] }
|
||||||
|
|
||||||
|
menu :admin_menu, :tweaks, { controller: 'settings', action: 'plugin', id: 'redmine_tweaks' }, caption: :label_tweaks
|
||||||
|
|
||||||
RedCloth3::ALLOWED_TAGS << 'div'
|
RedCloth3::ALLOWED_TAGS << 'div'
|
||||||
end
|
end
|
||||||
|
@ -52,7 +52,60 @@ module RedmineTweaks
|
|||||||
end
|
end
|
||||||
view_roles
|
view_roles
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def add_top_menu_custom_item(i, user_roles)
|
||||||
|
menu_name = 'custom_menu' + i.to_s
|
||||||
|
item = {
|
||||||
|
url: Setting.plugin_redmine_tweaks[menu_name + '_url'],
|
||||||
|
name: Setting.plugin_redmine_tweaks[menu_name + '_name'],
|
||||||
|
title: Setting.plugin_redmine_tweaks[menu_name + '_title'],
|
||||||
|
roles: Setting.plugin_redmine_tweaks[menu_name + '_roles']
|
||||||
|
}
|
||||||
|
|
||||||
|
unless item[:name].blank? || item[:url].blank? || item[:roles].nil?
|
||||||
|
show_entry = false
|
||||||
|
item[:roles].each do |role|
|
||||||
|
if user_roles.empty? && role.to_i == Role::BUILTIN_ANONYMOUS
|
||||||
|
show_entry = true
|
||||||
|
break
|
||||||
|
elsif User.current.logged? && role.to_i == Role::BUILTIN_NON_MEMBER
|
||||||
|
# if user is logged in and non_member is active in item,
|
||||||
|
# always show it
|
||||||
|
show_entry = true
|
||||||
|
break
|
||||||
|
end
|
||||||
|
|
||||||
|
user_roles.each do |user_role|
|
||||||
|
if role.to_i == user_role.id.to_i
|
||||||
|
show_entry = true
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
break if show_entry == true
|
||||||
|
end
|
||||||
|
handle_top_menu_item(menu_name, item, show_entry)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def handle_top_menu_item(menu_name, item, show_entry = false)
|
||||||
|
if Redmine::MenuManager.map(:top_menu).exists?(menu_name.to_sym)
|
||||||
|
Redmine::MenuManager.map(:top_menu).delete(menu_name.to_sym)
|
||||||
|
end
|
||||||
|
|
||||||
|
if show_entry
|
||||||
|
html_options = {}
|
||||||
|
html_options[:class] = 'external' if item[:url].include? '://'
|
||||||
|
html_options[:title] = item[:title] unless item[:title].blank?
|
||||||
|
Redmine::MenuManager.map(:top_menu).push menu_name,
|
||||||
|
item[:url],
|
||||||
|
caption: item[:name].to_s,
|
||||||
|
html: html_options,
|
||||||
|
before: :help
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
ActionView::Base.send :include, RedmineTweaks::Helper
|
unless ActionView::Base.included_modules.include?(RedmineTweaks::Helper)
|
||||||
|
ActionView::Base.send(:include, RedmineTweaks::Helper)
|
||||||
|
end
|
||||||
|
@ -11,18 +11,15 @@ module RedmineTweaks
|
|||||||
base.class_eval do
|
base.class_eval do
|
||||||
alias_method_chain :parse_redmine_links, :tweaks
|
alias_method_chain :parse_redmine_links, :tweaks
|
||||||
|
|
||||||
def link_to_user_static(user, display, format, only_path)
|
def link_to_user_static(user, display, format)
|
||||||
name = display || user.name(format)
|
name = display || user.name(format)
|
||||||
if user.active?
|
if user.active?
|
||||||
# user_id = user.login.match(%r{^[a-z0-9_\-]+$}i) ? user.login.downcase : user
|
link_to(h(name),
|
||||||
link = link_to(h(name),
|
user_path(user),
|
||||||
# { only_path: only_path, controller: 'users', action: 'show', id: user_id },
|
class: user.css_classes)
|
||||||
user_path(user),
|
|
||||||
class: user.css_classes)
|
|
||||||
else
|
else
|
||||||
link = h(name)
|
h(name)
|
||||||
end
|
end
|
||||||
link
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -63,19 +60,13 @@ module RedmineTweaks
|
|||||||
end
|
end
|
||||||
if sep == '#'
|
if sep == '#'
|
||||||
oid = identifier.to_i
|
oid = identifier.to_i
|
||||||
case prefix
|
if prefix == 'user' && user = User.find_by_id(oid)
|
||||||
when 'user'
|
link = link_to_user_static(user, display, format)
|
||||||
if user = User.find_by_id(oid)
|
|
||||||
link = link_to_user_static(user, display, format, only_path)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
elsif sep == ':'
|
elsif sep == ':'
|
||||||
oname = identifier.gsub(%r{^"(.*)"$}, '\\1')
|
oname = identifier.gsub(%r{^"(.*)"$}, '\\1')
|
||||||
case prefix
|
if prefix == 'user' && user = User.find_by_login(oname)
|
||||||
when 'user'
|
link = link_to_user_static(user, display, format)
|
||||||
if user = User.find_by_login(oname)
|
|
||||||
link = link_to_user_static(user, display, format, only_path)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user