##// END OF EJS Templates
Introduce virtual MenuNodes (#15880)....
Introduce virtual MenuNodes (#15880). They are characterized by having a blank url. they will only be rendered if the user is authorized to see at least one of its children. they render as links which do nothing when clicked. Patch by Jan Schulz-Hofen. git-svn-id: http://svn.redmine.org/redmine/trunk@15501 e93f8b46-1217-0410-a6f0-8f06a7374b81

File last commit:

r14885:a47eab886835
r15119:53710d80fc88
Show More
my_controller.rb
211 lines | 6.4 KiB | text/x-ruby | RubyLexer
Jean-Philippe Lang
Allow My Page blocks to be added to from a plugin (#2840)....
r2465 # Redmine - project management software
Jean-Philippe Lang
Updates copyright for 2016....
r14856 # Copyright (C) 2006-2016 Jean-Philippe Lang
Jean-Philippe Lang
- new controller "myController"...
r60 #
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
Toshi MARUYAMA
remove trailing white-spaces from app/controllers/my_controller.rb....
r6680 #
Jean-Philippe Lang
- new controller "myController"...
r60 # This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
Toshi MARUYAMA
remove trailing white-spaces from app/controllers/my_controller.rb....
r6680 #
Jean-Philippe Lang
- new controller "myController"...
r60 # You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
class MyController < ApplicationController
before_filter :require_login
Toshi MARUYAMA
gender neutral source comment at app/controllers/my_controller.rb...
r11858 # let user change user's password when user has to
Jean-Philippe Lang
Option to force a user to change his password (#3872)....
r11851 skip_before_filter :check_password_change, :only => :password
Jean-Philippe Lang
- new controller "myController"...
r60
Jean-Philippe Lang
Require password re-entry for sensitive actions (#19851)....
r13951 require_sudo_mode :account, only: :post
require_sudo_mode :reset_rss_key, :reset_api_key, :show_api_key, :destroy
Jean-Philippe Lang
Moves @layout 'base'@ to ApplicationController....
r1726 helper :issues
Jean-Philippe Lang
Code cleanup....
r4383 helper :users
Jean-Philippe Lang
User custom fields can now be set as editable so that users can edit them on 'My account'....
r2274 helper :custom_fields
Jean-Philippe Lang
Moves @layout 'base'@ to ApplicationController....
r1726
Jean-Philippe Lang
removed underscores in block names (problem with scriptaculous sortables)...
r239 BLOCKS = { 'issuesassignedtome' => :label_assigned_to_me_issues,
'issuesreportedbyme' => :label_reported_issues,
Jean-Philippe Lang
Added a new block available for my page: "Watched issues"...
r453 'issueswatched' => :label_watched_issues,
Jean-Philippe Lang
removed underscores in block names (problem with scriptaculous sortables)...
r239 'news' => :label_news_latest,
Jean-Philippe Lang
- new controller "myController"...
r60 'calendar' => :label_calendar,
Jean-Philippe Lang
Add a time tracking block for 'My page' (#615)....
r1245 'documents' => :label_document_plural,
'timelog' => :label_spent_time
Jean-Philippe Lang
Allow My Page blocks to be added to from a plugin (#2840)....
r2465 }.merge(Redmine::Views::MyPage::Block.additional_blocks).freeze
Jean-Philippe Lang
- new controller "myController"...
r60
Toshi MARUYAMA
remove trailing white-spaces from app/controllers/my_controller.rb....
r6680 DEFAULT_LAYOUT = { 'left' => ['issuesassignedtome'],
'right' => ['issuesreportedbyme']
Jean-Philippe Lang
removed underscores in block names (problem with scriptaculous sortables)...
r239 }.freeze
Jean-Philippe Lang
- new controller "myController"...
r60 def index
page
render :action => 'page'
end
# Show user's page
def page
Jean-Philippe Lang
Anonymous users can now be allowed to create, edit, comment issues, comment news and post messages in the forums....
r906 @user = User.current
Jean-Philippe Lang
removed underscores in block names (problem with scriptaculous sortables)...
r239 @blocks = @user.pref[:my_page_layout] || DEFAULT_LAYOUT
Jean-Philippe Lang
- new controller "myController"...
r60 end
# Edit user's account
def account
Jean-Philippe Lang
More flexible mail notifications settings at user level. A user has now 3 options:...
r842 @user = User.current
Jean-Philippe Lang
"hide my email address" preference added, so that it's not displayed on account/show...
r61 @pref = @user.pref
Jean-Philippe Lang
More flexible mail notifications settings at user level. A user has now 3 options:...
r842 if request.post?
Jean-Philippe Lang
Merged rails-4.1 branch (#14534)....
r13100 @user.safe_attributes = params[:user] if params[:user]
@user.pref.attributes = params[:pref] if params[:pref]
Jean-Philippe Lang
More flexible mail notifications settings at user level. A user has now 3 options:...
r842 if @user.save
@user.pref.save
set_language_if_valid @user.language
flash[:notice] = l(:notice_account_updated)
Jean-Philippe Lang
Use named routes in controllers....
r10754 redirect_to my_account_path
Jean-Philippe Lang
More flexible mail notifications settings at user level. A user has now 3 options:...
r842 return
end
Jean-Philippe Lang
- new controller "myController"...
r60 end
end
Jean-Philippe Lang
Adds the ability for users to delete their own account (#10664). Can be disabled in application settings....
r9283 # Destroys user's account
def destroy
@user = User.current
unless @user.own_account_deletable?
Jean-Philippe Lang
Use named routes in controllers....
r10754 redirect_to my_account_path
Jean-Philippe Lang
Adds the ability for users to delete their own account (#10664). Can be disabled in application settings....
r9283 return
end
if request.post? && params[:confirm]
@user.destroy
if @user.destroyed?
logout_user
flash[:notice] = l(:notice_account_deleted)
end
redirect_to home_path
end
end
Jean-Philippe Lang
More flexible mail notifications settings at user level. A user has now 3 options:...
r842 # Manage user's password
def password
Jean-Philippe Lang
Anonymous users can now be allowed to create, edit, comment issues, comment news and post messages in the forums....
r906 @user = User.current
Eric Davis
Allow AuthSources to control if they allow password changes....
r3631 unless @user.change_password_allowed?
Jean-Philippe Lang
Removes "xxx and return" calls (#4446)....
r3071 flash[:error] = l(:notice_can_t_change_password)
Jean-Philippe Lang
Use named routes in controllers....
r10754 redirect_to my_account_path
Jean-Philippe Lang
Removes "xxx and return" calls (#4446)....
r3071 return
end
Jean-Philippe Lang
More flexible mail notifications settings at user level. A user has now 3 options:...
r842 if request.post?
Jean-Philippe Lang
Option to force a user to change his password (#3872)....
r11851 if !@user.check_password?(params[:password])
flash.now[:error] = l(:notice_account_wrong_password)
elsif params[:password] == params[:new_password]
Jean-Philippe Lang
Removed hardcoded string (#3872)....
r11853 flash.now[:error] = l(:notice_new_password_must_be_different)
Jean-Philippe Lang
Option to force a user to change his password (#3872)....
r11851 else
Jean-Philippe Lang
More flexible mail notifications settings at user level. A user has now 3 options:...
r842 @user.password, @user.password_confirmation = params[:new_password], params[:new_password_confirmation]
Jean-Philippe Lang
Option to force a user to change his password (#3872)....
r11851 @user.must_change_passwd = false
Jean-Philippe Lang
More flexible mail notifications settings at user level. A user has now 3 options:...
r842 if @user.save
Jean-Philippe Lang
Keep track of valid user sessions (#21058)....
r14353 # The session token was destroyed by the password change, generate a new one
session[:tk] = @user.generate_session_token
Jean-Philippe Lang
Let the mailer set the email content (#21421)....
r14885 Mailer.password_updated(@user)
Jean-Philippe Lang
More flexible mail notifications settings at user level. A user has now 3 options:...
r842 flash[:notice] = l(:notice_account_password_updated)
Jean-Philippe Lang
Use named routes in controllers....
r10754 redirect_to my_account_path
Jean-Philippe Lang
More flexible mail notifications settings at user level. A user has now 3 options:...
r842 end
Jean-Philippe Lang
- new controller "myController"...
r60 end
end
Jean-Philippe Lang
Added the ability to reset its own RSS access key on "My account"....
r666 end
Toshi MARUYAMA
remove trailing white-spaces from app/controllers/my_controller.rb....
r6680
Jean-Philippe Lang
Added the ability to reset its own RSS access key on "My account"....
r666 # Create a new feeds key
def reset_rss_key
Eric Davis
Make sure the RSS token is getting destroyed and created....
r3096 if request.post?
if User.current.rss_token
User.current.rss_token.destroy
User.current.reload
end
User.current.rss_key
Jean-Philippe Lang
Added the ability to reset its own RSS access key on "My account"....
r666 flash[:notice] = l(:notice_feeds_access_key_reseted)
end
Jean-Philippe Lang
Use named routes in controllers....
r10754 redirect_to my_account_path
Jean-Philippe Lang
- new controller "myController"...
r60 end
Jean-Philippe Lang
Require password re-entry for sensitive actions (#19851)....
r13951 def show_api_key
@user = User.current
end
Eric Davis
Added an API token for each User to use when making API requests. (#3920)...
r3103 # Create a new API key
def reset_api_key
if request.post?
if User.current.api_token
User.current.api_token.destroy
User.current.reload
end
User.current.api_key
flash[:notice] = l(:notice_api_access_key_reseted)
end
Jean-Philippe Lang
Use named routes in controllers....
r10754 redirect_to my_account_path
Eric Davis
Added an API token for each User to use when making API requests. (#3920)...
r3103 end
Jean-Philippe Lang
- new controller "myController"...
r60 # User's page layout configuration
def page_layout
Jean-Philippe Lang
Anonymous users can now be allowed to create, edit, comment issues, comment news and post messages in the forums....
r906 @user = User.current
Jean-Philippe Lang
fixed: crash on my/page_layout (trying to modify a frozen hash)...
r255 @blocks = @user.pref[:my_page_layout] || DEFAULT_LAYOUT.dup
Jean-Philippe Lang
- new controller "myController"...
r60 @block_options = []
Jean-Philippe Lang
Removes most of the ajax stuff on my page layout....
r9850 BLOCKS.each do |k, v|
Jean-Philippe Lang
Code cleanup (#14766)....
r12383 unless @blocks.values.flatten.include?(k)
Jean-Philippe Lang
Removes most of the ajax stuff on my page layout....
r9850 @block_options << [l("my.blocks.#{v}", :default => [v, v.to_s.humanize]), k.dasherize]
end
end
Jean-Philippe Lang
- new controller "myController"...
r60 end
Toshi MARUYAMA
remove trailing white-spaces from app/controllers/my_controller.rb....
r6680
Jean-Philippe Lang
- new controller "myController"...
r60 # Add a block to user's page
# The block is added on top of the page
# params[:block] : id of the block to add
def add_block
Jean-Philippe Lang
Allow underscore in block partial name (#2840)....
r2464 block = params[:block].to_s.underscore
Jean-Philippe Lang
Fixed that adding a blank/invalid block to my page renders a blank page (#12838)....
r10995 if block.present? && BLOCKS.key?(block)
@user = User.current
layout = @user.pref[:my_page_layout] || {}
# remove if already present in a group
%w(top left right).each {|f| (layout[f] ||= []).delete block }
# add it on top
layout['top'].unshift block
@user.pref[:my_page_layout] = layout
@user.pref.save
end
Jean-Philippe Lang
Use named routes in controllers....
r10754 redirect_to my_page_layout_path
Jean-Philippe Lang
- new controller "myController"...
r60 end
Toshi MARUYAMA
remove trailing white-spaces from app/controllers/my_controller.rb....
r6680
Jean-Philippe Lang
- new controller "myController"...
r60 # Remove a block to user's page
# params[:block] : id of the block to remove
def remove_block
Jean-Philippe Lang
Allow underscore in block partial name (#2840)....
r2464 block = params[:block].to_s.underscore
Jean-Philippe Lang
Fixes block reordering on my page (#2971)....
r3080 @user = User.current
Jean-Philippe Lang
- new controller "myController"...
r60 # remove block in all groups
Jean-Philippe Lang
Fixes block reordering on my page (#2971)....
r3080 layout = @user.pref[:my_page_layout] || {}
%w(top left right).each {|f| (layout[f] ||= []).delete block }
@user.pref[:my_page_layout] = layout
Toshi MARUYAMA
remove trailing white-spaces from app/controllers/my_controller.rb....
r6680 @user.pref.save
Jean-Philippe Lang
Use named routes in controllers....
r10754 redirect_to my_page_layout_path
Jean-Philippe Lang
- new controller "myController"...
r60 end
# Change blocks order on user's page
# params[:group] : group to order (top, left or right)
# params[:list-(top|left|right)] : array of block ids of the group
def order_blocks
group = params[:group]
Jean-Philippe Lang
Fixes block reordering on my page (#2971)....
r3080 @user = User.current
Jean-Philippe Lang
Fixes that "My Page" personalization was not storing reordered blocks (#2971)....
r2545 if group.is_a?(String)
Jean-Philippe Lang
JQuery in, Prototype/Scriptaculous out (#11445)....
r9885 group_items = (params["blocks"] || []).collect(&:underscore)
group_items.each {|s| s.sub!(/^block_/, '')}
Jean-Philippe Lang
Allow underscore in block partial name (#2840)....
r2464 if group_items and group_items.is_a? Array
Jean-Philippe Lang
Fixes block reordering on my page (#2971)....
r3080 layout = @user.pref[:my_page_layout] || {}
Jean-Philippe Lang
Allow underscore in block partial name (#2840)....
r2464 # remove group blocks if they are presents in other groups
%w(top left right).each {|f|
Jean-Philippe Lang
Fixes block reordering on my page (#2971)....
r3080 layout[f] = (layout[f] || []) - group_items
Jean-Philippe Lang
Allow underscore in block partial name (#2840)....
r2464 }
Jean-Philippe Lang
Fixes block reordering on my page (#2971)....
r3080 layout[group] = group_items
@user.pref[:my_page_layout] = layout
Toshi MARUYAMA
remove trailing white-spaces from app/controllers/my_controller.rb....
r6680 @user.pref.save
Jean-Philippe Lang
Allow underscore in block partial name (#2840)....
r2464 end
Jean-Philippe Lang
- new controller "myController"...
r60 end
render :nothing => true
end
end